@gainsnetwork/sdk 1.6.0-rc1 → 1.6.0-rc2
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.
|
@@ -35,3 +35,12 @@ export declare const isGnsStakingCooldownActive: (traderFeeTiers: TraderFeeTiers
|
|
|
35
35
|
isActive: boolean;
|
|
36
36
|
expiryTs: number;
|
|
37
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* @dev Helper function to get the fee multiplier based on GNS and gGNS amounts. Useful to estimate fee multiplier after staking/unstaking.
|
|
40
|
+
* @param amountGns Amount of GNS staked
|
|
41
|
+
* @param amountGGns Amount of gGNS staked
|
|
42
|
+
* @param bonusAmount GNS bonus amount
|
|
43
|
+
* @param stakingTiers Array of staking fee tiers
|
|
44
|
+
* @param gGnsPrice Conversion ratio from gGNS to GNS (e.g., 0.8 means 1 gGNS = 0.8 GNS, 1.1 means 1 gGNS = 1.1 GNS); Defaults to 1 (e.g., 1 gGNS = 1 GNS)
|
|
45
|
+
*/
|
|
46
|
+
export declare const getStakingFeeMultiplier: (amountGns: number, amountGGns: number, bonusAmount: number, stakingTiers: FeeTier[], gGnsPrice?: number) => number;
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.isGnsStakingCooldownActive = exports.getTraderFeeMultiplier = exports.calculateFeeAmount = exports.computeFeeMultiplier = exports.getFeeMultiplier = exports.getFeeTiersCount = exports.getCurrentDay = exports.GNS_STAKING_COOLDOWN_SECONDS = exports.MAX_FEE_TIERS = exports.FEE_MULTIPLIER_SCALE = exports.TRAILING_PERIOD_DAYS = void 0;
|
|
17
|
+
exports.getStakingFeeMultiplier = exports.isGnsStakingCooldownActive = exports.getTraderFeeMultiplier = exports.calculateFeeAmount = exports.computeFeeMultiplier = exports.getFeeMultiplier = exports.getFeeTiersCount = exports.getCurrentDay = exports.GNS_STAKING_COOLDOWN_SECONDS = exports.MAX_FEE_TIERS = exports.FEE_MULTIPLIER_SCALE = exports.TRAILING_PERIOD_DAYS = void 0;
|
|
18
18
|
const types_1 = require("./types");
|
|
19
19
|
__exportStar(require("./types"), exports);
|
|
20
20
|
__exportStar(require("./converter"), exports);
|
|
@@ -112,3 +112,24 @@ const isGnsStakingCooldownActive = (traderFeeTiers) => {
|
|
|
112
112
|
return { isActive: now < expiryTs, expiryTs };
|
|
113
113
|
};
|
|
114
114
|
exports.isGnsStakingCooldownActive = isGnsStakingCooldownActive;
|
|
115
|
+
/**
|
|
116
|
+
* @dev Helper function to get the fee multiplier based on GNS and gGNS amounts. Useful to estimate fee multiplier after staking/unstaking.
|
|
117
|
+
* @param amountGns Amount of GNS staked
|
|
118
|
+
* @param amountGGns Amount of gGNS staked
|
|
119
|
+
* @param bonusAmount GNS bonus amount
|
|
120
|
+
* @param stakingTiers Array of staking fee tiers
|
|
121
|
+
* @param gGnsPrice Conversion ratio from gGNS to GNS (e.g., 0.8 means 1 gGNS = 0.8 GNS, 1.1 means 1 gGNS = 1.1 GNS); Defaults to 1 (e.g., 1 gGNS = 1 GNS)
|
|
122
|
+
*/
|
|
123
|
+
const getStakingFeeMultiplier = (amountGns, amountGGns, bonusAmount, stakingTiers, gGnsPrice = 1) => {
|
|
124
|
+
let feeMultiplier = exports.FEE_MULTIPLIER_SCALE;
|
|
125
|
+
for (let i = (0, exports.getFeeTiersCount)(stakingTiers); i > 0; --i) {
|
|
126
|
+
const stakingTier = stakingTiers[i - 1];
|
|
127
|
+
if (amountGns + amountGGns * gGnsPrice + bonusAmount >=
|
|
128
|
+
stakingTier.pointsThreshold) {
|
|
129
|
+
feeMultiplier = stakingTier.feeMultiplier;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return feeMultiplier;
|
|
134
|
+
};
|
|
135
|
+
exports.getStakingFeeMultiplier = getStakingFeeMultiplier;
|