// 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
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.
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.
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
// Success{"id": "d49c39ed-ff63-41c0-bf3a-75f6d56f7346","nonce": "6168514449590345","recipient": "0x9B85B4A413Efe69684290816a3E814B4aA1EFf63","chain": "base","positionUpdates": [ {"tokenAddress":"0x4200000000000000000000000000000000000006","amount":"-5000000000" } ],"creditChangeUsd": -0.00001168615,"trader": "0x9B85B4A413Efe69684290816a3E814B4aA1EFf63","requestAt": "2024-01-31T08:09:22.645Z","enableAt": "2024-01-31T08:14:22.645Z","expiresAt": "2024-01-31T08:15:22.645Z","type": "settlement"}// Errors// Try to withdraw more than long position amount{"statusCode": 400,"message": "Cannot make long position to become short position","error": "Bad Request"}// Try to deposit into long position{"statusCode": 400,"message": "Cannot increasing existing long position","error": "Bad Request"}// Try to deposit more than short position amount{"statusCode": 400,"message": "Cannot make short position to become long position","error": "Bad Request"}// Try to withdraw from short position{"statusCode": 400,"message": "Cannot decreasing existing short position","error": "Bad Request"}// Invalid token address{"statusCode": 400,"message": "Cannot settle unexist position","error": "Bad Request"}// Invalid mm{"statusCode": 404,"message": "MM Settings not found","error": "Not Found"}
// During time delay{"status": "pending","readyAt": "2024-01-31T07:12:26.976Z","expiresAt": "2024-01-31T07:13:26.976Z"}// Ready{"status": "ready","readyAt": "2024-01-08T02:03:15.635Z","expiresAt": "2024-01-08T02:04:15.636Z","data": {"request": {"nonce":2136417542436379,"deadline":1704679455,"positionUpdates": [ {"tokenAddress":"0x2A5Bf6854cA6c236D190b7cfE206457B8d46506C","amount":"200000000000000000000" } ] },"signature":"0x4ea3518372d87cebd8dc869062648b717aac4ba49766967afe4747023d619ce626eefe7be09ab5866b3977e1654af355c2bf80550386d82de4d123d0c70291a31b","recipient":"0x9B85B4A413Efe69684290816a3E814B4aA1EFf63","txRequest": {"to":"0xC71a906A4B0721E58fC36314474334FdB2bAB937","value":"0", "calldata": "0x4339a57d000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001200000000000000000000000009b85b4a413efe69684290816a3e814b4aa1eff630000000000000000000000000000000000000000000000000007970f78b5761b00000000000000000000000000000000000000000000000000000000659b581f000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000010000000000000000000000002a5bf6854ca6c236d190b7cfe206457b8d46506c00000000000000000000000000000000000000000000000ad78ebc5ac620000000000000000000000000000000000000000000000000000000000000000000414ea3518372d87cebd8dc869062648b717aac4ba49766967afe4747023d619ce626eefe7be09ab5866b3977e1654af355c2bf80550386d82de4d123d0c70291a31b00000000000000000000000000000000000000000000000000000000000000"
} }}// Expired{"status": "expired","readyAt": "2024-01-31T07:12:26.976Z","expiresAt": "2024-01-31T07:13:26.976Z"}// Error (no request made){"statusCode": 400,"message": "No request has been made","error": "Bad Request"}
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.
// During time delay{"status": "pending","readyAt": "2024-01-31T09:39:15.776Z","expiresAt": "2024-01-31T09:40:15.776Z"}// Ready{"status": "ready","readyAt": "2024-01-08T02:03:15.635Z","expiresAt": "2024-01-08T02:04:15.636Z","data": {"request": {"nonce":2136417542436379,"deadline":1704679455,"positionUpdates": [ {"tokenAddress":"0x2A5Bf6854cA6c236D190b7cfE206457B8d46506C","amount":"200000000000000000000" } ] },"signature":"0x4ea3518372d87cebd8dc869062648b717aac4ba49766967afe4747023d619ce626eefe7be09ab5866b3977e1654af355c2bf80550386d82de4d123d0c70291a31b","recipient":"0x9B85B4A413Efe69684290816a3E814B4aA1EFf63","txRequest": {"to":"0xC71a906A4B0721E58fC36314474334FdB2bAB937","value":"0", "calldata": "0x4339a57d000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001200000000000000000000000009b85b4a413efe69684290816a3e814b4aa1eff630000000000000000000000000000000000000000000000000007970f78b5761b00000000000000000000000000000000000000000000000000000000659b581f000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000010000000000000000000000002a5bf6854ca6c236d190b7cfe206457b8d46506c00000000000000000000000000000000000000000000000ad78ebc5ac620000000000000000000000000000000000000000000000000000000000000000000414ea3518372d87cebd8dc869062648b717aac4ba49766967afe4747023d619ce626eefe7be09ab5866b3977e1654af355c2bf80550386d82de4d123d0c70291a31b00000000000000000000000000000000000000000000000000000000000000"
} }}// Expired{"status": "expired","readyAt": "2024-01-31T09:39:15.776Z","expiresAt": "2024-01-31T09:40:15.776Z"}// Error (no request made){"statusCode": 400,"message": "No request has been made","error": "Bad Request"}
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.
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
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 mint
Approve AquaVault on LP token to call addCollateral
removeCollateral
MM needs to call Native API with the remove amounts to get the signature to execute the transaction
// nonce, deadline and signature are returned by APIstructRemoveCollateralRequest {uint nonce;uint deadline; TokenAmountUint[] tokens;}functionremoveCollateral(RemoveCollateralRequestcalldata request,bytescalldata signature,address recipient)
MM repays the short positions to decrease the open position
No signature needed
settle
MM needs to call Native API with the settlement proposal to get the signature for sending the settlement transaction
// nonce, deadline and signature are returned by APIstructSettlementRequest {uint nonce;uint deadline; TokenAmountInt[] positionUpdates;}functionsettle(SettlementRequestcalldata request,bytescalldata signature,address recipient)
liquidate
MM 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