Skip to Content

LP-API Methods

lp_register_account

Submits an extrinsic that registers your account as an LP, so that allow this account can provide liquidity. The role of an account only needs to be registered once, and cannot be changed after it has been. It waits for the extrinsic to be successfully included in a block, and returns an error if the extrinsic expires before being included, or the extrinsic dispatch fails on-chain.

Parameters: None

Returns: The transaction hash of the extrinsic, otherwise an error.

lp_liquidity_deposit

This RPC is deprecated as of 1.9. Please use the lp_request_liquidity_deposit_address RPC instead.

Submits an extrinsic that opens a deposit address that you can send assets to. Once any assets you send are detected they will be credited to this account’s free balance, and can then be used to create orders. We recommend waiting until the extrinsic is finalized before sending any assets to the deposit address to ensure the assets are correctly credited to your account.

Parameters:

  • asset: The asset you wish to deposit.
  • wait_for (Optional)
  • boost_fee (Optional): The maximum amount you are willing to pay to boost the deposit, expressed as basis points.

Response:

  • The encoded deposit address that you should send the deposit to.

Example

curl -H "Content-Type: application/json" -d '{ "id":1, "jsonrpc":"2.0", "method": "lp_liquidity_deposit", "params": { "asset":{"chain":"Bitcoin","asset":"BTC"}, "boost_fee": 10 } }' http://localhost:10589
{ "jsonrpc": "2.0", "result": { "tx_details": { "tx_hash": "0x676157322a644e5ba09f3c097d27ec17ec4768a19a2989ff603506bd42fd1fc4", "response": "bcrt1pflqt7c2mncux4l4j56xq84qn98agylesjtgusc5fgjqc0ku8mzfs23eqwz" } }, "id": 1 }

lp_request_liquidity_deposit_address

Note

This RPC is available from version 1.9 onwards.

Submits an extrinsic that opens a deposit address that you can send assets to. Once any assets you send are detected they will be credited to this account’s free balance, and can then be used to create orders. We recommend waiting until the extrinsic is finalized before sending any assets to the deposit address to ensure the assets are correctly credited to your account.

Parameters:

  • asset: The asset you wish to deposit.
  • wait_for (Optional)
  • boost_fee (Optional): The maximum amount you are willing to pay to boost the deposit, expressed as basis points.

Response:

  • An object containing The encoded deposit address and the block number of the deposit chain at which the deposit address will expire.
{ "deposit_address": <String>, "deposit_chain_expiry_block": <number> }

Example

curl -H "Content-Type: application/json" -d '{ "id":1, "jsonrpc":"2.0", "method": "lp_request_liquidity_deposit_address", "params": { "asset":{"chain":"Bitcoin","asset":"BTC"}, "boost_fee": 10 } }' http://localhost:10589
{ "jsonrpc": "2.0", "result": { "tx_details": { "tx_hash": "0xfa79d112b6fd0885dff76ebd1604b8493a6d0a018729aa1225d8acc0089997ba", "response": { "deposit_address": "bcrt1psd2tdr340jp7dta3jls2w4z8j5e56evxmwdslqa26x0fua5wczuqrnvpp3", "deposit_chain_expiry_block": 2379 } } }, "id": 1 }

lp_register_liquidity_refund_address

Submits an extrinsic that sets your lp account’s refund address for one of the external chains. For your lp account to have any assets associated with it, you must set a refund address with the external chain which those assets are associated with. For example, to create an order in the DOT-USDC pool, you must have Polkadot and Ethereum refund addresses registered. You can change your registered addresses at anytime via this RPC.

Parameters:

  • chain: The external chain the refund address exists on.
  • address: The refund address for the specified external chain. Any assets associated with that chain will be transferred there if a refund is needed, e.g. “USDC” would be transferred to the address associated with “Ethereum”.

Return:

  • The transaction hash of the extrinsic that registered the new withdrawal address.

Example

curl -H "Content-Type: application/json" -d '{ "id":1, "jsonrpc":"2.0", "method": "lp_register_liquidity_refund_address", "params": { "chain": "Ethereum", "address": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F" } }' http://localhost:10589
{ "jsonrpc": "2.0", "result": "0x006595fa7c1010fece1835c91cfb24971eebe3fa75c587b6b4a2b4b5e6dd7387", "id": 1 }

lp_withdraw_asset

This RPC allows you to withdraw assets associated with your lp account that are not currently deployed in orders. Note fees you earn are not automatically redeployed into your orders, and are therefore immediately withdrawable via this RPC.

Parameters:

Response:

  • Egress id, which is used as the identifier for the operation/s to egress/withdraw the requested funds. It is structured as a JSON object like this:
[<chain>, <unsigned 64 bit integer ID>]

Example

