Limit Order Subintents
Anthic currently supports limit orders for both trades going through the Trade API POST /trade/orders
endpoint and through the Flash Liquidity API.
To support off-chain processing of limit orders, Anthic uses Radix subintents. More specifically, Anthic requires a specific Subintent Manifest schema to express what is desired in the order.
The details of the exact manifest model is abstracted by the /construction/compose
endpoint. But if you wish to
build these manifests yourself either for performance reasons or for more complex manifests then this schema must
be understood.
Example
Examples of manually constructing subintent manifests can be found in the Anthic SDK Repo:
Subintent Manifest Schema
...
1. VERIFY_PARENT <verify_parent_access_rule>;
2. CALL_METHOD <account> "withdraw" <sell_resource> <sell_amount + anthic_fee_amount + settlement_fee_amount>;
3. TAKE_FROM_WORKTOP <sell_resource> <sell_amount>; -> [SellBucket]
4. ASSERT_NEXT_CALL_RETURNS_ONLY <buy_resource> AtleastAmount(<buy_amount>);
5. YIELD_TO_PARENT [SellBucket];
6. TAKE_FROM_WORKTOP <sell_resource> <anthic_fee_amount>; -> [AnthicFeeBucket]
7. TAKE_FROM_WORKTOP <sell_resource> <settlement_fee_amount>; -> [SettlementFeeBucket]
8. YIELD_TO_PARENT [AnthicFeeBucket], [SettlementFeeBucket];
9. DEPOSIT_ENTIRE_WORKTOP <account>
...
10. YIELD_TO_PARENT;
Variable | Description |
---|---|
<verify_parent_access_rule> | An AccessRule provided by Anthic on the /trade/info endpoint. It allows Anthic to ensure that the subintent gets processed by the Anthic server before being committed on-ledger. |
<account> | The user's account address which the order will swap against. The level of this account will also determine the Anthic fees required. |
<sell_resource> | The resource address the user is swapping from |
<sell_amount> | The amount the user is swapping from |
<buy_resource> | The resource address the user is swapping to |
<buy_amount> | The amount the user is swapping to |
<anthic_fee_amount> | The fee amount the user must pay to Anthic, based on the user's account level. |
<settlement_fee_amount> | The fee amount the user must pay to solvers and transaction execution |
Additional Rules:
- The manifest may begin with any number of instructions. This can include swap method calls on AMMs for example.
- 3 and only 3
YIELD_TO_PARENTS
in the pattern described in the schema above may be called. - Rebates from fees may be yielded to your subintent in the
YIELD_TO_PARENT
in line 8 (YIELD_TO_PARENT
will return some resources to you). - The execution cost of the subintent cannot exceed
5 XRD
. - The expiry timestamp of the subintent must be between 15 and 60 seconds from the time of receival by the Anthic server.