This repository was archived by the owner on Jan 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +11
-7
lines changed
Expand file tree Collapse file tree 3 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ pub struct ClosePosition<'info> {
2323
2424 #[ account(
2525 mut ,
26- constraint = receiving_account. mint == custody . mint,
26+ constraint = receiving_account. mint == collateral_custody . mint,
2727 has_one = owner
2828 ) ]
2929 pub receiving_account : Box < Account < ' info , TokenAccount > > ,
Original file line number Diff line number Diff line change @@ -23,14 +23,14 @@ pub struct Liquidate<'info> {
2323
2424 #[ account(
2525 mut ,
26- constraint = receiving_account. mint == custody . mint,
26+ constraint = receiving_account. mint == collateral_custody . mint,
2727 constraint = receiving_account. owner == position. owner
2828 ) ]
2929 pub receiving_account : Box < Account < ' info , TokenAccount > > ,
3030
3131 #[ account(
3232 mut ,
33- constraint = rewards_receiving_account. mint == custody . mint,
33+ constraint = rewards_receiving_account. mint == collateral_custody . mint,
3434 constraint = rewards_receiving_account. owner == signer. key( )
3535 ) ]
3636 pub rewards_receiving_account : Box < Account < ' info , TokenAccount > > ,
Original file line number Diff line number Diff line change @@ -408,10 +408,14 @@ impl Custody {
408408 if stats. open_positions > 0 {
409409 Ok ( Position {
410410 side,
411- price : math:: checked_as_u64 ( math:: checked_div (
412- stats. weighted_price ,
413- stats. total_quantity ,
414- ) ?) ?,
411+ price : if stats. total_quantity > 0 {
412+ math:: checked_as_u64 ( math:: checked_div (
413+ stats. weighted_price ,
414+ stats. total_quantity ,
415+ ) ?) ?
416+ } else {
417+ 0
418+ } ,
415419 size_usd : stats. size_usd ,
416420 unrealized_loss_usd : stats. cumulative_interest_usd ,
417421 cumulative_interest_snapshot : stats. cumulative_interest_snapshot ,
You can’t perform that action at this time.
0 commit comments