Deposit ETH into a DeFi Protocol (Aave)
This action shows how to use the swapped asset (in this case, native ETH) in a DeFi protocol. The example targets an Aave contract and calls depositETH. The crucial parameter is populateCallValueDynamically: true, which instructs the protocol to use the entire ETH balance received from the swap as the value for this contract call. All arguments to the depositETH function are provided as static values.
Request Body
{
"actions": [
{
"target": "0x5283BEcEd7ADF6D003225C13896E536f2D4264FF",
"functionSignature": "function depositETH(address, address onBehalfOf, uint16 referralCode)",
"args": [
{
"value": "0x0000000000000000000000000000000000000000",
"populateDynamically": false
},
{
"value": "0x718648C8c531F91b528A7757dD2bE813c3940608",
"populateDynamically": false
},
{
"value": "0",
"populateDynamically": false
}
],
"value": "0",
"isNativeTransfer": false,
"populateCallValueDynamically": true
}
]
}Initiates a crosschain swap approval and execution step. Requires query parameters and a JSON body of actions. Returns swap details, fees, steps, and transaction data.
Query parameters
tradeTypestring · enumRequiredExample:
exactInputPossible values: amountstringRequiredExample:
10000000inputTokenstringRequiredExample:
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48outputTokenstringRequiredExample:
0x0000000000000000000000000000000000000000originChainIdintegerRequiredExample:
1destinationChainIdintegerRequiredExample:
42161depositorstringRequiredExample:
0xA4d353BBc130cbeF1811f27ac70989F9d568CeABrecipientstringRequiredExample:
0xA4d353BBc130cbeF1811f27ac70989F9d568CeABBody
Responses
200
Successful swap approval
application/json
Responseobject
400
Invalid request
application/json
post
/swap/approvalPOST /api/swap/approval?tradeType=exactInput&amount=text&inputToken=text&outputToken=text&originChainId=1&destinationChainId=1&depositor=text&recipient=text HTTP/1.1
Host: app.across.to
Content-Type: application/json
Accept: */*
Content-Length: 451
{
"actions": [
{
"target": "0x5283BEcEd7ADF6D003225C13896E536f2D4264FF",
"functionSignature": "function depositETH(address, address onBehalfOf, uint16 referralCode)",
"args": [
{
"value": "0x0000000000000000000000000000000000000000",
"populateDynamically": false
},
{
"value": "0x718648C8c531F91b528A7757dD2bE813c3940608",
"populateDynamically": false
},
{
"value": "0",
"populateDynamically": false
}
],
"value": "0",
"isNativeTransfer": false,
"populateCallValueDynamically": true
}
]
}{
"crossSwapType": "bridgeableToAny",
"amountType": "exactInput",
"checks": {
"allowance": {
"token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"spender": "0x6f26Bf09B1C792e3228e5467807a900A503c0281",
"actual": "115792089237316195423570985008687907853269984665640564039457584007913092639935",
"expected": "10000000"
},
"balance": {
"token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"actual": "500000000",
"expected": "10000000"
}
},
"steps": {
"bridge": {
"inputAmount": "10000000",
"outputAmount": "9968133",
"tokenIn": {
"decimals": 6,
"symbol": "USDC",
"address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"name": "USD Coin",
"chainId": 1
},
"tokenOut": {
"address": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
"decimals": 6,
"symbol": "USDC",
"chainId": 42161
},
"fees": {
"totalRelay": {
"pct": "3186713237776016",
"total": "31867"
},
"relayerCapital": {
"pct": "100000000000000",
"total": "1000"
},
"relayerGas": {
"pct": "3077000000000000",
"total": "30770"
},
"lp": {
"pct": "9713237776016",
"total": "97"
},
"originGas": {
"pct": "123456000000000",
"total": "123"
},
"destinationGas": {
"pct": "654321000000000",
"total": "321"
},
"relayerTotal": {
"pct": "3170000000000000",
"total": "31700"
},
"lpFee": {
"pct": "716237776016",
"total": "67"
}
}
},
"destinationSwap": {
"tokenIn": {
"address": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
"decimals": 6,
"symbol": "USDC",
"chainId": 42161
},
"tokenOut": {
"decimals": 18,
"symbol": "ETH",
"address": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"name": "Ether",
"chainId": 42161
},
"inputAmount": "9968133",
"maxInputAmount": "9968133",
"outputAmount": "2061819304171612",
"minOutputAmount": "2041201111128300",
"swapProvider": {
"name": "0x",
"sources": [
"pancakeswap_v3"
]
}
}
},
"inputToken": {
"decimals": 6,
"symbol": "USDC",
"address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"name": "USD Coin",
"chainId": 1
},
"outputToken": {
"decimals": 18,
"symbol": "ETH",
"address": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"name": "Ether",
"chainId": 42161
},
"refundToken": {
"decimals": 6,
"symbol": "USDC",
"address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"name": "USD Coin",
"chainId": 1
},
"inputAmount": "10000000",
"expectedOutputAmount": "2061819304171612",
"minOutputAmount": "2041201111128300",
"expectedFillTime": 3,
"swapTx": {
"simulationSuccess": false,
"chainId": 1,
"to": "0x6f26Bf09B1C792e3228e5467807a900A503c0281",
"data": "0xad5425c600000000000000...",
"maxFeePerGas": "1002599",
"maxPriorityFeePerGas": "1000000"
},
"id": "c64fg-1755905774371-44a89a59ef9b"
}Last updated