File tree Expand file tree Collapse file tree 3 files changed +11
-15
lines changed
Expand file tree Collapse file tree 3 files changed +11
-15
lines changed Original file line number Diff line number Diff line change @@ -1588,7 +1588,16 @@ fn transfer_from_program_vault<'info>(
15881588
15891589 let balance_before = constituent. get_full_token_amount ( & spot_market) ?;
15901590
1591- let max_transfer = constituent. get_max_transfer ( & spot_market) ?;
1591+ let max_transfer = constituent
1592+ . max_borrow_token_amount
1593+ . cast :: < i128 > ( ) ?
1594+ . safe_add (
1595+ constituent
1596+ . spot_balance
1597+ . get_signed_token_amount ( spot_market) ?,
1598+ ) ?
1599+ . max ( 0 )
1600+ . cast :: < u64 > ( ) ?;
15921601
15931602 validate ! (
15941603 max_transfer >= amount,
Original file line number Diff line number Diff line change @@ -978,19 +978,6 @@ impl Constituent {
978978 bytemuck:: bytes_of ( bump) ,
979979 ]
980980 }
981-
982- pub fn get_max_transfer ( & self , spot_market : & SpotMarket ) -> DriftResult < u64 > {
983- let token_amount = self . get_full_token_amount ( spot_market) ?;
984- let max_transfer = if token_amount < 0 {
985- self . max_borrow_token_amount
986- . saturating_sub ( token_amount. abs ( ) . cast :: < u64 > ( ) ?)
987- } else {
988- self . max_borrow_token_amount
989- . saturating_add ( token_amount. abs ( ) . cast :: < u64 > ( ) ?)
990- } ;
991-
992- Ok ( max_transfer)
993- }
994981}
995982
996983#[ zero_copy]
Original file line number Diff line number Diff line change @@ -1571,7 +1571,7 @@ describe('LP Pool', () => {
15711571 ) ;
15721572 } catch ( e ) {
15731573 console . log ( e ) ;
1574- assert ( e . toString ( ) . includes ( '0x18b9 ' ) ) ; // invariant failed
1574+ assert ( e . toString ( ) . includes ( '0x18c1 ' ) ) ; // invariant failed
15751575 }
15761576 } ) ;
15771577
You can’t perform that action at this time.
0 commit comments