Closed liamzebedee closed 2 years ago
submitNextPriceOrder(...)
- if previous order exists reverts
- stores the order data + funding index
- deducts holding-fee from margin
- cancelNextPriceOrder():
- sends holding-fee to fee-pool
- removes order
- executeStoredOrder(address account)
- can be triggered by anyone, at any time after next price(reverts if too soon)
- in revertless low level call to itself (internal external low level call) executes modifyPosition, remember if call was success
- remove stored order
- pay holding fee:
- if account is sender:
- if call was success - returns fee to margin
- if call was failure - pay to fee-pool
- otherwise transfer holding fee to msg.sender (keeper)
A simpler mechanism after a discussion:
- submitNextPriceOrder(...)
- if previous order exists reverts
- stores the order data + funding index
- check order is possible with current price (to prevent submitting known bad orders)
- deduct holding-fee and keeper-fee from margin
- executeStoredOrder(address account)
- can be triggered by anyone, at any time after next price(reverts if too soon)
- in revertless low level call to itself (internal external low level call) executes modifyPosition, remember if call was success
- remove stored order
- pay fees (holding-fee and keeper-fee):
- call was success - holding-fee back to margin, otherwise to fee-pool
- sender is original account - keeper-fee back to margin, otherwise to msg.sender
parameters:
holdingFee - can be zero initially if no exploit scenarios are found for free cancellation
keeperFee - can be equal to minLiquidationFee (20 sUSD)
nextPriceFee - 5 bp instead of regular spot fee (30 bps)
minliquidationfee
-> minKeeperFee
, use that to pay the second tx sender.Mechanism was updated again (following another exploit scenario).
commitFee
.Follow ups for another PR / task:
Context