@defisaver/positions-sdk 2.1.44-aave-v1-dev → 2.1.44
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/compoundV2/index.js +1 -1
- package/cjs/staking/staking.js +22 -26
- package/esm/compoundV2/index.js +1 -1
- package/esm/staking/staking.js +22 -26
- package/package.json +1 -1
- package/src/compoundV2/index.ts +1 -1
- package/src/staking/staking.ts +20 -24
package/cjs/compoundV2/index.js
CHANGED
|
@@ -66,7 +66,7 @@ const _getCompoundV2MarketsData = (provider, network) => __awaiter(void 0, void
|
|
|
66
66
|
utilization: new decimal_js_1.default(market.totalBorrow.toString()).div(totalSupply).times(100).toString(),
|
|
67
67
|
totalSupply: (0, tokens_1.assetAmountInEth)(totalSupply, (0, utils_1.handleWbtcLegacy)(symbol)),
|
|
68
68
|
totalBorrow: (0, tokens_1.assetAmountInEth)(totalBorrow, (0, utils_1.handleWbtcLegacy)(symbol)),
|
|
69
|
-
exchangeRate: new decimal_js_1.default(market.exchangeRate.toString()).div(1e28).toString(),
|
|
69
|
+
exchangeRate: new decimal_js_1.default(market.exchangeRate.toString()).div(1e28).mul(Math.pow(10, pricePrecisionDiff)).toString(),
|
|
70
70
|
borrowCap: (0, tokens_1.assetAmountInEth)(borrowCap, (0, utils_1.handleWbtcLegacy)(symbol)),
|
|
71
71
|
canBeBorrowed: market.canBorrow,
|
|
72
72
|
canBeSupplied: market.canMint,
|
package/cjs/staking/staking.js
CHANGED
|
@@ -168,19 +168,17 @@ 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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
183
|
-
}
|
|
171
|
+
for (const supplyIncentive of assetData.supplyIncentives) {
|
|
172
|
+
const { apy, eligibilityId } = supplyIncentive;
|
|
173
|
+
const eligibilityCheck = eligibilityId ? eligibility_1.EligibilityMapping[eligibilityId] : null;
|
|
174
|
+
if (eligibilityCheck) {
|
|
175
|
+
const { isEligible, eligibleUSDAmount } = eligibilityCheck(usedAssets, optionalData);
|
|
176
|
+
const incentiveInterest = isEligible ? (0, exports.calculateInterestEarned)(eligibleUSDAmount, apy, 'year', true) : '0';
|
|
177
|
+
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
const incentiveInterest = (0, exports.calculateInterestEarned)(amount, apy, 'year', true);
|
|
181
|
+
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
184
182
|
}
|
|
185
183
|
}
|
|
186
184
|
}
|
|
@@ -190,19 +188,17 @@ const calculateNetApy = ({ usedAssets, assetsData, optionalData, }) => {
|
|
|
190
188
|
const rate = assetData.borrowRate;
|
|
191
189
|
const borrowInterest = (0, exports.calculateInterestEarned)(amount, rate, 'year', true);
|
|
192
190
|
acc.borrowInterest = new decimal_js_1.default(acc.borrowInterest).sub(borrowInterest.toString()).toString();
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
205
|
-
}
|
|
191
|
+
for (const borrowIncentive of assetData.borrowIncentives) {
|
|
192
|
+
const { apy, eligibilityId } = borrowIncentive;
|
|
193
|
+
const eligibilityCheck = eligibilityId ? eligibility_1.EligibilityMapping[eligibilityId] : null;
|
|
194
|
+
if (eligibilityCheck) {
|
|
195
|
+
const { isEligible, eligibleUSDAmount } = eligibilityCheck(usedAssets, optionalData);
|
|
196
|
+
const incentiveInterest = isEligible ? (0, exports.calculateInterestEarned)(eligibleUSDAmount, apy, 'year', true) : '0';
|
|
197
|
+
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
const incentiveInterest = (0, exports.calculateInterestEarned)(amount, apy, 'year', true);
|
|
201
|
+
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
206
202
|
}
|
|
207
203
|
}
|
|
208
204
|
}
|
package/esm/compoundV2/index.js
CHANGED
|
@@ -60,7 +60,7 @@ export const _getCompoundV2MarketsData = (provider, network) => __awaiter(void 0
|
|
|
60
60
|
utilization: new Dec(market.totalBorrow.toString()).div(totalSupply).times(100).toString(),
|
|
61
61
|
totalSupply: assetAmountInEth(totalSupply, handleWbtcLegacy(symbol)),
|
|
62
62
|
totalBorrow: assetAmountInEth(totalBorrow, handleWbtcLegacy(symbol)),
|
|
63
|
-
exchangeRate: new Dec(market.exchangeRate.toString()).div(1e28).toString(),
|
|
63
|
+
exchangeRate: new Dec(market.exchangeRate.toString()).div(1e28).mul(Math.pow(10, pricePrecisionDiff)).toString(),
|
|
64
64
|
borrowCap: assetAmountInEth(borrowCap, handleWbtcLegacy(symbol)),
|
|
65
65
|
canBeBorrowed: market.canBorrow,
|
|
66
66
|
canBeSupplied: market.canMint,
|
package/esm/staking/staking.js
CHANGED
|
@@ -161,19 +161,17 @@ 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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
176
|
-
}
|
|
164
|
+
for (const supplyIncentive of assetData.supplyIncentives) {
|
|
165
|
+
const { apy, eligibilityId } = supplyIncentive;
|
|
166
|
+
const eligibilityCheck = eligibilityId ? EligibilityMapping[eligibilityId] : null;
|
|
167
|
+
if (eligibilityCheck) {
|
|
168
|
+
const { isEligible, eligibleUSDAmount } = eligibilityCheck(usedAssets, optionalData);
|
|
169
|
+
const incentiveInterest = isEligible ? calculateInterestEarned(eligibleUSDAmount, apy, 'year', true) : '0';
|
|
170
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
const incentiveInterest = calculateInterestEarned(amount, apy, 'year', true);
|
|
174
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
177
175
|
}
|
|
178
176
|
}
|
|
179
177
|
}
|
|
@@ -183,19 +181,17 @@ export const calculateNetApy = ({ usedAssets, assetsData, optionalData, }) => {
|
|
|
183
181
|
const rate = assetData.borrowRate;
|
|
184
182
|
const borrowInterest = calculateInterestEarned(amount, rate, 'year', true);
|
|
185
183
|
acc.borrowInterest = new Dec(acc.borrowInterest).sub(borrowInterest.toString()).toString();
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
198
|
-
}
|
|
184
|
+
for (const borrowIncentive of assetData.borrowIncentives) {
|
|
185
|
+
const { apy, eligibilityId } = borrowIncentive;
|
|
186
|
+
const eligibilityCheck = eligibilityId ? EligibilityMapping[eligibilityId] : null;
|
|
187
|
+
if (eligibilityCheck) {
|
|
188
|
+
const { isEligible, eligibleUSDAmount } = eligibilityCheck(usedAssets, optionalData);
|
|
189
|
+
const incentiveInterest = isEligible ? calculateInterestEarned(eligibleUSDAmount, apy, 'year', true) : '0';
|
|
190
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
const incentiveInterest = calculateInterestEarned(amount, apy, 'year', true);
|
|
194
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
199
195
|
}
|
|
200
196
|
}
|
|
201
197
|
}
|
package/package.json
CHANGED
package/src/compoundV2/index.ts
CHANGED
|
@@ -64,7 +64,7 @@ export const _getCompoundV2MarketsData = async (provider: Client, network: Netwo
|
|
|
64
64
|
utilization: new Dec(market.totalBorrow.toString()).div(totalSupply).times(100).toString(),
|
|
65
65
|
totalSupply: assetAmountInEth(totalSupply, handleWbtcLegacy(symbol)),
|
|
66
66
|
totalBorrow: assetAmountInEth(totalBorrow, handleWbtcLegacy(symbol)),
|
|
67
|
-
exchangeRate: new Dec(market.exchangeRate.toString()).div(1e28).toString(),
|
|
67
|
+
exchangeRate: new Dec(market.exchangeRate.toString()).div(1e28).mul(10 ** pricePrecisionDiff).toString(),
|
|
68
68
|
borrowCap: assetAmountInEth(borrowCap, handleWbtcLegacy(symbol)),
|
|
69
69
|
canBeBorrowed: market.canBorrow,
|
|
70
70
|
canBeSupplied: market.canMint,
|
package/src/staking/staking.ts
CHANGED
|
@@ -135,18 +135,16 @@ 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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
149
|
-
}
|
|
138
|
+
for (const supplyIncentive of assetData.supplyIncentives) {
|
|
139
|
+
const { apy, eligibilityId } = supplyIncentive;
|
|
140
|
+
const eligibilityCheck = eligibilityId ? EligibilityMapping[eligibilityId] : null;
|
|
141
|
+
if (eligibilityCheck) {
|
|
142
|
+
const { isEligible, eligibleUSDAmount } = eligibilityCheck(usedAssets, optionalData);
|
|
143
|
+
const incentiveInterest = isEligible ? calculateInterestEarned(eligibleUSDAmount, apy, 'year', true) : '0';
|
|
144
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
145
|
+
} else {
|
|
146
|
+
const incentiveInterest = calculateInterestEarned(amount, apy, 'year', true);
|
|
147
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
150
148
|
}
|
|
151
149
|
}
|
|
152
150
|
}
|
|
@@ -158,18 +156,16 @@ export const calculateNetApy = ({
|
|
|
158
156
|
const borrowInterest = calculateInterestEarned(amount, rate as string, 'year', true);
|
|
159
157
|
acc.borrowInterest = new Dec(acc.borrowInterest).sub(borrowInterest.toString()).toString();
|
|
160
158
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
172
|
-
}
|
|
159
|
+
for (const borrowIncentive of assetData.borrowIncentives) {
|
|
160
|
+
const { apy, eligibilityId } = borrowIncentive;
|
|
161
|
+
const eligibilityCheck = eligibilityId ? EligibilityMapping[eligibilityId] : null;
|
|
162
|
+
if (eligibilityCheck) {
|
|
163
|
+
const { isEligible, eligibleUSDAmount } = eligibilityCheck(usedAssets, optionalData);
|
|
164
|
+
const incentiveInterest = isEligible ? calculateInterestEarned(eligibleUSDAmount, apy, 'year', true) : '0';
|
|
165
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
166
|
+
} else {
|
|
167
|
+
const incentiveInterest = calculateInterestEarned(amount, apy, 'year', true);
|
|
168
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
173
169
|
}
|
|
174
170
|
}
|
|
175
171
|
}
|