@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.
@@ -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,
@@ -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
- 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
- }
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
- 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
- }
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
  }
@@ -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,
@@ -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
- 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
- }
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
- 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
- }
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/positions-sdk",
3
- "version": "2.1.44-aave-v1-dev",
3
+ "version": "2.1.44",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -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,
@@ -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
- 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
- }
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
- 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
- }
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
  }