Add Liquidity to Across HubPool with ETH
This is a more advanced action that uses the resulting ETH balance for both a function argument and the transaction's value
. The addLiquidity
function requires the amount of ETH as an argument. We dynamically provide this by setting populateDynamically: true
and using the zero address (0x00...00
) for balanceSource
, which signifies the native ETH balance. When an argument is populated dynamically from the native balance, the value
of the transaction is automatically and implicitly set to that same amount, streamlining the process.
Request Body
{
"actions": [
{
"target": "0xc186fA914353c44b2E33eBE05f21846F1048bEda",
"functionSignature": "function addLiquidity(address l1Token, uint256 l1TokenAmount)",
"args": [
{
"value": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"populateDynamically": false
},
{
"value": "0",
"populateDynamically": true,
"balanceSourceToken": "0x0000000000000000000000000000000000000000"
}
],
"value": "0",
"isNativeTransfer": false,
"populateCallValueDynamically": true
}
]
}
Given input/output tokens, chain IDs, depositor/recipient, and post-bridge actions, this endpoint returns:
Allowance & balance checks
Approval transaction(s) if required
Swap and bridge execution steps
Final transaction payload (
swapTx
)Fees breakdown
exactInput
Possible values: Trade amount in smallest units (e.g., USDC 6 decimals).
10000000
Address of token to swap from (checksummed).
0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85
Address of token to swap to (checksummed).
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Chain ID where swap originates.
10
Chain ID where swap finalizes.
1
EVM address of depositor.
0xA4d353BBc130cbeF1811f27ac70989F9d568CeAB
EVM address of recipient after bridging.
0xA4d353BBc130cbeF1811f27ac70989F9d568CeAB
Successful swap approval response
Invalid request parameters
POST /api/swap/approval HTTP/1.1
Host: app.across.to
Content-Type: application/json
Accept: */*
Content-Length: 425
{
"actions": [
{
"target": "0xc186fA914353c44b2E33eBE05f21846F1048bEda",
"functionSignature": "function addLiquidity(address l1Token, uint256 l1TokenAmount)",
"args": [
{
"value": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"populateDynamically": false
},
{
"value": "0",
"populateDynamically": true,
"balanceSourceToken": "0x0000000000000000000000000000000000000000"
}
],
"value": "0",
"isNativeTransfer": false,
"populateCallValueDynamically": true
}
]
}
{
"crossSwapType": "anyToBridgeable",
"amountType": "exactInput",
"checks": {
"allowance": {
"token": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
"spender": "0x89415a82d909a7238d69094C3Dd1dCC1aCbDa85C",
"actual": "0",
"expected": "10000000"
},
"balance": {
"token": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
"actual": "169942",
"expected": "10000000"
}
},
"approvalTxns": [
{
"chainId": 10,
"to": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
"data": "0x095ea7b300000000000000000000000089415a82d909a7238d69094c3dd1dcc1acbda85cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
}
],
"steps": {
"originSwap": {
"tokenIn": {
"decimals": 6,
"symbol": "USDC",
"address": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
"name": "USD Coin",
"chainId": 10
},
"tokenOut": {
"address": "0x4200000000000000000000000000000000000006",
"decimals": 18,
"symbol": "ETH",
"chainId": 10
},
"inputAmount": "10000000",
"outputAmount": "2070607856240202",
"minOutputAmount": "2049901777677600",
"maxInputAmount": "10000000",
"swapProvider": {
"name": "0x",
"sources": [
"uniswap_v4",
"uniswap_v3",
"velodrome_v3"
]
}
},
"bridge": {
"inputAmount": "2049901777677600",
"outputAmount": "1942640017359211",
"tokenIn": {
"address": "0x4200000000000000000000000000000000000006",
"decimals": 18,
"symbol": "ETH",
"chainId": 10
},
"tokenOut": {
"address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"decimals": 18,
"symbol": "ETH",
"name": "Ether",
"chainId": 1
},
"fees": {
"totalRelay": {
"pct": "52325316991485989",
"total": "107261760318389"
},
"relayerCapital": {
"pct": "99914587425765",
"total": "204815090379"
},
"relayerGas": {
"pct": "52034031578669020",
"total": "106664653832845"
},
"lp": {
"pct": "191370825391204",
"total": "392291395165"
}
}
}
},
"inputToken": {
"decimals": 6,
"symbol": "USDC",
"address": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
"name": "USD Coin",
"chainId": 10
},
"outputToken": {
"decimals": 18,
"symbol": "ETH",
"address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"name": "Ether",
"chainId": 1
},
"refundToken": {
"address": "0x4200000000000000000000000000000000000006",
"decimals": 18,
"symbol": "WETH",
"chainId": 10
},
"fees": {
"total": {
"amount": "600687",
"amountUsd": "0.60050966243367121",
"pct": "60068746592358460",
"token": {
"decimals": 6,
"symbol": "USDC",
"address": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
"name": "USD Coin",
"chainId": 10
}
},
"originGas": {
"amount": "0",
"amountUsd": "0.0",
"token": {
"chainId": 10,
"address": "0x0000000000000000000000000000000000000000",
"decimals": 18,
"symbol": "ETH"
}
},
"destinationGas": {
"amount": "106664653832845",
"amountUsd": "0.515774800315645265",
"pct": "51592751486004382",
"token": {
"chainId": 1,
"address": "0x0000000000000000000000000000000000000000",
"decimals": 18,
"symbol": "ETH"
}
},
"relayerCapital": {
"amount": "204815090379",
"amountUsd": "0.000990379273225847",
"pct": "99067251228948",
"token": {
"address": "0x4200000000000000000000000000000000000006",
"decimals": 18,
"symbol": "ETH",
"chainId": 10
}
},
"lpFee": {
"amount": "392291395165",
"amountUsd": "0.001896917195492454",
"pct": "189747884923183",
"token": {
"address": "0x4200000000000000000000000000000000000006",
"decimals": 18,
"symbol": "ETH",
"chainId": 10
}
},
"relayerTotal": {
"amount": "107261760318389",
"amountUsd": "0.518662096784363591",
"pct": "51881566622156518",
"token": {
"address": "0x4200000000000000000000000000000000000006",
"decimals": 18,
"symbol": "ETH",
"chainId": 10
}
},
"app": {
"amount": "0",
"amountUsd": "0.0",
"pct": "0",
"token": {
"decimals": 18,
"symbol": "ETH",
"address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"name": "Ether",
"chainId": 1
}
}
},
"inputAmount": "10000000",
"expectedOutputAmount": "1942640017359211",
"minOutputAmount": "1942640017359211",
"expectedFillTime": 8,
"swapTx": {
"simulationSuccess": false,
"chainId": 10,
"to": "0x89415a82d909a7238d69094C3Dd1dCC1aCbDa85C",
"data": "0x110560ad0000000000000000000000000000000000000000000000000000000000000020...",
"maxFeePerGas": "1002808",
"maxPriorityFeePerGas": "1000000"
},
"id": "2mcw2-1755906874198-a000ed7c7701"
}
Last updated