From 5255cc1f2d87c5b92d6c84766b99732148c7fb5c Mon Sep 17 00:00:00 2001 From: Zikriya Date: Wed, 13 Mar 2024 15:07:27 +0500 Subject: [PATCH 01/24] Contracts network config updated for dev env. FiberRouter.json updated --- src/constants/FiberRouter.json | 26 +++++++++++++++++++++++++- src/constants/constants.ts | 8 ++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/constants/FiberRouter.json b/src/constants/FiberRouter.json index 7b6493a..4aa8b44 100644 --- a/src/constants/FiberRouter.json +++ b/src/constants/FiberRouter.json @@ -464,6 +464,15 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { "internalType": "address", "name": "_weth", "type": "address" } + ], + "name": "setWETH", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { "internalType": "address", "name": "token", "type": "address" }, @@ -520,6 +529,11 @@ "internalType": "bytes32", "name": "withdrawalData", "type": "bytes32" + }, + { + "internalType": "enum FiberRouter.OneInchFunction", + "name": "funcSelector", + "type": "uint8" } ], "name": "swapAndCrossOneInch", @@ -556,7 +570,12 @@ "name": "withdrawalData", "type": "bytes32" }, - { "internalType": "uint256", "name": "gasFee", "type": "uint256" } + { "internalType": "uint256", "name": "gasFee", "type": "uint256" }, + { + "internalType": "enum FiberRouter.OneInchFunction", + "name": "funcSelector", + "type": "uint8" + } ], "name": "swapAndCrossOneInchETH", "outputs": [], @@ -598,6 +617,11 @@ }, { "internalType": "address", "name": "targetToken", "type": "address" }, { "internalType": "bytes", "name": "oneInchData", "type": "bytes" }, + { + "internalType": "enum FiberRouter.OneInchFunction", + "name": "funcSelector", + "type": "uint8" + }, { "internalType": "bytes32", "name": "salt", "type": "bytes32" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "bytes", "name": "multiSignature", "type": "bytes" } diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 7b96344..df64bc4 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -21,14 +21,14 @@ export const NETWORKS = [ }, { chainId: '56', - fundManagerAddress: '0xbD9D99bb2A136a1936B87031c7A8102831855289', - fiberRouterAddress: '0x7A32c872619DFE0f07d04ef8EBEe77C5d0622c58', + fundManagerAddress: '0xBFE96b3524a5d31B803BA133844C002Beaa79373', + fiberRouterAddress: '0xfc3c6f9B7c4C0d7d9C10C313BBfFD1ed89afb1a7', foundaryTokenAddress: '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d', }, { chainId: '42161', - fundManagerAddress: '0xbD9D99bb2A136a1936B87031c7A8102831855289', - fiberRouterAddress: '0x7A32c872619DFE0f07d04ef8EBEe77C5d0622c58', + fundManagerAddress: '0x4Ba81924a6D7DaF6Dba27783168E5b6345D6A896', + fiberRouterAddress: '0xfd595F8031f49b75CD0e85B902316f5F8a428C76', foundaryTokenAddress: '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8', }, ]; From 42addb37ee3e6032c11bbd6dedcd011460272da3 Mon Sep 17 00:00:00 2001 From: Zikriya Date: Wed, 3 Apr 2024 14:26:22 +0500 Subject: [PATCH 02/24] NETWORKS config updated --- src/constants/constants.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 0fd5971..81d47a2 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -33,14 +33,14 @@ export const NETWORKS = [ }, { chainId: '10', - fundManagerAddress: '0xfbae4Ba5eD36e480A7176116A9B3aba5DfDc0Ecb', - fiberRouterAddress: '0x8f33fFeC330f86c2E2a82506b3634908B9d46780', + fundManagerAddress: '0x7655eE1bd794b0Fe4b9B4D477B0F5cCABD78137c', + fiberRouterAddress: '0x6a34da798839964e14850F585187f3d28079a500', foundaryTokenAddress: '0x0b2c639c533813f4aa9d7837caf62653d097ff85', }, { chainId: '43114', - fundManagerAddress: '0x5eBeF0bD015e4fAfe64172Ae00b9bB46a05906a7', - fiberRouterAddress: '0xa0881682543E8Ab02ef8B250EC292523aD368edf', + fundManagerAddress: '0x41eFd89cbeaCeCdf72d3fD8321C53A69A132CC1a', + fiberRouterAddress: '0x9cc84e262E3A2A6b8C257d493E3d3487495fb5a2', foundaryTokenAddress: '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E', }, ]; From f4c887cd1ea937a3514634317e51380bbd99fa84 Mon Sep 17 00:00:00 2001 From: Zikriya Date: Fri, 5 Apr 2024 15:38:51 +0500 Subject: [PATCH 03/24] NETWORKS updated --- src/constants/constants.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 81d47a2..04a5e0a 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -16,7 +16,7 @@ export const NETWORKS = [ { chainId: '1', fundManagerAddress: '0x5eBeF0bD015e4fAfe64172Ae00b9bB46a05906a7', - fiberRouterAddress: '0x7A32c872619DFE0f07d04ef8EBEe77C5d0622c58', + fiberRouterAddress: '0x4B87Ab46B56990Aff03dAD1caFEb33e760879d97', foundaryTokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', }, { @@ -28,7 +28,7 @@ export const NETWORKS = [ { chainId: '42161', fundManagerAddress: '0x4Ba81924a6D7DaF6Dba27783168E5b6345D6A896', - fiberRouterAddress: '0xfd595F8031f49b75CD0e85B902316f5F8a428C76', + fiberRouterAddress: '0xb73A2a6cd7297844B1CbfcFfEb2884bEaf4C22B1', foundaryTokenAddress: '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8', }, { From 3e8b18d88cda3341df021e235d058d9d956bf56d Mon Sep 17 00:00:00 2001 From: Zikriya Date: Fri, 5 Apr 2024 16:40:07 +0500 Subject: [PATCH 04/24] bug fixed --- src/constants/FiberRouter.json | 375 ++++++++++++++++++++++++++++----- src/constants/constants.ts | 2 +- 2 files changed, 328 insertions(+), 49 deletions(-) diff --git a/src/constants/FiberRouter.json b/src/constants/FiberRouter.json index 4aa8b44..376d71f 100644 --- a/src/constants/FiberRouter.json +++ b/src/constants/FiberRouter.json @@ -4,15 +4,7 @@ "sourceName": "contracts/upgradeable-Bridge/FiberRouter.sol", "abi": [ { - "inputs": [ - { "internalType": "address", "name": "_weth", "type": "address" }, - { - "internalType": "address", - "name": "_oneInchAggregatorRouter", - "type": "address" - }, - { "internalType": "address", "name": "_pool", "type": "address" } - ], + "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, @@ -200,6 +192,49 @@ "name": "SwapHandled", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "sourceToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "targetToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "sourceAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "settledAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "sourceAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "targetAddress", + "type": "address" + } + ], + "name": "SwapSameNetwork", + "type": "event" + }, { "anonymous": false, "inputs": [ @@ -363,7 +398,13 @@ { "inputs": [], "name": "WETH", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], "stateMutability": "view", "type": "function" }, @@ -371,25 +412,61 @@ "inputs": [], "name": "gasWallet", "outputs": [ - { "internalType": "address payable", "name": "", "type": "address" } + { + "internalType": "address payable", + "name": "", + "type": "address" + } ], "stateMutability": "view", "type": "function" }, { - "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], "name": "inventory", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], "stateMutability": "view", "type": "function" }, { "inputs": [ - { "internalType": "address", "name": "token", "type": "address" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" }, - { "internalType": "string", "name": "targetNetwork", "type": "string" }, - { "internalType": "string", "name": "targetToken", "type": "string" }, - { "internalType": "string", "name": "targetAddress", "type": "string" }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "string", + "name": "targetNetwork", + "type": "string" + }, + { + "internalType": "string", + "name": "targetToken", + "type": "string" + }, + { + "internalType": "string", + "name": "targetAddress", + "type": "string" + }, { "internalType": "bytes32", "name": "withdrawalData", @@ -404,21 +481,39 @@ { "inputs": [], "name": "oneInchAggregatorRouter", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "pool", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], "stateMutability": "view", "type": "function" }, @@ -457,7 +552,11 @@ }, { "inputs": [ - { "internalType": "address", "name": "_pool", "type": "address" } + { + "internalType": "address", + "name": "_pool", + "type": "address" + } ], "name": "setPool", "outputs": [], @@ -466,7 +565,11 @@ }, { "inputs": [ - { "internalType": "address", "name": "_weth", "type": "address" } + { + "internalType": "address", + "name": "_weth", + "type": "address" + } ], "name": "setWETH", "outputs": [], @@ -475,14 +578,26 @@ }, { "inputs": [ - { "internalType": "address", "name": "token", "type": "address" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, { "internalType": "uint256", "name": "targetNetwork", "type": "uint256" }, - { "internalType": "address", "name": "targetToken", "type": "address" }, + { + "internalType": "address", + "name": "targetToken", + "type": "address" + }, { "internalType": "address", "name": "targetAddress", @@ -501,8 +616,16 @@ }, { "inputs": [ - { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, - { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, { "internalType": "uint256", "name": "crossTargetNetwork", @@ -518,8 +641,16 @@ "name": "crossTargetAddress", "type": "address" }, - { "internalType": "bytes", "name": "oneInchData", "type": "bytes" }, - { "internalType": "address", "name": "fromToken", "type": "address" }, + { + "internalType": "bytes", + "name": "oneInchData", + "type": "bytes" + }, + { + "internalType": "address", + "name": "fromToken", + "type": "address" + }, { "internalType": "address", "name": "foundryToken", @@ -543,7 +674,11 @@ }, { "inputs": [ - { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, { "internalType": "uint256", "name": "crossTargetNetwork", @@ -559,7 +694,11 @@ "name": "crossTargetAddress", "type": "address" }, - { "internalType": "bytes", "name": "oneInchData", "type": "bytes" }, + { + "internalType": "bytes", + "name": "oneInchData", + "type": "bytes" + }, { "internalType": "address", "name": "foundryToken", @@ -570,7 +709,11 @@ "name": "withdrawalData", "type": "bytes32" }, - { "internalType": "uint256", "name": "gasFee", "type": "uint256" }, + { + "internalType": "uint256", + "name": "gasFee", + "type": "uint256" + }, { "internalType": "enum FiberRouter.OneInchFunction", "name": "funcSelector", @@ -584,7 +727,87 @@ }, { "inputs": [ - { "internalType": "address", "name": "newOwner", "type": "address" } + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "address", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "toToken", + "type": "address" + }, + { + "internalType": "address", + "name": "targetAddress", + "type": "address" + }, + { + "internalType": "bytes", + "name": "oneInchData", + "type": "bytes" + }, + { + "internalType": "enum FiberRouter.OneInchFunction", + "name": "funcSelector", + "type": "uint8" + } + ], + "name": "swapOnSameNetwork", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "address", + "name": "toToken", + "type": "address" + }, + { + "internalType": "address", + "name": "targetAddress", + "type": "address" + }, + { + "internalType": "bytes", + "name": "oneInchData", + "type": "bytes" + }, + { + "internalType": "enum FiberRouter.OneInchFunction", + "name": "funcSelector", + "type": "uint8" + } + ], + "name": "swapOnSameNetworkETH", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } ], "name": "transferOwnership", "outputs": [], @@ -593,12 +816,36 @@ }, { "inputs": [ - { "internalType": "address", "name": "token", "type": "address" }, - { "internalType": "address", "name": "payee", "type": "address" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" }, - { "internalType": "bytes32", "name": "salt", "type": "bytes32" }, - { "internalType": "uint256", "name": "expiry", "type": "uint256" }, - { "internalType": "bytes", "name": "multiSignature", "type": "bytes" } + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "payee", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "multiSignature", + "type": "bytes" + } ], "name": "withdrawSigned", "outputs": [], @@ -607,24 +854,56 @@ }, { "inputs": [ - { "internalType": "address payable", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, - { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { + "internalType": "address payable", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, { "internalType": "address", "name": "foundryToken", "type": "address" }, - { "internalType": "address", "name": "targetToken", "type": "address" }, - { "internalType": "bytes", "name": "oneInchData", "type": "bytes" }, + { + "internalType": "address", + "name": "targetToken", + "type": "address" + }, + { + "internalType": "bytes", + "name": "oneInchData", + "type": "bytes" + }, { "internalType": "enum FiberRouter.OneInchFunction", "name": "funcSelector", "type": "uint8" }, - { "internalType": "bytes32", "name": "salt", "type": "bytes32" }, - { "internalType": "uint256", "name": "expiry", "type": "uint256" }, - { "internalType": "bytes", "name": "multiSignature", "type": "bytes" } + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "multiSignature", + "type": "bytes" + } ], "name": "withdrawSignedAndSwapOneInch", "outputs": [], diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 04a5e0a..0a9fa5f 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -22,7 +22,7 @@ export const NETWORKS = [ { chainId: '56', fundManagerAddress: '0xBFE96b3524a5d31B803BA133844C002Beaa79373', - fiberRouterAddress: '0xfc3c6f9B7c4C0d7d9C10C313BBfFD1ed89afb1a7', + fiberRouterAddress: '0x4B87Ab46B56990Aff03dAD1caFEb33e760879d97', foundaryTokenAddress: '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d', }, { From 19419343f158721a8c6057564c17176e3a7e3362 Mon Sep 17 00:00:00 2001 From: Zikriya Date: Thu, 2 May 2024 21:05:55 +0500 Subject: [PATCH 05/24] router selector updates --- src/constants/FiberRouter.json | 512 ++++++++++++++++-------------- src/constants/constants.ts | 15 +- src/services/signature.service.ts | 21 +- src/services/web3.service.ts | 6 + 4 files changed, 314 insertions(+), 240 deletions(-) diff --git a/src/constants/FiberRouter.json b/src/constants/FiberRouter.json index 376d71f..cbb6daf 100644 --- a/src/constants/FiberRouter.json +++ b/src/constants/FiberRouter.json @@ -3,25 +3,20 @@ "contractName": "FiberRouter", "sourceName": "contracts/upgradeable-Bridge/FiberRouter.sol", "abi": [ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, { "anonymous": false, "inputs": [ { - "indexed": false, + "indexed": true, "internalType": "address", - "name": "sourceToken", + "name": "burnToken", "type": "address" }, { "indexed": false, - "internalType": "string", - "name": "targetToken", - "type": "string" + "internalType": "uint256", + "name": "sourceAmount", + "type": "uint256" }, { "indexed": false, @@ -29,16 +24,10 @@ "name": "sourceChainId", "type": "uint256" }, - { - "indexed": false, - "internalType": "string", - "name": "targetChainId", - "type": "string" - }, { "indexed": false, "internalType": "uint256", - "name": "sourceAmount", + "name": "targetChainId", "type": "uint256" }, { @@ -49,24 +38,18 @@ }, { "indexed": false, - "internalType": "string", + "internalType": "address", "name": "targetAddress", - "type": "string" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "settledAmount", - "type": "uint256" + "type": "address" }, { "indexed": false, - "internalType": "bytes32", - "name": "withdrawalData", - "type": "bytes32" + "internalType": "uint64", + "name": "depositNonce", + "type": "uint64" } ], - "name": "NonEvmSwap", + "name": "CCTPSwap", "type": "event" }, { @@ -88,6 +71,44 @@ "name": "OwnershipTransferred", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "router", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "selector", + "type": "bytes" + } + ], + "name": "RouterAndSelectorRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "router", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "selector", + "type": "bytes" + } + ], + "name": "RouterAndSelectorWhitelisted", + "type": "event" + }, { "anonymous": false, "inputs": [ @@ -155,43 +176,6 @@ "name": "Swap", "type": "event" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "swapRouter", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "fromToken", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amountIn", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amountOut", - "type": "uint256" - } - ], - "name": "SwapHandled", - "type": "event" - }, { "anonymous": false, "inputs": [ @@ -235,74 +219,6 @@ "name": "SwapSameNetwork", "type": "event" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "swapRouter", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amountIn", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amountOut", - "type": "uint256" - } - ], - "name": "UniswapV3SwapHandled", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "swapRouter", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "fromToken", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amountIn", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amountOut", - "type": "uint256" - } - ], - "name": "UnoSwapHandled", - "type": "event" - }, { "anonymous": false, "inputs": [ @@ -358,7 +274,7 @@ { "indexed": false, "internalType": "uint256", - "name": "amountOutOneInch", + "name": "amountOut", "type": "uint256" }, { @@ -373,10 +289,16 @@ "name": "targetToken", "type": "address" }, + { + "indexed": false, + "internalType": "address", + "name": "router", + "type": "address" + }, { "indexed": false, "internalType": "bytes", - "name": "oneInchData", + "name": "routerCalldata", "type": "bytes" }, { @@ -392,12 +314,30 @@ "type": "bytes" } ], - "name": "WithdrawOneInch", + "name": "WithdrawRouter", "type": "event" }, + { + "inputs": [ + { + "internalType": "address", + "name": "router", + "type": "address" + }, + { + "internalType": "bytes", + "name": "selector", + "type": "bytes" + } + ], + "name": "addRouterAndSelector", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [], - "name": "WETH", + "name": "cctpTokenMessenger", "outputs": [ { "internalType": "address", @@ -421,6 +361,29 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [ + { + "internalType": "address", + "name": "_cctpTokenMessenger", + "type": "address" + }, + { + "internalType": "address", + "name": "_usdcToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_sourceCCTPFundManager", + "type": "address" + } + ], + "name": "initCCTP", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -444,43 +407,29 @@ "inputs": [ { "internalType": "address", - "name": "token", + "name": "router", "type": "address" }, { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "internalType": "string", - "name": "targetNetwork", - "type": "string" - }, - { - "internalType": "string", - "name": "targetToken", - "type": "string" - }, - { - "internalType": "string", - "name": "targetAddress", - "type": "string" - }, + "internalType": "bytes", + "name": "selector", + "type": "bytes" + } + ], + "name": "isAllowListed", + "outputs": [ { - "internalType": "bytes32", - "name": "withdrawalData", - "type": "bytes32" + "internalType": "bool", + "name": "", + "type": "bool" } ], - "name": "nonEvmSwap", - "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function" }, { "inputs": [], - "name": "oneInchAggregatorRouter", + "name": "owner", "outputs": [ { "internalType": "address", @@ -493,7 +442,7 @@ }, { "inputs": [], - "name": "owner", + "name": "pool", "outputs": [ { "internalType": "address", @@ -505,16 +454,21 @@ "type": "function" }, { - "inputs": [], - "name": "pool", - "outputs": [ + "inputs": [ { "internalType": "address", - "name": "", + "name": "router", "type": "address" + }, + { + "internalType": "bytes", + "name": "selector", + "type": "bytes" } ], - "stateMutability": "view", + "name": "removeRouterAndSelector", + "outputs": [], + "stateMutability": "nonpayable", "type": "function" }, { @@ -541,24 +495,34 @@ "inputs": [ { "internalType": "address", - "name": "_newRouterAddress", + "name": "_pool", "type": "address" } ], - "name": "setOneInchAggregatorRouter", + "name": "setPool", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ + { + "internalType": "uint256", + "name": "_chainID", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "_targetNetworkDomain", + "type": "uint32" + }, { "internalType": "address", - "name": "_pool", + "name": "_targetCCTPFundManager", "type": "address" } ], - "name": "setPool", + "name": "setTargetCCTPNetwork", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -571,11 +535,24 @@ "type": "address" } ], - "name": "setWETH", + "name": "setWeth", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "sourceCCTPFundManager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -607,6 +584,11 @@ "internalType": "bytes32", "name": "withdrawalData", "type": "bytes32" + }, + { + "internalType": "bool", + "name": "cctpType", + "type": "bool" } ], "name": "swap", @@ -623,37 +605,42 @@ }, { "internalType": "uint256", - "name": "amountOut", + "name": "minAmountOut", "type": "uint256" }, { - "internalType": "uint256", - "name": "crossTargetNetwork", - "type": "uint256" + "internalType": "address", + "name": "fromToken", + "type": "address" }, { "internalType": "address", - "name": "crossTargetToken", + "name": "foundryToken", "type": "address" }, { "internalType": "address", - "name": "crossTargetAddress", + "name": "router", "type": "address" }, { "internalType": "bytes", - "name": "oneInchData", + "name": "routerCalldata", "type": "bytes" }, + { + "internalType": "uint256", + "name": "crossTargetNetwork", + "type": "uint256" + }, { "internalType": "address", - "name": "fromToken", + "name": "crossTargetToken", "type": "address" }, { "internalType": "address", - "name": "foundryToken", + "name": "crossTargetAddress", "type": "address" }, { @@ -662,12 +649,12 @@ "type": "bytes32" }, { - "internalType": "enum FiberRouter.OneInchFunction", - "name": "funcSelector", - "type": "uint8" + "internalType": "bool", + "name": "cctpType", + "type": "bool" } ], - "name": "swapAndCrossOneInch", + "name": "swapAndCrossRouter", "outputs": [], "stateMutability": "payable", "type": "function" @@ -676,32 +663,42 @@ "inputs": [ { "internalType": "uint256", - "name": "amountOut", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "crossTargetNetwork", + "name": "minAmountOut", "type": "uint256" }, { "internalType": "address", - "name": "crossTargetToken", + "name": "foundryToken", "type": "address" }, + { + "internalType": "uint256", + "name": "gasFee", + "type": "uint256" + }, { "internalType": "address", - "name": "crossTargetAddress", + "name": "router", "type": "address" }, { "internalType": "bytes", - "name": "oneInchData", + "name": "routerCalldata", "type": "bytes" }, + { + "internalType": "uint256", + "name": "crossTargetNetwork", + "type": "uint256" + }, { "internalType": "address", - "name": "foundryToken", + "name": "crossTargetToken", + "type": "address" + }, + { + "internalType": "address", + "name": "crossTargetAddress", "type": "address" }, { @@ -710,17 +707,12 @@ "type": "bytes32" }, { - "internalType": "uint256", - "name": "gasFee", - "type": "uint256" - }, - { - "internalType": "enum FiberRouter.OneInchFunction", - "name": "funcSelector", - "type": "uint8" + "internalType": "bool", + "name": "cctpType", + "type": "bool" } ], - "name": "swapAndCrossOneInchETH", + "name": "swapAndCrossRouterETH", "outputs": [], "stateMutability": "payable", "type": "function" @@ -734,7 +726,7 @@ }, { "internalType": "uint256", - "name": "amountOut", + "name": "minAmountOut", "type": "uint256" }, { @@ -753,14 +745,14 @@ "type": "address" }, { - "internalType": "bytes", - "name": "oneInchData", - "type": "bytes" + "internalType": "address", + "name": "router", + "type": "address" }, { - "internalType": "enum FiberRouter.OneInchFunction", - "name": "funcSelector", - "type": "uint8" + "internalType": "bytes", + "name": "routerCalldata", + "type": "bytes" } ], "name": "swapOnSameNetwork", @@ -772,7 +764,7 @@ "inputs": [ { "internalType": "uint256", - "name": "amountOut", + "name": "minAmountOut", "type": "uint256" }, { @@ -786,14 +778,14 @@ "type": "address" }, { - "internalType": "bytes", - "name": "oneInchData", - "type": "bytes" + "internalType": "address", + "name": "router", + "type": "address" }, { - "internalType": "enum FiberRouter.OneInchFunction", - "name": "funcSelector", - "type": "uint8" + "internalType": "bytes", + "name": "routerCalldata", + "type": "bytes" } ], "name": "swapOnSameNetworkETH", @@ -801,6 +793,30 @@ "stateMutability": "payable", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "targetNetworks", + "outputs": [ + { + "internalType": "uint32", + "name": "targetNetworkDomain", + "type": "uint32" + }, + { + "internalType": "address", + "name": "targetCCTPFundManager", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -814,6 +830,32 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "usdcToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "weth", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -845,6 +887,11 @@ "internalType": "bytes", "name": "multiSignature", "type": "bytes" + }, + { + "internalType": "bool", + "name": "cctpType", + "type": "bool" } ], "name": "withdrawSigned", @@ -866,7 +913,7 @@ }, { "internalType": "uint256", - "name": "amountOut", + "name": "minAmountOut", "type": "uint256" }, { @@ -880,14 +927,14 @@ "type": "address" }, { - "internalType": "bytes", - "name": "oneInchData", - "type": "bytes" + "internalType": "address", + "name": "router", + "type": "address" }, { - "internalType": "enum FiberRouter.OneInchFunction", - "name": "funcSelector", - "type": "uint8" + "internalType": "bytes", + "name": "routerCalldata", + "type": "bytes" }, { "internalType": "bytes32", @@ -903,9 +950,14 @@ "internalType": "bytes", "name": "multiSignature", "type": "bytes" + }, + { + "internalType": "bool", + "name": "cctpType", + "type": "bool" } ], - "name": "withdrawSignedAndSwapOneInch", + "name": "withdrawSignedAndSwapRouter", "outputs": [], "stateMutability": "nonpayable", "type": "function" diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 0a9fa5f..42b7260 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -18,30 +18,37 @@ export const NETWORKS = [ fundManagerAddress: '0x5eBeF0bD015e4fAfe64172Ae00b9bB46a05906a7', fiberRouterAddress: '0x4B87Ab46B56990Aff03dAD1caFEb33e760879d97', foundaryTokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', + aggregateRouterContractAddress: '', }, { chainId: '56', - fundManagerAddress: '0xBFE96b3524a5d31B803BA133844C002Beaa79373', - fiberRouterAddress: '0x4B87Ab46B56990Aff03dAD1caFEb33e760879d97', + fundManagerAddress: '0xB4A5D95BFEC6AFd359e05aA982718C11bF04a7Ff', + fiberRouterAddress: '0xbB1886FA834917716049094090387DEa0680BFFc', foundaryTokenAddress: '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d', + aggregateRouterContractAddress: + '0x111111125421ca6dc452d289314280a0f8842a65', }, { chainId: '42161', - fundManagerAddress: '0x4Ba81924a6D7DaF6Dba27783168E5b6345D6A896', - fiberRouterAddress: '0xb73A2a6cd7297844B1CbfcFfEb2884bEaf4C22B1', + fundManagerAddress: '0x2AB6D6c328978D0DCC5a9ac0BA04E45e358e3B9a', + fiberRouterAddress: '0x8d8559221D55338369C1B305A58eb86fdcE3B8b9', foundaryTokenAddress: '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8', + aggregateRouterContractAddress: + '0x111111125421ca6dc452d289314280a0f8842a65', }, { chainId: '10', fundManagerAddress: '0x7655eE1bd794b0Fe4b9B4D477B0F5cCABD78137c', fiberRouterAddress: '0x6a34da798839964e14850F585187f3d28079a500', foundaryTokenAddress: '0x0b2c639c533813f4aa9d7837caf62653d097ff85', + aggregateRouterContractAddress: '', }, { chainId: '43114', fundManagerAddress: '0x41eFd89cbeaCeCdf72d3fD8321C53A69A132CC1a', fiberRouterAddress: '0x9cc84e262E3A2A6b8C257d493E3d3487495fb5a2', foundaryTokenAddress: '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E', + aggregateRouterContractAddress: '', }, ]; diff --git a/src/services/signature.service.ts b/src/services/signature.service.ts index 8d8e741..b71d7eb 100644 --- a/src/services/signature.service.ts +++ b/src/services/signature.service.ts @@ -24,6 +24,7 @@ import { bufferToHex, } from 'ethereumjs-util'; import { decimals, decimalsIntoNumber, withSlippage } from '../constants/utils'; +import { getAggregateRouterTokenAddress } from './web3.service'; export const getDataForSignature = async (job: any): Promise => { let decodedData = job.signatureData; @@ -55,6 +56,9 @@ export const getDataForSignature = async (job: any): Promise => { sourceOneInchData: withdrawalData?.sourceOneInchData, destinationOneInchData: withdrawalData?.destinationOneInchData, expiry: job.data.expiry, + aggregateRouterContractAddress: getAggregateRouterTokenAddress( + decodedData.targetChainId, + ), }; return txData; }; @@ -132,9 +136,10 @@ export const createSignedPayment = ( amountIn: string, amountOut: string, targetFoundaryToken: string, - oneInchData: string, + routerCalldata: string, expiry: number, web3: Web3, + aggregateRouterContractAddress: string, ) => { let hash; if (destinationAssetType == FOUNDARY) { @@ -158,9 +163,10 @@ export const createSignedPayment = ( amountOut, targetFoundaryToken, targetToken, - oneInchData, + routerCalldata, salt, expiry, + aggregateRouterContractAddress, ); } const privateKey = getPrivateKey(); @@ -218,13 +224,14 @@ export const produceOneInchHash = ( amountOut: string, foundryToken: string, targetToken: string, - oneInchData: string, + routerCalldata: string, salt: string, expiry: number, + aggregateRouterContractAddress: string, ): any => { const methodHash = Web3.utils.keccak256( Web3.utils.utf8ToHex( - 'WithdrawSignedOneInch(address to,uint256 amountIn,uint256 amountOut,address foundryToken,address targetToken,bytes oneInchData,bytes32 salt,uint256 expiry)', + 'withdrawSignedAndSwapRouter(address to,uint256 amountIn,uint256 minAmountOut,address foundryToken,address targetToken,address router,bytes32 routerCalldata,bytes32 salt,uint256 expiry)', ), ); const params = [ @@ -234,7 +241,8 @@ export const produceOneInchHash = ( 'uint256', 'address', 'address', - 'bytes', + 'address', + 'bytes32', 'bytes32', 'uint256', ]; @@ -245,7 +253,8 @@ export const produceOneInchHash = ( amountOut, foundryToken, targetToken, - oneInchData, + aggregateRouterContractAddress, + Web3.utils.keccak256(routerCalldata), salt, expiry, ]); diff --git a/src/services/web3.service.ts b/src/services/web3.service.ts index e86222b..d59b0ee 100644 --- a/src/services/web3.service.ts +++ b/src/services/web3.service.ts @@ -61,6 +61,7 @@ export const signedTransaction = async ( txData.destinationOneInchData, txData.expiry, web3, + txData.aggregateRouterContractAddress, ); return { @@ -98,6 +99,11 @@ export const getFoundaryTokenAddress = (targetChainId: string): string => { return ''; }; +export const getAggregateRouterTokenAddress = (chainId: string) => { + let item = NETWORKS.find((item: any) => item.chainId === chainId); + return item ? item.aggregateRouterContractAddress : ''; +}; + const getDestinationAmount = async (data: any) => { return data.swapBridgeAmount; }; From 2a03269cb0db3a4c53a285c410f71d2e77db15d0 Mon Sep 17 00:00:00 2001 From: Zikriya Date: Sat, 4 May 2024 18:15:49 +0500 Subject: [PATCH 06/24] zksync and base network configs added --- src/constants/constants.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 42b7260..9da5e78 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -50,6 +50,22 @@ export const NETWORKS = [ foundaryTokenAddress: '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E', aggregateRouterContractAddress: '', }, + { + chainId: '8453', + fundManagerAddress: '0x1ab9e7689b9eD478aA65EE409aA7d3086d8c37cE', + fiberRouterAddress: '0x20e7d7150B5FCe330290aB4c23aC799046153c41', + foundaryTokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', + aggregateRouterContractAddress: + '0x111111125421ca6dc452d289314280a0f8842a65', + }, + { + chainId: '324', + fundManagerAddress: '0x09a3078fdb233e3De911cFba3D49D6902d29E36F', + fiberRouterAddress: '0x60ACb601eaE3ec5F9BC7679F20128b07Fc703Dbd', + foundaryTokenAddress: '0x1d17CBcF0D6D143135aE902365D2E5e2A16538D4', + aggregateRouterContractAddress: + '0x6fd4383cb451173d5f9304f041c7bcbf27d561ff', + }, ]; const getAllowedPublicAddress = function (): [] { From ae05a8c130449a983e790bfdd510009b721ed55e Mon Sep 17 00:00:00 2001 From: Arslan Kibria Date: Mon, 6 May 2024 14:51:10 +0500 Subject: [PATCH 07/24] CCTP flow --- src/constants/FiberRouter.json | 502 ++++------------------------ src/constants/constants.ts | 14 +- src/interfaces/job.interface.ts | 1 + src/services/signature.service.ts | 2 + src/services/transaction.service.ts | 36 +- src/services/web3.service.ts | 8 +- 6 files changed, 101 insertions(+), 462 deletions(-) diff --git a/src/constants/FiberRouter.json b/src/constants/FiberRouter.json index cbb6daf..dcd42c9 100644 --- a/src/constants/FiberRouter.json +++ b/src/constants/FiberRouter.json @@ -3,55 +3,6 @@ "contractName": "FiberRouter", "sourceName": "contracts/upgradeable-Bridge/FiberRouter.sol", "abi": [ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "burnToken", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "sourceAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "sourceChainId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "targetChainId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "sourceAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "targetAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint64", - "name": "depositNonce", - "type": "uint64" - } - ], - "name": "CCTPSwap", - "type": "event" - }, { "anonymous": false, "inputs": [ @@ -171,6 +122,12 @@ "internalType": "uint256", "name": "gasAmount", "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "depositNonce", + "type": "uint256" } ], "name": "Swap", @@ -319,16 +276,8 @@ }, { "inputs": [ - { - "internalType": "address", - "name": "router", - "type": "address" - }, - { - "internalType": "bytes", - "name": "selector", - "type": "bytes" - } + { "internalType": "address", "name": "router", "type": "address" }, + { "internalType": "bytes", "name": "selector", "type": "bytes" } ], "name": "addRouterAndSelector", "outputs": [], @@ -337,134 +286,55 @@ }, { "inputs": [], - "name": "cctpTokenMessenger", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], + "name": "cctpFundManager", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], - "name": "gasWallet", - "outputs": [ - { - "internalType": "address payable", - "name": "", - "type": "address" - } - ], + "name": "fundManager", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { - "inputs": [ - { - "internalType": "address", - "name": "_cctpTokenMessenger", - "type": "address" - }, - { - "internalType": "address", - "name": "_usdcToken", - "type": "address" - }, - { - "internalType": "address", - "name": "_sourceCCTPFundManager", - "type": "address" - } + "inputs": [], + "name": "gasWallet", + "outputs": [ + { "internalType": "address payable", "name": "", "type": "address" } ], - "name": "initCCTP", - "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function" }, { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], "name": "inventory", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [ - { - "internalType": "address", - "name": "router", - "type": "address" - }, - { - "internalType": "bytes", - "name": "selector", - "type": "bytes" - } + { "internalType": "address", "name": "router", "type": "address" }, + { "internalType": "bytes", "name": "selector", "type": "bytes" } ], "name": "isAllowListed", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "pool", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [ - { - "internalType": "address", - "name": "router", - "type": "address" - }, - { - "internalType": "bytes", - "name": "selector", - "type": "bytes" - } + { "internalType": "address", "name": "router", "type": "address" }, + { "internalType": "bytes", "name": "selector", "type": "bytes" } ], "name": "removeRouterAndSelector", "outputs": [], @@ -481,25 +351,21 @@ { "inputs": [ { - "internalType": "address payable", - "name": "_gasWallet", + "internalType": "address", + "name": "_cctpFundManager", "type": "address" } ], - "name": "setGasWallet", + "name": "setCCTPFundManager", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ - { - "internalType": "address", - "name": "_pool", - "type": "address" - } + { "internalType": "address", "name": "_fundManager", "type": "address" } ], - "name": "setPool", + "name": "setFundManager", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -507,74 +373,35 @@ { "inputs": [ { - "internalType": "uint256", - "name": "_chainID", - "type": "uint256" - }, - { - "internalType": "uint32", - "name": "_targetNetworkDomain", - "type": "uint32" - }, - { - "internalType": "address", - "name": "_targetCCTPFundManager", + "internalType": "address payable", + "name": "_gasWallet", "type": "address" } ], - "name": "setTargetCCTPNetwork", + "name": "setGasWallet", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ - { - "internalType": "address", - "name": "_weth", - "type": "address" - } + { "internalType": "address", "name": "_weth", "type": "address" } ], "name": "setWeth", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, - { - "inputs": [], - "name": "sourceCCTPFundManager", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ - { - "internalType": "address", - "name": "token", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" }, { "internalType": "uint256", "name": "targetNetwork", "type": "uint256" }, - { - "internalType": "address", - "name": "targetToken", - "type": "address" - }, + { "internalType": "address", "name": "targetToken", "type": "address" }, { "internalType": "address", "name": "targetAddress", @@ -585,11 +412,7 @@ "name": "withdrawalData", "type": "bytes32" }, - { - "internalType": "bool", - "name": "cctpType", - "type": "bool" - } + { "internalType": "bool", "name": "cctpType", "type": "bool" } ], "name": "swap", "outputs": [], @@ -598,36 +421,20 @@ }, { "inputs": [ - { - "internalType": "uint256", - "name": "amountIn", - "type": "uint256" - }, + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, { "internalType": "uint256", "name": "minAmountOut", "type": "uint256" }, - { - "internalType": "address", - "name": "fromToken", - "type": "address" - }, + { "internalType": "address", "name": "fromToken", "type": "address" }, { "internalType": "address", "name": "foundryToken", "type": "address" }, - { - "internalType": "address", - "name": "router", - "type": "address" - }, - { - "internalType": "bytes", - "name": "routerCalldata", - "type": "bytes" - }, + { "internalType": "address", "name": "router", "type": "address" }, + { "internalType": "bytes", "name": "routerCalldata", "type": "bytes" }, { "internalType": "uint256", "name": "crossTargetNetwork", @@ -648,11 +455,7 @@ "name": "withdrawalData", "type": "bytes32" }, - { - "internalType": "bool", - "name": "cctpType", - "type": "bool" - } + { "internalType": "bool", "name": "cctpType", "type": "bool" } ], "name": "swapAndCrossRouter", "outputs": [], @@ -671,21 +474,9 @@ "name": "foundryToken", "type": "address" }, - { - "internalType": "uint256", - "name": "gasFee", - "type": "uint256" - }, - { - "internalType": "address", - "name": "router", - "type": "address" - }, - { - "internalType": "bytes", - "name": "routerCalldata", - "type": "bytes" - }, + { "internalType": "uint256", "name": "gasFee", "type": "uint256" }, + { "internalType": "address", "name": "router", "type": "address" }, + { "internalType": "bytes", "name": "routerCalldata", "type": "bytes" }, { "internalType": "uint256", "name": "crossTargetNetwork", @@ -706,11 +497,7 @@ "name": "withdrawalData", "type": "bytes32" }, - { - "internalType": "bool", - "name": "cctpType", - "type": "bool" - } + { "internalType": "bool", "name": "cctpType", "type": "bool" } ], "name": "swapAndCrossRouterETH", "outputs": [], @@ -719,41 +506,21 @@ }, { "inputs": [ - { - "internalType": "uint256", - "name": "amountIn", - "type": "uint256" - }, + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, { "internalType": "uint256", "name": "minAmountOut", "type": "uint256" }, - { - "internalType": "address", - "name": "fromToken", - "type": "address" - }, - { - "internalType": "address", - "name": "toToken", - "type": "address" - }, + { "internalType": "address", "name": "fromToken", "type": "address" }, + { "internalType": "address", "name": "toToken", "type": "address" }, { "internalType": "address", "name": "targetAddress", "type": "address" }, - { - "internalType": "address", - "name": "router", - "type": "address" - }, - { - "internalType": "bytes", - "name": "routerCalldata", - "type": "bytes" - } + { "internalType": "address", "name": "router", "type": "address" }, + { "internalType": "bytes", "name": "routerCalldata", "type": "bytes" } ], "name": "swapOnSameNetwork", "outputs": [], @@ -767,26 +534,14 @@ "name": "minAmountOut", "type": "uint256" }, - { - "internalType": "address", - "name": "toToken", - "type": "address" - }, + { "internalType": "address", "name": "toToken", "type": "address" }, { "internalType": "address", "name": "targetAddress", "type": "address" }, - { - "internalType": "address", - "name": "router", - "type": "address" - }, - { - "internalType": "bytes", - "name": "routerCalldata", - "type": "bytes" - } + { "internalType": "address", "name": "router", "type": "address" }, + { "internalType": "bytes", "name": "routerCalldata", "type": "bytes" } ], "name": "swapOnSameNetworkETH", "outputs": [], @@ -795,104 +550,29 @@ }, { "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "targetNetworks", - "outputs": [ - { - "internalType": "uint32", - "name": "targetNetworkDomain", - "type": "uint32" - }, - { - "internalType": "address", - "name": "targetCCTPFundManager", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } + { "internalType": "address", "name": "newOwner", "type": "address" } ], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, - { - "inputs": [], - "name": "usdcToken", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [], "name": "weth", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [ - { - "internalType": "address", - "name": "token", - "type": "address" - }, - { - "internalType": "address", - "name": "payee", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "expiry", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "multiSignature", - "type": "bytes" - }, - { - "internalType": "bool", - "name": "cctpType", - "type": "bool" - } + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "address", "name": "payee", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "bytes32", "name": "salt", "type": "bytes32" }, + { "internalType": "uint256", "name": "expiry", "type": "uint256" }, + { "internalType": "bytes", "name": "multiSignature", "type": "bytes" }, + { "internalType": "bool", "name": "cctpType", "type": "bool" } ], "name": "withdrawSigned", "outputs": [], @@ -901,16 +581,8 @@ }, { "inputs": [ - { - "internalType": "address payable", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amountIn", - "type": "uint256" - }, + { "internalType": "address payable", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, { "internalType": "uint256", "name": "minAmountOut", @@ -921,41 +593,13 @@ "name": "foundryToken", "type": "address" }, - { - "internalType": "address", - "name": "targetToken", - "type": "address" - }, - { - "internalType": "address", - "name": "router", - "type": "address" - }, - { - "internalType": "bytes", - "name": "routerCalldata", - "type": "bytes" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "expiry", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "multiSignature", - "type": "bytes" - }, - { - "internalType": "bool", - "name": "cctpType", - "type": "bool" - } + { "internalType": "address", "name": "targetToken", "type": "address" }, + { "internalType": "address", "name": "router", "type": "address" }, + { "internalType": "bytes", "name": "routerCalldata", "type": "bytes" }, + { "internalType": "bytes32", "name": "salt", "type": "bytes32" }, + { "internalType": "uint256", "name": "expiry", "type": "uint256" }, + { "internalType": "bytes", "name": "multiSignature", "type": "bytes" }, + { "internalType": "bool", "name": "cctpType", "type": "bool" } ], "name": "withdrawSignedAndSwapRouter", "outputs": [], diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 9da5e78..683f70e 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -2,7 +2,7 @@ import moment from 'moment'; var crypto = require('crypto'); var CryptoJS = require('crypto-js'); -export const NAME = 'FUND_MANAGER'; +export const NAME = 'CCTP_FUND_MANAGER'; export const VERSION = '000.004'; export const CONTRACT_ADDRESS = '0x9aFe354fb34a6303a9b9C89fF43A509A5320ba2D'; export const BEARER = 'Bearer '; @@ -30,11 +30,12 @@ export const NETWORKS = [ }, { chainId: '42161', - fundManagerAddress: '0x2AB6D6c328978D0DCC5a9ac0BA04E45e358e3B9a', - fiberRouterAddress: '0x8d8559221D55338369C1B305A58eb86fdcE3B8b9', - foundaryTokenAddress: '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8', + fundManagerAddress: '0x80944eeaec9634F02889ca7c165d3fc1A473AeCA', + fiberRouterAddress: '0xE6A7A9dD2C0F02D572F9BEbc875B98E013918522', + foundaryTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', aggregateRouterContractAddress: '0x111111125421ca6dc452d289314280a0f8842a65', + cctpFundManager: '0x5D414D40cEc9A9d81877FB8eeB218Cc577271941', }, { chainId: '10', @@ -52,11 +53,12 @@ export const NETWORKS = [ }, { chainId: '8453', - fundManagerAddress: '0x1ab9e7689b9eD478aA65EE409aA7d3086d8c37cE', - fiberRouterAddress: '0x20e7d7150B5FCe330290aB4c23aC799046153c41', + fundManagerAddress: '0xEd2cE4f32779249682B0CcA7b7eC3Fc8B19Be9B6', + fiberRouterAddress: '0x4408ea5C17dC6E610eb7327361297D094762f9B0', foundaryTokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', aggregateRouterContractAddress: '0x111111125421ca6dc452d289314280a0f8842a65', + cctpFundManager: '0x8EcDf548e4daB7ecB611Ed39cA62ff36Ebc52d73', }, { chainId: '324', diff --git a/src/interfaces/job.interface.ts b/src/interfaces/job.interface.ts index 61bde90..88659be 100644 --- a/src/interfaces/job.interface.ts +++ b/src/interfaces/job.interface.ts @@ -19,6 +19,7 @@ export interface JobRequestBody { sourceChainId: string; destinationChaibId: string; slippage: number; + isCCTP: boolean; } export interface SignatureData { diff --git a/src/services/signature.service.ts b/src/services/signature.service.ts index b71d7eb..6a98931 100644 --- a/src/services/signature.service.ts +++ b/src/services/signature.service.ts @@ -36,6 +36,7 @@ export const getDataForSignature = async (job: any): Promise => { amount: decodedData.amount, fundManagerContractAddress: web3Service.getFundManagerAddress( decodedData.targetChainId, + job.data.isCCTP, ), fiberRouterAddress: web3Service.getFiberRouterAddress( decodedData.targetChainId, @@ -188,6 +189,7 @@ export const produceFoundaryHash = ( swapTxId: string, expiry: number, ): any => { + console.log(contractAddress, 'contractAddress'); const methodHash = Web3.utils.keccak256( Web3.utils.utf8ToHex( 'WithdrawSigned(address token,address payee,uint256 amount,bytes32 salt,uint256 expiry)', diff --git a/src/services/transaction.service.ts b/src/services/transaction.service.ts index bd93ba6..99ca9e1 100644 --- a/src/services/transaction.service.ts +++ b/src/services/transaction.service.ts @@ -30,6 +30,7 @@ export async function prepareObjectsAndVerifySignatures(tx: any) { sourceChainId: sourceNetwork.chainId, destinationChaibId: destinationNetwork.chainId, slippage: tx.slippage, + isCCTP: tx?.isCCTP ? tx?.isCCTP : false, }; let signatureData: SignatureData = { @@ -56,22 +57,15 @@ export async function prepareObjectsAndVerifySignatures(tx: any) { export async function verifySignatures(job: any) { try { - if (job.data.isDestinationNonEVM != null && job.data.isDestinationNonEVM) { - // let sd = await cosmWasmService.signedTransaction(job, decodedData, tx); - // if (cosmWasmService.validateSignature(job, sd.signatures) == false) { - // await updateTransaction(job); - // } - } else { - let sd = await web3Service.signedTransaction( - job, - getGeneratorHash(job.transaction), - ); - if ( - (await signatureService.validateSignature(job, sd.signatures)) == false - ) { - await updateTransaction(job.data.txId, null, true); - return; - } + let sd = await web3Service.signedTransaction( + job, + getGeneratorHash(job.transaction), + ); + if ( + (await signatureService.validateSignature(job, sd.signatures)) == false + ) { + await updateTransaction(job.data.txId, null, true); + return; } await createWithdrawalSignature(job); } catch (error) { @@ -83,15 +77,7 @@ export async function createWithdrawalSignature(job: any) { try { let tx: any = {}; let signedData; - if (job.data.isDestinationNonEVM != null && job.data.isDestinationNonEVM) { - // signedData = await cosmWasmService.signedTransaction( - // job, - // decodedData, - // tx, - // ); - } else { - signedData = await web3Service.signedTransaction(job, ''); - } + signedData = await web3Service.signedTransaction(job, ''); await updateTransaction(job.data.txId, signedData, false); } catch (error) { console.error('error occured', error); diff --git a/src/services/web3.service.ts b/src/services/web3.service.ts index d59b0ee..b32dfd1 100644 --- a/src/services/web3.service.ts +++ b/src/services/web3.service.ts @@ -75,10 +75,14 @@ export const signedTransaction = async ( } }; -export const getFundManagerAddress = (chainId: string) => { +export const getFundManagerAddress = (chainId: string, isCCTP: boolean) => { if (NETWORKS && NETWORKS.length > 0) { let item = NETWORKS.find((item: any) => item.chainId === chainId); - return item ? item.fundManagerAddress : ''; + if (isCCTP) { + return item ? item.cctpFundManager : ''; + } else { + return item ? item.fundManagerAddress : ''; + } } return ''; }; From ef11516a46bac5834ae3d7149114c163467c3344 Mon Sep 17 00:00:00 2001 From: Zikriya Date: Mon, 6 May 2024 21:14:06 +0500 Subject: [PATCH 08/24] config updated --- src/constants/constants.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 683f70e..6db43b4 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -2,7 +2,7 @@ import moment from 'moment'; var crypto = require('crypto'); var CryptoJS = require('crypto-js'); -export const NAME = 'CCTP_FUND_MANAGER'; +export const NAME = 'FUND_MANAGER'; export const VERSION = '000.004'; export const CONTRACT_ADDRESS = '0x9aFe354fb34a6303a9b9C89fF43A509A5320ba2D'; export const BEARER = 'Bearer '; @@ -35,7 +35,7 @@ export const NETWORKS = [ foundaryTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', aggregateRouterContractAddress: '0x111111125421ca6dc452d289314280a0f8842a65', - cctpFundManager: '0x5D414D40cEc9A9d81877FB8eeB218Cc577271941', + cctpFundManager: '0x98E4F18F63Cb0B815ad7C6DdFfAfbabb54550a0e', }, { chainId: '10', @@ -58,7 +58,7 @@ export const NETWORKS = [ foundaryTokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', aggregateRouterContractAddress: '0x111111125421ca6dc452d289314280a0f8842a65', - cctpFundManager: '0x8EcDf548e4daB7ecB611Ed39cA62ff36Ebc52d73', + cctpFundManager: '0xd0e48dDf333a3c445aC2391153991851045E8162', }, { chainId: '324', From ad0bc8609dbb39fb9fda015cec11707a70b46d38 Mon Sep 17 00:00:00 2001 From: Zikriya Date: Thu, 9 May 2024 13:45:46 +0500 Subject: [PATCH 09/24] Scroll network config --- src/constants/constants.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 6db43b4..9064c9d 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -68,6 +68,14 @@ export const NETWORKS = [ aggregateRouterContractAddress: '0x6fd4383cb451173d5f9304f041c7bcbf27d561ff', }, + { + chainId: '534352', + fundManagerAddress: '0xb28d89D2B218ced7B64272CD61036F655c2573e4', + fiberRouterAddress: '0x35dA469ECbFFCBfaF8cAC31Fe0645B158e252Eb6', + foundaryTokenAddress: '0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4', + aggregateRouterContractAddress: + '0x6131B5fae19EA4f9D964eAc0408E4408b66337b5', + }, ]; const getAllowedPublicAddress = function (): [] { From de3693bba386f509fa44b0cc185157aa39c1fffc Mon Sep 17 00:00:00 2001 From: Zikriya Date: Sun, 12 May 2024 00:09:43 +0500 Subject: [PATCH 10/24] Improvements for fee distribution flow --- src/constants/FiberRouter.json | 355 ++++++++++++++++++++++------ src/constants/constants.ts | 12 +- src/interfaces/job.interface.ts | 1 + src/services/signature.service.ts | 8 +- src/services/transaction.service.ts | 1 + 5 files changed, 299 insertions(+), 78 deletions(-) diff --git a/src/constants/FiberRouter.json b/src/constants/FiberRouter.json index dcd42c9..a3d159b 100644 --- a/src/constants/FiberRouter.json +++ b/src/constants/FiberRouter.json @@ -3,6 +3,37 @@ "contractName": "FiberRouter", "sourceName": "contracts/upgradeable-Bridge/FiberRouter.sol", "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "preFeeAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "afterFeeAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalFee", + "type": "uint256" + } + ], + "name": "FeesDistributed", + "type": "event" + }, { "anonymous": false, "inputs": [ @@ -52,9 +83,9 @@ }, { "indexed": false, - "internalType": "bytes", + "internalType": "bytes4", "name": "selector", - "type": "bytes" + "type": "bytes4" } ], "name": "RouterAndSelectorWhitelisted", @@ -274,12 +305,49 @@ "name": "WithdrawRouter", "type": "event" }, + { + "inputs": [], + "name": "DISTRIBUTE_FEES_TYPEHASH", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "FEE_ALLOCATION_TYPEHASH", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "NAME", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VERSION", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { "internalType": "address", "name": "router", "type": "address" }, - { "internalType": "bytes", "name": "selector", "type": "bytes" } + { "internalType": "bytes4[]", "name": "selectors", "type": "bytes4[]" } + ], + "name": "addRouterAndSelectors", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_signer", "type": "address" } ], - "name": "addRouterAndSelector", + "name": "addSigner", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -341,6 +409,15 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { "internalType": "address", "name": "_signer", "type": "address" } + ], + "name": "removeSigner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [], "name": "renounceOwnership", @@ -392,160 +469,291 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "signers", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ - { "internalType": "address", "name": "token", "type": "address" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, { "internalType": "uint256", - "name": "targetNetwork", + "name": "minAmountOut", "type": "uint256" }, - { "internalType": "address", "name": "targetToken", "type": "address" }, + { "internalType": "address", "name": "fromToken", "type": "address" }, + { "internalType": "address", "name": "toToken", "type": "address" }, { "internalType": "address", "name": "targetAddress", "type": "address" }, - { - "internalType": "bytes32", - "name": "withdrawalData", - "type": "bytes32" - }, - { "internalType": "bool", "name": "cctpType", "type": "bool" } + { "internalType": "address", "name": "router", "type": "address" }, + { "internalType": "bytes", "name": "routerCalldata", "type": "bytes" } ], - "name": "swap", + "name": "swapOnSameNetwork", "outputs": [], - "stateMutability": "payable", + "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ - { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, { "internalType": "uint256", "name": "minAmountOut", "type": "uint256" }, - { "internalType": "address", "name": "fromToken", "type": "address" }, + { "internalType": "address", "name": "toToken", "type": "address" }, { "internalType": "address", - "name": "foundryToken", + "name": "targetAddress", "type": "address" }, { "internalType": "address", "name": "router", "type": "address" }, - { "internalType": "bytes", "name": "routerCalldata", "type": "bytes" }, - { - "internalType": "uint256", - "name": "crossTargetNetwork", - "type": "uint256" - }, - { - "internalType": "address", - "name": "crossTargetToken", - "type": "address" - }, + { "internalType": "bytes", "name": "routerCalldata", "type": "bytes" } + ], + "name": "swapOnSameNetworkETH", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" }, { - "internalType": "address", - "name": "crossTargetAddress", - "type": "address" + "components": [ + { + "internalType": "uint256", + "name": "targetNetwork", + "type": "uint256" + }, + { + "internalType": "address", + "name": "targetToken", + "type": "address" + }, + { + "internalType": "address", + "name": "targetAddress", + "type": "address" + } + ], + "internalType": "struct FiberRouter.SwapCrossData", + "name": "sd", + "type": "tuple" }, { "internalType": "bytes32", "name": "withdrawalData", "type": "bytes32" }, - { "internalType": "bool", "name": "cctpType", "type": "bool" } + { "internalType": "bool", "name": "cctpType", "type": "bool" }, + { + "components": [ + { + "components": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint16", + "name": "rateInBps", + "type": "uint16" + } + ], + "internalType": "struct FeeDistributor.FeeAllocation[]", + "name": "feeAllocations", + "type": "tuple[]" + }, + { "internalType": "bytes32", "name": "salt", "type": "bytes32" }, + { "internalType": "uint256", "name": "expiry", "type": "uint256" }, + { "internalType": "bytes", "name": "signature", "type": "bytes" } + ], + "internalType": "struct FeeDistributor.FeeDistributionData", + "name": "fd", + "type": "tuple" + } ], - "name": "swapAndCrossRouter", + "name": "swapSigned", "outputs": [], "stateMutability": "payable", "type": "function" }, { "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, { "internalType": "uint256", "name": "minAmountOut", "type": "uint256" }, + { "internalType": "address", "name": "fromToken", "type": "address" }, { "internalType": "address", "name": "foundryToken", "type": "address" }, - { "internalType": "uint256", "name": "gasFee", "type": "uint256" }, { "internalType": "address", "name": "router", "type": "address" }, { "internalType": "bytes", "name": "routerCalldata", "type": "bytes" }, { - "internalType": "uint256", - "name": "crossTargetNetwork", - "type": "uint256" - }, - { - "internalType": "address", - "name": "crossTargetToken", - "type": "address" - }, - { - "internalType": "address", - "name": "crossTargetAddress", - "type": "address" + "components": [ + { + "internalType": "uint256", + "name": "targetNetwork", + "type": "uint256" + }, + { + "internalType": "address", + "name": "targetToken", + "type": "address" + }, + { + "internalType": "address", + "name": "targetAddress", + "type": "address" + } + ], + "internalType": "struct FiberRouter.SwapCrossData", + "name": "sd", + "type": "tuple" }, { "internalType": "bytes32", "name": "withdrawalData", "type": "bytes32" }, - { "internalType": "bool", "name": "cctpType", "type": "bool" } + { "internalType": "bool", "name": "cctpType", "type": "bool" }, + { + "components": [ + { + "components": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint16", + "name": "rateInBps", + "type": "uint16" + } + ], + "internalType": "struct FeeDistributor.FeeAllocation[]", + "name": "feeAllocations", + "type": "tuple[]" + }, + { "internalType": "bytes32", "name": "salt", "type": "bytes32" }, + { "internalType": "uint256", "name": "expiry", "type": "uint256" }, + { "internalType": "bytes", "name": "signature", "type": "bytes" } + ], + "internalType": "struct FeeDistributor.FeeDistributionData", + "name": "fd", + "type": "tuple" + } ], - "name": "swapAndCrossRouterETH", + "name": "swapSignedAndCrossRouter", "outputs": [], "stateMutability": "payable", "type": "function" }, { "inputs": [ - { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, { "internalType": "uint256", "name": "minAmountOut", "type": "uint256" }, - { "internalType": "address", "name": "fromToken", "type": "address" }, - { "internalType": "address", "name": "toToken", "type": "address" }, { "internalType": "address", - "name": "targetAddress", + "name": "foundryToken", "type": "address" }, + { "internalType": "uint256", "name": "gasFee", "type": "uint256" }, { "internalType": "address", "name": "router", "type": "address" }, - { "internalType": "bytes", "name": "routerCalldata", "type": "bytes" } + { "internalType": "bytes", "name": "routerCalldata", "type": "bytes" }, + { + "components": [ + { + "internalType": "uint256", + "name": "targetNetwork", + "type": "uint256" + }, + { + "internalType": "address", + "name": "targetToken", + "type": "address" + }, + { + "internalType": "address", + "name": "targetAddress", + "type": "address" + } + ], + "internalType": "struct FiberRouter.SwapCrossData", + "name": "sd", + "type": "tuple" + }, + { + "internalType": "bytes32", + "name": "withdrawalData", + "type": "bytes32" + }, + { "internalType": "bool", "name": "cctpType", "type": "bool" }, + { + "components": [ + { + "components": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint16", + "name": "rateInBps", + "type": "uint16" + } + ], + "internalType": "struct FeeDistributor.FeeAllocation[]", + "name": "feeAllocations", + "type": "tuple[]" + }, + { "internalType": "bytes32", "name": "salt", "type": "bytes32" }, + { "internalType": "uint256", "name": "expiry", "type": "uint256" }, + { "internalType": "bytes", "name": "signature", "type": "bytes" } + ], + "internalType": "struct FeeDistributor.FeeDistributionData", + "name": "fd", + "type": "tuple" + } ], - "name": "swapOnSameNetwork", + "name": "swapSignedAndCrossRouterETH", "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "payable", "type": "function" }, { - "inputs": [ + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "targetNetworks", + "outputs": [ { - "internalType": "uint256", - "name": "minAmountOut", - "type": "uint256" + "internalType": "uint32", + "name": "targetNetworkDomain", + "type": "uint32" }, - { "internalType": "address", "name": "toToken", "type": "address" }, { "internalType": "address", - "name": "targetAddress", + "name": "targetFundManager", "type": "address" - }, - { "internalType": "address", "name": "router", "type": "address" }, - { "internalType": "bytes", "name": "routerCalldata", "type": "bytes" } + } ], - "name": "swapOnSameNetworkETH", - "outputs": [], - "stateMutability": "payable", + "stateMutability": "view", "type": "function" }, { @@ -557,6 +765,13 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "name": "usedSalt", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "weth", diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 9064c9d..94d69e4 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -30,12 +30,12 @@ export const NETWORKS = [ }, { chainId: '42161', - fundManagerAddress: '0x80944eeaec9634F02889ca7c165d3fc1A473AeCA', - fiberRouterAddress: '0xE6A7A9dD2C0F02D572F9BEbc875B98E013918522', + fundManagerAddress: '0xC7b23d5Da44f3d421aD27863788bEdcce4b34B0d', + fiberRouterAddress: '0x68902Ec3058fdBb37Ac3D832a62112d7764a08ed', foundaryTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', aggregateRouterContractAddress: '0x111111125421ca6dc452d289314280a0f8842a65', - cctpFundManager: '0x98E4F18F63Cb0B815ad7C6DdFfAfbabb54550a0e', + cctpFundManager: '0x7bD02622F39E458D5d5eaAD51C304Cac064ACFf4', }, { chainId: '10', @@ -53,12 +53,12 @@ export const NETWORKS = [ }, { chainId: '8453', - fundManagerAddress: '0xEd2cE4f32779249682B0CcA7b7eC3Fc8B19Be9B6', - fiberRouterAddress: '0x4408ea5C17dC6E610eb7327361297D094762f9B0', + fundManagerAddress: '0x7022a2dE2434AbA5985e87A84E93E5C9Cc3AB05F', + fiberRouterAddress: '0x84250F8d4617485C3D5f1d7b1bC8C624e5695A80', foundaryTokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', aggregateRouterContractAddress: '0x111111125421ca6dc452d289314280a0f8842a65', - cctpFundManager: '0xd0e48dDf333a3c445aC2391153991851045E8162', + cctpFundManager: '0x7EA16f3a967db7133D50807e5Fb3ca5FBc4A3dD6', }, { chainId: '324', diff --git a/src/interfaces/job.interface.ts b/src/interfaces/job.interface.ts index 88659be..7bbd7df 100644 --- a/src/interfaces/job.interface.ts +++ b/src/interfaces/job.interface.ts @@ -20,6 +20,7 @@ export interface JobRequestBody { destinationChaibId: string; slippage: number; isCCTP: boolean; + distributedFee: string; } export interface SignatureData { diff --git a/src/services/signature.service.ts b/src/services/signature.service.ts index 6a98931..349dcdb 100644 --- a/src/services/signature.service.ts +++ b/src/services/signature.service.ts @@ -84,6 +84,7 @@ export const getValidWithdrawalData = async ( decodedData.targetChainId, data.destinationAmountIn, decodedData.settledAmount, + data.distributedFee, )) ) { return { @@ -104,6 +105,7 @@ export const isValidSettledAmount = async ( destinationChainId: string, destinationAmountIn: any, settledAmount: any, + distributedFee: string, ): Promise => { const sWeb3 = new Web3(rpcNodeService.getRpcNodeByChainId(sourceChainId).url); const dWeb3 = new Web3( @@ -118,9 +120,11 @@ export const isValidSettledAmount = async ( web3Service.getFoundaryTokenAddress(destinationChainId), ); settledAmount = decimalsIntoNumber(settledAmount, sDecimal); + distributedFee = decimalsIntoNumber(distributedFee, sDecimal); destinationAmountIn = decimalsIntoNumber(destinationAmountIn, dDecimal); - console.log(settledAmount, destinationAmountIn); - if (Big(settledAmount).gte(Big(destinationAmountIn))) { + let sdAmount = Big(settledAmount).add(Big(distributedFee)); + console.log(settledAmount, destinationAmountIn, sdAmount?.toString()); + if (sdAmount.gte(Big(destinationAmountIn))) { return true; } return false; diff --git a/src/services/transaction.service.ts b/src/services/transaction.service.ts index 99ca9e1..f8cf689 100644 --- a/src/services/transaction.service.ts +++ b/src/services/transaction.service.ts @@ -31,6 +31,7 @@ export async function prepareObjectsAndVerifySignatures(tx: any) { destinationChaibId: destinationNetwork.chainId, slippage: tx.slippage, isCCTP: tx?.isCCTP ? tx?.isCCTP : false, + distributedFee: tx?.distributedFee ? tx?.distributedFee : '0', }; let signatureData: SignatureData = { From 6bb0b789384d63c687120e9ff71fae87cfd8276c Mon Sep 17 00:00:00 2001 From: Arslan Kibria Date: Mon, 13 May 2024 19:53:05 +0500 Subject: [PATCH 11/24] bug fixing during testing fee management --- src/constants/FiberRouter.json | 123 +++++++++++++++++++++++---------- src/constants/constants.ts | 12 ++-- 2 files changed, 91 insertions(+), 44 deletions(-) diff --git a/src/constants/FiberRouter.json b/src/constants/FiberRouter.json index a3d159b..0b54c81 100644 --- a/src/constants/FiberRouter.json +++ b/src/constants/FiberRouter.json @@ -27,7 +27,7 @@ { "indexed": false, "internalType": "uint256", - "name": "totalFee", + "name": "totalPlatformFee", "type": "uint256" } ], @@ -305,34 +305,6 @@ "name": "WithdrawRouter", "type": "event" }, - { - "inputs": [], - "name": "DISTRIBUTE_FEES_TYPEHASH", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "FEE_ALLOCATION_TYPEHASH", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "NAME", - "outputs": [{ "internalType": "string", "name": "", "type": "string" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "VERSION", - "outputs": [{ "internalType": "string", "name": "", "type": "string" }], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { "internalType": "address", "name": "router", "type": "address" }, @@ -562,15 +534,40 @@ "type": "address" }, { - "internalType": "uint16", - "name": "rateInBps", - "type": "uint16" + "internalType": "uint256", + "name": "platformFee", + "type": "uint256" } ], "internalType": "struct FeeDistributor.FeeAllocation[]", "name": "feeAllocations", "type": "tuple[]" }, + { + "internalType": "uint256", + "name": "totalPlatformFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sourceAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sourceAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "destinationAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "destinationAmountOut", + "type": "uint256" + }, { "internalType": "bytes32", "name": "salt", "type": "bytes32" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "bytes", "name": "signature", "type": "bytes" } @@ -639,15 +636,40 @@ "type": "address" }, { - "internalType": "uint16", - "name": "rateInBps", - "type": "uint16" + "internalType": "uint256", + "name": "platformFee", + "type": "uint256" } ], "internalType": "struct FeeDistributor.FeeAllocation[]", "name": "feeAllocations", "type": "tuple[]" }, + { + "internalType": "uint256", + "name": "totalPlatformFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sourceAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sourceAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "destinationAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "destinationAmountOut", + "type": "uint256" + }, { "internalType": "bytes32", "name": "salt", "type": "bytes32" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "bytes", "name": "signature", "type": "bytes" } @@ -715,15 +737,40 @@ "type": "address" }, { - "internalType": "uint16", - "name": "rateInBps", - "type": "uint16" + "internalType": "uint256", + "name": "platformFee", + "type": "uint256" } ], "internalType": "struct FeeDistributor.FeeAllocation[]", "name": "feeAllocations", "type": "tuple[]" }, + { + "internalType": "uint256", + "name": "totalPlatformFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sourceAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sourceAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "destinationAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "destinationAmountOut", + "type": "uint256" + }, { "internalType": "bytes32", "name": "salt", "type": "bytes32" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "bytes", "name": "signature", "type": "bytes" } diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 94d69e4..bd9d7ee 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -30,12 +30,12 @@ export const NETWORKS = [ }, { chainId: '42161', - fundManagerAddress: '0xC7b23d5Da44f3d421aD27863788bEdcce4b34B0d', - fiberRouterAddress: '0x68902Ec3058fdBb37Ac3D832a62112d7764a08ed', + fundManagerAddress: '0x5dBF50235fdD9D4D5669E6e0B3Bef3655dEAffe7', + fiberRouterAddress: '0xaDE10E8522AeCadBBe02279c133Fc46E45f92194', foundaryTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', aggregateRouterContractAddress: '0x111111125421ca6dc452d289314280a0f8842a65', - cctpFundManager: '0x7bD02622F39E458D5d5eaAD51C304Cac064ACFf4', + cctpFundManager: '0x82496D3bDE9168dfeF6bc8dF0439B51790ff42DF', }, { chainId: '10', @@ -53,12 +53,12 @@ export const NETWORKS = [ }, { chainId: '8453', - fundManagerAddress: '0x7022a2dE2434AbA5985e87A84E93E5C9Cc3AB05F', - fiberRouterAddress: '0x84250F8d4617485C3D5f1d7b1bC8C624e5695A80', + fundManagerAddress: '0x1938b36110e4016c54647de123a07F4dB13026C7', + fiberRouterAddress: '0x851930502D363D75C4a0C0c8366ADc43980aA048', foundaryTokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', aggregateRouterContractAddress: '0x111111125421ca6dc452d289314280a0f8842a65', - cctpFundManager: '0x7EA16f3a967db7133D50807e5Fb3ca5FBc4A3dD6', + cctpFundManager: '0x59C1CF95a57F63094637Af70008c55452fFD1b9f', }, { chainId: '324', From 48263cc756b126cf1949050e894b3075d5f95e40 Mon Sep 17 00:00:00 2001 From: Zikriya Date: Thu, 16 May 2024 00:35:33 +0500 Subject: [PATCH 12/24] Settled amount and destinationAmountIn decoupled --- src/constants/FiberRouter.json | 9 +++++ src/constants/constants.ts | 12 +++--- src/constants/utils.ts | 6 ++- src/interfaces/job.interface.ts | 1 + src/services/signature.service.ts | 58 ++++++++++++++++++----------- src/services/transaction.service.ts | 4 +- 6 files changed, 60 insertions(+), 30 deletions(-) diff --git a/src/constants/FiberRouter.json b/src/constants/FiberRouter.json index 0b54c81..a203ece 100644 --- a/src/constants/FiberRouter.json +++ b/src/constants/FiberRouter.json @@ -364,6 +364,15 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [ + { "internalType": "uint256", "name": "cdPtr", "type": "uint256" } + ], + "name": "isCctp", + "outputs": [{ "internalType": "bool", "name": "cctp", "type": "bool" }], + "stateMutability": "pure", + "type": "function" + }, { "inputs": [], "name": "owner", diff --git a/src/constants/constants.ts b/src/constants/constants.ts index bd9d7ee..e3b58f7 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -30,12 +30,12 @@ export const NETWORKS = [ }, { chainId: '42161', - fundManagerAddress: '0x5dBF50235fdD9D4D5669E6e0B3Bef3655dEAffe7', - fiberRouterAddress: '0xaDE10E8522AeCadBBe02279c133Fc46E45f92194', + fundManagerAddress: '0xA893673e9264195D8F5192975ABc3D3821de789d', + fiberRouterAddress: '0x6e84E6c702E6748C255A7A46347B01Db7CA95Bf3', foundaryTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', aggregateRouterContractAddress: '0x111111125421ca6dc452d289314280a0f8842a65', - cctpFundManager: '0x82496D3bDE9168dfeF6bc8dF0439B51790ff42DF', + cctpFundManager: '0xBe6D480a7f5519BFD9D4EAf6E4Fb86A217736168', }, { chainId: '10', @@ -53,12 +53,12 @@ export const NETWORKS = [ }, { chainId: '8453', - fundManagerAddress: '0x1938b36110e4016c54647de123a07F4dB13026C7', - fiberRouterAddress: '0x851930502D363D75C4a0C0c8366ADc43980aA048', + fundManagerAddress: '0x488aEa3F75271e9A79B86392E40de2Fbed468b2B', + fiberRouterAddress: '0xc74819b4e1Dd4B19A545a417378eB0bA7aD96ddb', foundaryTokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', aggregateRouterContractAddress: '0x111111125421ca6dc452d289314280a0f8842a65', - cctpFundManager: '0x59C1CF95a57F63094637Af70008c55452fFD1b9f', + cctpFundManager: '0x648Abb2c787C2ED5E33506B729Bab5971541D08C', }, { chainId: '324', diff --git a/src/constants/utils.ts b/src/constants/utils.ts index 9c982a1..c164fd6 100644 --- a/src/constants/utils.ts +++ b/src/constants/utils.ts @@ -64,7 +64,11 @@ export const removeExponential = function (n: any) { }; export const numberIntoDecimals = function (amount: any, decimal: any) { - let formattedValue = ethers.utils.parseUnits(amount.toString(), decimal); + amount = Big(amount); + decimal = Big(10 ** Number(decimal)); + let formattedValue = amount.mul(decimal); + formattedValue = removeExponential(formattedValue.toString()); + formattedValue = parseInt(formattedValue); formattedValue = removeExponential(formattedValue.toString()); return formattedValue; }; diff --git a/src/interfaces/job.interface.ts b/src/interfaces/job.interface.ts index 7bbd7df..a997734 100644 --- a/src/interfaces/job.interface.ts +++ b/src/interfaces/job.interface.ts @@ -21,6 +21,7 @@ export interface JobRequestBody { slippage: number; isCCTP: boolean; distributedFee: string; + minDestinationAmountIn: string; } export interface SignatureData { diff --git a/src/services/signature.service.ts b/src/services/signature.service.ts index 349dcdb..02bc5f4 100644 --- a/src/services/signature.service.ts +++ b/src/services/signature.service.ts @@ -23,7 +23,12 @@ import { pubToAddress, bufferToHex, } from 'ethereumjs-util'; -import { decimals, decimalsIntoNumber, withSlippage } from '../constants/utils'; +import { + decimals, + decimalsIntoNumber, + numberIntoDecimals, + withSlippage, +} from '../constants/utils'; import { getAggregateRouterTokenAddress } from './web3.service'; export const getDataForSignature = async (job: any): Promise => { @@ -71,26 +76,26 @@ export const getValidWithdrawalData = async ( let latestHash = Web3.utils.keccak256( data.sourceOneInchData + data.destinationOneInchData + - data.destinationAmountIn + + data.minDestinationAmountIn + data.destinationAmountOut + data.sourceAssetType + data.destinationAssetType, ); - if ( - latestHash == data.withdrawalData && - (await isValidSettledAmount( - data.slippage, - decodedData.sourceChainId, - decodedData.targetChainId, - data.destinationAmountIn, - decodedData.settledAmount, - data.distributedFee, - )) - ) { + const { isValid, destinationAmountIn } = await isValidSettledAmount( + data.slippage, + decodedData.sourceChainId, + decodedData.targetChainId, + data.destinationAmountIn, + data.minDestinationAmountIn, + decodedData.settledAmount, + data.distributedFee, + ); + console.log({ isValid, destinationAmountIn }); + if (latestHash == data.withdrawalData && isValid) { return { sourceOneInchData: data.sourceOneInchData, destinationOneInchData: data.destinationOneInchData, - destinationAmountIn: data.destinationAmountIn, + destinationAmountIn: destinationAmountIn, destinationAmountOut: data.destinationAmountOut, sourceAssetType: data.sourceAssetType, destinationAssetType: data.destinationAssetType, @@ -104,9 +109,10 @@ export const isValidSettledAmount = async ( sourceChainId: string, destinationChainId: string, destinationAmountIn: any, + minDestinationAmountIn: any, settledAmount: any, distributedFee: string, -): Promise => { +): Promise => { const sWeb3 = new Web3(rpcNodeService.getRpcNodeByChainId(sourceChainId).url); const dWeb3 = new Web3( rpcNodeService.getRpcNodeByChainId(destinationChainId).url, @@ -122,12 +128,22 @@ export const isValidSettledAmount = async ( settledAmount = decimalsIntoNumber(settledAmount, sDecimal); distributedFee = decimalsIntoNumber(distributedFee, sDecimal); destinationAmountIn = decimalsIntoNumber(destinationAmountIn, dDecimal); + minDestinationAmountIn = decimalsIntoNumber(minDestinationAmountIn, dDecimal); let sdAmount = Big(settledAmount).add(Big(distributedFee)); - console.log(settledAmount, destinationAmountIn, sdAmount?.toString()); - if (sdAmount.gte(Big(destinationAmountIn))) { - return true; + console.log( + settledAmount, + minDestinationAmountIn, + sdAmount?.toString(), + destinationAmountIn, + ); + if ( + sdAmount.gte(Big(minDestinationAmountIn)) && + Big(destinationAmountIn).eq(Big(settledAmount)) + ) { + destinationAmountIn = numberIntoDecimals(settledAmount, dDecimal); + return { isValid: true, destinationAmountIn }; } - return false; + return { isValid: false, destinationAmountIn }; }; export const createSignedPayment = ( @@ -237,7 +253,7 @@ export const produceOneInchHash = ( ): any => { const methodHash = Web3.utils.keccak256( Web3.utils.utf8ToHex( - 'withdrawSignedAndSwapRouter(address to,uint256 amountIn,uint256 minAmountOut,address foundryToken,address targetToken,address router,bytes32 routerCalldata,bytes32 salt,uint256 expiry)', + 'withdrawSignedAndSwapRouter(address to,uint256 amountIn,uint256 minAmountOut,address foundryToken,address targetToken,address router,bytes32 salt,uint256 expiry)', ), ); const params = [ @@ -249,7 +265,6 @@ export const produceOneInchHash = ( 'address', 'address', 'bytes32', - 'bytes32', 'uint256', ]; const structure = web3.eth.abi.encodeParameters(params, [ @@ -260,7 +275,6 @@ export const produceOneInchHash = ( foundryToken, targetToken, aggregateRouterContractAddress, - Web3.utils.keccak256(routerCalldata), salt, expiry, ]); diff --git a/src/services/transaction.service.ts b/src/services/transaction.service.ts index f8cf689..c68397b 100644 --- a/src/services/transaction.service.ts +++ b/src/services/transaction.service.ts @@ -32,6 +32,7 @@ export async function prepareObjectsAndVerifySignatures(tx: any) { slippage: tx.slippage, isCCTP: tx?.isCCTP ? tx?.isCCTP : false, distributedFee: tx?.distributedFee ? tx?.distributedFee : '0', + minDestinationAmountIn: tx?.minDestinationAmountIn, }; let signatureData: SignatureData = { @@ -70,7 +71,8 @@ export async function verifySignatures(job: any) { } await createWithdrawalSignature(job); } catch (error) { - console.error('error occured', error); + console.error('verifySignatures error occured', error); + await updateTransaction(job.data.txId, null, true); } } From c0cbb8df068cc2f7c339f2bf5d8d105fc43c7442 Mon Sep 17 00:00:00 2001 From: Zikriya Date: Sat, 18 May 2024 14:22:56 +0500 Subject: [PATCH 13/24] Network configs --- src/constants/FiberRouter.json | 121 ++++++++++++++++++++------------- src/constants/constants.ts | 16 ++--- 2 files changed, 81 insertions(+), 56 deletions(-) diff --git a/src/constants/FiberRouter.json b/src/constants/FiberRouter.json index a203ece..e12f127 100644 --- a/src/constants/FiberRouter.json +++ b/src/constants/FiberRouter.json @@ -305,6 +305,20 @@ "name": "WithdrawRouter", "type": "event" }, + { + "inputs": [], + "name": "NAME", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VERSION", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { "internalType": "address", "name": "router", "type": "address" }, @@ -331,6 +345,13 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "feeWallet", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "fundManager", @@ -380,6 +401,13 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "platformFee", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { "internalType": "address", "name": "router", "type": "address" }, @@ -419,6 +447,15 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { "internalType": "address", "name": "_feeWallet", "type": "address" } + ], + "name": "setFeeWallet", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { "internalType": "address", "name": "_fundManager", "type": "address" } @@ -441,6 +478,15 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { "internalType": "uint256", "name": "_platformFee", "type": "uint256" } + ], + "name": "setPlatformFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { "internalType": "address", "name": "_weth", "type": "address" } @@ -536,25 +582,18 @@ { "components": [ { - "components": [ - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "platformFee", - "type": "uint256" - } - ], - "internalType": "struct FeeDistributor.FeeAllocation[]", - "name": "feeAllocations", - "type": "tuple[]" + "internalType": "address", + "name": "referral", + "type": "address" }, { "internalType": "uint256", - "name": "totalPlatformFee", + "name": "referralFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "referralDiscount", "type": "uint256" }, { @@ -638,25 +677,18 @@ { "components": [ { - "components": [ - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "platformFee", - "type": "uint256" - } - ], - "internalType": "struct FeeDistributor.FeeAllocation[]", - "name": "feeAllocations", - "type": "tuple[]" + "internalType": "address", + "name": "referral", + "type": "address" + }, + { + "internalType": "uint256", + "name": "referralFee", + "type": "uint256" }, { "internalType": "uint256", - "name": "totalPlatformFee", + "name": "referralDiscount", "type": "uint256" }, { @@ -739,25 +771,18 @@ { "components": [ { - "components": [ - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "platformFee", - "type": "uint256" - } - ], - "internalType": "struct FeeDistributor.FeeAllocation[]", - "name": "feeAllocations", - "type": "tuple[]" + "internalType": "address", + "name": "referral", + "type": "address" + }, + { + "internalType": "uint256", + "name": "referralFee", + "type": "uint256" }, { "internalType": "uint256", - "name": "totalPlatformFee", + "name": "referralDiscount", "type": "uint256" }, { diff --git a/src/constants/constants.ts b/src/constants/constants.ts index e3b58f7..df93b26 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -30,12 +30,12 @@ export const NETWORKS = [ }, { chainId: '42161', - fundManagerAddress: '0xA893673e9264195D8F5192975ABc3D3821de789d', - fiberRouterAddress: '0x6e84E6c702E6748C255A7A46347B01Db7CA95Bf3', + fundManagerAddress: '0xB9f5302D6b271FBa79f9415ACe14E127Ad17e3aE', + fiberRouterAddress: '0x04d4E91bb4C4c1d90149CFf98894a27b487470fA', foundaryTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', aggregateRouterContractAddress: '0x111111125421ca6dc452d289314280a0f8842a65', - cctpFundManager: '0xBe6D480a7f5519BFD9D4EAf6E4Fb86A217736168', + cctpFundManager: '0x99452be41556b4e8E265b764A06676AAE90B12D5', }, { chainId: '10', @@ -53,12 +53,12 @@ export const NETWORKS = [ }, { chainId: '8453', - fundManagerAddress: '0x488aEa3F75271e9A79B86392E40de2Fbed468b2B', - fiberRouterAddress: '0xc74819b4e1Dd4B19A545a417378eB0bA7aD96ddb', + fundManagerAddress: '0x6C2aEfE5E6BF22F238E2142b3f539Ee40fbE0288', + fiberRouterAddress: '0xb4748e06367FA8ee1d616a668649643605Fac3d5', foundaryTokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', aggregateRouterContractAddress: '0x111111125421ca6dc452d289314280a0f8842a65', - cctpFundManager: '0x648Abb2c787C2ED5E33506B729Bab5971541D08C', + cctpFundManager: '0xbE6E744400C1398D9Aa88Cd89588f82687444D8c', }, { chainId: '324', @@ -70,8 +70,8 @@ export const NETWORKS = [ }, { chainId: '534352', - fundManagerAddress: '0xb28d89D2B218ced7B64272CD61036F655c2573e4', - fiberRouterAddress: '0x35dA469ECbFFCBfaF8cAC31Fe0645B158e252Eb6', + fundManagerAddress: '0xB25c0cE3aDC8A48CCf045E754e98e5982AF0094f', + fiberRouterAddress: '0x12AB9422C5938B37BdbED19a07a78e8FC997313E', foundaryTokenAddress: '0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4', aggregateRouterContractAddress: '0x6131B5fae19EA4f9D964eAc0408E4408b66337b5', From 56877f14b19b490a56e1a58bc56c3eee823dd9a7 Mon Sep 17 00:00:00 2001 From: Zikriya Date: Sat, 18 May 2024 15:36:11 +0500 Subject: [PATCH 14/24] Network configs --- src/constants/constants.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/constants/constants.ts b/src/constants/constants.ts index df93b26..9127aa3 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -22,11 +22,12 @@ export const NETWORKS = [ }, { chainId: '56', - fundManagerAddress: '0xB4A5D95BFEC6AFd359e05aA982718C11bF04a7Ff', - fiberRouterAddress: '0xbB1886FA834917716049094090387DEa0680BFFc', + fundManagerAddress: '0xF44a80eAe2E93b435D62967663701AD5F2Ec7650', + fiberRouterAddress: '0x99d3Fa0Cf0a5C748F357028De4AdF50072098e72', foundaryTokenAddress: '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d', aggregateRouterContractAddress: '0x111111125421ca6dc452d289314280a0f8842a65', + cctpFundManager: '', }, { chainId: '42161', @@ -70,8 +71,8 @@ export const NETWORKS = [ }, { chainId: '534352', - fundManagerAddress: '0xB25c0cE3aDC8A48CCf045E754e98e5982AF0094f', - fiberRouterAddress: '0x12AB9422C5938B37BdbED19a07a78e8FC997313E', + fundManagerAddress: '0x7022a2dE2434AbA5985e87A84E93E5C9Cc3AB05F', + fiberRouterAddress: '0x17BD1758A7d954AD3a0BD7Cf530932397374273f', foundaryTokenAddress: '0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4', aggregateRouterContractAddress: '0x6131B5fae19EA4f9D964eAc0408E4408b66337b5', From c1cdfaf24d657ed5cb46648e19e3c5d4dacf8652 Mon Sep 17 00:00:00 2001 From: Zikriya Date: Sat, 18 May 2024 20:34:51 +0500 Subject: [PATCH 15/24] Bug fixed --- src/services/signature.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/signature.service.ts b/src/services/signature.service.ts index 02bc5f4..cc59dd2 100644 --- a/src/services/signature.service.ts +++ b/src/services/signature.service.ts @@ -138,7 +138,9 @@ export const isValidSettledAmount = async ( ); if ( sdAmount.gte(Big(minDestinationAmountIn)) && - Big(destinationAmountIn).eq(Big(settledAmount)) + Big(destinationAmountIn).eq( + Big(decimalsIntoNumber(settledAmount, dDecimal)), + ) ) { destinationAmountIn = numberIntoDecimals(settledAmount, dDecimal); return { isValid: true, destinationAmountIn }; From db00beaafe25631493c655e76734cd64b5aaefa4 Mon Sep 17 00:00:00 2001 From: Zikriya Date: Sat, 18 May 2024 21:17:20 +0500 Subject: [PATCH 16/24] Bug fixed for settledAmount check --- src/services/signature.service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/signature.service.ts b/src/services/signature.service.ts index cc59dd2..2195fe0 100644 --- a/src/services/signature.service.ts +++ b/src/services/signature.service.ts @@ -125,6 +125,7 @@ export const isValidSettledAmount = async ( dWeb3, web3Service.getFoundaryTokenAddress(destinationChainId), ); + let settledAmountInDesDeciamls = decimalsIntoNumber(settledAmount, dDecimal); settledAmount = decimalsIntoNumber(settledAmount, sDecimal); distributedFee = decimalsIntoNumber(distributedFee, sDecimal); destinationAmountIn = decimalsIntoNumber(destinationAmountIn, dDecimal); @@ -135,12 +136,11 @@ export const isValidSettledAmount = async ( minDestinationAmountIn, sdAmount?.toString(), destinationAmountIn, + settledAmountInDesDeciamls, ); if ( sdAmount.gte(Big(minDestinationAmountIn)) && - Big(destinationAmountIn).eq( - Big(decimalsIntoNumber(settledAmount, dDecimal)), - ) + Big(destinationAmountIn).eq(Big(settledAmountInDesDeciamls)) ) { destinationAmountIn = numberIntoDecimals(settledAmount, dDecimal); return { isValid: true, destinationAmountIn }; From 0158296ae4f85a58496ab821b503ff7e0b09be0d Mon Sep 17 00:00:00 2001 From: Zikriya Date: Sat, 18 May 2024 21:38:31 +0500 Subject: [PATCH 17/24] Bug fixed for settledAmount conversion --- src/constants/utils.ts | 9 ++++++++- src/services/signature.service.ts | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/constants/utils.ts b/src/constants/utils.ts index c164fd6..5170219 100644 --- a/src/constants/utils.ts +++ b/src/constants/utils.ts @@ -68,7 +68,7 @@ export const numberIntoDecimals = function (amount: any, decimal: any) { decimal = Big(10 ** Number(decimal)); let formattedValue = amount.mul(decimal); formattedValue = removeExponential(formattedValue.toString()); - formattedValue = parseInt(formattedValue); + formattedValue = removeDecimals(formattedValue); formattedValue = removeExponential(formattedValue.toString()); return formattedValue; }; @@ -80,6 +80,13 @@ export const decimalsIntoNumber = function (amount: any, decimal: any) { return formattedValue; }; +export const removeDecimals = function (amount: any) { + if (amount.includes('.')) { + amount = amount.split('.')[0]; + } + return amount; +}; + export const withSlippage = function (value: any, slippage: number) { let slippageProportion = 100 - slippage; let valueWithSlippage = (value * slippageProportion) / 100; diff --git a/src/services/signature.service.ts b/src/services/signature.service.ts index 2195fe0..d8872ad 100644 --- a/src/services/signature.service.ts +++ b/src/services/signature.service.ts @@ -27,6 +27,7 @@ import { decimals, decimalsIntoNumber, numberIntoDecimals, + removeDecimals, withSlippage, } from '../constants/utils'; import { getAggregateRouterTokenAddress } from './web3.service'; @@ -126,6 +127,7 @@ export const isValidSettledAmount = async ( web3Service.getFoundaryTokenAddress(destinationChainId), ); let settledAmountInDesDeciamls = decimalsIntoNumber(settledAmount, dDecimal); + settledAmountInDesDeciamls = removeDecimals(settledAmountInDesDeciamls); settledAmount = decimalsIntoNumber(settledAmount, sDecimal); distributedFee = decimalsIntoNumber(distributedFee, sDecimal); destinationAmountIn = decimalsIntoNumber(destinationAmountIn, dDecimal); From 5127141f7b87712c67a6444544a858dfa5bb5884 Mon Sep 17 00:00:00 2001 From: Zikriya Date: Sat, 18 May 2024 22:02:29 +0500 Subject: [PATCH 18/24] Bug fixed for settledAmount conversion --- src/constants/utils.ts | 9 +-------- src/services/signature.service.ts | 9 +-------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/constants/utils.ts b/src/constants/utils.ts index 5170219..c164fd6 100644 --- a/src/constants/utils.ts +++ b/src/constants/utils.ts @@ -68,7 +68,7 @@ export const numberIntoDecimals = function (amount: any, decimal: any) { decimal = Big(10 ** Number(decimal)); let formattedValue = amount.mul(decimal); formattedValue = removeExponential(formattedValue.toString()); - formattedValue = removeDecimals(formattedValue); + formattedValue = parseInt(formattedValue); formattedValue = removeExponential(formattedValue.toString()); return formattedValue; }; @@ -80,13 +80,6 @@ export const decimalsIntoNumber = function (amount: any, decimal: any) { return formattedValue; }; -export const removeDecimals = function (amount: any) { - if (amount.includes('.')) { - amount = amount.split('.')[0]; - } - return amount; -}; - export const withSlippage = function (value: any, slippage: number) { let slippageProportion = 100 - slippage; let valueWithSlippage = (value * slippageProportion) / 100; diff --git a/src/services/signature.service.ts b/src/services/signature.service.ts index d8872ad..506573f 100644 --- a/src/services/signature.service.ts +++ b/src/services/signature.service.ts @@ -27,7 +27,6 @@ import { decimals, decimalsIntoNumber, numberIntoDecimals, - removeDecimals, withSlippage, } from '../constants/utils'; import { getAggregateRouterTokenAddress } from './web3.service'; @@ -126,8 +125,6 @@ export const isValidSettledAmount = async ( dWeb3, web3Service.getFoundaryTokenAddress(destinationChainId), ); - let settledAmountInDesDeciamls = decimalsIntoNumber(settledAmount, dDecimal); - settledAmountInDesDeciamls = removeDecimals(settledAmountInDesDeciamls); settledAmount = decimalsIntoNumber(settledAmount, sDecimal); distributedFee = decimalsIntoNumber(distributedFee, sDecimal); destinationAmountIn = decimalsIntoNumber(destinationAmountIn, dDecimal); @@ -138,12 +135,8 @@ export const isValidSettledAmount = async ( minDestinationAmountIn, sdAmount?.toString(), destinationAmountIn, - settledAmountInDesDeciamls, ); - if ( - sdAmount.gte(Big(minDestinationAmountIn)) && - Big(destinationAmountIn).eq(Big(settledAmountInDesDeciamls)) - ) { + if (sdAmount.gte(Big(minDestinationAmountIn))) { destinationAmountIn = numberIntoDecimals(settledAmount, dDecimal); return { isValid: true, destinationAmountIn }; } From 5aacd1946ca5b7936b31931bfdc2a2c040c55d96 Mon Sep 17 00:00:00 2001 From: Zikriya Date: Mon, 20 May 2024 20:18:04 +0500 Subject: [PATCH 19/24] numberIntoDecimals conversion fixed --- src/constants/utils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/constants/utils.ts b/src/constants/utils.ts index c164fd6..38b7dcb 100644 --- a/src/constants/utils.ts +++ b/src/constants/utils.ts @@ -68,7 +68,9 @@ export const numberIntoDecimals = function (amount: any, decimal: any) { decimal = Big(10 ** Number(decimal)); let formattedValue = amount.mul(decimal); formattedValue = removeExponential(formattedValue.toString()); - formattedValue = parseInt(formattedValue); + if (formattedValue.includes('.')) { + formattedValue = formattedValue.split('.')[0]; + } formattedValue = removeExponential(formattedValue.toString()); return formattedValue; }; From b6e2c2eea7242fc2144ca38b0a3d5da6560c5351 Mon Sep 17 00:00:00 2001 From: Zikriya Date: Wed, 22 May 2024 18:44:23 +0500 Subject: [PATCH 20/24] Network config updated --- src/constants/constants.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 9127aa3..40b0fd0 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -22,8 +22,8 @@ export const NETWORKS = [ }, { chainId: '56', - fundManagerAddress: '0xF44a80eAe2E93b435D62967663701AD5F2Ec7650', - fiberRouterAddress: '0x99d3Fa0Cf0a5C748F357028De4AdF50072098e72', + fundManagerAddress: '0x033Af723ce4D799FBeD58a4a53754efaA4b0Fdae', + fiberRouterAddress: '0x30Bf6F2Ed9a7b060c777cE8FEf07cF5993525CF0', foundaryTokenAddress: '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d', aggregateRouterContractAddress: '0x111111125421ca6dc452d289314280a0f8842a65', @@ -31,12 +31,12 @@ export const NETWORKS = [ }, { chainId: '42161', - fundManagerAddress: '0xB9f5302D6b271FBa79f9415ACe14E127Ad17e3aE', - fiberRouterAddress: '0x04d4E91bb4C4c1d90149CFf98894a27b487470fA', + fundManagerAddress: '0x106E2eF36123Cb573d0925C1f4a3b377d11CBF70', + fiberRouterAddress: '0xDf5Df008Fa3397ac0Bd895A1aFDBda0231D883e0', foundaryTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', aggregateRouterContractAddress: '0x111111125421ca6dc452d289314280a0f8842a65', - cctpFundManager: '0x99452be41556b4e8E265b764A06676AAE90B12D5', + cctpFundManager: '0x5aC3e55B1582A27E9B734679708210e1b84818C4', }, { chainId: '10', From 1f1c22be389a8f321ece366c032fe7c26cc9126d Mon Sep 17 00:00:00 2001 From: Zikriya Date: Wed, 22 May 2024 22:39:44 +0500 Subject: [PATCH 21/24] Network config updated --- src/constants/constants.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 40b0fd0..583e03f 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -54,25 +54,25 @@ export const NETWORKS = [ }, { chainId: '8453', - fundManagerAddress: '0x6C2aEfE5E6BF22F238E2142b3f539Ee40fbE0288', - fiberRouterAddress: '0xb4748e06367FA8ee1d616a668649643605Fac3d5', + fundManagerAddress: '0xdE3a9704bb91117c040b23c03beb11124FD22882', + fiberRouterAddress: '0x877BA251159a8128741eE0cE9E1951E96Ec10477', foundaryTokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', aggregateRouterContractAddress: '0x111111125421ca6dc452d289314280a0f8842a65', - cctpFundManager: '0xbE6E744400C1398D9Aa88Cd89588f82687444D8c', + cctpFundManager: '0x5729c1d7E75Dad6B44e10965e063A3a006cC5c5a', }, { chainId: '324', - fundManagerAddress: '0x09a3078fdb233e3De911cFba3D49D6902d29E36F', - fiberRouterAddress: '0x60ACb601eaE3ec5F9BC7679F20128b07Fc703Dbd', + fundManagerAddress: '0x9524aA7870CE93b73AFc31a7D3Bf9808513Dd25f', + fiberRouterAddress: '0x450d68a4Be9470296810162a09BB658D6948600b', foundaryTokenAddress: '0x1d17CBcF0D6D143135aE902365D2E5e2A16538D4', aggregateRouterContractAddress: '0x6fd4383cb451173d5f9304f041c7bcbf27d561ff', }, { chainId: '534352', - fundManagerAddress: '0x7022a2dE2434AbA5985e87A84E93E5C9Cc3AB05F', - fiberRouterAddress: '0x17BD1758A7d954AD3a0BD7Cf530932397374273f', + fundManagerAddress: '0xC7b23d5Da44f3d421aD27863788bEdcce4b34B0d', + fiberRouterAddress: '0x90b4C9Cc6AAf15be692d20D409A86bd32897D9b1', foundaryTokenAddress: '0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4', aggregateRouterContractAddress: '0x6131B5fae19EA4f9D964eAc0408E4408b66337b5', From 2f4277d400ac82d39c258a232ce431546def575a Mon Sep 17 00:00:00 2001 From: Zikriya Date: Thu, 23 May 2024 13:23:15 +0500 Subject: [PATCH 22/24] Network config updated --- src/constants/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 583e03f..ec98bd4 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -64,7 +64,7 @@ export const NETWORKS = [ { chainId: '324', fundManagerAddress: '0x9524aA7870CE93b73AFc31a7D3Bf9808513Dd25f', - fiberRouterAddress: '0x450d68a4Be9470296810162a09BB658D6948600b', + fiberRouterAddress: '0xB1b56b46A7961a1797dcA7eaF58d28903DA6623A', foundaryTokenAddress: '0x1d17CBcF0D6D143135aE902365D2E5e2A16538D4', aggregateRouterContractAddress: '0x6fd4383cb451173d5f9304f041c7bcbf27d561ff', From 96f20335c3baf765c350eccc8fa415417807fbd1 Mon Sep 17 00:00:00 2001 From: Zikriya Date: Thu, 23 May 2024 17:38:15 +0500 Subject: [PATCH 23/24] Network config updated --- src/constants/constants.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/constants/constants.ts b/src/constants/constants.ts index ec98bd4..adbdc65 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -63,8 +63,8 @@ export const NETWORKS = [ }, { chainId: '324', - fundManagerAddress: '0x9524aA7870CE93b73AFc31a7D3Bf9808513Dd25f', - fiberRouterAddress: '0xB1b56b46A7961a1797dcA7eaF58d28903DA6623A', + fundManagerAddress: '0x7C6454aEd2d0843b3C2A76822328C4AfECc99747', + fiberRouterAddress: '0xe0595a09a154EF11d98C44a4A84D93bB9F46b74E', foundaryTokenAddress: '0x1d17CBcF0D6D143135aE902365D2E5e2A16538D4', aggregateRouterContractAddress: '0x6fd4383cb451173d5f9304f041c7bcbf27d561ff', From 35853ea1cd159c08fe5229c36248949e234f667c Mon Sep 17 00:00:00 2001 From: Zikriya Date: Fri, 24 May 2024 17:28:05 +0500 Subject: [PATCH 24/24] Network config updated --- src/constants/constants.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/constants/constants.ts b/src/constants/constants.ts index adbdc65..532c3c8 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -40,17 +40,21 @@ export const NETWORKS = [ }, { chainId: '10', - fundManagerAddress: '0x7655eE1bd794b0Fe4b9B4D477B0F5cCABD78137c', - fiberRouterAddress: '0x6a34da798839964e14850F585187f3d28079a500', + fundManagerAddress: '0x7aCeB18DB714424678a711a31432ec47A053820D', + fiberRouterAddress: '0x47Bee1648Eb4B375E27038314738455419B3766b', foundaryTokenAddress: '0x0b2c639c533813f4aa9d7837caf62653d097ff85', - aggregateRouterContractAddress: '', + aggregateRouterContractAddress: + '0x111111125421ca6dc452d289314280a0f8842a65', + cctpFundManager: '0xd860D4Feed23f5Cd6ec4D3f76C7A47ED1c27102C', }, { chainId: '43114', - fundManagerAddress: '0x41eFd89cbeaCeCdf72d3fD8321C53A69A132CC1a', - fiberRouterAddress: '0x9cc84e262E3A2A6b8C257d493E3d3487495fb5a2', + fundManagerAddress: '0x39E205B5477Bf41CB05B18299D279b6535ba180f', + fiberRouterAddress: '0x4256b41a6B56CD4D93f35B3eD2889A57e1882C72', foundaryTokenAddress: '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E', - aggregateRouterContractAddress: '', + aggregateRouterContractAddress: + '0x111111125421ca6dc452d289314280a0f8842a65', + cctpFundManager: '0x90b4C9Cc6AAf15be692d20D409A86bd32897D9b1', }, { chainId: '8453',