diff --git a/packages/canonical-bridge-sdk/src/layerZero/index.ts b/packages/canonical-bridge-sdk/src/layerZero/index.ts index a441c588..b0e5eff1 100644 --- a/packages/canonical-bridge-sdk/src/layerZero/index.ts +++ b/packages/canonical-bridge-sdk/src/layerZero/index.ts @@ -33,13 +33,22 @@ export class LayerZero { walletClient, gasAmount = 200000n, version = 1, + airDropGas = 0n, + dstAddress = '0x', }: ISendCakeTokenInput): Promise { try { const address32Bytes = pad(userAddress, { size: 32 }); - const adapterParams = encodePacked( - ['uint16', 'uint256'], - [version, gasAmount] - ); + /* version 1 - send token + * version 2 - send token and air drop native gas on destination chain + * https://docs.layerzero.network/v1/developers/evm/evm-guides/advanced/relayer-adapter-parameters#airdrop + */ + const adapterParams = + version === 1 + ? encodePacked(['uint16', 'uint256'], [version, gasAmount]) + : encodePacked( + ['uint16', 'uint', 'uint', 'address'], + [2, gasAmount, airDropGas, dstAddress] + ); const fees = await publicClient.readContract({ address: bridgeAddress, abi: CAKE_PROXY_OFT_ABI, @@ -109,13 +118,18 @@ export class LayerZero { publicClient, gasAmount = 200000n, version = 1, + airDropGas = 0n, + dstAddress = '0x', }: IGetEstimateFeeInput) { try { const address32Bytes = pad(userAddress, { size: 32 }); - const adapterParams = encodePacked( - ['uint16', 'uint256'], - [version, gasAmount] - ); + const adapterParams = + version === 1 + ? encodePacked(['uint16', 'uint256'], [version, gasAmount]) + : encodePacked( + ['uint16', 'uint', 'uint', 'address'], + [2, gasAmount, airDropGas, dstAddress] + ); const fees = await publicClient.readContract({ address: bridgeAddress, abi: CAKE_PROXY_OFT_ABI, diff --git a/packages/canonical-bridge-sdk/src/layerZero/types/index.ts b/packages/canonical-bridge-sdk/src/layerZero/types/index.ts index de081be1..915e3672 100644 --- a/packages/canonical-bridge-sdk/src/layerZero/types/index.ts +++ b/packages/canonical-bridge-sdk/src/layerZero/types/index.ts @@ -11,6 +11,8 @@ export interface ISendCakeTokenInput { version?: number; publicClient: PublicClient; walletClient: WalletClient; + dstAddress?: `0x${string}`; + airDropGas?: bigint; } export interface IGetEstimateFeeInput { @@ -21,6 +23,8 @@ export interface IGetEstimateFeeInput { gasAmount?: bigint; version?: number; publicClient: PublicClient; + dstAddress?: `0x${string}`; + airDropGas?: bigint; } export interface LayerZeroToken {