API endpoints for positions management on Aqua
BASE API URL for testing: https://newapi.native.org/swap-api/v1
headers:
api_key:<mm_apiKey>
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 addresschain: 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"
}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
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 addresschain: Native blockchain name, ex:ethereum,bsc, etc
Example response
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 addresschain: Native blockchain name, ex:ethereum,bsc, etc
Response
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-settlementendpoint to make sure your settlement request is validcall
/aqua/request-settlementendpoint 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-settlementendpoint to cancel settlement request and unpause the trading activities.call
/aqua/settlement-statusendpoint 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
POST
/aqua/request-settlement
Request settlement
Request body
Example response
POST
/aqua/cancel-settlement
Cancel pending settlement request
Request body
Response body
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
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-removalendpoint to make sure your request is validcall
/aqua/request-collateral-removalendpoint 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-removalendpoint to cancel settlement request and unpause the trading activities.call
/aqua/collateral-removal-statusendpoint to check the status of the time delay and get the signature calldata if the time delay has been passed.
Request body
Response body
POST
/aqua/request-collateral-removal
Request collateral removal
Request body
Response body
POST
/aqua/cancel-collateral-removal
Cancel pending collateral removal
Request body
Response body
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
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
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
addCollateralnote: uses >100k gas
AquaVault takes in LP token to serve as collateral for trading
MM needs to give allowance in advance
Approve LP token on ERC20 token in order to call
mintApprove AquaVault on LP token to call
addCollateral
removeCollateralMM needs to call Native API with the remove amounts to get the signature to execute the transaction
repayMM repays the short positions to decrease the open position
No signature needed
settleMM needs to call Native API with the settlement proposal to get the signature for sending the settlement transaction
liquidateMM needs to call Native API with the liquidation proposal to get the signature for sending the liquidation transaction
only whitelisted liquidator can request for liquidation
Last updated