@tradeport/sui-trading-sdk 0.1.34 → 0.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @tradeport/sui-trading-sdk
2
2
 
3
+ ## 0.1.35
4
+
5
+ ### Patch Changes
6
+
7
+ - ebb249c: Fixed royalty fee in price lock calcuation
8
+
3
9
  ## 0.1.30
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1726,13 +1726,17 @@ function calculatePremium(price) {
1726
1726
 
1727
1727
  // src/helpers/calculateRoyaltyFee.ts
1728
1728
  function calculateRoyaltyFee(transferPolicyRules, price) {
1729
- const royaltyRules = transferPolicyRules.filter(
1729
+ const royaltyRule = transferPolicyRules?.filter(
1730
1730
  (rule) => rule.type === "royalty_rule"
1731
- );
1732
- return royaltyRules.reduce(
1733
- (sum, rule) => sum + BigInt(rule.min_amount) + BigInt(rule.amount_bp) * price / 10000n,
1734
- 0n
1735
- );
1731
+ )?.[0];
1732
+ if (!royaltyRule || !royaltyRule.amount_bp && !royaltyRule.min_amount) {
1733
+ return 0n;
1734
+ }
1735
+ const royaltyFee = royaltyRule.amount_bp ? BigInt(royaltyRule.amount_bp) * price / 10000n : 0n;
1736
+ if (royaltyRule.min_amount && BigInt(royaltyRule.min_amount) > royaltyFee) {
1737
+ return BigInt(royaltyRule.min_amount);
1738
+ }
1739
+ return royaltyFee;
1736
1740
  }
1737
1741
 
1738
1742
  // src/graphql/queries/fetchLockById.ts