curl -H "Content-Type: application/json" -d '{ "id": 1, "jsonrpc": "2.0", "method": "lp_withdraw_asset", "params": { "amount": 1000000000000000000, "asset": "ETH", "destination_address": "0xcfE27Ce6D57B81Ea86046aD1789104E5B7F0a2E7" } }' http://localhost:10589
{ "jsonrpc":"2.0", "result": { "tx_details": { "tx_hash": "0xd3ab0132b7b4fb3f8d693d5588bc0493932bdc4f5e102f0627892cdf81932d96", "response": ["Ethereum", 1] } }, "id": 1 }

lp_transfer_asset

This RPC allows you to transfer assets internally between your lp accounts. The destination account must be registered as an LP account.

Parameters:

Response:

  • The transaction hash of the extrinsic that transferred the funds.

Example

curl -H "Content-Type: application/json" -d '{ "id":1, "jsonrpc":"2.0", "method": "lp_transfer_asset", "params": { "amount": "2386f26fc10000", "asset": "ETH", "destination_account": "5GBa2utuhVfFpQePwTsWT9aTF4vDLV326dgrr8iJJZj9fXnT" } }' http://localhost:10589
{ "jsonrpc": "2.0", "result": "0x9a43bb0f60976345c58b05b7ebb80bec2091070971bc4da4df628d31f03559b2", "id": 1 }

lp_update_range_order

This RPC submits an extrinsic that will increase or decrease the size of an existing range order in the specified pool. If you try to increase the size of a non-existent order, that will result in a new range order being created with that id. If you decrease the size of an order by an amount equal to or greater than the order’s size, that will close the order.

It can also be used to move assets from one range order to a new range order (in the same pool), by setting the optional argument tick_range to the new tick range you want to move them to, and specifying the id of an existing order. Any leftover assets, i.e. those that cannot be moved due to the new asset ratio requirement at the new tick range, will be deposited back into your free balance.

When creating a new order via this method you must specify the initial tick_range to use, but assuming you don’t wish to change the tick_range as described above and you only want to increase or decrease the size of the existing order, you don’t need to specify the tick_range in future updates to that order.

Parameters:

  • base_asset
  • quote_asset
  • id
  • tick_range (Optional): A JSON array of two Ticks, representing the lower and upper bound of the order’s price range. Must be specified if no range order with the specified id exists in this pool. If not specified, the tick range of the existing order with the same id will be used.
  • size_change
  • wait_for

Response: A chronological list of all the updates that were done as part of the operation. Each item in the JSON array is an object with this structure:

{ "base_asset:" <asset>, "quote_asset": <asset>, "id": <order_id>, "tick_range": [<tick>, <tick>], "liquidity_total": <liquidity>, "collected_fees": { "base": <amount>, "quote": <amount> }, "size_change": <order-update> }

For example if a lp_update_range_order request moves an existing range order to a new tick_range, the return would contain two of these, one for the decrease to zero/destruction of the order at the previous tick range, and then one for the increase/creation of the order at the new tick range.

Also this list will begin with updates to range orders, that do nothing to those range orders, and are just reporting the collected_fees, from any range orders that have collected fees since the last successful order update/asset withdrawal. So you will likely want to filter these out.

Example

curl -H "Content-Type: application/json" -d '{ "id": 1, "jsonrpc": "2.0", "method": "lp_update_range_order", "params": { "base_asset": "ETH", "quote_asset": "USDC", "id": "11", "tick_range": [ 0, 10 ], "size_change": { "increase": { "AssetAmounts": { "maximum": { "base": "0xDE0B6B3A76400", "quote": "0xF4240" }, "minimum": { "base": "0x0", "quote": "0x0" } } } } } }' http://localhost:10589
{ "jsonrpc": "2.0", "result": { "tx_details": { "tx_hash": "0xd7b48f3064d6ba6c9d88f0cf1c5dd23f4968eeaf9606ce3ad9dfce5302497ba5", "response": [ { "base_asset": "ETH", "quote_asset": "USDC", "id": "0x11", "tick_range": { "start": 0, "end": 10 }, "liquidity_total": "0x6c73e720beb1104f", "collected_fees": { "base": "0x0", "quote": "0x0" }, "size_change": { "increase": { "liquidity": "0x6c73e720beb1104f", "amounts": { "base": "0xde0b6b3a76400", "quote": "0x0" } } } } ] } }, "id": 1 }

lp_set_range_order

This RPC submits an extrinsic that will open/close a range order in the specified pool. If you set a range order to a “zero” size, that will result in that range order being closed. If you set a non-existent range order to a non-zero “size”, that will result in the creation of a new order.

It can also be used to move assets from one range order to a new range order (in the same pool), by setting the optional argument tick_range to the new tick range you want to move them to, and specifying the id of an existing order. Any leftover assets, i.e. those that cannot be moved due to the new asset ratio requirement at the new tick range, will be deposited back into your free balance.

