tcs: net borrow checks
This commit is contained in:
parent
1dd934f8ad
commit
7e804b228f
|
@ -275,10 +275,14 @@ fn action(
|
|||
|
||||
sell_bank.collected_fees_native += I80F48::from(maker_fee + taker_fee);
|
||||
|
||||
// No need to check net borrow limits on buy_bank or sell_bank, because this mostly transfers
|
||||
// tokens between two accounts. For the sell token, the withdraw is higher than the deposit
|
||||
// due to fees, so net borrows can technically increase a bit: but the difference gets "deposited"
|
||||
// into collected_fees_native.
|
||||
// Check net borrows on both banks.
|
||||
//
|
||||
// While tcs triggering doesn't cause actual tokens to leave the platform, it can increase the amount
|
||||
// of borrows. For instance, if someone with USDC has a tcs to buy SOL and sell BTC, execution would
|
||||
// create BTC borrows (unless the executor had BTC borrows that get repaid by the execution, but
|
||||
// most executors will work on margin)
|
||||
buy_bank.check_net_borrows(buy_token_price)?;
|
||||
sell_bank.check_net_borrows(sell_token_price)?;
|
||||
|
||||
let post_liqee_sell_token = liqee_sell_token.native(&sell_bank);
|
||||
let post_liqor_sell_token = liqor_sell_token.native(&sell_bank);
|
||||
|
|
Loading…
Reference in New Issue