DEX liquidity

To use DEX liquidity we need to transform exchangeContractPath array from swapInfo response

"exchangeContractPath": [
	{
		"pool": "0x684fd3c5cdfe279c82adc33029b095292d31ca35",
		"assetIn": "ORN",
		"assetOut": "USDT",
		"factory": "OrionV2"
	},
	{
		"pool": "0x8bc495dbeac561d5a7700e9403518d74123bd65a",
		"assetIn": "USDT",
		"assetOut": "DAI",
		"factory": "UniswapV3"
	}
]

To do so we need to use the following generateSwapCalldata endpoint

generateSwapCalldata

Request example

curl -X 'POST' \
  'https://trade.orion.xyz/bsc-mainnet/api/trade/generate-swap-calldata' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
    "amount": "1000000000000000000",
    "minReturnAmount": "1",
    "receiverAddress": "0xc60f286f57cd8dc5ff2070ea5e578d837d1157b6",
    "path": [
        {
            "pool": "0x684fd3c5cdfe279c82adc33029b095292d31ca35",
            "assetIn": "ORN",
            "assetOut": "USDT",
            "factory": "OrionV2"
	},
	{
            "pool": "0x8bc495dbeac561d5a7700e9403518d74123bd65a",
            "assetIn": "USDT",
            "assetOut": "DAI",
            "factory": "UniswapV3"
	}
    ]
}'

Response example

{
  "swapDescription": {
    "srcToken": "0xe4ca1f75eca6214393fce1c1b316c237664eaa8e",
    "dstToken": "0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3",
    "srcReceiver": "0x38714485186f8138e3cd0dc8192736a5d0b7a6bf",
    "dstReceiver": "0xc60f286f57cd8dc5ff2070ea5e578d837d1157b6",
    "amount": "1000000000000000000",
    "minReturnAmount": "1",
    "flags": "57896044618658097711785492504343953926634992332820282019728792003956564819968"
  },
  "calldata": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000012500b067487d00000000000000000000000000000000000000000000000000000000000000808000000000000000000000000000000000000000000000000000000000000044000000000000000000000000e4ca1f75eca6214393fce1c1b316c237664eaa8effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000006500d1660f99000000000000000000000000e4ca1f75eca6214393fce1c1b316c237664eaa8e000000000000000000000000684fd3c5cdfe279c82adc33029b095292d31ca35000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000850014f77a31000000000000000000000000684fd3c5cdfe279c82adc33029b095292d31ca35000000000000000000000000e4ca1f75eca6214393fce1c1b316c237664eaa8e00000000000000000000000055d398326f99059ff775485246999027b319795500000000000000000000000338714485186f8138e3cd0dc8192736a5d0b7a6bf000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012500b067487d0000000000000000000000000000000000000000000000000000000000000080800000000000000000000000000000000000000000000000000000000000004400000000000000000000000055d398326f99059ff775485246999027b3197955ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000006500727f665a8000000000000000000000008bc495dbeac561d5a7700e9403518d74123bd65a00000000000000000000000038714485186f8138e3cd0dc8192736a5d0b7a6bf0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012500b067487d000000000000000000000000000000000000000000000000000000000000008080000000000000000000000000000000000000000000000000000000000000440000000000000000000000001af3f329e8be154074d8769d1ffa4ee058b1dbc3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000006500d1660f990000000000000000000000001af3f329e8be154074d8769d1ffa4ee058b1dbc3000000000000000000000000c60f286f57cd8dc5ff2070ea5e578d837d1157b60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
}

To fulfill this trade we need to call swap function on our Exchange contract

Exchange.swap

Executor and Exchange addresses can be fetched from /api/info endpoint from fields swapExecutorContractAddress and exchangeContractAddress respectively

Request example

curl -X 'GET' \
  'https://trade.orion.xyz/bsc-mainnet/api/info' \
  -H 'accept: application/json'

Response example

{
  "chainId": 56,
  "chainName": "bsc-mainnet",
  "swapExecutorContractAddress": "0x38714485186f8138e3cd0dc8192736a5d0b7a6bf",
  "exchangeContractAddress": "0xe9d1d2a27458378dd6c6f0b2c390807aed2217ca",
  "oracleContractAddress": "0x468006964cee0e4aaf5837a5ab39874ac7fd9e0e",
  "cfdOracleContractAddress": "",
  "matcherAddress": "0x2d23c313feac4810d9d014f840741363fccba675",
  "orderFeePercent": 0.2,
  "assetToAddress": {
    ...
  },
  "assetToDecimals": {
    ...
  },
  "assetToIcons": {
    ...
  },
  "cexTokens": [
    ...
   ],
  "internalFeeAssets": [
    ...
  ],
  "l2": {
    "enabled": false,
    "l1ChainId": null
  }
}

Last updated