When creating a new order via this method you must specify the initial tick_range to use, but assuming you don’t wish to change the tick_range as described above and you only want to change the size of the existing order, you don’t need to specify the tick_range in future updates to that order.

Parameters:

  • base_asset
  • quote_asset
  • id
  • tick_range (Optional): A JSON array of two Ticks, representing the lower and upper bound of the order’s price range. Must be specified if no range order with the specified id exists in this pool. If not specified, the tick range of the existing order with the same id will be used.
  • size
  • wait_for

Response: A chronological list of all the updates that were done as part of the operation. Each item in the JSON array is an object with this structure:

{ "base_asset:" <asset>, "pair_asset": <asset>, "id": <order_id>, "tick_range": [<tick>, <tick>], "liquidity_total": <liquidity>, "collected_fees": { "base": <amount> , "pair": <amount> }, "size_change": }

For example if a lp_set_range_order request changes the total size of an existing range order, the return would contain two of these, one for the decrease to zero/destruction of the previous order, and then one for the increase/creation of the order with the new size.

Also this list will begin with updates to range orders, that do nothing to those range orders, and are just reporting the collected_fees, from any range orders that have collected fees since the last successful order update/asset withdrawal. So you will likely want to filter these out.

Example

curl -H "Content-Type: application/json" -d '{ "id": 1, "jsonrpc": "2.0", "method": "lp_set_range_order", "params": { "base_asset": "ETH", "quote_asset": "USDC", "id": "11", "tick_range": [ 0, 10 ], "size": { "AssetAmounts": { "maximum": { "base": "0xDE0B6B3A76400", "quote": "0xF4240" }, "minimum": { "base": "0x0", "quote": "0x0" } } } } }' http://localhost:10589
{ "jsonrpc": "2.0", "result": { "tx_details": { "tx_hash": "0xfc013c63d5b510c6f5a3f1657f93b796ca3e4d3bdb877bd5f1cfb37d2240d830", "response": [ { "base_asset": "ETH", "quote_asset": "USDC", "id": "0x11", "tick_range": { "start": 0, "end": 10 }, "liquidity_total": "0x6c73e720beb1104f", "collected_fees": { "base": "0x0", "quote": "0x0" }, "size_change": { "increase": { "liquidity": "0x6c73e720beb1104f", "amounts": { "base": "0xde0b6b3a76400", "quote": "0x0" } } } } ] } }, "id": 1 }

lp_update_limit_order

This RPC submits an extrinsic that will increase or decrease the size of an existing limit order in the specified pool. If you try to increase the size of a non-existent order, that will result in a new limit order being created with that id. If you decrease the size of an order by an amount equal to or greater than the order’s size, that will close the order.

It can also be used to change the price of an existing limit order, by setting the optional argument tick to the new tick you want, and specifying the id of the existing order.

When creating a new order via this method you must specify the tick to use, but assuming you don’t wish to change the tick as described above and you only want to increase or decrease the size of the existing order, you don’t need to specify the tick in future updates to that order.

Parameters:

  • base_asset
  • quote_asset
  • side
  • id
  • tick (Optional): The price of the limit order.
  • amount_change: The amount of assets to add or remove from the limit order. For “buy” orders, this is measured in the quote asset, and for “sell” orders, this is measured in the base asset.
  • dispatch_at (Optional): If specified this RPC instead of submitting an extrinsic that does the specified operation, will submit an extrinsic that schedules the operation to occur at the specified block number. Note the RPC doesn’t wait until the operation is scheduled, but only for the extrinsic (to the extent specified by the wait_for argument). If the dispatch_at block has already elapsed, this method returns an error.
  • wait_for

Response: A chronological list of all the updates that were done as part of the operation. Each item in the JSON array is an object with this structure:

{ "base_asset": <asset>, "quote_asset": <asset>, "side": <side>, "id": <order_id>, "tick": <tick>, "sell_amount_total": <amount>, "collected_fees": <amount>, "bought_amount": <amount>, "sell_amount_change": { <increase_or_decrease>: <amount> } }

For example if a lp_update_limit_order request changes the total size of an existing range order, the return would contain two of these, one for the decrease to zero/destruction of the previous order, and then one for the increase/creation of the order with the new size.

Also this list will begin with updates to limit orders, that do nothing to those limit orders, and are just reporting the collected_fees, from any limit orders that have collected fees since the last successful order update/asset withdrawal. So you will likely want to filter these out.

Example

