Examples

Here you will some of the examples of the API integration

The values and responses provided are solely for illustrative purposes and to aid in the understanding of requests and responses; actual values and responses may vary.

1. ExactIn swap: Get Transaction Data for swap from lzUSDC to APT when fromTokenAmount is entered

POST https://api.panora.exchange/swap

const end_point = 'https://api.panora.exchange/swap'
const query = {
    fromTokenAddress: "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
    toTokenAddress: "0x1::aptos_coin::AptosCoin",
    toWalletAddress: "0x7b4ae66213a59a1bae10818347a826cb40d143bad45bd1460aeefd5bc4f52ce5",
    fromTokenAmount: 100,
};

const headers = {
    "x-api-key": "Your API key"
};

const queryString = new URLSearchParams(query).toString();
const url = `${end_point}?${queryString}`;

const response = await (
    await fetch(url, {
        method: 'POST',
        headers: headers
    })
).json();

Below is the response for the above request

//successfull response
{
    "fromToken": {
        "address": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
        "current_price": "0.999676"
    },
    "toToken": {
        "address": "0x1::aptos_coin::AptosCoin",
        "current_price": "6.74000000"
    },
    "fromTokenAmount": "100",
    "fromTokenAmountUSD": "99.97",
    "quotes": [
        {
            "toTokenAmount": "14.85992752",
            "route": [
                {
                    "percentage": 100,
                    "routeTaken": [
                        [
                            {
                                "fromToken": {
                                    "tokenType": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
                                    "name": "USD Coin",
                                    "symbol": "USDC",
                                    "decimals": 6
                                },
                                "toToken": {
                                    "tokenType": "0x1::aptos_coin::AptosCoin",
                                    "name": "Aptos Coin",
                                    "symbol": "APT",
                                    "decimals": 8
                                },
                                "percentage": 100,
                                "dexName": "Obric",
                                "aggregatorName": "Panora"
                            }
                        ]
                    ]
                }
            ],
            "priceImpact": "0.19",
            "slippagePercentage": "0",
            "feeAmount": "0",
            "minToTokenAmount": "14.85992752",
            "txData": {
                "function": "0x1c3206329806286fd2223647c9f9b130e66baeb6d7224a18c1f642ffe48f3b4c::panora_swap_aggregator::split_multi_step_split_route_exact_input_entry",
                "type_arguments": [
                    "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::string::String",
                    "0x1::aptos_coin::AptosCoin"
                ],
                "arguments": [
                    "0x7b4ae66213a59a1bae10818347a826cb40d143bad45bd1460aeefd5bc4f52ce5",
                    1,
                    [
                        1
                    ],
                    [
                        [
                            12
                        ]
                    ],
                    [
                        [
                            6
                        ]
                    ],
                    [
                        [
                            false
                        ]
                    ],
                    [
                        []
                    ],
                    [
                        []
                    ],
                    [
                        []
                    ],
                    [
                        []
                    ],
                    [
                        []
                    ],
                    [
                        []
                    ],
                    [
                        [
                            100
                        ]
                    ],
                    [
                        []
                    ],
                    [
                        []
                    ],
                    "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12",
                    [
                        100000000
                    ],
                    1485992752,
                    0,
                    "0xd96748eaad3ccc6514d15554c8627a713d881912d5309bf84b6cfac47aaf797f"
                ]
            },
            "toTokenAmountUSD": "100.16"
        }
    ]
}

This response can be sent to Aptos chain with the required signatures to execute the transaction.

2. ExactOut swap: Get transaction data for swap from lzUSDC to APT when toTokenAmount is entered

POST https://api.panora.exchange/swap

const end_point = 'https://api.panora.exchange/swap'
const query = {  
    fromTokenAddress: "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
    toTokenAddress: "0x1::aptos_coin::AptosCoin",
    toTokenAmount: 10.5,
    toWalletAddress: "0x7b4ae66213a59a1bae10818347a826cb40d143bad45bd1460aeefd5bc4f52ce5",
};

const headers = {
    "x-api-key": "Your API key"
};

const queryString = new URLSearchParams(query).toString();
const url = `${end_point}?${queryString}`;

const response = await (
    await fetch(url, {
        method: 'POST',
        headers: headers
    })
).json();

Note: toTokenAmount here is amount (without Token Decimals) that the user desires to receive after the swap is executed

Below is the response for the above request

//Successfull response
{
    "fromToken": {
        "address": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
        "current_price": "0.999676"
    },
    "toToken": {
        "address": "0x1::aptos_coin::AptosCoin",
        "current_price": "6.73000000"
    },
    "toTokenAmount": "10.5",
    "toTokenAmountUSD": "70.665",
    "quotes": [
        {
            "fromTokenAmount": 70.776334,
            "route": [
                {
                    "percentage": 100,
                    "routeTokens": [
                        {
                            "tokenType": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
                            "name": "USD Coin",
                            "symbol": "USDC",
                            "decimals": 6
                        },
                        {
                            "tokenType": "0x1::aptos_coin::AptosCoin",
                            "name": "Aptos Coin",
                            "symbol": "APT",
                            "decimals": 8
                        }
                    ],
                    "routeTaken": [
                        [
                            {
                                "percentage": 100,
                                "fromToken": {
                                    "tokenType": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
                                    "name": "USD Coin",
                                    "symbol": "USDC",
                                    "decimals": 6
                                },
                                "toToken": {
                                    "tokenType": "0x1::aptos_coin::AptosCoin",
                                    "name": "Aptos Coin",
                                    "symbol": "APT",
                                    "decimals": 8
                                },
                                "dexName": "Sushi",
                                "aggregatorName": "Panora"
                            }
                        ]
                    ]
                }
            ],
            "slippagePercentage": 0,
            "maxFromTokenAmount": 70.776334,
            "feeAmount": 0,
            "priceImpact": "-0.12",
            "txData": {
                "function": "0x1c3206329806286fd2223647c9f9b130e66baeb6d7224a18c1f642ffe48f3b4c::panora_swap_aggregator::one_step_route_output",
                "type_arguments": [
                    "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
                    "0x1::aptos_coin::AptosCoin",
                    "u8"
                ],
                "arguments": [
                    "0x7b4ae66213a59a1bae10818347a826cb40d143bad45bd1460aeefd5bc4f52ce5",
                    20,
                    "0",
                    true,
                    "70776334",
                    0,
                    "0xd96748eaad3ccc6514d15554c8627a713d881912d5309bf84b6cfac47aaf797f"
                ]
            },
            "fromTokenAmountUSD": "70.75"
        }
    ]
}

This response can be sent to Aptos chain with the required signatures to execute the transaction.

3. ExactIn swap: Get Quote Data for swap from lzUSDC to APT when fromTokenAmount is entered

GET https://api.panora.exchange/swap/quote

const end_point = 'https://api.panora.exchange/swap/quote'
const query = {
    fromTokenAddress: "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
    toTokenAddress: "0x1::aptos_coin::AptosCoin",
    fromTokenAmount: 100,
};

const headers = {
    "x-api-key": "Your API key"
};

const queryString = new URLSearchParams(query).toString();
const url = `${end_point}?${queryString}`;

const response = await (
    await fetch(url, {
        method: 'GET',
        headers: headers
    })
).json();

Below is the response for the above request

//Successfull response
{
    "fromToken": {
        "address": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
        "current_price": "0.999682"
    },
    "toToken": {
        "address": "0x1::aptos_coin::AptosCoin",
        "current_price": "6.73000000"
    },
    "fromTokenAmount": "100",
    "fromTokenAmountUSD": "99.97",
    "quotes": [
        {
            "toTokenAmount": "14.93620707",
            "route": [
                {
                    "percentage": 100,
                    "routeTaken": [
                        [
                            {
                                "fromToken": {
                                    "tokenType": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
                                    "name": "USD Coin",
                                    "symbol": "USDC",
                                    "decimals": 6
                                },
                                "toToken": {
                                    "tokenType": "0x1::aptos_coin::AptosCoin",
                                    "name": "Aptos Coin",
                                    "symbol": "APT",
                                    "decimals": 8
                                },
                                "percentage": 100,
                                "dexName": "Obric",
                                "aggregatorName": "Panora"
                            }
                        ]
                    ]
                }
            ],
            "priceImpact": "0.55",
            "slippagePercentage": "0",
            "feeAmount": "0",
            "minToTokenAmount": "14.93620707",
            "toTokenAmountUSD": "100.52"
        }
    ]
}

4. ExactOut swap: Get Quote data for swap from lzUSDC to APT when toTokenAmount is entered

GET https://api.panora.exchange/swap/quote

const query = {  
    fromTokenAddress: "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
    toTokenAddress: "0x1::aptos_coin::AptosCoin",
    toTokenAmount: 10.5
};

const headers = {
    "x-api-key": "Your API key"
};

const queryString = new URLSearchParams(query).toString();
const url = `${end_point}?${queryString}`;

const response = await (
    await fetch(url, {
        method: 'GET',
        headers: headers
    })
).json();

Below is the response for the request.

//Successfull response
{
    "fromToken": {
        "address": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
        "current_price": "0.999682"
    },
    "toToken": {
        "address": "0x1::aptos_coin::AptosCoin",
        "current_price": "6.73000000"
    },
    "toTokenAmount": "10.5",
    "toTokenAmountUSD": "70.665",
    "quotes": [
        {
            "fromTokenAmount": 70.776336,
            "route": [
                {
                    "percentage": 100,
                    "routeTokens": [
                        {
                            "tokenType": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
                            "name": "USD Coin",
                            "symbol": "USDC",
                            "decimals": 6
                        },
                        {
                            "tokenType": "0x1::aptos_coin::AptosCoin",
                            "name": "Aptos Coin",
                            "symbol": "APT",
                            "decimals": 8
                        }
                    ],
                    "routeTaken": [
                        [
                            {
                                "percentage": 100,
                                "fromToken": {
                                    "tokenType": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
                                    "name": "USD Coin",
                                    "symbol": "USDC",
                                    "decimals": 6
                                },
                                "toToken": {
                                    "tokenType": "0x1::aptos_coin::AptosCoin",
                                    "name": "Aptos Coin",
                                    "symbol": "APT",
                                    "decimals": 8
                                },
                                "dexName": "Sushi",
                                "aggregatorName": "Panora"
                            }
                        ]
                    ]
                }
            ],
            "slippagePercentage": 0,
            "maxFromTokenAmount": 70.776336,
            "feeAmount": 0,
            "priceImpact": "-0.12",
            "fromTokenAmountUSD": "70.75"
        }
    ]
}

Last updated