Skip to content

Commit

Permalink
address more feedback comments (delete / add comments to code)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbigz committed Jul 5, 2024
1 parent bf22aa8 commit bc4e962
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 19 deletions.
7 changes: 2 additions & 5 deletions programs/drift/src/controller/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,6 @@ fn fulfill_perp_order(
taker_margin_calculation.fuel_deposits,
taker_margin_calculation.fuel_borrows,
taker_margin_calculation.fuel_positions,
now,
)?;
user.last_fuel_bonus_update_ts = now;

Expand Down Expand Up @@ -1765,7 +1764,6 @@ fn fulfill_perp_order(
maker_margin_calculation.fuel_deposits,
maker_margin_calculation.fuel_borrows,
maker_margin_calculation.fuel_positions,
now,
)?;
}
maker.last_fuel_bonus_update_ts = now;
Expand Down Expand Up @@ -4088,7 +4086,6 @@ fn fulfill_spot_order(
taker_margin_calculation.fuel_deposits,
taker_margin_calculation.fuel_borrows,
taker_margin_calculation.fuel_positions,
now,
)?;
user.last_fuel_bonus_update_ts = now;

Expand Down Expand Up @@ -4176,10 +4173,10 @@ fn fulfill_spot_order(
maker_margin_calculation.fuel_deposits,
maker_margin_calculation.fuel_borrows,
maker_margin_calculation.fuel_positions,
now,
)?;

maker.last_fuel_bonus_update_ts = now;
}
maker.last_fuel_bonus_update_ts = now;

if !maker_margin_calculation.meets_margin_requirement() {
msg!(
Expand Down
7 changes: 2 additions & 5 deletions programs/drift/src/state/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ impl User {
if self.last_fuel_bonus_update_ts > 0 {
now.safe_sub(self.last_fuel_bonus_update_ts)
} else {
// start ts for exisiting accounts for when fuel accumulates from
return Ok(now.safe_sub(1715745600_i64)?.max(0));
}
}
Expand All @@ -448,7 +449,7 @@ impl User {
user_stats: &mut UserStats,
now: i64,
) -> DriftResult {
user_stats.update_fuel_bonus(fuel_deposits, fuel_borrows, fuel_positions, now)?;
user_stats.update_fuel_bonus(fuel_deposits, fuel_borrows, fuel_positions)?;
self.last_fuel_bonus_update_ts = now;

Ok(())
Expand Down Expand Up @@ -488,7 +489,6 @@ impl User {
margin_calculation.fuel_deposits,
margin_calculation.fuel_borrows,
margin_calculation.fuel_positions,
now,
)?;

self.last_fuel_bonus_update_ts = now;
Expand Down Expand Up @@ -542,7 +542,6 @@ impl User {
calculation.fuel_deposits,
calculation.fuel_borrows,
calculation.fuel_positions,
now,
)?;
self.last_fuel_bonus_update_ts = now;

Expand Down Expand Up @@ -1615,12 +1614,10 @@ impl UserStats {
fuel_deposits: u32,
fuel_borrows: u32,
fuel_positions: u32,
_now: i64,
) -> DriftResult {
self.fuel_deposits = self.fuel_deposits.saturating_add(fuel_deposits);
self.fuel_borrows = self.fuel_borrows.saturating_add(fuel_borrows);
self.fuel_positions = self.fuel_positions.saturating_add(fuel_positions);
// self.last_fuel_bonus_update_ts = now;

Ok(())
}
Expand Down
8 changes: 0 additions & 8 deletions sdk/src/adminClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3561,14 +3561,6 @@ export class AdminClient extends DriftClient {
fuelBoostTaker?: number,
fuelBoostMaker?: number
): Promise<TransactionInstruction> {
// const params = {
// spotMarketIndex,
// fuelBoostDeposits: fuelBoostDeposits || null,
// fuelBoostBorrows: fuelBoostBorrows || null,
// fuelBoostTaker: fuelBoostTaker || null,
// fuelBoostMaker: fuelBoostMaker || null,
// };

const spotMarketPublicKey = await getSpotMarketPublicKey(
this.program.programId,
spotMarketIndex
Expand Down
1 change: 1 addition & 0 deletions test-scripts/run-anchor-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ test_files=(
# updateK.ts
# postOnlyAmmFulfillment.ts
# TODO BROKEN ^^
fuel.ts
admin.ts
assetTier.ts
cancelAllOrders.ts
Expand Down
1 change: 0 additions & 1 deletion tests/fuel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ describe('place and fill spot order', () => {
console.log(fuelDict);
assert(fuelDict['depositFuel'].gt(ZERO));
assert(fuelDict['depositFuel'].eqn(2142));
return 0;

await makerDriftClient.placeSpotOrder(
getLimitOrderParams({
Expand Down

0 comments on commit bc4e962

Please sign in to comment.