curl -H "Content-Type: application/json" -d '{ "id": 1, "jsonrpc": "2.0", "method": "lp_update_limit_order", "params": { "base_asset": {"chain": "Ethereum", "asset": "ETH"}, "quote_asset": {"chain": "Ethereum", "asset": "USDC"}, "side": "buy", "id": "11", "tick": 50, "amount_change": { "increase": "0x100000" } } }' http://localhost:10589
{ "jsonrpc": "2.0", "result": { "tx_details": { "tx_hash": "0x3f03edc0180fc9c7852f6fb429870794f07be80c241c9b93c9864041f97d8903", "response": [ { "base_asset": {"chain": "Ethereum", "asset": "ETH"}, "quote_asset": {"chain": "Ethereum", "asset": "USDC"}, "side": "buy", "id": "0x11", "tick": 50, "sell_amount_total": "0x200000", "collected_fees": "0x0", "bought_amount": "0x0", "sell_amount_change": { "increase": "0x100000" } } ] } }, "id": 1 }

NOTE: If you pass the dispatch_at parameter the response may not return any results due to the fact that order is not created/updated yet. Instead the response array will be empty. The exception to this would be if the transaction is included in the dispatch_at block, in which case the operation is executed immediately.

lp_set_limit_order

This RPC submits an extrinsic that will set the size of an existing limit order in the specified pool. If you try to set the size of a non-existent order, that will result in a new limit order being created with that id. If you set the size of an order to zero, that will close the order.

It can also be used to change the price of an existing limit order, by setting the optional argument tick to the new tick you want, and specifying the id of the existing order.

When creating a new order via this method you must specify the tick to use, but assuming you don’t wish to change the tick as described above and you only want to increase or decrease the size of the existing order, you don’t need to specify the tick in future updates to that order.

Parameters:

  • base_asset
  • quote_asset
  • side
  • id
  • tick (Optional): The price of the limit order.
  • sell_amount: The amount of assets the limit order should sell. For “buy” orders, this is measured in the quote asset, and for “sell” orders, this is measured in the base asset.
  • dispatch_at (Optional): If specified this RPC instead of submitting an extrinsic that does the specified operation, will submit an extrinsic that schedules the operation to occur at the specified block number. Note the RPC doesn’t wait until the operation is scheduled, but only for the extrinsic (to the extent specified by the wait_for argument). If the dispatch_at block has already elapsed, this method returns an error.
  • wait_for
  • close_order_at (Optional): (available from version 1.10 onwards) If specified this RPC will also schedule the order to be closed at the given block. Must be within 3600 blocks of the latest block and larger than the dispatch_at argument if provided. Note that the scheduled close will still get executed even if the limit order has been updated/closed before the close_order_at block. In particular, note that a schedule close operation cannot be canceled.

Response:

  • A chronological list of all the updates that were made as part of the operation. Each item in the list is a JSON object:
{ "base_asset": <asset>, "quote_asset": <asset>, "side": <side>, "id": <order_id>, "tick": <tick>, "sell_amount_total": <amount>, "collected_fees": <amount>, "bought_amount": <amount>, "sell_amount_change": { <increase_or_decrease>: <amount> } }

For example if a lp_set_limit_order request changes the price of a limit order, the response would contain two of these, one for the decrease to zero/destruction of the previous order, and then one for the increase/creation of the order with the price/tick.

Also this list will begin with updates to limit orders, that do nothing to those limit orders, and are just reporting the collected_fees, from any limit orders that have collected fees since the last successful order update/asset withdrawal. So you will likely want to filter these out.

NOTE: If you pass the dispatch_at parameter the response may not return any results due to the fact that order is not created/updated yet. The exception to this would be if the submitted extrinsic is included in the dispatch_at block, in which case the operation is executed immediately.

Example

curl -H "Content-Type: application/json" -d '{ "id": 1, "jsonrpc": "2.0", "method": "lp_set_limit_order", "params": { "base_asset": {"chain": "Ethereum", "asset": "ETH"}, "quote_asset": {"chain": "Ethereum", "asset": "USDC"}, "side": "buy", "id": "11", "tick": 50, "sell_amount": "0x100000" } }' http://localhost:10589
{ "jsonrpc": "2.0", "result": { "tx_details": { "tx_hash": "0x3cb78cdbbfc34634e33d556a94ee7438938b65a5b852ee523e4fc3c0ec3f8151", "response": [ { "base_asset": {"chain": "Ethereum", "asset": "ETH"}, "quote_asset": {"chain": "Ethereum", "asset": "USDC"}, "side": "buy", "id": "0x11", "tick": 50, "sell_amount_total": "0x100000", "collected_fees": "0x0", "bought_amount": "0x0", "sell_amount_change": { "increase": "0x100000" } } ] } }, "id": 1 }

lp_free_balances

Tip

This RPC method can also be called as lp_asset_balances.

This RPC returns the free balances of your LP account as of the latest finalized block. Note that ‘Free Balances’ does not include any assets currently active in LP orders or in boost pools.

Parameters: None

Return:

  • An JSON object where each key is a Chain, and the values are arrays of { <asset>, <amount> } pairs.

Example

curl -H "Content-Type: application/json" -d '{ "id":1, "jsonrpc": "2.0", "method": "lp_free_balances", "params": [] }' http://localhost:10589
{ "jsonrpc": "2.0", "result":{ "Ethereum":{ "ETH":"0x45939e6733a79d71", "FLIP":"0x128d484779ed9a9b", "USDC":"0x45dde576d3", "USDT":"0x9d2687" }, "Polkadot":{ "DOT":"0x25c7d0cb6" }, "Bitcoin":{ "BTC":"0x18c12" }, "Arbitrum":{ "ETH":"0x303467cadd3773", "USDC":"0x9dc14c" } }, "id": 1 }

lp_get_open_swap_channels

Returns a list of all the open deposit addresses currently open for swaps at the current finalized block. These are addresses that swappers will send funds they want to swap. Once a deposit to one of these addresses is detected we will then perform the swap on the State Chain after a waiting period to confirm the deposit.

Parameters: None

Return:

  • All the open swap channels and their associated details in JSON format.

Example

curl -H "Content-Type: application/json" -d '{ "id":1, "jsonrpc": "2.0", "method": "lp_get_open_swap_channels", "params": [] }' http://localhost:10589
{ "jsonrpc": "2.0", "result": { "ethereum": [ { "deposit_address": "0x0360dc218f90ab7b051078d5e6f7dcaa3946e78b", "source_asset": "FLIP", "destination_asset": "ETH" }, { "deposit_address": "0x606c4a8ef964acd004ae0075a4ed1a88f92b78d4", "source_asset": "FLIP", "destination_asset": "ETH" }, { "deposit_address": "0x677e7329ef04fdd798db49aed91557f583bb5f49", "source_asset": "ETH", "destination_asset": "USDC" }, { "deposit_address": "0x8c7951c65bdb8e57745ce980a5325c43e9a45c63", "source_asset": "FLIP", "destination_asset": "ETH" }, { "deposit_address": "0xbfbc1bdc3687efb7178ca48ab99be6966096fabf", "source_asset": "ETH", "destination_asset": "USDC" }, { "deposit_address": "0xd9c547e7f4ce721ad5b1be186ee6e608fd8a53b3", "source_asset": "FLIP", "destination_asset": "ETH" }, { "deposit_address": "0xe720e23f62efc931d465a9d16ca303d72ad6c0bc", "source_asset": "ETH", "destination_asset": "USDC" }, { "deposit_address": "0xfbfce7788b31c536bbeef0658f107f3b2cdfd6e4", "source_asset": "ETH", "destination_asset": "USDC" } ], "bitcoin": [ { "deposit_address": "bcrt1pyv39rawd28erjv8h7xjwvq98wpmswl8vmcw4qr2j2n2f8jpwnztsuukr75", "source_asset": "BTC", "destination_asset": "ETH" }, { "deposit_address": "bcrt1pflqt7c2mncux4l4j56xq84qn98agylesjtgusc5fgjqc0ku8mzfs23eqwz", "source_asset": "BTC", "destination_asset": "ETH" }, { "deposit_address": "bcrt1pe9nd6pn8fez64ynwfk86zvkh209p4utcyl0sxg3gl7d52wex382s42yw67", "source_asset": "BTC", "destination_asset": "ETH" }, { "deposit_address": "bcrt1paf8lre750rw4d7hzmf8tea542sudxe0ssms7f7sjzemq9dhezxkqpe32ns", "source_asset": "BTC", "destination_asset": "ETH" } ], "polkadot": [ { "deposit_address": "1WjReaZbkFDZF4XZ2GqMBtGJnDnB2c6SXBaGA39quiS8J7d", "source_asset": "DOT", "destination_asset": "FLIP" }, { "deposit_address": "1tDZGgNpmiAgHoR1J6e9akKfgqcMn16yKRRq6RcizC6cmVg", "source_asset": "DOT", "destination_asset": "FLIP" }, { "deposit_address": "13LnFhoh83G13Wtgiz8HCqmVdPaE5Sme4CHAndifv2kZ3BpF", "source_asset": "DOT", "destination_asset": "FLIP" }, { "deposit_address": "14kEEbKVd5PTCn3z1NVFfccU9oQ1TBXeZgH2BqhFnQTDC2D6", "source_asset": "DOT", "destination_asset": "FLIP" } ] }, "id": 1 }

lp_request_redemption

Request a redemption of all $FLIP or a specified amount. Please see Redeeming Funds & Retiring for more details on redeeming. Returns the transaction hash of the extrinsic that requested the redemption.

