From 6954b5baf35119240a914342eb57968cc55bd6ce Mon Sep 17 00:00:00 2001 From: David Hintermann <David.Hintermann@ost.ch> Date: Tue, 26 Nov 2024 13:18:32 +0000 Subject: [PATCH] wip: fix params --- .../Configuration/Abi/swapRouterV2.abi.json | 1063 +++++++++++++++++ Frontend/Configuration/ChainSettings.cs | 3 +- Frontend/Configuration/UniswapSettings.cs | 4 +- Frontend/Functions/ApproveFunction.cs | 15 + .../Functions/SwapExactInputSingleFunction.cs | 27 +- .../Functions/SwapExactTokensForTokens.cs | 0 Frontend/Pages/Index.cshtml.cs | 31 +- Frontend/PoolV3Client.cs | 11 +- Frontend/appsettings.json | 5 +- 9 files changed, 1135 insertions(+), 24 deletions(-) create mode 100644 Frontend/Configuration/Abi/swapRouterV2.abi.json create mode 100644 Frontend/Functions/ApproveFunction.cs create mode 100644 Frontend/Functions/SwapExactTokensForTokens.cs diff --git a/Frontend/Configuration/Abi/swapRouterV2.abi.json b/Frontend/Configuration/Abi/swapRouterV2.abi.json new file mode 100644 index 0000000..dbbcca0 --- /dev/null +++ b/Frontend/Configuration/Abi/swapRouterV2.abi.json @@ -0,0 +1,1063 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_factoryV2", + "type": "address" + }, + { + "internalType": "address", + "name": "factoryV3", + "type": "address" + }, + { + "internalType": "address", + "name": "_positionManager", + "type": "address" + }, + { + "internalType": "address", + "name": "_WETH9", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "WETH9", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "approveMax", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "approveMaxMinusOne", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "approveZeroThenMax", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "approveZeroThenMaxMinusOne", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "callPositionManager", + "outputs": [ + { + "internalType": "bytes", + "name": "result", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "paths", + "type": "bytes[]" + }, + { + "internalType": "uint128[]", + "name": "amounts", + "type": "uint128[]" + }, + { + "internalType": "uint24", + "name": "maximumTickDivergence", + "type": "uint24" + }, + { + "internalType": "uint32", + "name": "secondsAgo", + "type": "uint32" + } + ], + "name": "checkOracleSlippage", + "outputs": [], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "path", + "type": "bytes" + }, + { + "internalType": "uint24", + "name": "maximumTickDivergence", + "type": "uint24" + }, + { + "internalType": "uint32", + "name": "secondsAgo", + "type": "uint32" + } + ], + "name": "checkOracleSlippage", + "outputs": [], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "path", + "type": "bytes" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMinimum", + "type": "uint256" + } + ], + "internalType": "struct IV3SwapRouter.ExactInputParams", + "name": "params", + "type": "tuple" + } + ], + "name": "exactInput", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMinimum", + "type": "uint256" + }, + { + "internalType": "uint160", + "name": "sqrtPriceLimitX96", + "type": "uint160" + } + ], + "internalType": "struct IV3SwapRouter.ExactInputSingleParams", + "name": "params", + "type": "tuple" + } + ], + "name": "exactInputSingle", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "path", + "type": "bytes" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountInMaximum", + "type": "uint256" + } + ], + "internalType": "struct IV3SwapRouter.ExactOutputParams", + "name": "params", + "type": "tuple" + } + ], + "name": "exactOutput", + "outputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountInMaximum", + "type": "uint256" + }, + { + "internalType": "uint160", + "name": "sqrtPriceLimitX96", + "type": "uint160" + } + ], + "internalType": "struct IV3SwapRouter.ExactOutputSingleParams", + "name": "params", + "type": "tuple" + } + ], + "name": "exactOutputSingle", + "outputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "factory", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "factoryV2", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "getApprovalType", + "outputs": [ + { + "internalType": "enum IApproveAndCall.ApprovalType", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "token0", + "type": "address" + }, + { + "internalType": "address", + "name": "token1", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount0Min", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Min", + "type": "uint256" + } + ], + "internalType": "struct IApproveAndCall.IncreaseLiquidityParams", + "name": "params", + "type": "tuple" + } + ], + "name": "increaseLiquidity", + "outputs": [ + { + "internalType": "bytes", + "name": "result", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "token0", + "type": "address" + }, + { + "internalType": "address", + "name": "token1", + "type": "address" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "internalType": "uint256", + "name": "amount0Min", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Min", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "internalType": "struct IApproveAndCall.MintParams", + "name": "params", + "type": "tuple" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "bytes", + "name": "result", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "previousBlockhash", + "type": "bytes32" + }, + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "multicall", + "outputs": [ + { + "internalType": "bytes[]", + "name": "", + "type": "bytes[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "multicall", + "outputs": [ + { + "internalType": "bytes[]", + "name": "", + "type": "bytes[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "multicall", + "outputs": [ + { + "internalType": "bytes[]", + "name": "results", + "type": "bytes[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "positionManager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "pull", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "refundETH", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "selfPermit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "selfPermitAllowed", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "selfPermitAllowedIfNecessary", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "selfPermitIfNecessary", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMin", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "swapExactTokensForTokens", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountInMax", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "swapTokensForExactTokens", + "outputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "sweepToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + } + ], + "name": "sweepToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feeBips", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeRecipient", + "type": "address" + } + ], + "name": "sweepTokenWithFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feeBips", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeRecipient", + "type": "address" + } + ], + "name": "sweepTokenWithFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "amount0Delta", + "type": "int256" + }, + { + "internalType": "int256", + "name": "amount1Delta", + "type": "int256" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "uniswapV3SwapCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "unwrapWETH9", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + } + ], + "name": "unwrapWETH9", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feeBips", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeRecipient", + "type": "address" + } + ], + "name": "unwrapWETH9WithFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feeBips", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeRecipient", + "type": "address" + } + ], + "name": "unwrapWETH9WithFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "wrapETH", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +] \ No newline at end of file diff --git a/Frontend/Configuration/ChainSettings.cs b/Frontend/Configuration/ChainSettings.cs index dc07625..34d2cb6 100644 --- a/Frontend/Configuration/ChainSettings.cs +++ b/Frontend/Configuration/ChainSettings.cs @@ -3,6 +3,7 @@ public class ChainSettings { public int ChainId { get; set; } public string TokenAddress { get; set; } + public string WethTokenAddress { get; set; } public UniswapSettings Uniswap { get; set; } - public string SwapRouterV2Address { get; set; } + } \ No newline at end of file diff --git a/Frontend/Configuration/UniswapSettings.cs b/Frontend/Configuration/UniswapSettings.cs index fb0505a..0ea0580 100644 --- a/Frontend/Configuration/UniswapSettings.cs +++ b/Frontend/Configuration/UniswapSettings.cs @@ -3,7 +3,9 @@ { public string UniswapV3Factory { get; set; } public string QuoterV2 { get; set; } - public string WethTokenAddress { get; set; } + public string SwapRouterV2Address { get; set; } public string RocEthPoolAddress {get;set;} + + public string PermitV2Address {get;set;} } \ No newline at end of file diff --git a/Frontend/Functions/ApproveFunction.cs b/Frontend/Functions/ApproveFunction.cs new file mode 100644 index 0000000..dfa7c8c --- /dev/null +++ b/Frontend/Functions/ApproveFunction.cs @@ -0,0 +1,15 @@ +using System.Numerics; +using Nethereum.ABI.FunctionEncoding.Attributes; +using Nethereum.Contracts; + +namespace Frontend.Functions; + +[Function("approve")] +public class ApproveFunction : FunctionMessage +{ + [Parameter("address", "spender", 1)] + public string? Spender { get; set; } + + [Parameter("uint256", "value", 2)] + public BigInteger Value { get; set; } +} diff --git a/Frontend/Functions/SwapExactInputSingleFunction.cs b/Frontend/Functions/SwapExactInputSingleFunction.cs index 2dd799e..6629e94 100644 --- a/Frontend/Functions/SwapExactInputSingleFunction.cs +++ b/Frontend/Functions/SwapExactInputSingleFunction.cs @@ -4,30 +4,27 @@ using Nethereum.Contracts; using HexBigInteger = Nethereum.Hex.HexTypes.HexBigInteger; namespace Frontend.Functions; -[Function("swapExactInputSingle", "uint256")] +[Function("exactInputSingle", "uint256")] public class SwapExactInputSingleFunction : FunctionMessage { - [Parameter("address", "tokenIn", 1)] + [Parameter("address", "tokenIn",1)] public string TokenIn { get; set; } - [Parameter("address", "tokenOut", 2)] + [Parameter("address", "tokenOut",2)] public string TokenOut { get; set; } + + [Parameter("uint24", "fee",3)] + public BigInteger Fee { get; set; } + + [Parameter("address", "recipient",4)] + public string Recipient { get; set; } - [Parameter("uint256", "amountIn", 3)] + [Parameter("uint256", "amountIn",5)] public BigInteger AmountIn { get; set; } - [Parameter("uint256", "amountOutMinimum", 4)] + [Parameter("uint256", "amountOutMinimum",6)] public BigInteger AmountOutMinimum { get; set; } - [Parameter("address", "recipient", 5)] - public string Recipient { get; set; } - - [Parameter("uint256", "deadline", 6)] - public BigInteger Deadline { get; set; } - - [Parameter("uint24", "fee", 7)] - public uint Fee { get; set; } - - [Parameter("uint160", "sqrtPriceLimitX96", 8)] + [Parameter("uint160", "sqrtPriceLimitX96",7)] public BigInteger SqrtPriceLimitX96 { get; set; } } \ No newline at end of file diff --git a/Frontend/Functions/SwapExactTokensForTokens.cs b/Frontend/Functions/SwapExactTokensForTokens.cs new file mode 100644 index 0000000..e69de29 diff --git a/Frontend/Pages/Index.cshtml.cs b/Frontend/Pages/Index.cshtml.cs index 5c1304a..ebe2a8b 100644 --- a/Frontend/Pages/Index.cshtml.cs +++ b/Frontend/Pages/Index.cshtml.cs @@ -1,19 +1,46 @@ -using Microsoft.AspNetCore.Mvc; +using Frontend.Configuration; using Microsoft.AspNetCore.Mvc.RazorPages; +using Nethereum.Web3; +using Nethereum.Web3.Accounts; namespace Frontend.Pages; public class IndexModel : PageModel { private readonly ILogger<IndexModel> _logger; + private readonly PoolV3Client _poolV3Client; + private readonly ChainSettings _chainSettings; + private readonly Account _account; - public IndexModel(ILogger<IndexModel> logger) + public IndexModel(ILogger<IndexModel> logger, Web3 web3, ChainSettings chainSettings, Account account) { _logger = logger; + _poolV3Client = new PoolV3Client(web3, chainSettings); + _chainSettings = chainSettings; + _account = account; } public void OnGet() { + string? fromTokenAddress = null; + string? toTokenAddress = null; + decimal amount = 0; + if (Request.Query.ContainsKey("swapROCToETH")) + { + fromTokenAddress = _chainSettings.TokenAddress; + toTokenAddress = _chainSettings.WethTokenAddress; + amount = decimal.Parse(Request.Query["swapROCToETH"]); + + }else if (Request.Query.ContainsKey("swapETHToROC")) + { + fromTokenAddress = _chainSettings.WethTokenAddress; + toTokenAddress = _chainSettings.TokenAddress; + amount = decimal.Parse(Request.Query["swapETHToROC"]); + } + if (amount > 0) + { + var amountRecieved = _poolV3Client.SwapAsync(fromTokenAddress, toTokenAddress, amount, _account).Result; + } } } diff --git a/Frontend/PoolV3Client.cs b/Frontend/PoolV3Client.cs index eddb65d..73d6f5a 100644 --- a/Frontend/PoolV3Client.cs +++ b/Frontend/PoolV3Client.cs @@ -7,6 +7,7 @@ using Nethereum.Web3; using Nethereum.Web3.Accounts; using Frontend.Configuration; + namespace Frontend; public class PoolV3Client @@ -107,13 +108,15 @@ public class PoolV3Client AmountIn = Web3.Convert.ToWei(amount), AmountOutMinimum = Web3.Convert.ToWei(amountOutMinimum), // Set your minimum amount out Recipient = account.Address, - Deadline = new BigInteger(DateTimeOffset.UtcNow.ToUnixTimeSeconds() + 90), // 1:30 minutes from now - Fee = await getPoolFeeTier(), + Fee = new BigInteger(await getPoolFeeTier()), SqrtPriceLimitX96 = sqrtPriceLimitX96 }; + swapFunction.Gas= new BigInteger(300000); + var handler = _web3.Eth.GetContractTransactionHandler<SwapExactInputSingleFunction>(); - var transactionReceipt = await handler.SendRequestAndWaitForReceiptAsync(_chainSettings.SwapRouterV2Address, swapFunction); + + var transactionReceipt = await handler.SendRequestAndWaitForReceiptAsync(_chainSettings.Uniswap.SwapRouterV2Address, swapFunction); var swapEvent = transactionReceipt.DecodeAllEvents<SwapEventDTO>(); if (swapEvent.Count > 0) { @@ -124,4 +127,6 @@ public class PoolV3Client throw new Exception("Swap event not found in transaction receipt"); } + + } \ No newline at end of file diff --git a/Frontend/appsettings.json b/Frontend/appsettings.json index 9cbb59b..250caa9 100644 --- a/Frontend/appsettings.json +++ b/Frontend/appsettings.json @@ -8,12 +8,13 @@ "Chain": { "ChainId": 11155111, "TokenAddress": "0xaF9EeB7b30fb1e1De40b284a3a92F5cB8E93cfff", + "WethTokenAddress":"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14", "Uniswap": { "UniswapV3Factory":"0x0227628f3F023bb0B980b67D528571c95c6DaC1c", "QuoterV2":"0xEd1f6473345F45b75F8179591dd5bA1888cf2FB3", - "WethTokenAddress": "0xfff9976782d46cc05630d1f6ebab18b2324d6b14", "RocEthPoolAddress": "0xF22CA6B27eaC677f132945C50Cd3499A9b8a6CBC", - "SwapRouterV2Address": "0x3bFA4769FB09eefC5a80d6E87c3B9C650f7Ae48E" + "SwapRouterV2Address": "0x3bFA4769FB09eefC5a80d6E87c3B9C650f7Ae48E", + "PermitV2Address":"0x000000000022D473030F116dDEE9F6B43aC78BA3" } }, "AllowedHosts": "*", -- GitLab