Skip to content

Conversation

@lmvdz
Copy link

@lmvdz lmvdz commented Feb 15, 2022

Port of the fees.rs

@@ -0,0 +1,148 @@
import { BN, ClearingHouseUser, FeeStructure, ZERO } from "@drift-labs/sdk";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do these need to be imported from @drift-labs/sdk? I think they should be imported from same package.


Object.keys(feeStructure.discountTokenTiers).forEach(tier => {
const possibleDiscount = tryToCalculateTokenDiscountForTier(fee, feeStructure.discountTokenTiers[tier], discountToken);
if (possibleDiscount > discount) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this needs to be gt instead of > since it is a BN

refereeDiscount: BN
}

export function calculateFeeForMarketOrder(quoteAssetAmount: BN, feeStructure: FeeStructure, discountToken?: AccountInfo, referrer?: ClearingHouseUser ) : MarketOrderFee {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of passing in ClearingHouseUser as referrer, might just be nice to pass in a boolean so you dont need a whole ClearingHouseUser object


// https://github.com/indutny/bn.js/pull/277
// https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
function sqrt (input: BN) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crispheaney crispheaney force-pushed the crispheaney/off-chain-orders branch from 012a8ef to e05a4e2 Compare February 16, 2022 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants