Open
Conversation
crispheaney
requested changes
Feb 15, 2022
| @@ -0,0 +1,148 @@ | |||
| import { BN, ClearingHouseUser, FeeStructure, ZERO } from "@drift-labs/sdk"; | |||
Member
There was a problem hiding this comment.
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) { |
Member
There was a problem hiding this comment.
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 { |
Member
There was a problem hiding this comment.
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) { |
Member
There was a problem hiding this comment.
we have a similar method here that you can use: https://github.com/drift-labs/protocol-v1/blob/master/sdk/src/math/utils.ts#L3
012a8ef to
e05a4e2
Compare
…into off-chain-orders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port of the fees.rs