@@ -220,7 +220,7 @@ impl LPPool {
220220
221221 let out_fee_amount = out_amount
222222 . cast :: < i128 > ( ) ?
223- . safe_mul ( out_fee as i128 ) ?
223+ . safe_mul ( out_fee) ?
224224 . safe_div ( PERCENTAGE_PRECISION_I128 ) ?;
225225
226226 Ok ( ( in_amount, out_amount, in_fee_amount, out_fee_amount) )
@@ -472,7 +472,7 @@ impl LPPool {
472472 let out_spot_market = out_spot_market. unwrap ( ) ;
473473 let out_oracle_price = out_oracle_price. unwrap ( ) ;
474474 let out_amount = notional_trade_size
475- . safe_mul ( 10_i128 . pow ( out_spot_market. decimals as u32 ) ) ?
475+ . safe_mul ( 10_i128 . pow ( out_spot_market. decimals ) ) ?
476476 . safe_div ( out_oracle_price. cast :: < i128 > ( ) ?) ?;
477477 (
478478 false ,
@@ -693,10 +693,10 @@ impl LPPool {
693693
694694 if total_quote_owed > 0 {
695695 aum = aum
696- . saturating_sub ( total_quote_owed as i128 )
696+ . saturating_sub ( total_quote_owed)
697697 . max ( QUOTE_PRECISION_I128 ) ;
698698 } else if total_quote_owed < 0 {
699- aum = aum. saturating_add ( ( -total_quote_owed) as i128 ) ;
699+ aum = aum. saturating_add ( -total_quote_owed) ;
700700 }
701701
702702 let aum_u128 = aum. max ( 0 ) . cast :: < u128 > ( ) ?;
@@ -739,7 +739,7 @@ impl SpotBalance for ConstituentSpotBalance {
739739 }
740740
741741 fn balance ( & self ) -> u128 {
742- self . scaled_balance as u128
742+ self . scaled_balance
743743 }
744744
745745 fn increase_balance ( & mut self , delta : u128 ) -> DriftResult {
@@ -883,15 +883,15 @@ impl Constituent {
883883 self . pubkey,
884884 self . spot_market_index
885885 ) ;
886- return Err ( ErrorCode :: InvalidConstituentOperation . into ( ) ) ;
886+ Err ( ErrorCode :: InvalidConstituentOperation )
887887 } else if ConstituentLpOperation :: is_operation_paused ( self . paused_operations , operation) {
888888 msg ! (
889889 "Constituent {:?}, spot market {}, is paused for operation {:?}" ,
890890 self . pubkey,
891891 self . spot_market_index,
892892 operation
893893 ) ;
894- return Err ( ErrorCode :: InvalidConstituentOperation . into ( ) ) ;
894+ Err ( ErrorCode :: InvalidConstituentOperation )
895895 } else {
896896 Ok ( ( ) )
897897 }
@@ -1175,7 +1175,7 @@ impl<'a> AccountZeroCopy<'a, TargetsDatum, ConstituentTargetBaseFixed> {
11751175
11761176 // TODO: validate spot market
11771177 let datum = self . get ( constituent_index as u32 ) ;
1178- let target_weight = calculate_target_weight ( datum. target_base , & spot_market, price, aum) ?;
1178+ let target_weight = calculate_target_weight ( datum. target_base , spot_market, price, aum) ?;
11791179 Ok ( target_weight)
11801180 }
11811181}
@@ -1197,7 +1197,7 @@ pub fn calculate_target_weight(
11971197 . safe_mul ( PERCENTAGE_PRECISION_I128 ) ?
11981198 . safe_div ( lp_pool_aum. cast :: < i128 > ( ) ?) ?
11991199 . cast :: < i64 > ( ) ?
1200- . clamp ( -1 * PERCENTAGE_PRECISION_I64 , PERCENTAGE_PRECISION_I64 ) ;
1200+ . clamp ( -PERCENTAGE_PRECISION_I64 , PERCENTAGE_PRECISION_I64 ) ;
12011201
12021202 Ok ( target_weight)
12031203}
@@ -1268,11 +1268,10 @@ impl<'a> AccountZeroCopyMut<'a, TargetsDatum, ConstituentTargetBaseFixed> {
12681268 mapping_index = j;
12691269
12701270 let cell = self . get_mut ( i as u32 ) ;
1271- let target_base = target_notional
1271+ let target_base = - target_notional
12721272 . safe_div ( PERCENTAGE_PRECISION_I128 ) ?
12731273 . safe_mul ( 10_i128 . pow ( decimals as u32 ) ) ?
1274- . safe_div ( price as i128 ) ?
1275- * -1 ; // Want to target opposite sign of total scaled notional inventory
1274+ . safe_div ( price as i128 ) ?; // Want to target opposite sign of total scaled notional inventory
12761275
12771276 msg ! (
12781277 "updating constituent index {} target base to {} from aggregated perp notional {}" ,
@@ -1295,7 +1294,7 @@ impl<'a> AccountZeroCopyMut<'a, AmmConstituentDatum, AmmConstituentMappingFixed>
12951294
12961295 let mut open_slot_index: Option < u32 > = None ;
12971296 for i in 0 ..len {
1298- let cell = self . get ( i as u32 ) ;
1297+ let cell = self . get ( i) ;
12991298 if cell. constituent_index == datum. constituent_index
13001299 && cell. perp_market_index == datum. perp_market_index
13011300 {
@@ -1305,7 +1304,7 @@ impl<'a> AccountZeroCopyMut<'a, AmmConstituentDatum, AmmConstituentMappingFixed>
13051304 open_slot_index = Some ( i) ;
13061305 }
13071306 }
1308- let open_slot = open_slot_index. ok_or_else ( || ErrorCode :: DefaultError . into ( ) ) ?;
1307+ let open_slot = open_slot_index. ok_or ( ErrorCode :: DefaultError ) ?;
13091308
13101309 let cell = self . get_mut ( open_slot) ;
13111310 * cell = datum;
@@ -1319,11 +1318,11 @@ impl<'a> AccountZeroCopyMut<'a, AmmConstituentDatum, AmmConstituentMappingFixed>
13191318 let len = self . len ( ) ;
13201319 let mut data: Vec < AmmConstituentDatum > = Vec :: with_capacity ( len as usize ) ;
13211320 for i in 0 ..len {
1322- data. push ( * self . get ( i as u32 ) ) ;
1321+ data. push ( * self . get ( i) ) ;
13231322 }
13241323 data. sort_by_key ( |datum| datum. constituent_index ) ;
13251324 for i in 0 ..len {
1326- let cell = self . get_mut ( i as u32 ) ;
1325+ let cell = self . get_mut ( i) ;
13271326 * cell = data[ i as usize ] ;
13281327 }
13291328 Ok ( ( ) )
@@ -1482,8 +1481,8 @@ impl ConstituentCorrelations {
14821481 "ConstituentCorrelation correlations must be between 0 and PERCENTAGE_PRECISION"
14831482 ) ?;
14841483
1485- self . correlations [ ( i as usize * num_constituents + j as usize ) as usize ] = corr;
1486- self . correlations [ ( j as usize * num_constituents + i as usize ) as usize ] = corr;
1484+ self . correlations [ ( i as usize * num_constituents + j as usize ) ] = corr;
1485+ self . correlations [ ( j as usize * num_constituents + i as usize ) ] = corr;
14871486
14881487 self . validate ( ) ?;
14891488
@@ -1568,7 +1567,7 @@ pub fn update_constituent_target_base_for_derivatives(
15681567 constituent_target_base : & mut AccountZeroCopyMut < ' _ , TargetsDatum , ConstituentTargetBaseFixed > ,
15691568) -> DriftResult < ( ) > {
15701569 for ( parent_index, constituent_indexes) in derivative_groups. iter ( ) {
1571- let parent_constituent = constituent_map. get_ref ( & ( parent_index) ) ?;
1570+ let parent_constituent = constituent_map. get_ref ( parent_index) ?;
15721571 let parent_target_base = constituent_target_base
15731572 . get ( * parent_index as u32 )
15741573 . target_base ;
0 commit comments