Parameters:

  • redeem_address: The Ethereum address to send the redeemed funds to.
  • exact_amount (Optional): The amount of flip to redeem. If not specified, all $FLIP will be redeemed.
  • executor_address (Optional): Restricts the executeRedemption function call in the Gateway contract to only be callable by the specified address for this redemption. If not specified, anyone can execute the redemption.

Example

Redeem all $FLIP:

curl -H "Content-Type: application/json" \ -d '{ "id": 1, "jsonrpc": "2.0", "method": "lp_request_redemption", "params": ["0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"] }' \ http://localhost:10589

Redeem an exact amount:

curl -H "Content-Type: application/json" \ -d '{ "id": 1, "jsonrpc": "2.0", "method": "lp_request_redemption", "params": { "redeem_address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "exact_amount": "0x1000000000", "executor_address": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F" } }' \ http://localhost:10589

lp_order_fills

Returns a list of all the fills in a given block.

Parameters:

  • at (Optional): The block hash of the fills to return. The default is the latest finalized block’s hash.

Return:

  • Block hash
  • Block number
  • JSON array of all the fills in this finalized block. Exactly matching the structures returned by lp_subscribe_order_fills

Example

curl -H "Content-Type: application/json" -d '{ "id": 1, "jsonrpc": "2.0", "method": "lp_order_fills", "params": { "at": "0xc65c18f81c4a9b1b5cd7e203f09eaa2288b44771e13d43791e1319a2695c72e9" } }' http://localhost:10589
{ "jsonrpc": "2.0", "result": { "block_hash": "0xc65c18f81c4a9b1b5cd7e203f09eaa2288b44771e13d43791e1319a2695c72e9", "block_number": 67, "fills": [ { "range_order": { "lp": "cFPdef3hF5zEwbWUG6ZaCJ3X7mTvEeAog7HxZ8QyFcCgDVGDM", "base_asset": "FLIP", "quote_asset": "USDC", "id": "0x0", "range": { "start": -887272, "end": 887272 }, "fees": { "base": "0x13fbe85edc90000", "quote": "0x1e63a" }, "liquidity": "0x7055df27b7e148" } }, { "range_order": { "lp": "cFPdef3hF5zEwbWUG6ZaCJ3X7mTvEeAog7HxZ8QyFcCgDVGDM", "base_asset": "DOT", "quote_asset": "USDC", "id": "0x0", "range": { "start": -887272, "end": 887272 }, "fees": { "base": "0x0", "quote": "0x1d33c" }, "liquidity": "0x2e033968552" } }, { "range_order": { "lp": "cFPdef3hF5zEwbWUG6ZaCJ3X7mTvEeAog7HxZ8QyFcCgDVGDM", "base_asset": "ETH", "quote_asset": "USDC", "id": "0x0", "range": { "start": -887272, "end": 887272 }, "fees": { "base": "0x330b9eb022000", "quote": "0x262d6" }, "liquidity": "0xb3bc983f8c9bb" } }, { "range_order": { "lp": "cFPdef3hF5zEwbWUG6ZaCJ3X7mTvEeAog7HxZ8QyFcCgDVGDM", "base_asset": "BTC", "quote_asset": "USDC", "id": "0x0", "range": { "start": -887272, "end": 887272 }, "fees": { "base": "0x2bc", "quote": "0x6a5dd" }, "liquidity": "0x253fca1c0" } } ] }, "id": 1, }

lp_cancel_all_orders

This RPC queries for all your open orders (both range and limit) in all the available pools, and submits one/multiple extrinsics to delete them all.

This API uses the underlying extrinsic cancel_orders_batch which supports a maximum of 100 orders, if the number of open orders is above that value multiple extrinsics will be sent, each one closing up to 100 orders.

If WaitFor is set to InBlock/Finalized the command will take multiple blocks to execute (for every extrinsic submitted it will wait for it to be included in a block or finalize), the exact number of blocks depends on how many extrinsics it has to send (which depends on the number of orders, 1 extrinsic for each 100 orders) and the WaitFor parameter.

Warning

The orders to be deleted are gathered at the beginning, this means that new orders opened while the command is being executed won’t be deleted (but existing orders being updated could still be deleted anyway since theirs IDs does not change and that is what is used to choose the order to delete).

In general we suggests to stop submitting new orders/updates until the command is fully executed.

Parameters:

Response: A chronological list of all the updates that were done as part of the operation. Each item in the JSON array is an object with one of the following structure:

{ "RangeOrder": { ... } }
{ "LimitOrder": { ... } }

Where the content of RangeOrder or LimitOrder is the same as the response of the above functions lp_set_limit_order and lp_set_range_order.

Example

curl -H "Content-Type: application/json" -d '{ "id":1, "jsonrpc":"2.0", "method": "lp_cancel_all_orders", "params": [] }' http://localhost:10589
{ "jsonrpc":"2.0", "result":[ { "tx_details":{ "tx_hash":"0x6192307ea8596517a06db33008eaefe4d8d711abf89436c40d579877c6dece4b", "response":[ { "RangeOrder":{ "base_asset":{ "chain":"Ethereum", "asset":"ETH" }, "quote_asset":{ "chain":"Ethereum", "asset":"USDC" }, "id":"0x0", "tick_range":{ "start":-887272, "end":887272 }, "liquidity_total":"0x0", "collected_fees":{ "base":"0x0", "quote":"0x0" }, "size_change":{ "decrease":{ "liquidity":"0x7055df27b7e14c", "amounts":{ "base":"0x363466684d81170047", "quote":"0xe8ceaf2eff" } } } } }, { "RangeOrder":{ "base_asset":{ "chain":"Ethereum", "asset":"FLIP" }, "quote_asset":{ "chain":"Ethereum", "asset":"USDC" }, "id":"0x0", "tick_range":{ "start":-887272, "end":887272 }, "liquidity_total":"0x0", "collected_fees":{ "base":"0x0", "quote":"0x0" }, "size_change":{ "decrease":{ "liquidity":"0x4635ab78d2ecd00", "amounts":{ "base":"0x152c7800be466d8060eb", "quote":"0xe8ceaf2eff" } } } } }, { "RangeOrder":{ "base_asset":{ "chain":"Ethereum", "asset":"USDT" }, "quote_asset":{ "chain":"Ethereum", "asset":"USDC" }, "id":"0x0", "tick_range":{ "start":-887272, "end":887272 }, "liquidity_total":"0x0", "collected_fees":{ "base":"0x0", "quote":"0x0" }, "size_change":{ "decrease":{ "liquidity":"0xe8ceaf2f00", "amounts":{ "base":"0xe8ceaf2eff", "quote":"0xe8ceaf2eff" } } } } }, { "RangeOrder":{ "base_asset":{ "chain":"Polkadot", "asset":"DOT" }, "quote_asset":{ "chain":"Ethereum", "asset":"USDC" }, "id":"0x0", "tick_range":{ "start":-887272, "end":887272 }, "liquidity_total":"0x0", "collected_fees":{ "base":"0x0", "quote":"0x0" }, "size_change":{ "decrease":{ "liquidity":"0x1cc203e13538", "amounts":{ "base":"0x38d675c4f980b", "quote":"0xe8ceaf2f00" } } } } }, { "RangeOrder":{ "base_asset":{ "chain":"Bitcoin", "asset":"BTC" }, "quote_asset":{ "chain":"Ethereum", "asset":"USDC" }, "id":"0x0", "tick_range":{ "start":-887272, "end":887272 }, "liquidity_total":"0x0", "collected_fees":{ "base":"0x0", "quote":"0x0" }, "size_change":{ "decrease":{ "liquidity":"0x1747de5180", "amounts":{ "base":"0x253fca1bf", "quote":"0xe8ceaf2eff" } } } } }, { "RangeOrder":{ "base_asset":{ "chain":"Arbitrum", "asset":"ETH" }, "quote_asset":{ "chain":"Ethereum", "asset":"USDC" }, "id":"0x0", "tick_range":{ "start":-887272, "end":887272 }, "liquidity_total":"0x0", "collected_fees":{ "base":"0x0", "quote":"0x0" }, "size_change":{ "decrease":{ "liquidity":"0x7055df27b7e14c", "amounts":{ "base":"0x363466684d81170047", "quote":"0xe8ceaf2eff" } } } } }, { "RangeOrder":{ "base_asset":{ "chain":"Arbitrum", "asset":"USDC" }, "quote_asset":{ "chain":"Ethereum", "asset":"USDC" }, "id":"0x0", "tick_range":{ "start":-887272, "end":887272 }, "liquidity_total":"0x0", "collected_fees":{ "base":"0x0", "quote":"0x0" }, "size_change":{ "decrease":{ "liquidity":"0xe8ceaf2f00", "amounts":{ "base":"0xe8ceaf2eff", "quote":"0xe8ceaf2eff" } } } } }, { "RangeOrder":{ "base_asset":{ "chain":"Solana", "asset":"SOL" }, "quote_asset":{ "chain":"Ethereum", "asset":"USDC" }, "id":"0x0", "tick_range":{ "start":-887272, "end":887272 }, "liquidity_total":"0x0", "collected_fees":{ "base":"0x0", "quote":"0x0" }, "size_change":{ "decrease":{ "liquidity":"0x499ec24088", "amounts":{ "base":"0xe8ceaf2eff", "quote":"0x1747de517f" } } } } }, { "RangeOrder":{ "base_asset":{ "chain":"Solana", "asset":"USDC" }, "quote_asset":{ "chain":"Ethereum", "asset":"USDC" }, "id":"0x0", "tick_range":{ "start":-887272, "end":887272 }, "liquidity_total":"0x0", "collected_fees":{ "base":"0x0", "quote":"0x0" }, "size_change":{ "decrease":{ "liquidity":"0xe8ceaf2f00", "amounts":{ "base":"0xe8ceaf2eff", "quote":"0xe8ceaf2eff" } } } } } ] } } ], "id":1 }

