Users can request token swaps to happen when the oracle price
is within a price band. Once the price is right, an executor can
trigger the swap. The executors are rewarded with a premium
over the oracle price.
This allows limit and stop loss orders on arbitrary spot pairs.
The PR comes with basic ts support and adjustments to the liquidator,
to execute available token conditional swaps.
Co-authored-by: microwavedcola1 <microwavedcola@gmail.com>
* Stable Price: Reset on first price != 0
This helps when listing tokens or perp markets with an upcoming
oracle. Currently the stable price would be 0 and would need to be
manually reset by DAO proposal.
With this change, the first non-zero value will be used as the starting
point for the stable price instead.
* Listing instructions: Succeed even if oracle is invalid
But require the stable price to reset once it becomes valid.
* Vendor `fixed` crate to have checked math in release mode
* remove all cm!()
* drop superfluous parens
* drop use of checked_math crate
* manual removal of redundant checked_* functions
It is tracked in the StablePriceModel and updated on
TokenUpdateIndexAndRate and PerpUpdateFunding instructions.
The stable price is used in health computations.