Skip to content
Snippets Groups Projects
Commit 333c709c authored by David Hintermann's avatar David Hintermann
Browse files

wip: swap async

parent 4704a025
No related branches found
No related tags found
1 merge request!7feat(dex): dex integration
......@@ -40,7 +40,7 @@ public class PrometheusService : BackgroundService
};
_erc20TokenMetrics.CreateMetrics();
_ethMetrics.CreateMetrics();
PoolV3Client poolClient = new(chainSettings.Uniswap.RocEthPoolAddress, web3);
PoolV3Client poolClient = new( web3,chainSettings);
_poolMetrics.CreateMetrics(poolClient);
}
......
......@@ -4,7 +4,7 @@ using Nethereum.Contracts;
using HexBigInteger = Nethereum.Hex.HexTypes.HexBigInteger;
namespace Frontend.Functions;
[Function("swapExactInputSingle", "uint256")]
public class SwapExactInputSingleFunction : FunctionMessage
{
[Parameter("address", "tokenIn", 1)]
......@@ -23,7 +23,7 @@ public class SwapExactInputSingleFunction : FunctionMessage
public string Recipient { get; set; }
[Parameter("uint256", "deadline", 6)]
public HexBigInteger Deadline { get; set; }
public BigInteger Deadline { get; set; }
[Parameter("uint24", "fee", 7)]
public uint Fee { get; set; }
......
......@@ -19,7 +19,7 @@ public class PoolV3Client
private string? token1Address = null;
private uint? poolFeeTier = null;
public PoolV3Client(string poolAddress, Web3 web3, ChainSettings chainSettings)
public PoolV3Client(Web3 web3, ChainSettings chainSettings)
{
_pool = web3.Eth.GetContract(
......@@ -31,7 +31,7 @@ public class PoolV3Client
"uniswapV3Pool.abi.json"
)
),
poolAddress
chainSettings.Uniswap.RocEthPoolAddress
);
_web3 = web3;
_chainSettings = chainSettings;
......@@ -107,7 +107,7 @@ public class PoolV3Client
AmountIn = Web3.Convert.ToWei(amount),
AmountOutMinimum = Web3.Convert.ToWei(amountOutMinimum), // Set your minimum amount out
Recipient = account.Address,
Deadline = new HexBigInteger(DateTimeOffset.UtcNow.ToUnixTimeSeconds() + 90), // 1:30 minutes from now
Deadline = new BigInteger(DateTimeOffset.UtcNow.ToUnixTimeSeconds() + 90), // 1:30 minutes from now
Fee = await getPoolFeeTier(),
SqrtPriceLimitX96 = sqrtPriceLimitX96
};
......
......@@ -46,6 +46,8 @@ builder.Services.AddSingleton(provider => new TokenClient(
chainId
));
builder.Services.AddSingleton(provider=>account);
builder.Services.AddSingleton(provider => new Web3(account, chainApiUrl));
builder.Services.AddSingleton<PoolMetrics>();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment