-
Notifications
You must be signed in to change notification settings - Fork 192
Open
Milestone
Description
Onchain order hook
Create @HapiTest regression tests verifying the Lambdaplex account order hook still works as expected on each PR being merged.
Prerequisites
The @HapiTest scaffolding for these tests will need,
- A mock Supra oracle that "echoes" given prices or fails per input args w/
SpecOperationsupport - A Supra pair registry also with
SpecOperationsupport - A hook contract instantiated w/ well-known addresses above
- A
LambdaplexVerbsextension to standard@HapiTest"vocabulary" for expressive testing
Happy paths
For LIMIT orders,
- HBAR/HTS full fill, no fees (order deleted)
- HBAR/HTS full fill with fees (fees accounted, order deleted)
- Multiple HBAR/HTS full fills with fees (fees accounted, orders deleted)
- HBAR/HTS partial fill, no fees (quantity writeback)
- HBAR/HTS partial fill with fees (fees accounted, quantity writeback)
- Multiple HBAR/HTS full plus a partial fill (fees accounted, filled orders deleted + quantity writeback for partial)
- HTS/HTS full fill, no fees (order deleted)
- HTS/HTS full fill with fees (fees accounted, order deleted)
- HTS/HTS partial fill, no fees (quantity writeback)
- HTS/HTS partial fill with fees (fees accounted, quantity writeback)
- Multiple HTS/HTS full plus a partial fill (fees accounted, filled orders deleted + quantity writeback for partial)
For MARKET orders,
- HBAR/HTS full fill, no fee, no slippage (order deleted)
- HBAR/HTS full fill, no fee, in-range slippage (order deleted)
- HBAR/HTS full fill with fee, no slippage (fees accounted, order deleted)
- HBAR/HTS full fill with fee, in-range slippage (fees accounted, order deleted)
- HBAR/HTS satisficing partial fill with fee, no slippage (fees accounted, order deleted)
- HBAR/HTS satisficing partial fill with fee, in-range slippage (fees accounted, order deleted)
- HTS/HTS full fill, no fee, no slippage (order deleted)
- HTS/HTS full fill, no fee, in-range slippage (order deleted)
- HTS/HTS full fill with fee, no slippage (fees accounted, order deleted)
- HTS/HTS full fill with fee, in-range slippage (fees accounted, order deleted)
- HTS/HTS satisficing partial fill with fee, no slippage (fees accounted, order deleted)
- HTS/HTS satisficing partial fill with fee, in-range slippage (fees accounted, order deleted)
For STOP_LIMIT_{LT,GT} orders,
- HBAR/HTS trigger and immediate full fill, no fee (order deleted)
- HBAR/HTS trigger and immediate partial fill, no fee (order converted with writeback)
- HBAR/HTS trigger and immediate partial fill with fee (order converted with writeback)
- Multiple HBAR/HTS triggers to full plus a partial fill, no fees (filled deleted, partial converted with writeback)
- Multiple HBAR/HTS triggers to full plus a partial fill with fees (filled deleted, partial converted with writeback)
- HBAR/HTS "poke" (order converted to LIMIT, full quantity)
- HTS/HTS trigger and immediate full fill, no fee (order deleted)
- HTS/HTS trigger and immediate partial fill, no fee (order converted with remainder)
- HTS/HTS trigger and immediate partial fill with fee (order converted with remainder)
- HTS/HTS "poke" (order converted to LIMIT, full quantity)
- Multiple HTS/HTS triggers to full plus a partial fill, no fees (filled deleted, partial converted with writeback)
- Multiple HTS/HTS triggers to full plus a partial fill with fees (filled deleted, partial converted with writeback)
For STOP_MARKET_{LT,GT} orders,
- HBAR/HTS trigger and immediate full fill, no fee, in-range slippage (order deleted)
- HBAR/HTS trigger and immediate satisficing partial fill with fee, in-range slippage (order deleted)
- HBAR/HTS "poke" (order converted to MARKET)
- Multiple HBAR/HTS triggers to full plus a satisficing partial fill, no fees (all deleted)
- HTS/HTS trigger and immediate full fill, no fee, in-range slippage (order deleted)
- HTS/HTS trigger and immediate satisficing partial fill with fee, in-range slippage (order deleted)
- HTS/HTS "poke" (order converted to MARKET)
- Multiple HTS/HTS triggers to full plus a satisficing partial fill, no fees (all deleted)
For "mixed" batch orders with the same input/output tokens,
- HBAR/HTS mixed batches settle as expected.
- HTS/HTS mixed batches settle as expected.
Failure paths
Core transfer valiation and accounting,
- Asserts signs of order property values
- Rejects "foreign" tokens in the proposed transfers
- Rejects duplicated token ids ("invalid path")
- Reverts expired orders
- Fails fast on degenerate order "details"
- Reverts if proposed debit exceeds authorized by single limit order
- Reverts if proposed debit exceeds authorized by single market order
- Reverts if proposed debit exceeds total authorized using multiple limit orders
- Reverts if proposed debit exceeds total authorized using multiple mixed orders
- Reverts if proposed credit less than required by single limit order
- Reverts if proposed credit less than required by single market order
- Reverts if proposed credit less than total authorized using multiple limit orders
- Reverts if proposed credit less than total authorized using multiple mixed orders
- Reverts if fee amount in BPS exceeds permitted by single limit order
- Reverts if fee amount in BPS exceeds permitted by single market order
- Reverts if fee amount in BPS exceeds permitted by multiple limit orders
- Reverts if fee amount in BPS exceeds permitted by multiple market orders
- Reverts if fee amount in BPS exceeds permitted by multiple mixed orders
- Reverts if min fill configured and not met for a single market order
- Reverts if min fill configured and not met for a single stop market order
- Reverts if min fill configured and not met for a stop market order in mixed multiple
- Fails if oracle registry does not support pair
- Fails on missing oracle proof length
- Fails on excessive oracle proof length
- Fails on truncated oracle proof
- Fails on stale oracle timestamp
- Fails on out-of-range oracle decimals
- Fails to trigger
LTstop if order price above oracle - Fails to trigger
GTstop if order price below oracle - Reverts on truncated data
- Reverts on unsupported order type
- Reverts on non-oracle batch with
datalength not a multiple of 32 - Rejects any proposed transfers with NFT transfers
- Rejects any proposed transfers with custom HBAR fees
- Rejects any proposed transfers with custom HBAR fees
- Rejects mixed input tokens in multiple order invocation
- Rejects mixed output tokens in multiple order invocation
- Rejects any HBAR transfers when input and output tokens are both HTS
- Rejects out-of-range slippage for market and stop market orders
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels