Skip to content

Commit

Permalink
feat(auction-calculator): add helpers for AuctionGasCostInfo calc (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
vbrvk authored Mar 19, 2024
1 parent 71f6717 commit cb46030
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/auction-calculator/auction-calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@ export class AuctionCalculator {
return addRatioToAmount(auctionTakingAmount, takerFeeRatio)
}

/**
* Encode estimation `baseFee` as `gasPriceEstimate` for `AuctionGasCostInfo`
*/
static baseFeeToGasPriceEstimate(baseFee: bigint): bigint {
return baseFee / AuctionCalculator.GAS_PRICE_BASE
}

/**
* Calculates `gasBumpEstimate` for `AuctionGasCostInfo`
*
* @param endTakingAmount min return in destToken
* @param gasCostInToToken gas cost in destToken
*/
static calcGasBumpEstimate(
endTakingAmount: bigint,
gasCostInToToken: bigint
): bigint {
return (gasCostInToToken * RATE_BUMP_DENOMINATOR) / endTakingAmount
}

public calcAuctionTakingAmount(takingAmount: bigint, rate: number): bigint {
return AuctionCalculator.calcAuctionTakingAmount(
takingAmount,
Expand Down

0 comments on commit cb46030

Please sign in to comment.