From 223a45fb4f05599a4414b2f51aaa9c067d9ffd20 Mon Sep 17 00:00:00 2001 From: Michal Mironczuk Date: Fri, 12 Sep 2025 14:47:32 +0200 Subject: [PATCH 1/6] added Sui --- src/Facets/RelayFacet.sol | 11 ++++++++--- test/solidity/Facets/RelayFacet.t.sol | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Facets/RelayFacet.sol b/src/Facets/RelayFacet.sol index 275f26a21..d91074b1f 100644 --- a/src/Facets/RelayFacet.sol +++ b/src/Facets/RelayFacet.sol @@ -219,21 +219,26 @@ contract RelayFacet is } /// @notice get Relay specific chain id for non-EVM chains - /// IDs found here https://li.quest/v1/chains?chainTypes=UTXO,SVM + /// IDs found here https://api.relay.link/chains /// @param chainId LIFI specific chain id function _getMappedChainId( uint256 chainId ) internal pure returns (uint256) { // Bitcoin - if (chainId == 20000000000001) { + if (chainId == LIFI_CHAIN_ID_BTC) { return 8253038; } // Solana - if (chainId == 1151111081099710) { + if (chainId == LIFI_CHAIN_ID_SOLANA) { return 792703809; } + // Sui + if (chainId == LIFI_CHAIN_ID_SUI) { + return 103665049; + } + return chainId; } } diff --git a/test/solidity/Facets/RelayFacet.t.sol b/test/solidity/Facets/RelayFacet.t.sol index 119340f71..3225c30ba 100644 --- a/test/solidity/Facets/RelayFacet.t.sol +++ b/test/solidity/Facets/RelayFacet.t.sol @@ -734,6 +734,12 @@ contract RelayFacetTest is TestBaseFacet { return; } + // Sui + if (chainId == 9270000000000000) { + assertEq(mapped, 103665049); + return; + } + assertEq(mapped, chainId); } From 82b334775c55845b131404e2ff11bfcab8ca1360 Mon Sep 17 00:00:00 2001 From: Michal Mironczuk Date: Fri, 12 Sep 2025 14:50:59 +0200 Subject: [PATCH 2/6] bumped contract version, added staging deployment --- deployments/_deployments_log_file.json | 11 +++++++++++ deployments/arbitrum.diamond.staging.json | 12 ++++++++++++ deployments/arbitrum.staging.json | 2 +- src/Facets/RelayFacet.sol | 2 +- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/deployments/_deployments_log_file.json b/deployments/_deployments_log_file.json index f78d139f6..44c2b4cae 100644 --- a/deployments/_deployments_log_file.json +++ b/deployments/_deployments_log_file.json @@ -37434,6 +37434,17 @@ "SALT": "", "VERIFIED": "true" } + ], + "1.0.2": [ + { + "ADDRESS": "0xdaD5da5FB53EAe15f490Fb31F4573e56277b59CA", + "OPTIMIZER_RUNS": "1000000", + "TIMESTAMP": "2025-09-12 14:50:00", + "CONSTRUCTOR_ARGS": "0x000000000000000000000000a5f565650890fba1824ee0f21ebbbf660a179934000000000000000000000000f70da97812cb96acdf810712aa562db8dfa3dbef", + "SALT": "22345116", + "VERIFIED": "false", + "ZK_SOLC_VERSION": "" + } ] }, "production": { diff --git a/deployments/arbitrum.diamond.staging.json b/deployments/arbitrum.diamond.staging.json index c600fde1a..2f645eaeb 100644 --- a/deployments/arbitrum.diamond.staging.json +++ b/deployments/arbitrum.diamond.staging.json @@ -180,6 +180,18 @@ "0x004E291b9244C811B0BE00cA2C179d54FAA5073D": { "Name": "RelayDepositoryFacet", "Version": "1.0.0" + }, + "0xdaD5da5FB53EAe15f490Fb31F4573e56277b59CA": { + "Name": "RelayFacet", + "Version": "1.0.2" + }, + "0xaA1E88f4D0cb0a798f1FeBAfc8fAb4778629D4e7": { + "Name": "", + "Version": "" + }, + "0x33EcEb68994E0499a61FAda3b49Ab243e63555F1": { + "Name": "", + "Version": "" } }, "Periphery": { diff --git a/deployments/arbitrum.staging.json b/deployments/arbitrum.staging.json index d49ac733d..4ea15ec8b 100644 --- a/deployments/arbitrum.staging.json +++ b/deployments/arbitrum.staging.json @@ -50,7 +50,7 @@ "AcrossFacetV3": "0xF336cc028Fc5328472f96e377d32Fd32F8eE1750", "ReceiverAcrossV3": "0xe4F3DEF14D61e47c696374453CD64d438FD277F8", "AcrossFacetPackedV3": "0x21767081Ff52CE5563A29f27149D01C7127775A2", - "RelayFacet": "0x681a3409c35F12224c436D50Ce14F25f954B6Ea2", + "RelayFacet": "0xdaD5da5FB53EAe15f490Fb31F4573e56277b59CA", "GlacisFacet": "0x36e1375B0755162d720276dFF6893DF02bd49225", "PioneerFacet": "0x371E61d9DC497C506837DFA47B8dccEF1da30459", "GasZipFacet": "0x7C27b0FD92dbC5a1cA268255A649320E8C649e70", diff --git a/src/Facets/RelayFacet.sol b/src/Facets/RelayFacet.sol index d91074b1f..9463e6df6 100644 --- a/src/Facets/RelayFacet.sol +++ b/src/Facets/RelayFacet.sol @@ -15,7 +15,7 @@ import { InvalidConfig } from "../Errors/GenericErrors.sol"; /// @title RelayFacet /// @author LI.FI (https://li.fi) /// @notice Provides functionality for bridging through Relay Protocol -/// @custom:version 1.0.1 +/// @custom:version 1.0.2 contract RelayFacet is ILiFi, ReentrancyGuard, From 09ea9bc35d5d853371dea28bed0d9d2a9a621067 Mon Sep 17 00:00:00 2001 From: Michal Mironczuk Date: Tue, 16 Sep 2025 16:34:40 +0200 Subject: [PATCH 3/6] changes --- script/demoScripts/demoRelay.ts | 519 ++++++++++++++++++-------------- 1 file changed, 295 insertions(+), 224 deletions(-) diff --git a/script/demoScripts/demoRelay.ts b/script/demoScripts/demoRelay.ts index a69a16627..92df9b5b0 100644 --- a/script/demoScripts/demoRelay.ts +++ b/script/demoScripts/demoRelay.ts @@ -35,269 +35,340 @@ const main = async () => { // Bridge ETH - let params = { - user: deployments.LiFiDiamond, - originChainId: 42161, - destinationChainId: 137, - originCurrency: '0x0000000000000000000000000000000000000000', - destinationCurrency: '0x0000000000000000000000000000000000000000', - recipient: address, - tradeType: 'EXACT_INPUT', - amount: '1000000000000000', - referrer: 'relay.link/swap', - useExternalLiquidity: false, - } - - let resp = await fetch('https://api.relay.link/quote', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(params), - }) - let quote = await resp.json() - let requestId = quote.steps[0].requestId - - let sigResp = await fetch( - `https://api.relay.link/requests/${requestId}/signature/v2`, - { headers: { 'Content-Type': 'application/json' } } - ) - let sigData = await sigResp.json() - - let bridgeData: ILiFi.BridgeDataStruct = { - transactionId: utils.randomBytes(32), - bridge: 'Relay', - integrator: 'ACME Devs', - referrer: '0x0000000000000000000000000000000000000000', - sendingAssetId: '0x0000000000000000000000000000000000000000', - receiver: address, - minAmount: ethers.utils.parseEther('0.001'), - destinationChainId: 137, - hasSourceSwaps: false, - hasDestinationCall: false, - } - - let relayData: RelayFacet.RelayDataStruct = { - requestId, - nonEVMReceiver: ethers.constants.HashZero, - receivingAssetId: ethers.constants.HashZero, - signature: sigData.signature, - } - - console.info('Dev Wallet Address: ', address) - console.info('Bridging ETH...') - tx = await relay - .connect(signer) - .startBridgeTokensViaRelay(bridgeData, relayData, { - value: ethers.utils.parseEther('0.001'), - }) - await tx.wait() - console.info('Bridged ETH') - - // Bridge USDC - - params = { - user: deployments.LiFiDiamond, - originChainId: 42161, - destinationChainId: 10, - originCurrency: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', - destinationCurrency: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85', - recipient: address, - tradeType: 'EXACT_INPUT', - amount: '5000000', - referrer: 'relay.link/swap', - useExternalLiquidity: false, - } - - resp = await fetch('https://api.relay.link/quote', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(params), - }) - quote = await resp.json() - requestId = quote.steps[0].requestId - - sigResp = await fetch( - `https://api.relay.link/requests/${requestId}/signature/v2`, - { headers: { 'Content-Type': 'application/json' } } - ) - sigData = await sigResp.json() + // let params = { + // user: deployments.LiFiDiamond, + // originChainId: 42161, + // destinationChainId: 137, + // originCurrency: '0x0000000000000000000000000000000000000000', + // destinationCurrency: '0x0000000000000000000000000000000000000000', + // recipient: address, + // tradeType: 'EXACT_INPUT', + // amount: '1000000000000000', + // referrer: 'relay.link/swap', + // useExternalLiquidity: false, + // } + + // let resp = await fetch('https://api.relay.link/quote', { + // method: 'POST', + // headers: { + // 'Content-Type': 'application/json', + // }, + // body: JSON.stringify(params), + // }) + // let quote = await resp.json() + // let requestId = quote.steps[0].requestId + + // let sigResp = await fetch( + // `https://api.relay.link/requests/${requestId}/signature/v2`, + // { headers: { 'Content-Type': 'application/json' } } + // ) + // let sigData = await sigResp.json() + + // let bridgeData: ILiFi.BridgeDataStruct = { + // transactionId: utils.randomBytes(32), + // bridge: 'Relay', + // integrator: 'ACME Devs', + // referrer: '0x0000000000000000000000000000000000000000', + // sendingAssetId: '0x0000000000000000000000000000000000000000', + // receiver: address, + // minAmount: ethers.utils.parseEther('0.001'), + // destinationChainId: 137, + // hasSourceSwaps: false, + // hasDestinationCall: false, + // } + + // let relayData: RelayFacet.RelayDataStruct = { + // requestId, + // nonEVMReceiver: ethers.constants.HashZero, + // receivingAssetId: ethers.constants.HashZero, + // signature: sigData.signature, + // } + + // console.info('Dev Wallet Address: ', address) + // console.info('Bridging ETH...') + // tx = await relay + // .connect(signer) + // .startBridgeTokensViaRelay(bridgeData, relayData, { + // value: ethers.utils.parseEther('0.001'), + // }) + // await tx.wait() + // console.info('Bridged ETH') + + // // Bridge USDC + + // params = { + // user: deployments.LiFiDiamond, + // originChainId: 42161, + // destinationChainId: 10, + // originCurrency: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', + // destinationCurrency: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85', + // recipient: address, + // tradeType: 'EXACT_INPUT', + // amount: '5000000', + // referrer: 'relay.link/swap', + // useExternalLiquidity: false, + // } + + // resp = await fetch('https://api.relay.link/quote', { + // method: 'POST', + // headers: { + // 'Content-Type': 'application/json', + // }, + // body: JSON.stringify(params), + // }) + // quote = await resp.json() + // requestId = quote.steps[0].requestId + + // sigResp = await fetch( + // `https://api.relay.link/requests/${requestId}/signature/v2`, + // { headers: { 'Content-Type': 'application/json' } } + // ) + // sigData = await sigResp.json() const token = ERC20__factory.connect( '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', provider ) - bridgeData = { - transactionId: utils.randomBytes(32), - bridge: 'Relay', - integrator: 'ACME Devs', - referrer: '0x0000000000000000000000000000000000000000', - sendingAssetId: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', - receiver: address, - minAmount: '5000000', - destinationChainId: 10, - hasSourceSwaps: false, - hasDestinationCall: false, - } - - relayData = { - requestId, - nonEVMReceiver: ethers.constants.HashZero, - receivingAssetId: ethers.utils.hexZeroPad( - '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85', - 32 - ), - signature: sigData.signature, - } - - console.info('Dev Wallet Address: ', address) - console.info('Approving USDC...') - tx = await token.connect(signer).approve(LIFI_ADDRESS, '5000000') - await tx.wait() - console.info('Approved USDC') - console.info('Bridging USDC...') - tx = await relay - .connect(signer) - .startBridgeTokensViaRelay(bridgeData, relayData) - await tx.wait() - console.info('Bridged USDC') - - // Swap USDC and Bridge ETH - - params = { - user: deployments.LiFiDiamond, - originChainId: 42161, - destinationChainId: 137, - originCurrency: '0x0000000000000000000000000000000000000000', - destinationCurrency: '0x0000000000000000000000000000000000000000', - recipient: address, - tradeType: 'EXACT_INPUT', - amount: '1000000000000000', - referrer: 'relay.link/swap', - useExternalLiquidity: false, - } - - resp = await fetch('https://api.relay.link/quote', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(params), - }) - quote = await resp.json() - requestId = quote.steps[0].requestId - - sigResp = await fetch( - `https://api.relay.link/requests/${requestId}/signature/v2`, - { headers: { 'Content-Type': 'application/json' } } - ) - sigData = await sigResp.json() - console.log(sigData) - - bridgeData = { - transactionId: utils.randomBytes(32), - bridge: 'Relay', - integrator: 'ACME Devs', - referrer: '0x0000000000000000000000000000000000000000', - sendingAssetId: '0x0000000000000000000000000000000000000000', - receiver: address, - minAmount: ethers.utils.parseEther('0.001'), - destinationChainId: 137, - hasSourceSwaps: true, - hasDestinationCall: false, - } - - const swapData = [] - - const uniswapAddress = ADDRESS_UNISWAP_ARB - swapData[0] = await getUniswapSwapDataERC20ToETH( - uniswapAddress, - 42161, - ADDRESS_USDC_ARB, - ADDRESS_WETH_ARB, - ethers.utils.parseUnits('4', 6), - LIFI_ADDRESS, - true - ) - - relayData = { - requestId, - nonEVMReceiver: ethers.constants.HashZero, - receivingAssetId: ethers.constants.HashZero, - signature: sigData.signature, - } - - console.info('Dev Wallet Address: ', address) - console.info('Approving USDC...') - tx = await token.connect(signer).approve(LIFI_ADDRESS, '4000000') - await tx.wait() - console.info('Approved USDC') - console.info('Bridging USDC -> ETH...') - tx = await relay - .connect(signer) - .swapAndStartBridgeTokensViaRelay(bridgeData, swapData, relayData) - await tx.wait() - console.info('Bridged ETH') - - // Bridge USDC to Solana - - const solanaReceiver = 'EoW7FWTdPdZKpd3WAhH98c2HMGHsdh5yhzzEtk1u68Bb' - const solanaUSDC = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' - - params = { + // bridgeData = { + // transactionId: utils.randomBytes(32), + // bridge: 'Relay', + // integrator: 'ACME Devs', + // referrer: '0x0000000000000000000000000000000000000000', + // sendingAssetId: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', + // receiver: address, + // minAmount: '5000000', + // destinationChainId: 10, + // hasSourceSwaps: false, + // hasDestinationCall: false, + // } + + // relayData = { + // requestId, + // nonEVMReceiver: ethers.constants.HashZero, + // receivingAssetId: ethers.utils.hexZeroPad( + // '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85', + // 32 + // ), + // signature: sigData.signature, + // } + + // console.info('Dev Wallet Address: ', address) + // console.info('Approving USDC...') + // tx = await token.connect(signer).approve(LIFI_ADDRESS, '5000000') + // await tx.wait() + // console.info('Approved USDC') + // console.info('Bridging USDC...') + // tx = await relay + // .connect(signer) + // .startBridgeTokensViaRelay(bridgeData, relayData) + // await tx.wait() + // console.info('Bridged USDC') + + // // Swap USDC and Bridge ETH + + // params = { + // user: deployments.LiFiDiamond, + // originChainId: 42161, + // destinationChainId: 137, + // originCurrency: '0x0000000000000000000000000000000000000000', + // destinationCurrency: '0x0000000000000000000000000000000000000000', + // recipient: address, + // tradeType: 'EXACT_INPUT', + // amount: '1000000000000000', + // referrer: 'relay.link/swap', + // useExternalLiquidity: false, + // } + + // resp = await fetch('https://api.relay.link/quote', { + // method: 'POST', + // headers: { + // 'Content-Type': 'application/json', + // }, + // body: JSON.stringify(params), + // }) + // quote = await resp.json() + // requestId = quote.steps[0].requestId + + // sigResp = await fetch( + // `https://api.relay.link/requests/${requestId}/signature/v2`, + // { headers: { 'Content-Type': 'application/json' } } + // ) + // sigData = await sigResp.json() + // console.log(sigData) + + // bridgeData = { + // transactionId: utils.randomBytes(32), + // bridge: 'Relay', + // integrator: 'ACME Devs', + // referrer: '0x0000000000000000000000000000000000000000', + // sendingAssetId: '0x0000000000000000000000000000000000000000', + // receiver: address, + // minAmount: ethers.utils.parseEther('0.001'), + // destinationChainId: 137, + // hasSourceSwaps: true, + // hasDestinationCall: false, + // } + + // const swapData = [] + + // const uniswapAddress = ADDRESS_UNISWAP_ARB + // swapData[0] = await getUniswapSwapDataERC20ToETH( + // uniswapAddress, + // 42161, + // ADDRESS_USDC_ARB, + // ADDRESS_WETH_ARB, + // ethers.utils.parseUnits('4', 6), + // LIFI_ADDRESS, + // true + // ) + + // relayData = { + // requestId, + // nonEVMReceiver: ethers.constants.HashZero, + // receivingAssetId: ethers.constants.HashZero, + // signature: sigData.signature, + // } + + // console.info('Dev Wallet Address: ', address) + // console.info('Approving USDC...') + // tx = await token.connect(signer).approve(LIFI_ADDRESS, '4000000') + // await tx.wait() + // console.info('Approved USDC') + // console.info('Bridging USDC -> ETH...') + // tx = await relay + // .connect(signer) + // .swapAndStartBridgeTokensViaRelay(bridgeData, swapData, relayData) + // await tx.wait() + // console.info('Bridged ETH') + + // // Bridge USDC to Solana + + // const solanaReceiver = 'EoW7FWTdPdZKpd3WAhH98c2HMGHsdh5yhzzEtk1u68Bb' + // const solanaUSDC = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' + + // params = { + // user: deployments.LiFiDiamond, + // originChainId: 42161, + // destinationChainId: 792703809, + // originCurrency: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', + // destinationCurrency: solanaUSDC, + // recipient: solanaReceiver, + // tradeType: 'EXACT_INPUT', + // amount: '5000000', + // referrer: 'relay.link/swap', + // useExternalLiquidity: false, + // } + + // resp = await fetch('https://api.relay.link/quote', { + // method: 'POST', + // headers: { + // 'Content-Type': 'application/json', + // }, + // body: JSON.stringify(params), + // }) + // quote = await resp.json() + // console.log(quote) + // requestId = quote.steps[0].requestId + + // console.log(requestId) + // sigResp = await fetch( + // `https://api.relay.link/requests/${requestId}/signature/v2`, + // { headers: { 'Content-Type': 'application/json' } } + // ) + // sigData = await sigResp.json() + // console.log(sigData) + + // bridgeData = { + // transactionId: utils.randomBytes(32), + // bridge: 'Relay', + // integrator: 'ACME Devs', + // referrer: '0x0000000000000000000000000000000000000000', + // sendingAssetId: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', + // receiver: '0x11f111f111f111F111f111f111F111f111f111F1', + // minAmount: '5000000', + // destinationChainId: 1151111081099710, + // hasSourceSwaps: false, + // hasDestinationCall: false, + // } + + // relayData = { + // requestId, + // nonEVMReceiver: `0x${new PublicKey(solanaReceiver) + // .toBuffer() + // .toString('hex')}`, + // receivingAssetId: `0x${new PublicKey(solanaUSDC) + // .toBuffer() + // .toString('hex')}`, + // signature: sigData.signature, + // } + + // console.info('Dev Wallet Address: ', address) + // console.info('Approving USDC...') + // tx = await token.connect(signer).approve(LIFI_ADDRESS, '5000000') + // await tx.wait() + // console.info('Approved USDC') + // console.info('Bridging USDC...') + // tx = await relay + // .connect(signer) + // .startBridgeTokensViaRelay(bridgeData, relayData) + // await tx.wait() + // console.info('Bridged USDC') + + const suiUSDC = '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC'; + const suiRandomReceiver = '0x02a212de6a9dfa3a69e22387acfbafbb1a9e591bd9d636e7895dcfc8de05f331' + + const params = { user: deployments.LiFiDiamond, originChainId: 42161, - destinationChainId: 792703809, + destinationChainId: 9270000000000000, // SUI originCurrency: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', - destinationCurrency: solanaUSDC, - recipient: solanaReceiver, + destinationCurrency: suiUSDC, + recipient: suiRandomReceiver, tradeType: 'EXACT_INPUT', - amount: '5000000', + amount: '500000', referrer: 'relay.link/swap', useExternalLiquidity: false, } - resp = await fetch('https://api.relay.link/quote', { + const resp = await fetch('https://api.relay.link/quote', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(params), }) - quote = await resp.json() + const quote = await resp.json() console.log(quote) - requestId = quote.steps[0].requestId + const requestId = quote.steps[0].requestId console.log(requestId) - sigResp = await fetch( + const sigResp = await fetch( `https://api.relay.link/requests/${requestId}/signature/v2`, { headers: { 'Content-Type': 'application/json' } } ) - sigData = await sigResp.json() + const sigData = await sigResp.json() console.log(sigData) - bridgeData = { + const bridgeData = { transactionId: utils.randomBytes(32), bridge: 'Relay', integrator: 'ACME Devs', referrer: '0x0000000000000000000000000000000000000000', sendingAssetId: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', - receiver: '0x11f111f111f111F111f111f111F111f111f111F1', - minAmount: '5000000', - destinationChainId: 1151111081099710, + receiver: suiRandomReceiver, + minAmount: '500000', + destinationChainId: 9270000000000000, // SUI hasSourceSwaps: false, hasDestinationCall: false, } - relayData = { + const relayData = { requestId, - nonEVMReceiver: `0x${new PublicKey(solanaReceiver) + nonEVMReceiver: `0x${new PublicKey(suiRandomReceiver) .toBuffer() .toString('hex')}`, - receivingAssetId: `0x${new PublicKey(solanaUSDC) + receivingAssetId: `0x${new PublicKey(suiUSDC) .toBuffer() .toString('hex')}`, signature: sigData.signature, @@ -305,7 +376,7 @@ const main = async () => { console.info('Dev Wallet Address: ', address) console.info('Approving USDC...') - tx = await token.connect(signer).approve(LIFI_ADDRESS, '5000000') + tx = await token.connect(signer).approve(LIFI_ADDRESS, '500000') await tx.wait() console.info('Approved USDC') console.info('Bridging USDC...') From 17cc65726319e51bcf6674572520113651f5f72c Mon Sep 17 00:00:00 2001 From: Michal Mironczuk Date: Wed, 17 Sep 2025 10:25:24 +0200 Subject: [PATCH 4/6] changes --- script/demoScripts/demoRelay.ts | 85 +++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 36 deletions(-) diff --git a/script/demoScripts/demoRelay.ts b/script/demoScripts/demoRelay.ts index 92df9b5b0..89775dfab 100644 --- a/script/demoScripts/demoRelay.ts +++ b/script/demoScripts/demoRelay.ts @@ -321,15 +321,17 @@ const main = async () => { const params = { user: deployments.LiFiDiamond, originChainId: 42161, - destinationChainId: 9270000000000000, // SUI - originCurrency: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', + destinationChainId: 103665049, // SUI + originCurrency: ADDRESS_USDC_ARB, destinationCurrency: suiUSDC, recipient: suiRandomReceiver, tradeType: 'EXACT_INPUT', - amount: '500000', + amount: '1000000', referrer: 'relay.link/swap', useExternalLiquidity: false, } + console.log(params) + const resp = await fetch('https://api.relay.link/quote', { method: 'POST', @@ -342,49 +344,60 @@ const main = async () => { console.log(quote) const requestId = quote.steps[0].requestId + console.log("requestId") + console.log("requestId") + console.log("requestId") + console.log("requestId") + console.log("requestId") + console.log(requestId) + console.log(requestId) + console.log(requestId) + console.log(requestId) console.log(requestId) const sigResp = await fetch( `https://api.relay.link/requests/${requestId}/signature/v2`, { headers: { 'Content-Type': 'application/json' } } ) + console.log("sigResp") + console.log(sigResp) const sigData = await sigResp.json() console.log(sigData) - const bridgeData = { - transactionId: utils.randomBytes(32), - bridge: 'Relay', - integrator: 'ACME Devs', - referrer: '0x0000000000000000000000000000000000000000', - sendingAssetId: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', - receiver: suiRandomReceiver, - minAmount: '500000', - destinationChainId: 9270000000000000, // SUI - hasSourceSwaps: false, - hasDestinationCall: false, - } + // const bridgeData = { + // transactionId: utils.randomBytes(32), + // bridge: 'Relay', + // integrator: 'ACME Devs', + // referrer: '0x0000000000000000000000000000000000000000', + // sendingAssetId: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', + // receiver: suiRandomReceiver, + // minAmount: '500000', + // destinationChainId: 9270000000000000, // SUI + // hasSourceSwaps: false, + // hasDestinationCall: false, + // } - const relayData = { - requestId, - nonEVMReceiver: `0x${new PublicKey(suiRandomReceiver) - .toBuffer() - .toString('hex')}`, - receivingAssetId: `0x${new PublicKey(suiUSDC) - .toBuffer() - .toString('hex')}`, - signature: sigData.signature, - } + // const relayData = { + // requestId, + // nonEVMReceiver: `0x${new PublicKey(suiRandomReceiver) + // .toBuffer() + // .toString('hex')}`, + // receivingAssetId: `0x${new PublicKey(suiUSDC) + // .toBuffer() + // .toString('hex')}`, + // signature: sigData.signature, + // } - console.info('Dev Wallet Address: ', address) - console.info('Approving USDC...') - tx = await token.connect(signer).approve(LIFI_ADDRESS, '500000') - await tx.wait() - console.info('Approved USDC') - console.info('Bridging USDC...') - tx = await relay - .connect(signer) - .startBridgeTokensViaRelay(bridgeData, relayData) - await tx.wait() - console.info('Bridged USDC') + // console.info('Dev Wallet Address: ', address) + // console.info('Approving USDC...') + // tx = await token.connect(signer).approve(LIFI_ADDRESS, '500000') + // await tx.wait() + // console.info('Approved USDC') + // console.info('Bridging USDC...') + // tx = await relay + // .connect(signer) + // .startBridgeTokensViaRelay(bridgeData, relayData) + // await tx.wait() + // console.info('Bridged USDC') } main() From aa29e21989681503651f033d60391d7c2b4adc37 Mon Sep 17 00:00:00 2001 From: Michal Mironczuk Date: Mon, 22 Sep 2025 12:59:13 +0200 Subject: [PATCH 5/6] changes --- script/demoScripts/demoRelay.ts | 59 ++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/script/demoScripts/demoRelay.ts b/script/demoScripts/demoRelay.ts index 89775dfab..78f54de0f 100644 --- a/script/demoScripts/demoRelay.ts +++ b/script/demoScripts/demoRelay.ts @@ -361,31 +361,34 @@ const main = async () => { console.log("sigResp") console.log(sigResp) const sigData = await sigResp.json() + console.log("sigData") console.log(sigData) - // const bridgeData = { - // transactionId: utils.randomBytes(32), - // bridge: 'Relay', - // integrator: 'ACME Devs', - // referrer: '0x0000000000000000000000000000000000000000', - // sendingAssetId: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', - // receiver: suiRandomReceiver, - // minAmount: '500000', - // destinationChainId: 9270000000000000, // SUI - // hasSourceSwaps: false, - // hasDestinationCall: false, - // } + const bridgeData = { + transactionId: utils.randomBytes(32), + bridge: 'Relay', + integrator: 'ACME Devs', + referrer: '0x0000000000000000000000000000000000000000', + sendingAssetId: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', + receiver: '0x11f111f111f111F111f111f111F111f111f111F1', // Non-EVM address + minAmount: '500000', + destinationChainId: "9270000000000000", // SUI + hasSourceSwaps: false, + hasDestinationCall: false, + } - // const relayData = { - // requestId, - // nonEVMReceiver: `0x${new PublicKey(suiRandomReceiver) - // .toBuffer() - // .toString('hex')}`, - // receivingAssetId: `0x${new PublicKey(suiUSDC) - // .toBuffer() - // .toString('hex')}`, - // signature: sigData.signature, - // } + console.log("bridgeData") + console.log(bridgeData) + + const relayData = { + requestId, + nonEVMReceiver: ethers.utils.hexZeroPad( + suiRandomReceiver, + 32 + ), + receivingAssetId: suiUSDC, + signature: sigData.signature, + } // console.info('Dev Wallet Address: ', address) // console.info('Approving USDC...') @@ -393,11 +396,13 @@ const main = async () => { // await tx.wait() // console.info('Approved USDC') // console.info('Bridging USDC...') - // tx = await relay - // .connect(signer) - // .startBridgeTokensViaRelay(bridgeData, relayData) - // await tx.wait() - // console.info('Bridged USDC') + tx = await relay + .connect(signer) + .startBridgeTokensViaRelay(bridgeData, relayData) + console.log("tx") + console.log(tx.hash) + await tx.wait() + console.info('Bridged USDC') } main() From 6cac30c7f9db744fc6fef2d779736c0b14c76e0e Mon Sep 17 00:00:00 2001 From: Michal Mironczuk Date: Mon, 22 Sep 2025 19:48:27 +0200 Subject: [PATCH 6/6] updates --- script/demoScripts/demoRelay.ts | 64 +++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/script/demoScripts/demoRelay.ts b/script/demoScripts/demoRelay.ts index 78f54de0f..0e0ab55ee 100644 --- a/script/demoScripts/demoRelay.ts +++ b/script/demoScripts/demoRelay.ts @@ -315,9 +315,15 @@ const main = async () => { // await tx.wait() // console.info('Bridged USDC') - const suiUSDC = '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC'; - const suiRandomReceiver = '0x02a212de6a9dfa3a69e22387acfbafbb1a9e591bd9d636e7895dcfc8de05f331' - + /// === BRIDGE TO SUI === + /// Success tx: https://arbiscan.io/tx/0x82e067d09e240805c1a2745e4119077af0c0281b04ca27808fa6cf95307e097b + /// Relay explorer: https://relay.link/transaction/0x3b2a172ac09209eb32d6c2042757eaf61eeb9be5c63b33891a23822cd31c362e + + const suiUSDC = + '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC' + const suiRandomReceiver = + '0x102fec3799bcae8f987a023f52c468156ebca136bdaa32bc148669027a5cbc98' + const usdcAmount = '500000' const params = { user: deployments.LiFiDiamond, originChainId: 42161, @@ -326,13 +332,12 @@ const main = async () => { destinationCurrency: suiUSDC, recipient: suiRandomReceiver, tradeType: 'EXACT_INPUT', - amount: '1000000', + amount: usdcAmount, referrer: 'relay.link/swap', useExternalLiquidity: false, } console.log(params) - const resp = await fetch('https://api.relay.link/quote', { method: 'POST', headers: { @@ -344,11 +349,11 @@ const main = async () => { console.log(quote) const requestId = quote.steps[0].requestId - console.log("requestId") - console.log("requestId") - console.log("requestId") - console.log("requestId") - console.log("requestId") + console.log('requestId') + console.log('requestId') + console.log('requestId') + console.log('requestId') + console.log('requestId') console.log(requestId) console.log(requestId) console.log(requestId) @@ -358,10 +363,10 @@ const main = async () => { `https://api.relay.link/requests/${requestId}/signature/v2`, { headers: { 'Content-Type': 'application/json' } } ) - console.log("sigResp") + console.log('sigResp') console.log(sigResp) const sigData = await sigResp.json() - console.log("sigData") + console.log('sigData') console.log(sigData) const bridgeData = { @@ -371,35 +376,40 @@ const main = async () => { referrer: '0x0000000000000000000000000000000000000000', sendingAssetId: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', receiver: '0x11f111f111f111F111f111f111F111f111f111F1', // Non-EVM address - minAmount: '500000', - destinationChainId: "9270000000000000", // SUI + minAmount: usdcAmount, + destinationChainId: '9270000000000000', // SUI hasSourceSwaps: false, hasDestinationCall: false, } - console.log("bridgeData") + console.log('bridgeData') console.log(bridgeData) const relayData = { requestId, - nonEVMReceiver: ethers.utils.hexZeroPad( - suiRandomReceiver, - 32 - ), - receivingAssetId: suiUSDC, + nonEVMReceiver: suiRandomReceiver, + receivingAssetId: suiUSDC.substring(0, 66), // take first 66 characters (32 bytes) - there is no documentation on this, Relay team said to do this "We take the first 32 bytes of the currency when we generate the signature" signature: sigData.signature, } - // console.info('Dev Wallet Address: ', address) - // console.info('Approving USDC...') - // tx = await token.connect(signer).approve(LIFI_ADDRESS, '500000') - // await tx.wait() - // console.info('Approved USDC') - // console.info('Bridging USDC...') + const balance = await token.balanceOf(address) + console.log('USDC Balance:', ethers.utils.formatUnits(balance, 6), 'USDC') + + if (balance.lt(ethers.BigNumber.from(usdcAmount))) { + console.log('Insufficient USDC balance!') + return + } + + console.info('Dev Wallet Address: ', address) + console.info('Approving USDC...') + tx = await token.connect(signer).approve(LIFI_ADDRESS, usdcAmount) + await tx.wait() + console.info('Approved USDC') + console.info('Bridging USDC...') tx = await relay .connect(signer) .startBridgeTokensViaRelay(bridgeData, relayData) - console.log("tx") + console.log('tx') console.log(tx.hash) await tx.wait() console.info('Bridged USDC')