lp_cancel_orders_batch

This RPC allows you to cancel multiple orders in the same extrinsic (up to 100), this can mix both limit and range orders.

Parameters:

  • orders: Array of CloseOrder (max 100 elements)
  • wait_for

where CloseOrder is an object defined as follow:

for LimitOrder:

for RangeOrder

Response: A chronological list of all the updates that were done as part of the operation. Each item in the JSON array is an object with one of the following structure:

{ "RangeOrder": { ... } }
{ "LimitOrder": { ... } }

Where the content of RangeOrder or LimitOrder is the same as the response of the above functions lp_set_limit_order and lp_set_range_order.

Example

curl -H "Content-Type: application/json" -d ' { "id":1, "jsonrpc":"2.0", "method":"lp_cancel_orders_batch", "params": {"orders":[{ "base_asset":{ "chain":"Ethereum", "asset":"FLIP" }, "quote_asset":{ "chain":"Ethereum", "asset":"USDC" }, "id":0 },{ "base_asset":{ "chain":"Ethereum", "asset":"ETH" }, "quote_asset":{ "chain":"Ethereum", "asset":"USDC" }, "id":0 }]} }' http://localhost:10589
{ "jsonrpc":"2.0", "result":{ "tx_details":{ "tx_hash":"0x41757a1ec2bdf07bf9168c5e73a4c0d9eed7e88d830e8a5ec82f6af98e6ccc46", "response":[ { "RangeOrder":{ "base_asset":{ "chain":"Ethereum", "asset":"ETH" }, "quote_asset":{ "chain":"Ethereum", "asset":"USDC" }, "id":"0x0", "tick_range":{ "start":-887272, "end":887272 }, "liquidity_total":"0x0", "collected_fees":{ "base":"0x0", "quote":"0x0" }, "size_change":{ "decrease":{ "liquidity":"0x7055df27b7e14c", "amounts":{ "base":"0x363466684d81170047", "quote":"0xe8ceaf2eff" } } } } }, { "RangeOrder":{ "base_asset":{ "chain":"Ethereum", "asset":"FLIP" }, "quote_asset":{ "chain":"Ethereum", "asset":"USDC" }, "id":"0x0", "tick_range":{ "start":-887272, "end":887272 }, "liquidity_total":"0x0", "collected_fees":{ "base":"0x0", "quote":"0x0" }, "size_change":{ "decrease":{ "liquidity":"0x4635ab78d2ecd00", "amounts":{ "base":"0x152c7800be466d8060eb", "quote":"0xe8ceaf2eff" } } } } } ] } }, "id":1 }

lp_schedule_swap

This RPC allows you to initiate an internal swap.

Parameters:

  • amount: The amount of input asset to swap.
  • input_asset: The asset to swap from.
  • output_asset: The asset to swap into.
  • retry_duration: A number of blocks for which the swap will be retried if it fails (see FoK section).
  • price_limits: minimum price and maximum oracle slippage (basis points) in a Json object {"min_price": <hex_string>, "max_oracle_price_slippage": <number | undefined>} (see slippage protection section).
  • dca_params: (optional) DcaParameters, which determines whether (and how) the swap should be split into chunks (see DCA section).
  • wait_for

where DcaParameters is an object containing the following fields:

  • number_of_chunks: The number of chunks to split the swap into.
  • chunk_interval: The number of blocks between each chunk.

Response:

  • swap_request_id: The id of the initiated swap request.

Example

Request to initiate a swap from USDC to USDT on Ethereum:

curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "lp_schedule_swap", "params": { "amount": 10000000, "input_asset": {"chain": "Ethereum", "asset": "USDC"}, "output_asset": {"chain": "Ethereum", "asset": "USDT"}, "retry_duration": 10, "min_price": "1004189374bc6a7ef9db22d0e56041894", "dca_params": { "number_of_chunks": 2, "chunk_interval": 2 } }}' localhost:10589

A possible response:

{ "jsonrpc": "2.0", "result": { "tx_details": { "tx_hash": "0x0e20cc2637a37628a03737b50e28f22c572778916a97dbb270ab1681aa173f6b", "response": { "swap_request_id": 1 } } }, "id": 1 }
Last updated on