-
Notifications
You must be signed in to change notification settings - Fork 19
Add market-based fee discount and user staking discount #824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| ): Double? { | ||
| if (fee == null) return fee | ||
|
|
||
| var finalFee = fee |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need to check if finalFee *= marketFeeDiscount.chargePercent is greater than 0 before applying the userStakingTierDiscountPercent?
@tqin7 would it ever be negative?
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class OnChainFeeDiscountsResponse( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @@ -0,0 +1,26 @@ | |||
| /** | |||
| * Indexer API | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | ||
|
|
||
| private fun retrieveUserStakingTier() { | ||
| val params = iMapOf("address" to accountAddress) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| existing: InternalUserState?, | ||
| payload: OnChainUserStakingTierResponse?, | ||
| ): InternalUserState { | ||
| val internalState = existing ?: InternalUserState() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| internal fun TradingStateMachine.onChainUserStakingTier(payload: String): StateChanges { | ||
| val json = parser.decodeJsonObject(payload) | ||
| val payload = parser.asTypedObject<OnChainUserStakingTierResponse>(json) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| try { | ||
| val newValue = PerpetualMarket( | ||
| id = name, | ||
| clobPairId = payload.clobPairId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
| val feeDiscountState = InternalMarketFeeDiscountState( | ||
| startTime = feeDiscount.startTime, | ||
| endTime = feeDiscount.endTime, | ||
| chargePercent = feeDiscount.chargePpm?.div(QUANTUM_MULTIPLIER), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chargePpm / 1e6 🔥
Also ran codegen to update some of the indexer data models