@defisaver/positions-sdk 2.1.44 → 2.1.45
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/cjs/staking/staking.js +26 -22
- package/esm/staking/staking.js +26 -22
- package/package.json +1 -1
- package/src/staking/staking.ts +24 -20
package/cjs/staking/staking.js
CHANGED
|
@@ -168,17 +168,19 @@ const calculateNetApy = ({ usedAssets, assetsData, optionalData, }) => {
|
|
|
168
168
|
const rate = assetData.supplyRate;
|
|
169
169
|
const supplyInterest = (0, exports.calculateInterestEarned)(amount, rate, 'year', true);
|
|
170
170
|
acc.supplyInterest = new decimal_js_1.default(acc.supplyInterest).add(supplyInterest.toString()).toString();
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
171
|
+
if (assetData.supplyIncentives) {
|
|
172
|
+
for (const supplyIncentive of assetData.supplyIncentives) {
|
|
173
|
+
const { apy, eligibilityId } = supplyIncentive;
|
|
174
|
+
const eligibilityCheck = eligibilityId ? eligibility_1.EligibilityMapping[eligibilityId] : null;
|
|
175
|
+
if (eligibilityCheck) {
|
|
176
|
+
const { isEligible, eligibleUSDAmount } = eligibilityCheck(usedAssets, optionalData);
|
|
177
|
+
const incentiveInterest = isEligible ? (0, exports.calculateInterestEarned)(eligibleUSDAmount, apy, 'year', true) : '0';
|
|
178
|
+
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
const incentiveInterest = (0, exports.calculateInterestEarned)(amount, apy, 'year', true);
|
|
182
|
+
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
183
|
+
}
|
|
182
184
|
}
|
|
183
185
|
}
|
|
184
186
|
}
|
|
@@ -188,17 +190,19 @@ const calculateNetApy = ({ usedAssets, assetsData, optionalData, }) => {
|
|
|
188
190
|
const rate = assetData.borrowRate;
|
|
189
191
|
const borrowInterest = (0, exports.calculateInterestEarned)(amount, rate, 'year', true);
|
|
190
192
|
acc.borrowInterest = new decimal_js_1.default(acc.borrowInterest).sub(borrowInterest.toString()).toString();
|
|
191
|
-
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
193
|
+
if (assetData.borrowIncentives) {
|
|
194
|
+
for (const borrowIncentive of assetData.borrowIncentives) {
|
|
195
|
+
const { apy, eligibilityId } = borrowIncentive;
|
|
196
|
+
const eligibilityCheck = eligibilityId ? eligibility_1.EligibilityMapping[eligibilityId] : null;
|
|
197
|
+
if (eligibilityCheck) {
|
|
198
|
+
const { isEligible, eligibleUSDAmount } = eligibilityCheck(usedAssets, optionalData);
|
|
199
|
+
const incentiveInterest = isEligible ? (0, exports.calculateInterestEarned)(eligibleUSDAmount, apy, 'year', true) : '0';
|
|
200
|
+
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
const incentiveInterest = (0, exports.calculateInterestEarned)(amount, apy, 'year', true);
|
|
204
|
+
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
205
|
+
}
|
|
202
206
|
}
|
|
203
207
|
}
|
|
204
208
|
}
|
package/esm/staking/staking.js
CHANGED
|
@@ -161,17 +161,19 @@ export const calculateNetApy = ({ usedAssets, assetsData, optionalData, }) => {
|
|
|
161
161
|
const rate = assetData.supplyRate;
|
|
162
162
|
const supplyInterest = calculateInterestEarned(amount, rate, 'year', true);
|
|
163
163
|
acc.supplyInterest = new Dec(acc.supplyInterest).add(supplyInterest.toString()).toString();
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
164
|
+
if (assetData.supplyIncentives) {
|
|
165
|
+
for (const supplyIncentive of assetData.supplyIncentives) {
|
|
166
|
+
const { apy, eligibilityId } = supplyIncentive;
|
|
167
|
+
const eligibilityCheck = eligibilityId ? EligibilityMapping[eligibilityId] : null;
|
|
168
|
+
if (eligibilityCheck) {
|
|
169
|
+
const { isEligible, eligibleUSDAmount } = eligibilityCheck(usedAssets, optionalData);
|
|
170
|
+
const incentiveInterest = isEligible ? calculateInterestEarned(eligibleUSDAmount, apy, 'year', true) : '0';
|
|
171
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
const incentiveInterest = calculateInterestEarned(amount, apy, 'year', true);
|
|
175
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
176
|
+
}
|
|
175
177
|
}
|
|
176
178
|
}
|
|
177
179
|
}
|
|
@@ -181,17 +183,19 @@ export const calculateNetApy = ({ usedAssets, assetsData, optionalData, }) => {
|
|
|
181
183
|
const rate = assetData.borrowRate;
|
|
182
184
|
const borrowInterest = calculateInterestEarned(amount, rate, 'year', true);
|
|
183
185
|
acc.borrowInterest = new Dec(acc.borrowInterest).sub(borrowInterest.toString()).toString();
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
186
|
+
if (assetData.borrowIncentives) {
|
|
187
|
+
for (const borrowIncentive of assetData.borrowIncentives) {
|
|
188
|
+
const { apy, eligibilityId } = borrowIncentive;
|
|
189
|
+
const eligibilityCheck = eligibilityId ? EligibilityMapping[eligibilityId] : null;
|
|
190
|
+
if (eligibilityCheck) {
|
|
191
|
+
const { isEligible, eligibleUSDAmount } = eligibilityCheck(usedAssets, optionalData);
|
|
192
|
+
const incentiveInterest = isEligible ? calculateInterestEarned(eligibleUSDAmount, apy, 'year', true) : '0';
|
|
193
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
const incentiveInterest = calculateInterestEarned(amount, apy, 'year', true);
|
|
197
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
198
|
+
}
|
|
195
199
|
}
|
|
196
200
|
}
|
|
197
201
|
}
|
package/package.json
CHANGED
package/src/staking/staking.ts
CHANGED
|
@@ -135,16 +135,18 @@ export const calculateNetApy = ({
|
|
|
135
135
|
const supplyInterest = calculateInterestEarned(amount, rate as string, 'year', true);
|
|
136
136
|
acc.supplyInterest = new Dec(acc.supplyInterest).add(supplyInterest.toString()).toString();
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
138
|
+
if (assetData.supplyIncentives) {
|
|
139
|
+
for (const supplyIncentive of assetData.supplyIncentives) {
|
|
140
|
+
const { apy, eligibilityId } = supplyIncentive;
|
|
141
|
+
const eligibilityCheck = eligibilityId ? EligibilityMapping[eligibilityId] : null;
|
|
142
|
+
if (eligibilityCheck) {
|
|
143
|
+
const { isEligible, eligibleUSDAmount } = eligibilityCheck(usedAssets, optionalData);
|
|
144
|
+
const incentiveInterest = isEligible ? calculateInterestEarned(eligibleUSDAmount, apy, 'year', true) : '0';
|
|
145
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
146
|
+
} else {
|
|
147
|
+
const incentiveInterest = calculateInterestEarned(amount, apy, 'year', true);
|
|
148
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
149
|
+
}
|
|
148
150
|
}
|
|
149
151
|
}
|
|
150
152
|
}
|
|
@@ -156,16 +158,18 @@ export const calculateNetApy = ({
|
|
|
156
158
|
const borrowInterest = calculateInterestEarned(amount, rate as string, 'year', true);
|
|
157
159
|
acc.borrowInterest = new Dec(acc.borrowInterest).sub(borrowInterest.toString()).toString();
|
|
158
160
|
|
|
159
|
-
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
161
|
+
if (assetData.borrowIncentives) {
|
|
162
|
+
for (const borrowIncentive of assetData.borrowIncentives) {
|
|
163
|
+
const { apy, eligibilityId } = borrowIncentive;
|
|
164
|
+
const eligibilityCheck = eligibilityId ? EligibilityMapping[eligibilityId] : null;
|
|
165
|
+
if (eligibilityCheck) {
|
|
166
|
+
const { isEligible, eligibleUSDAmount } = eligibilityCheck(usedAssets, optionalData);
|
|
167
|
+
const incentiveInterest = isEligible ? calculateInterestEarned(eligibleUSDAmount, apy, 'year', true) : '0';
|
|
168
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
169
|
+
} else {
|
|
170
|
+
const incentiveInterest = calculateInterestEarned(amount, apy, 'year', true);
|
|
171
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
172
|
+
}
|
|
169
173
|
}
|
|
170
174
|
}
|
|
171
175
|
}
|