API endpoints for positions management on Aqua

BASE API URL for testing: https://newapi.native.org/swap-api/v1

  • headers: api_key:<mm_apiKey>

  1. GET /aqua/mm-settings

Get mm settings data that includes information such as additional credit limit, pause status, and liquidation factor.

Query params

  • address : mm address

  • chain: Native blockchain name, ex: ethereum , bsc , etc

Example response

// Success
{
    "mm_address": "0x9B85B4A413Efe69684290816a3E814B4aA1EFf63",
    "mm_partner": "testPmm",
    "hard_limit_usd_threshold": 10000, //additional credit limit on top of collateral
    "token_amount_limit": null,
    "is_forced_paused": false, //force paused by admin from all activities
    "is_paused": false, //pause borrowing because of time delay of settlement or collateral removal
    "is_interest_paused": false,
    "liquidation_factor": 0.8,
    "leverage": 10, //leverage factor to decide max position that MM can open
}

// Missing or invalid params
{
    "statusCode": 404,
    "message": "MM Settings not found",
    "error": "Not Found"
}
  1. GET /aqua/token-settings

Get aqua related token settings such as short fee, long fee, and collateral factor

Query params

  • chain: Native blockchain name, ex: ethereum , bsc , etc

Example response

  1. GET /aqua/mm-positions

Get current mm position for the specific chain. Note that there will be a time delay of 1 minute to 2 minute before Market Maker position is updated

Query params

  • address : mm address

  • chain: Native blockchain name, ex: ethereum , bsc , etc

Example response

  1. GET /aqua/mm-available-borrow

Get all borrowable token and max token amount that MM is able to borrow from aqua. The token amount depends on the collateral amount, max leverage, and available token in aqua vault.

Query params

  • address : mm address

  • chain: Native blockchain name, ex: ethereum , bsc , etc

Response

  1. POST /aqua/verify-settlement

In order to do settlement, Market maker will be paused from further trading and collateral removal activities to make sure that the credit is still healthy after the settlement is done. There will be a time delay of 10 minutes before you are able to get the approval signature to do settlement and execute it within an expire time.

steps to do settlement

  • call /aqua/verify-settlement endpoint to make sure your settlement request is valid

  • call /aqua/request-settlement endpoint to create settlement request and start the time delay. Note that Market Maker will be paused at this point from other activities.

  • call /aqua/cancel-settlement endpoint to cancel settlement request and unpause the trading activities.

  • call /aqua/settlement-status endpoint to check the status of the time delay and get the signature calldata if the time delay has been passed.

Request body

  • note that: positive amount means you want to close short position by depositing money in, negative amount means you want to close long position by withdraw the money out

Example response

  1. POST /aqua/request-settlement

Request settlement

Request body

Example response

  1. POST /aqua/cancel-settlement

Cancel pending settlement request

Request body

Response body

  1. POST /aqua/settlement-status

Get status of the settlement request. If the time delay has been passed, the signature calldata will be returned

Request body

Response body

  1. POST /aqua/verify-collateral-removal

In order to do collateral removal, Market maker will be paused from further trading and settlement activities to make sure that the credit is still healthy after the collateral is removed. There will be a time delay of 10 minutes before you are able to get the approval signature to remove your collateral and execute it within an expire time.

steps to do collateral removal

  • call /aqua/verify-collateral-removal endpoint to make sure your request is valid

  • call /aqua/request-collateral-removal endpoint to create collateral removal request and start the time delay. Note that Market Maker will be paused at this point from other activities.

  • call /aqua/cancel-collateral-removal endpoint to cancel settlement request and unpause the trading activities.

  • call /aqua/collateral-removal-status endpoint to check the status of the time delay and get the signature calldata if the time delay has been passed.

Request body

Response body

  1. POST /aqua/request-collateral-removal

Request collateral removal

Request body

Response body

  1. POST /aqua/cancel-collateral-removal

Cancel pending collateral removal

Request body

Response body

  1. POST /aqua/collateral-removal-status

Get status of the collateral removal request. If the time delay has been passed, the signature calldata will be returned

Request body

Response body

  1. POST /aqua/liquidation

Whitelisted liquidator can request for Marker Maker liquidation by specify what position they want to close and how much collateral they want to claim. Liquidator can do partial liquidation as long as the Market Maker credit health is increasing.

Request body

  • Note that for position updates: positive amount means you want to close short position by depositing money in, negative amount means you want to close long position by withdraw the money out.

  • claim collateral amount is always positive meaning how much collateral amount you want to claim

  1. GET /aqua/all-mm-settings

return all mm address and the chain they are in.

Query params

  • liquidator : whitelisted liquidator address

response

Contract Call for Market Maker

common structs reference

  1. addCollateral

    note: uses >100k gas

    1. AquaVault takes in LP token to serve as collateral for trading

    2. MM needs to give allowance in advance

      1. Approve LP token on ERC20 token in order to call mint

      2. Approve AquaVault on LP token to call addCollateral

  2. removeCollateral

    1. MM needs to call Native API with the remove amounts to get the signature to execute the transaction

  3. repay

    1. MM repays the short positions to decrease the open position

    2. No signature needed

  4. settle

    1. MM needs to call Native API with the settlement proposal to get the signature for sending the settlement transaction

  5. liquidate

    1. MM needs to call Native API with the liquidation proposal to get the signature for sending the liquidation transaction

    2. only whitelisted liquidator can request for liquidation

Last updated