This repository was archived by the owner on Mar 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +7
-13
lines changed
token-lending/program/src Expand file tree Collapse file tree 5 files changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ impl<'a> TokenConverter for TradeSimulator<'a> {
93
93
} else {
94
94
input_token. try_div ( best_order_price)
95
95
} ?;
96
- Ok ( output_token_price. try_mul ( self . dex_market . get_lots ( currency. opposite ( ) ) ) ? )
96
+ output_token_price. try_mul ( self . dex_market . get_lots ( currency. opposite ( ) ) )
97
97
}
98
98
99
99
fn convert (
@@ -165,7 +165,7 @@ impl<'a> TradeSimulator<'a> {
165
165
166
166
let input_quantity: Decimal = quantity. try_div ( self . dex_market . get_lots ( currency) ) ?;
167
167
let output_quantity = self . exchange_with_order_book ( input_quantity, currency) ?;
168
- Ok ( output_quantity. try_mul ( self . dex_market . get_lots ( currency. opposite ( ) ) ) ? )
168
+ output_quantity. try_mul ( self . dex_market . get_lots ( currency. opposite ( ) ) )
169
169
}
170
170
171
171
/// Exchange tokens by filling orders
Original file line number Diff line number Diff line change @@ -64,10 +64,9 @@ impl Obligation {
64
64
65
65
/// Maximum amount of loan that can be repaid by liquidators
66
66
pub fn max_liquidation_amount ( & self ) -> Result < u64 , ProgramError > {
67
- Ok ( self
68
- . borrowed_liquidity_wads
67
+ self . borrowed_liquidity_wads
69
68
. try_mul ( Rate :: from_percent ( LIQUIDATION_CLOSE_FACTOR ) ) ?
70
- . try_floor_u64 ( ) ? )
69
+ . try_floor_u64 ( )
71
70
}
72
71
73
72
/// Ratio of loan balance to collateral value
Original file line number Diff line number Diff line change @@ -247,8 +247,7 @@ mod tests {
247
247
let unpacked = SwapCurve :: unpack_from_slice ( & packed) . unwrap ( ) ;
248
248
assert_eq ! ( swap_curve, unpacked) ;
249
249
250
- let mut packed = vec ! [ ] ;
251
- packed. push ( curve_type as u8 ) ;
250
+ let mut packed = vec ! [ curve_type as u8 ] ;
252
251
packed. extend_from_slice ( & [ 0u8 ; 32 ] ) ; // 32 bytes reserved for curve
253
252
let unpacked = SwapCurve :: unpack_from_slice ( & packed) . unwrap ( ) ;
254
253
assert_eq ! ( swap_curve, unpacked) ;
Original file line number Diff line number Diff line change @@ -620,9 +620,7 @@ mod tests {
620
620
swap_curve,
621
621
} ) ;
622
622
let packed = check. pack ( ) ;
623
- let mut expect = vec ! [ ] ;
624
- expect. push ( 0u8 ) ;
625
- expect. push ( nonce) ;
623
+ let mut expect = vec ! [ 0u8 , nonce] ;
626
624
expect. extend_from_slice ( & trade_fee_numerator. to_le_bytes ( ) ) ;
627
625
expect. extend_from_slice ( & trade_fee_denominator. to_le_bytes ( ) ) ;
628
626
expect. extend_from_slice ( & owner_trade_fee_numerator. to_le_bytes ( ) ) ;
Original file line number Diff line number Diff line change @@ -344,9 +344,7 @@ mod tests {
344
344
let unpacked = SwapV1 :: unpack ( & packed) . unwrap ( ) ;
345
345
assert_eq ! ( swap_info, unpacked) ;
346
346
347
- let mut packed = vec ! [ ] ;
348
- packed. push ( 1u8 ) ;
349
- packed. push ( TEST_NONCE ) ;
347
+ let mut packed = vec ! [ 1u8 , TEST_NONCE ] ;
350
348
packed. extend_from_slice ( & TEST_TOKEN_PROGRAM_ID . to_bytes ( ) ) ;
351
349
packed. extend_from_slice ( & TEST_TOKEN_A . to_bytes ( ) ) ;
352
350
packed. extend_from_slice ( & TEST_TOKEN_B . to_bytes ( ) ) ;
You can’t perform that action at this time.
0 commit comments