You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The lease owner can set Stop Loss, SL, or/and TakeProfit, TP, triggers after the lease has been fully opened. They may be set up and removed individually, or together until the lease is fully paid, fully closed, or fully liquidated.
Partial closes are defined in percent of the total position. It is not an absolute value, because it might change over time, for example past partial close or liquidations, partial TPs, etc.
The trigger of SL and TP is defined as LTV percent such as Liquidation% > SL > current LTV > TP. Note that the Liquidation% is set on the Lease Open time and remains intact over the Lease Lifetime.
Correspondingly, Partial or Full Close occurs if
Partial or Full SL is set and SL% <= lease LTV%
Partial or Full TP is set and lease LTV% <= TP% .
If a liquidation occurs despite having a SL set, then the higher amount of liquidation and the stop-loss should be closed to guarantee the position's healthiness.
Once a trigger is fired it is consumed and no longer valid.
It's worth noting that:
if TP > healthy LTV and a partial liquidation occurs a TP would be triggered, and
the TP, if set, might be triggered right after payment due to lowered LTV
Both would be communicated with the customers, the former on setting TP, and the latter on payment.
Design
Define struct ClosePolicy and keep an instance in lease::position::spec::Spec next to liability.
Introduce enum Close<Asset> with two variants Full and Partial, similar to lease::position::Liquidation<Asset>, and fn Position::trigger(&Due, Price<Asset>) -> Option<Close<Asset>> .
Two options to continue, either
(a) Rename appropriately, and amend fn Lease::check_debt to accommodate the trigger result handling, optionally starting a position close. Add a new variant DebtStatus::FireClose(Close<asset>) (how are the alarms scheduled?) , or
(b) add a sibling method to fn Lease::check_debt that checks for a position close. Merge the liability and trigger zones to proceed with setting up alarms.
Tasks
implement the core logic and unit tests as per the design described above
add a Lease execute message to setup triggers
consider "smart" or no migration of the existing leases to add the new properties or ClosePolicy to the Position Spec, e.g. "#serde[default]"
add events that leave enough trace in the chain for audibility
add integration tests
The text was updated successfully, but these errors were encountered:
@kostovster selected Medium size though my confidence is not higher than 50%, so would say it would take somewhat in between Medium and Large Tasks, i.e. 3-4w
The lease owner can set Stop Loss, SL, or/and TakeProfit, TP, triggers after the lease has been fully opened. They may be set up and removed individually, or together until the lease is fully paid, fully closed, or fully liquidated.
Partial closes are defined in percent of the total position. It is not an absolute value, because it might change over time, for example past partial close or liquidations, partial TPs, etc.
The trigger of SL and TP is defined as LTV percent such as
Liquidation% > SL > current LTV > TP
. Note that theLiquidation%
is set on the Lease Open time and remains intact over the Lease Lifetime.Correspondingly, Partial or Full Close occurs if
SL% <= lease LTV%
lease LTV% <= TP%
.If a liquidation occurs despite having a SL set, then the higher amount of liquidation and the stop-loss should be closed to guarantee the position's healthiness.
Once a trigger is fired it is consumed and no longer valid.
It's worth noting that:
Both would be communicated with the customers, the former on setting TP, and the latter on payment.
Design
Define
struct ClosePolicy
and keep an instance inlease::position::spec::Spec
next toliability
.Introduce
enum Close<Asset>
with two variantsFull
andPartial
, similar tolease::position::Liquidation<Asset>
, andfn Position::trigger(&Due, Price<Asset>) -> Option<Close<Asset>>
.Two options to continue, either
(a) Rename appropriately, and amend
fn Lease::check_debt
to accommodate the trigger result handling, optionally starting a position close. Add a new variantDebtStatus::FireClose(Close<asset>)
(how are the alarms scheduled?) , or(b) add a sibling method to
fn Lease::check_debt
that checks for a position close. Merge the liability and trigger zones to proceed with setting up alarms.Tasks
The text was updated successfully, but these errors were encountered: