Skip to content
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

refactor: update limit order logic #637

Closed
wants to merge 8 commits into from

Conversation

hoanguyenkh
Copy link
Member

@hoanguyenkh hoanguyenkh commented Dec 6, 2024

Why did we need it?

For new logic fee merchanism we add a new field IsTakerAssetFee in the order payload,
New logic is:

  • if IsTakerAssetFee is true then take fee from takerAsset
  • if IsTakerAssetFee is false then take fee from makerAsset

Related Issue

Release Note

How Has This Been Tested?

Screenshots (if appropriate):

feeAmountWeiByOrder = p.calcFeeAmountPerOrder(order, remainingTakingAmountWei)
} else {
feeAmountWeiByOrder = p.calcFeeAmountPerOrder(order, remainingMakingAmountWei)
}
actualAmountOut := new(big.Int).Sub(remainingMakingAmountWei, feeAmountWeiByOrder)
Copy link
Member

@hieuvo hieuvo Dec 6, 2024

Choose a reason for hiding this comment

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

actualAmountOut := new(big.Int).Sub(remainingMakingAmountWei, feeAmountWeiByOrder)

in case of order.IsTakerAssetFee = true, the logic of this line doesn't make sense anymore, we have to

// psuedo code, not tested
remainingTakingAmountWei = remainingTakingAmountWei - feeAmountWeiByOrder
actualAmountOut := remainingTakingAmountWei * order.MakingAmount / order.TakingAmount

feeAmountWeiByOrder = p.calcFeeAmountPerOrder(order, filledTakingAmountWei)
} else {
feeAmountWeiByOrder = p.calcFeeAmountPerOrder(order, filledMakingAmountWei)
}
totalFeeAmountWei = new(big.Int).Add(totalFeeAmountWei, feeAmountWeiByOrder)
actualAmountOut := new(big.Int).Sub(filledMakingAmountWei, feeAmountWeiByOrder)
Copy link
Member

Choose a reason for hiding this comment

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

same as below

@hoanguyenkh
Copy link
Member Author

Move to -> #643

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.

2 participants