@gearbox-protocol/sdk 2.1.34 → 3.0.0-next.2
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/lib/apy/convexAPY.d.ts +4 -6
- package/lib/apy/convexAPY.js +15 -16
- package/lib/apy/curveAPY.d.ts +2 -2
- package/lib/apy/curveAPY.js +3 -4
- package/lib/apy/index.d.ts +1 -1
- package/lib/apy/index.js +2 -2
- package/lib/apy/lidoAPY.js +2 -2
- package/lib/apy/yearnAPY.d.ts +1 -1
- package/lib/apy/yearnAPY.js +3 -5
- package/lib/contracts/contractsRegister.d.ts +1 -1
- package/lib/contracts/contractsRegister.js +6 -7
- package/lib/core/creditAccount.js +20 -22
- package/lib/core/creditAccount.spec.js +32 -34
- package/lib/core/creditManager.js +16 -17
- package/lib/core/creditSession.js +12 -13
- package/lib/core/events.js +34 -35
- package/lib/core/pool/data.js +22 -23
- package/lib/core/priceOracle.js +3 -3
- package/lib/core/rewardClaimer.d.ts +1 -3
- package/lib/core/rewardConvex.d.ts +1 -4
- package/lib/core/rewardConvex.js +7 -10
- package/lib/core/rewardConvex.spec.js +15 -16
- package/lib/core/strategy.js +14 -16
- package/lib/core/strategy.spec.js +20 -22
- package/lib/core/trade.d.ts +1 -1
- package/lib/core/trade.js +12 -15
- package/lib/core/transactions.d.ts +1 -1
- package/lib/core/transactions.js +18 -20
- package/lib/index.d.ts +2 -20
- package/lib/index.js +27 -24
- package/lib/parsers/ERC20Parser.d.ts +1 -1
- package/lib/parsers/abstractParser.d.ts +1 -1
- package/lib/parsers/abstractParser.js +3 -4
- package/lib/parsers/convexBaseRewardPoolAdapterParser.d.ts +1 -1
- package/lib/parsers/convexBaseRewardPoolAdapterParser.js +2 -2
- package/lib/parsers/convexBaseRewardPoolAdapterParser.spec.js +4 -4
- package/lib/parsers/convexBoosterAdapterParser.d.ts +1 -1
- package/lib/parsers/convexBoosterAdapterParser.js +3 -3
- package/lib/parsers/convexBoosterAdapterParser.spec.js +3 -3
- package/lib/parsers/convextRewardPoolParser.d.ts +1 -1
- package/lib/parsers/creditFacadeParser.d.ts +1 -1
- package/lib/parsers/creditFacadeParser.spec.js +8 -9
- package/lib/parsers/curveAdapterParser.d.ts +1 -2
- package/lib/parsers/curveAdapterParser.js +5 -5
- package/lib/parsers/curveAdapterParser.spec.js +13 -13
- package/lib/parsers/lidoAdapterParser.d.ts +1 -1
- package/lib/parsers/lidoAdapterParser.spec.js +2 -2
- package/lib/parsers/lidoSTETHParser.d.ts +1 -1
- package/lib/parsers/txParser.d.ts +1 -3
- package/lib/parsers/txParser.js +12 -15
- package/lib/parsers/uniV2AdapterParser.d.ts +1 -1
- package/lib/parsers/uniV2AdapterParser.spec.js +15 -16
- package/lib/parsers/uniV3AdapterParser.d.ts +1 -1
- package/lib/parsers/uniV3AdapterParser.spec.js +15 -16
- package/lib/parsers/wstETHAdapterParser.d.ts +1 -1
- package/lib/parsers/wstETHAdapterParser.spec.js +3 -3
- package/lib/parsers/yearnAdapterParser.spec.js +12 -12
- package/lib/parsers/yearnV2AdapterParser.d.ts +1 -1
- package/lib/parsers/yearnV2AdapterParser.js +2 -2
- package/lib/pathfinder/pathOptions.d.ts +1 -2
- package/lib/pathfinder/pathOptions.js +12 -16
- package/lib/pathfinder/pathOptions.spec.js +36 -36
- package/lib/pathfinder/pathfinder.d.ts +1 -2
- package/lib/pathfinder/pathfinder.js +9 -10
- package/lib/pathfinder/pathfinder.spec.js +11 -12
- package/lib/payload/creditAccount.d.ts +1 -1
- package/lib/payload/creditManager.d.ts +1 -1
- package/lib/payload/pool.d.ts +1 -1
- package/lib/tokens/tokenData.d.ts +0 -4
- package/lib/tokens/tokenData.js +1 -16
- package/lib/utils/formatter.js +3 -3
- package/lib/utils/math.js +5 -5
- package/lib/utils/price.js +4 -4
- package/lib/watchers/creditAccountWatcher.js +2 -2
- package/lib/watchers/creditAccountWatcher.spec.js +18 -18
- package/lib/watchers/creditManagerWatcher.spec.js +19 -19
- package/package.json +2 -1
- package/lib/contracts/adapters.d.ts +0 -24
- package/lib/contracts/adapters.js +0 -28
- package/lib/contracts/contracts.d.ts +0 -112
- package/lib/contracts/contracts.js +0 -654
- package/lib/contracts/protocols.d.ts +0 -12
- package/lib/contracts/protocols.js +0 -16
- package/lib/contracts/utilsContracts.d.ts +0 -7
- package/lib/contracts/utilsContracts.js +0 -28
- package/lib/core/chains.d.ts +0 -23
- package/lib/core/chains.js +0 -63
- package/lib/core/constants.d.ts +0 -21
- package/lib/core/constants.js +0 -31
- package/lib/tokens/aave.d.ts +0 -20
- package/lib/tokens/aave.js +0 -62
- package/lib/tokens/balancer.d.ts +0 -12
- package/lib/tokens/balancer.js +0 -36
- package/lib/tokens/compound.d.ts +0 -11
- package/lib/tokens/compound.js +0 -38
- package/lib/tokens/convex.d.ts +0 -30
- package/lib/tokens/convex.js +0 -262
- package/lib/tokens/curveLP.d.ts +0 -27
- package/lib/tokens/curveLP.js +0 -141
- package/lib/tokens/decimals.d.ts +0 -2
- package/lib/tokens/decimals.js +0 -115
- package/lib/tokens/gear.d.ts +0 -14
- package/lib/tokens/gear.js +0 -47
- package/lib/tokens/normal.d.ts +0 -9
- package/lib/tokens/normal.js +0 -194
- package/lib/tokens/quoted.d.ts +0 -3
- package/lib/tokens/quoted.js +0 -7
- package/lib/tokens/token.d.ts +0 -25
- package/lib/tokens/token.js +0 -305
- package/lib/tokens/tokenType.d.ts +0 -15
- package/lib/tokens/tokenType.js +0 -19
- package/lib/tokens/tokens.spec.d.ts +0 -1
- package/lib/tokens/tokens.spec.js +0 -151
- package/lib/tokens/yearn.d.ts +0 -26
- package/lib/tokens/yearn.js +0 -52
- package/lib/utils/mappers.d.ts +0 -8
- package/lib/utils/mappers.js +0 -13
- package/lib/utils/multicall.d.ts +0 -36
- package/lib/utils/multicall.js +0 -90
- package/lib/utils/safeEnum.d.ts +0 -1
- package/lib/utils/safeEnum.js +0 -10
- package/lib/utils/types.d.ts +0 -10
- package/lib/utils/types.js +0 -2
|
@@ -4,10 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.UserCreditSessionsBuilder = exports.CreditSessionFiltered = exports.CreditSession = exports.CREDIT_SESSION_ID_BY_STATUS = exports.CREDIT_SESSION_STATUS_BY_ID = void 0;
|
|
7
|
+
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
7
8
|
const moment_1 = __importDefault(require("moment"));
|
|
8
9
|
const formatter_1 = require("../utils/formatter");
|
|
9
|
-
const mappers_1 = require("../utils/mappers");
|
|
10
|
-
const constants_1 = require("./constants");
|
|
11
10
|
exports.CREDIT_SESSION_STATUS_BY_ID = {
|
|
12
11
|
0: "active",
|
|
13
12
|
1: "closed",
|
|
@@ -16,7 +15,7 @@ exports.CREDIT_SESSION_STATUS_BY_ID = {
|
|
|
16
15
|
4: "liquidateExpired",
|
|
17
16
|
5: "liquidatePaused",
|
|
18
17
|
};
|
|
19
|
-
exports.CREDIT_SESSION_ID_BY_STATUS =
|
|
18
|
+
exports.CREDIT_SESSION_ID_BY_STATUS = sdk_gov_1.TypedObjectUtils.swapKeyValue(exports.CREDIT_SESSION_STATUS_BY_ID);
|
|
20
19
|
class CreditSession {
|
|
21
20
|
id;
|
|
22
21
|
status;
|
|
@@ -87,14 +86,14 @@ class CreditSession {
|
|
|
87
86
|
this.quoteToken = (payload.quoteToken || "").toLowerCase();
|
|
88
87
|
this.borrowAPY_RAY = (0, formatter_1.toBigInt)(payload.borrowAPY_RAY || 0);
|
|
89
88
|
this.borrowAPY7DAverage =
|
|
90
|
-
(payload.borrowAPY7DAverage || 0) * Number(
|
|
89
|
+
(payload.borrowAPY7DAverage || 0) * Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
91
90
|
this.totalValueUSD = payload.totalValueUSD || 0;
|
|
92
91
|
this.debt = (0, formatter_1.toBigInt)(payload.debt || 0);
|
|
93
92
|
this.debtUSD = payload.debtUSD || 0;
|
|
94
93
|
this.leverage = payload.leverage || 0;
|
|
95
|
-
this.tfIndex = (payload.tfIndex || 0) * Number(
|
|
96
|
-
this.roi = (payload.roi || 0) / Number(
|
|
97
|
-
this.apy = (payload.apy || 0) / Number(
|
|
94
|
+
this.tfIndex = (payload.tfIndex || 0) * Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
95
|
+
this.roi = (payload.roi || 0) / Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
96
|
+
this.apy = (payload.apy || 0) / Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
98
97
|
this.currentBlock = payload.currentBlock || 0;
|
|
99
98
|
this.currentTimestamp = payload.currentTimestamp || 0;
|
|
100
99
|
this.spotDebt = (0, formatter_1.toBigInt)(payload.spotDebt || 0);
|
|
@@ -164,7 +163,7 @@ class CreditSessionFiltered {
|
|
|
164
163
|
this.totalValueUSD = payload.totalValueUSD || 0;
|
|
165
164
|
this.profitInUSD = payload.pnlUSD || 0;
|
|
166
165
|
this.profitInUnderlying = payload.pnl || 0;
|
|
167
|
-
this.tfIndex = (payload.tfIndex || 0) * Number(
|
|
166
|
+
this.tfIndex = (payload.tfIndex || 0) * Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
168
167
|
this.balances = Object.entries(payload.balances || {}).map(([token, balance]) => ({
|
|
169
168
|
token: token.toLowerCase(),
|
|
170
169
|
balance: (0, formatter_1.toBigInt)(balance.BI || 0),
|
|
@@ -178,7 +177,7 @@ class UserCreditSessionsBuilder {
|
|
|
178
177
|
const { accounts, totalValue10kBasis = 0, ...sessionsUnfiltered } = payload;
|
|
179
178
|
return {
|
|
180
179
|
...sessionsUnfiltered,
|
|
181
|
-
totalValueChange: totalValue10kBasis * Number(
|
|
180
|
+
totalValueChange: totalValue10kBasis * Number(sdk_gov_1.PERCENTAGE_DECIMALS),
|
|
182
181
|
accounts: accounts.map(p => new CreditSession(p)),
|
|
183
182
|
};
|
|
184
183
|
}
|
|
@@ -188,10 +187,10 @@ class UserCreditSessionsBuilder {
|
|
|
188
187
|
...rest,
|
|
189
188
|
leverage: leverage,
|
|
190
189
|
leverageOld: leverageOld,
|
|
191
|
-
healthFactorChange: healthFactor10kBasis * Number(
|
|
192
|
-
leverageChange: leverage10kBasis * Number(
|
|
193
|
-
activeAccountsChange: activeAccounts10kBasis * Number(
|
|
194
|
-
openedAccountsChange: openedAccounts10kBasis * Number(
|
|
190
|
+
healthFactorChange: healthFactor10kBasis * Number(sdk_gov_1.PERCENTAGE_DECIMALS),
|
|
191
|
+
leverageChange: leverage10kBasis * Number(sdk_gov_1.PERCENTAGE_DECIMALS),
|
|
192
|
+
activeAccountsChange: activeAccounts10kBasis * Number(sdk_gov_1.PERCENTAGE_DECIMALS),
|
|
193
|
+
openedAccountsChange: openedAccounts10kBasis * Number(sdk_gov_1.PERCENTAGE_DECIMALS),
|
|
195
194
|
healthFactor: (0, formatter_1.toBigInt)(healthFactor || 0),
|
|
196
195
|
healthFactorOld: (0, formatter_1.toBigInt)(healthFactorOld || 0),
|
|
197
196
|
};
|
package/lib/core/events.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EventEmergencyLiquidatorRemoved = exports.EventEmergencyLiquidatorAdded = exports.EventRemovedFromUpgradeable = exports.EventAddedToUpgradeable = exports.EventLimitPerBlockUpdated = exports.EventMaxEnabledTokensUpdated = exports.EventExpirationDateUpdated = exports.EventIncreaseDebtForbiddenModeChanged = exports.EventLTUpdated = exports.EventNewConfigurator = exports.EventCreditFacadeUpgraded = exports.EventFeesUpdated = exports.EventLimitsUpdated = exports.EventTokenAllowedV2 = exports.EventTransferOwnership = exports.EventUnPausableAdminRemoved = exports.EventUnPausableAdminAdded = exports.EventPausableAdminRemoved = exports.EventPausableAdminAdded = exports.EventUnPaused = exports.EventPaused = exports.EventTakeForever = exports.EventNewPriceFeed = exports.EventNewWithdrawFee = exports.EventNewExpectedLiquidityLimit = exports.EventBorrowForbidden = exports.EventNewCreditManagerConnected = exports.EventNewInterestRateModel = exports.EventTransferPluginAllowed = exports.EventPriceOracleUpdated = exports.EventNewFastCheckParameters = exports.EventContractForbidden = exports.EventContractAllowed = exports.EventTokenForbidden = exports.EventTokenAllowed = exports.EventCMNewParameters = exports.EventDecreaseBorrowAmount = exports.EventIncreaseBorrowAmount = exports.EventAddCollateral = exports.EventRepayCreditAccount = exports.EventLiquidateCreditAccount = exports.EventCloseCreditAccount = exports.EventOpenCreditAccount = exports.EventRemoveLiquidity = exports.EventAddLiquidity = exports.EventParser = void 0;
|
|
4
|
+
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
4
5
|
const contractsRegister_1 = require("../contracts/contractsRegister");
|
|
5
|
-
const token_1 = require("../tokens/token");
|
|
6
6
|
const formatter_1 = require("../utils/formatter");
|
|
7
|
-
const constants_1 = require("./constants");
|
|
8
7
|
const eventOrTx_1 = require("./eventOrTx");
|
|
9
8
|
class EventParser {
|
|
10
9
|
static serialize(items) {
|
|
@@ -124,7 +123,7 @@ class EventAddLiquidity extends eventOrTx_1.EVMEvent {
|
|
|
124
123
|
this.pool = opts.pool;
|
|
125
124
|
}
|
|
126
125
|
toString() {
|
|
127
|
-
const [symbol, decimals = 18] = (0,
|
|
126
|
+
const [symbol, decimals = 18] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
128
127
|
return `Pool ${(0, contractsRegister_1.getContractName)(this.pool)}: Deposit ${(0, formatter_1.formatBN)(this.amount, decimals)} ${symbol}`;
|
|
129
128
|
}
|
|
130
129
|
}
|
|
@@ -142,7 +141,7 @@ class EventRemoveLiquidity extends eventOrTx_1.EVMEvent {
|
|
|
142
141
|
this.pool = opts.pool;
|
|
143
142
|
}
|
|
144
143
|
toString() {
|
|
145
|
-
const [symbol, decimals = 18] = (0,
|
|
144
|
+
const [symbol, decimals = 18] = (0, sdk_gov_1.extractTokenData)(this.dieselToken);
|
|
146
145
|
return `Pool ${(0, contractsRegister_1.getContractName)(this.pool)}: withdraw ${(0, formatter_1.formatBN)(this.amount, decimals)} ${symbol}`;
|
|
147
146
|
}
|
|
148
147
|
}
|
|
@@ -158,7 +157,7 @@ class EventOpenCreditAccount extends eventOrTx_1.EVMEvent {
|
|
|
158
157
|
this.creditManager = opts.creditManager;
|
|
159
158
|
}
|
|
160
159
|
toString() {
|
|
161
|
-
const [symbol, decimals = 18] = (0,
|
|
160
|
+
const [symbol, decimals = 18] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
162
161
|
return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: opened with debt ${(0, formatter_1.formatBN)(this.amount, decimals)} ${symbol}`;
|
|
163
162
|
}
|
|
164
163
|
}
|
|
@@ -187,7 +186,7 @@ class EventLiquidateCreditAccount extends eventOrTx_1.EVMEvent {
|
|
|
187
186
|
this.creditManager = opts.creditManager;
|
|
188
187
|
}
|
|
189
188
|
toString() {
|
|
190
|
-
const [symbol, decimals = 18] = (0,
|
|
189
|
+
const [symbol, decimals = 18] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
191
190
|
return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: was liquidated. ${(0, formatter_1.formatBN)(this.amount, decimals)} ${symbol} were paid back as remaining funds`;
|
|
192
191
|
}
|
|
193
192
|
}
|
|
@@ -216,7 +215,7 @@ class EventAddCollateral extends eventOrTx_1.EVMEvent {
|
|
|
216
215
|
this.creditManager = opts.creditManager;
|
|
217
216
|
}
|
|
218
217
|
toString() {
|
|
219
|
-
const [symbol, decimals = 18] = (0,
|
|
218
|
+
const [symbol, decimals = 18] = (0, sdk_gov_1.extractTokenData)(this.addedToken);
|
|
220
219
|
return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: added ${(0, formatter_1.formatBN)(this.amount, decimals)} ${symbol} as collateral`;
|
|
221
220
|
}
|
|
222
221
|
}
|
|
@@ -232,7 +231,7 @@ class EventIncreaseBorrowAmount extends eventOrTx_1.EVMEvent {
|
|
|
232
231
|
this.creditManager = opts.creditManager;
|
|
233
232
|
}
|
|
234
233
|
toString() {
|
|
235
|
-
const [symbol, decimals = 18] = (0,
|
|
234
|
+
const [symbol, decimals = 18] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
236
235
|
return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: borrowed amount was increased for ${(0, formatter_1.formatBN)(this.amount, decimals)} ${symbol}`;
|
|
237
236
|
}
|
|
238
237
|
}
|
|
@@ -248,7 +247,7 @@ class EventDecreaseBorrowAmount extends eventOrTx_1.EVMEvent {
|
|
|
248
247
|
this.creditManager = opts.creditManager;
|
|
249
248
|
}
|
|
250
249
|
toString() {
|
|
251
|
-
const [symbol, decimals = 18] = (0,
|
|
250
|
+
const [symbol, decimals = 18] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
252
251
|
return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: borrowed amount was decreased for ${(0, formatter_1.formatBN)(this.amount, decimals)} ${symbol}`;
|
|
253
252
|
}
|
|
254
253
|
}
|
|
@@ -286,7 +285,7 @@ class EventCMNewParameters extends eventOrTx_1.EVMEvent {
|
|
|
286
285
|
this.prevLiquidationDiscount = opts.prevLiquidationDiscount;
|
|
287
286
|
}
|
|
288
287
|
toString() {
|
|
289
|
-
const [symbol, decimals = 18] = (0,
|
|
288
|
+
const [symbol, decimals = 18] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
290
289
|
let msg = `Credit manager ${(0, contractsRegister_1.getContractName)(this.creditManager)} updated: `;
|
|
291
290
|
if (this.minAmount !== this.prevMinAmount) {
|
|
292
291
|
msg += `min amount: ${(0, formatter_1.formatBN)(this.prevMinAmount, decimals)} => ${(0, formatter_1.formatBN)(this.minAmount, decimals)} ${symbol}, `;
|
|
@@ -295,18 +294,18 @@ class EventCMNewParameters extends eventOrTx_1.EVMEvent {
|
|
|
295
294
|
msg += `max amount: ${(0, formatter_1.formatBN)(this.prevMaxAmount, decimals)} => ${(0, formatter_1.formatBN)(this.maxAmount, decimals)} ${symbol}, `;
|
|
296
295
|
}
|
|
297
296
|
if (this.maxLeverage !== this.prevMaxLeverage) {
|
|
298
|
-
msg += `max leverage: ${this.prevMaxLeverage / Number(
|
|
297
|
+
msg += `max leverage: ${this.prevMaxLeverage / Number(sdk_gov_1.LEVERAGE_DECIMALS) + 1} => ${this.maxLeverage / Number(sdk_gov_1.LEVERAGE_DECIMALS) + 1}, `;
|
|
299
298
|
}
|
|
300
299
|
if (this.feeInterest !== this.prevFeeInterest) {
|
|
301
|
-
msg += `interest fee: ${this.prevFeeInterest / Number(
|
|
300
|
+
msg += `interest fee: ${this.prevFeeInterest / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}% => ${this.feeInterest / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}%, `;
|
|
302
301
|
}
|
|
303
302
|
if (this.feeLiquidation !== this.prevFeeLiquidation) {
|
|
304
|
-
msg += `liquidation fee: ${this.prevFeeLiquidation / Number(
|
|
303
|
+
msg += `liquidation fee: ${this.prevFeeLiquidation / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}% => ${this.feeLiquidation / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}%, `;
|
|
305
304
|
}
|
|
306
305
|
if (this.liquidationDiscount !== this.prevLiquidationDiscount) {
|
|
307
|
-
msg += `liquidation premium: ${Number(
|
|
308
|
-
this.prevLiquidationDiscount / Number(
|
|
309
|
-
this.liquidationDiscount / Number(
|
|
306
|
+
msg += `liquidation premium: ${Number(sdk_gov_1.PERCENTAGE_DECIMALS) -
|
|
307
|
+
this.prevLiquidationDiscount / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}% => ${Number(sdk_gov_1.PERCENTAGE_DECIMALS) -
|
|
308
|
+
this.liquidationDiscount / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}%, `;
|
|
310
309
|
}
|
|
311
310
|
return msg.slice(0, msg.length - 2);
|
|
312
311
|
}
|
|
@@ -327,15 +326,15 @@ class EventTokenAllowed extends eventOrTx_1.EVMEvent {
|
|
|
327
326
|
this.status = opts.status;
|
|
328
327
|
}
|
|
329
328
|
toString() {
|
|
330
|
-
const [symbol] = (0,
|
|
329
|
+
const [symbol] = (0, sdk_gov_1.extractTokenData)(this.token);
|
|
331
330
|
const msg = `Credit manager ${(0, contractsRegister_1.getContractName)(this.creditManager)} updated `;
|
|
332
331
|
switch (this.status) {
|
|
333
332
|
case "NewToken":
|
|
334
|
-
return `${msg}: New token allowed: ${symbol}, liquidation threshold: ${this.liquidityThreshold / Number(
|
|
333
|
+
return `${msg}: New token allowed: ${symbol}, liquidation threshold: ${this.liquidityThreshold / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}%`;
|
|
335
334
|
case "Allowed":
|
|
336
|
-
return `${msg}: ${symbol} is allowed now, liquidation threshold: ${this.liquidityThreshold / Number(
|
|
335
|
+
return `${msg}: ${symbol} is allowed now, liquidation threshold: ${this.liquidityThreshold / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}%`;
|
|
337
336
|
case "LTUpdated":
|
|
338
|
-
return `${msg}: ${symbol} liquidation threshold: ${(this.prevLiquidationThreshold || 0) / Number(
|
|
337
|
+
return `${msg}: ${symbol} liquidation threshold: ${(this.prevLiquidationThreshold || 0) / Number(sdk_gov_1.PERCENTAGE_DECIMALS)} => ${this.liquidityThreshold / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}%`;
|
|
339
338
|
default:
|
|
340
339
|
return "Error: TokenAllowedProps";
|
|
341
340
|
}
|
|
@@ -351,7 +350,7 @@ class EventTokenForbidden extends eventOrTx_1.EVMEvent {
|
|
|
351
350
|
this.token = opts.token;
|
|
352
351
|
}
|
|
353
352
|
toString() {
|
|
354
|
-
const [symbol] = (0,
|
|
353
|
+
const [symbol] = (0, sdk_gov_1.extractTokenData)(this.token);
|
|
355
354
|
return `Credit manager ${(0, contractsRegister_1.getContractName)(this.creditManager)} updated ${symbol} forbidden`;
|
|
356
355
|
}
|
|
357
356
|
}
|
|
@@ -500,7 +499,7 @@ class EventNewExpectedLiquidityLimit extends eventOrTx_1.EVMEvent {
|
|
|
500
499
|
this.prevLimit = (0, formatter_1.toBigInt)(opts.oldLimit || 0);
|
|
501
500
|
}
|
|
502
501
|
toString() {
|
|
503
|
-
const [symbol, decimals = 18] = (0,
|
|
502
|
+
const [symbol, decimals = 18] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
504
503
|
return this.prevLimit === 0n
|
|
505
504
|
? `Pool ${(0, contractsRegister_1.getContractName)(this.pool)} updated: expected liquidity limit was set to ${(0, formatter_1.formatBN)(this.newLimit, decimals)} ${symbol}`
|
|
506
505
|
: `Pool ${(0, contractsRegister_1.getContractName)(this.pool)} updated: expected liquidity limit was ${this.newLimit > this.prevLimit ? "increased" : "decreased"}: ${(0, formatter_1.formatBN)(this.prevLimit, decimals)} ${symbol} => ${(0, formatter_1.formatBN)(this.newLimit, decimals)} ${symbol}`;
|
|
@@ -521,8 +520,8 @@ class EventNewWithdrawFee extends eventOrTx_1.EVMEvent {
|
|
|
521
520
|
}
|
|
522
521
|
toString() {
|
|
523
522
|
return this.prevFee === 0
|
|
524
|
-
? `Pool ${(0, contractsRegister_1.getContractName)(this.pool)} updated: withdraw fee was set to: ${this.newFee / Number(
|
|
525
|
-
: `Pool ${(0, contractsRegister_1.getContractName)(this.pool)} updated: withdraw fee was ${this.newFee > this.prevFee ? "increased" : "decreased"}: ${this.prevFee / Number(
|
|
523
|
+
? `Pool ${(0, contractsRegister_1.getContractName)(this.pool)} updated: withdraw fee was set to: ${this.newFee / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}%`
|
|
524
|
+
: `Pool ${(0, contractsRegister_1.getContractName)(this.pool)} updated: withdraw fee was ${this.newFee > this.prevFee ? "increased" : "decreased"}: ${this.prevFee / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}% => ${this.newFee / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}%`;
|
|
526
525
|
}
|
|
527
526
|
}
|
|
528
527
|
exports.EventNewWithdrawFee = EventNewWithdrawFee;
|
|
@@ -535,7 +534,7 @@ class EventNewPriceFeed extends eventOrTx_1.EVMEvent {
|
|
|
535
534
|
this.priceFeed = opts.priceFeed;
|
|
536
535
|
}
|
|
537
536
|
toString() {
|
|
538
|
-
const [symbol] = (0,
|
|
537
|
+
const [symbol] = (0, sdk_gov_1.extractTokenData)(this.token);
|
|
539
538
|
return `PriceOracle: oracle for ${symbol} was updated to ${(0, contractsRegister_1.getContractName)(this.priceFeed)}`;
|
|
540
539
|
}
|
|
541
540
|
}
|
|
@@ -646,15 +645,15 @@ class EventTokenAllowedV2 extends eventOrTx_1.EVMEvent {
|
|
|
646
645
|
this.status = opts.status;
|
|
647
646
|
}
|
|
648
647
|
toString() {
|
|
649
|
-
const [symbol] = (0,
|
|
648
|
+
const [symbol] = (0, sdk_gov_1.extractTokenData)(this.token);
|
|
650
649
|
const msg = `Credit manager ${(0, contractsRegister_1.getContractName)(this.creditManager)} updated `;
|
|
651
650
|
switch (this.status) {
|
|
652
651
|
case "NewToken":
|
|
653
|
-
return `${msg}: New token allowed: ${symbol}, liquidation threshold: ${this.liquidityThreshold / Number(
|
|
652
|
+
return `${msg}: New token allowed: ${symbol}, liquidation threshold: ${this.liquidityThreshold / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}%`;
|
|
654
653
|
case "Allowed":
|
|
655
|
-
return `${msg}: ${symbol} is allowed now, liquidation threshold: ${this.liquidityThreshold / Number(
|
|
654
|
+
return `${msg}: ${symbol} is allowed now, liquidation threshold: ${this.liquidityThreshold / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}%`;
|
|
656
655
|
case "LTUpdated":
|
|
657
|
-
return `${msg}: ${symbol} liquidation threshold: ${(this.prevLiquidationThreshold || 0) / Number(
|
|
656
|
+
return `${msg}: ${symbol} liquidation threshold: ${(this.prevLiquidationThreshold || 0) / Number(sdk_gov_1.PERCENTAGE_DECIMALS)} => ${this.liquidityThreshold / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}%`;
|
|
658
657
|
default:
|
|
659
658
|
return "Error: TokenAllowedV2Props";
|
|
660
659
|
}
|
|
@@ -678,7 +677,7 @@ class EventLimitsUpdated extends eventOrTx_1.EVMEvent {
|
|
|
678
677
|
this.creditManager = opts.creditManager;
|
|
679
678
|
}
|
|
680
679
|
toString() {
|
|
681
|
-
const [symbol, decimals = 18] = (0,
|
|
680
|
+
const [symbol, decimals = 18] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
682
681
|
let msg = `Credit manager ${(0, contractsRegister_1.getContractName)(this.creditManager)} updated: `;
|
|
683
682
|
if (this.minBorrowedAmount !== this.prevMinBorrowedAmount) {
|
|
684
683
|
msg += `min amount: ${(0, formatter_1.formatBN)(this.prevMinBorrowedAmount, decimals)} => ${(0, formatter_1.formatBN)(this.minBorrowedAmount, decimals)} ${symbol}, `;
|
|
@@ -719,13 +718,13 @@ class EventFeesUpdated extends eventOrTx_1.EVMEvent {
|
|
|
719
718
|
toString() {
|
|
720
719
|
let msg = `Credit manager ${(0, contractsRegister_1.getContractName)(this.creditManager)} updated: `;
|
|
721
720
|
if (this.feeInterest !== this.prevFeeInterest) {
|
|
722
|
-
msg += `interest fee: ${this.prevFeeInterest / Number(
|
|
721
|
+
msg += `interest fee: ${this.prevFeeInterest / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}% => ${this.feeInterest / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}%, `;
|
|
723
722
|
}
|
|
724
723
|
if (this.feeLiquidation !== this.prevFeeLiquidation) {
|
|
725
|
-
msg += `liquidation fee: ${this.prevFeeLiquidation / Number(
|
|
724
|
+
msg += `liquidation fee: ${this.prevFeeLiquidation / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}% => ${this.feeLiquidation / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}%, `;
|
|
726
725
|
}
|
|
727
726
|
if (this.liquidationPremium !== this.prevLiquidationPremium) {
|
|
728
|
-
msg += `liquidation premium: ${this.prevLiquidationPremium / Number(
|
|
727
|
+
msg += `liquidation premium: ${this.prevLiquidationPremium / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}% => ${this.liquidationPremium / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}%, `;
|
|
729
728
|
}
|
|
730
729
|
if (this.feeLiquidationExpired !== this.prevFeeLiquidationExpired) {
|
|
731
730
|
msg += `liquidation expired: ${(0, formatter_1.formatDateTime)(this.prevFeeLiquidationExpired)} => ${(0, formatter_1.formatDateTime)(this.feeLiquidationExpired)}, `;
|
|
@@ -778,7 +777,7 @@ class EventLTUpdated extends eventOrTx_1.EVMEvent {
|
|
|
778
777
|
this.prevLt = opts.prevLt;
|
|
779
778
|
}
|
|
780
779
|
toString() {
|
|
781
|
-
return `Credit manager ${(0, contractsRegister_1.getContractName)(this.creditManager)} updated: liquidation fee: ${this.prevLt / Number(
|
|
780
|
+
return `Credit manager ${(0, contractsRegister_1.getContractName)(this.creditManager)} updated: liquidation fee: ${this.prevLt / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}% => ${this.lt / Number(sdk_gov_1.PERCENTAGE_DECIMALS)}%`;
|
|
782
781
|
}
|
|
783
782
|
}
|
|
784
783
|
exports.EventLTUpdated = EventLTUpdated;
|
|
@@ -838,7 +837,7 @@ class EventLimitPerBlockUpdated extends eventOrTx_1.EVMEvent {
|
|
|
838
837
|
this.creditManager = opts.creditManager;
|
|
839
838
|
}
|
|
840
839
|
toString() {
|
|
841
|
-
const [symbol, decimals = 18] = (0,
|
|
840
|
+
const [symbol, decimals = 18] = (0, sdk_gov_1.extractTokenData)(this.token);
|
|
842
841
|
return `Credit manager ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Limit Per Block Updated ${(0, formatter_1.formatBN)(this.prevLimit, decimals)} => ${(0, formatter_1.formatBN)(this.limit, decimals)} ${symbol}`;
|
|
843
842
|
}
|
|
844
843
|
}
|
package/lib/core/pool/data.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UserPoolData = exports.ChartsPoolData = exports.PoolData = void 0;
|
|
4
|
-
const
|
|
4
|
+
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
5
5
|
const types_1 = require("../../types");
|
|
6
6
|
const formatter_1 = require("../../utils/formatter");
|
|
7
|
-
const constants_1 = require("../constants");
|
|
8
7
|
class PoolData {
|
|
9
8
|
id;
|
|
10
9
|
address;
|
|
@@ -33,20 +32,20 @@ class PoolData {
|
|
|
33
32
|
this.dieselToken = payload.dieselToken.toLowerCase();
|
|
34
33
|
this.isWETH = payload.isWETH || false;
|
|
35
34
|
this.isWSTETH =
|
|
36
|
-
|
|
35
|
+
sdk_gov_1.tokenSymbolByAddress[payload.underlying.toLowerCase()] === "wstETH";
|
|
37
36
|
this.expectedLiquidity = (0, formatter_1.toBigInt)(payload.expectedLiquidity || 0);
|
|
38
37
|
this.expectedLiquidityLimit = (0, formatter_1.toBigInt)(payload.expectedLiquidityLimit || 0);
|
|
39
38
|
this.availableLiquidity = (0, formatter_1.toBigInt)(payload.availableLiquidity || 0);
|
|
40
39
|
this.totalBorrowed = (0, formatter_1.toBigInt)(payload.totalBorrowed || 0);
|
|
41
40
|
this.depositAPY =
|
|
42
|
-
(0, formatter_1.rayToNumber)(payload.depositAPY_RAY) * Number(
|
|
41
|
+
(0, formatter_1.rayToNumber)(payload.depositAPY_RAY) * Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
43
42
|
this.borrowAPY =
|
|
44
|
-
(0, formatter_1.rayToNumber)(payload.borrowAPY_RAY) * Number(
|
|
43
|
+
(0, formatter_1.rayToNumber)(payload.borrowAPY_RAY) * Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
45
44
|
this.borrowAPYRay = (0, formatter_1.toBigInt)(payload.borrowAPY_RAY || 0);
|
|
46
45
|
this.dieselRate = (0, formatter_1.rayToNumber)(payload.dieselRate_RAY || 0);
|
|
47
46
|
this.dieselRateRay = (0, formatter_1.toBigInt)(payload.dieselRate_RAY || 0);
|
|
48
47
|
this.withdrawFee =
|
|
49
|
-
Number((0, formatter_1.toBigInt)(payload.withdrawFee || 0)) / Number(
|
|
48
|
+
Number((0, formatter_1.toBigInt)(payload.withdrawFee || 0)) / Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
50
49
|
this.timestampLU = (0, formatter_1.toBigInt)(payload.timestampLU || 0);
|
|
51
50
|
this.cumulativeIndex_RAY = (0, formatter_1.toBigInt)(payload.cumulativeIndex_RAY || 0);
|
|
52
51
|
}
|
|
@@ -119,31 +118,31 @@ class ChartsPoolData {
|
|
|
119
118
|
this.earned7D = payload.earned7D || 0;
|
|
120
119
|
this.earned7DInUSD = payload.earned7DInUSD || 0;
|
|
121
120
|
this.utilization =
|
|
122
|
-
Number(((0, formatter_1.toBigInt)(payload.totalBorrowed || 0) *
|
|
123
|
-
(0, formatter_1.toBigInt)(payload.expectedLiquidity || 0)) / Number(
|
|
121
|
+
Number(((0, formatter_1.toBigInt)(payload.totalBorrowed || 0) * sdk_gov_1.PERCENTAGE_FACTOR) /
|
|
122
|
+
(0, formatter_1.toBigInt)(payload.expectedLiquidity || 0)) / Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
124
123
|
this.dieselRate = (0, formatter_1.rayToNumber)(payload.dieselRate_RAY || 0);
|
|
125
124
|
this.dieselRateRay = (0, formatter_1.toBigInt)(payload.dieselRate_RAY || 0);
|
|
126
125
|
this.depositAPY =
|
|
127
|
-
(0, formatter_1.rayToNumber)(payload.depositAPY_RAY || 0) * Number(
|
|
126
|
+
(0, formatter_1.rayToNumber)(payload.depositAPY_RAY || 0) * Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
128
127
|
this.depositAPYRay = (0, formatter_1.toBigInt)(payload.depositAPY_RAY);
|
|
129
128
|
this.borrowAPY =
|
|
130
|
-
(0, formatter_1.rayToNumber)(payload.borrowAPY_RAY || 0) * Number(
|
|
129
|
+
(0, formatter_1.rayToNumber)(payload.borrowAPY_RAY || 0) * Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
131
130
|
this.borrowAPYRay = (0, formatter_1.toBigInt)(payload.borrowAPY_RAY || 0);
|
|
132
|
-
this.lmAPY = (payload.lmAPY || 0) / Number(
|
|
131
|
+
this.lmAPY = (payload.lmAPY || 0) / Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
133
132
|
this.availableLiquidity = (0, formatter_1.toBigInt)(payload.availableLiquidity || 0);
|
|
134
133
|
this.oldAvailableLiquidity = (0, formatter_1.toBigInt)(payload.availableLiquidityOld || 0);
|
|
135
134
|
this.availableLiquidityChange =
|
|
136
|
-
(payload.availableLiquidity10kBasis || 0) * Number(
|
|
135
|
+
(payload.availableLiquidity10kBasis || 0) * Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
137
136
|
this.availableLiquidityInUSD = payload.availableLiquidityInUSD || 0;
|
|
138
137
|
this.caLockedValue = payload.caLockedValue || 0;
|
|
139
138
|
this.oldCALockedValue = payload.caLockedValueOld || 0;
|
|
140
139
|
this.caLockedValueChange =
|
|
141
|
-
(payload.caLockedValue10kBasis || 0) * Number(
|
|
140
|
+
(payload.caLockedValue10kBasis || 0) * Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
142
141
|
this.caLockedValueInUSD = payload.caLockedValueUSD || 0;
|
|
143
142
|
this.expectedLiquidity = (0, formatter_1.toBigInt)(payload.expectedLiquidity || 0);
|
|
144
143
|
this.oldExpectedLiquidity = (0, formatter_1.toBigInt)(payload.expectedLiquidityOld || 0);
|
|
145
144
|
this.expectedLiquidityChange =
|
|
146
|
-
(payload.expectedLiquidity10kBasis || 0) * Number(
|
|
145
|
+
(payload.expectedLiquidity10kBasis || 0) * Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
147
146
|
this.expectedLiquidityInUSD = payload.expectedLiquidityInUSD || 0;
|
|
148
147
|
this.expectedLiqWeekAgo = payload.expectedLiqWeekAgo || 0;
|
|
149
148
|
this.expectedLiquidityLimit = (0, formatter_1.toBigInt)(payload.expectedLiquidityLimit || 0);
|
|
@@ -151,12 +150,12 @@ class ChartsPoolData {
|
|
|
151
150
|
this.totalBorrowed = (0, formatter_1.toBigInt)(payload.totalBorrowed || 0);
|
|
152
151
|
this.oldTotalBorrowed = (0, formatter_1.toBigInt)(payload.totalBorrowedOld || 0);
|
|
153
152
|
this.totalBorrowedChange =
|
|
154
|
-
(payload.totalBorrowed10kBasis || 0) * Number(
|
|
153
|
+
(payload.totalBorrowed10kBasis || 0) * Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
155
154
|
this.totalBorrowedInUSD = payload.totalBorrowedInUSD || 0;
|
|
156
155
|
this.debtWithInterest = (0, formatter_1.toBigInt)(payload.debtWithInterest || 0);
|
|
157
156
|
this.debtWithInterestOld = (0, formatter_1.toBigInt)(payload.debtWithInterestOld || 0);
|
|
158
157
|
this.debtWithInterestChange =
|
|
159
|
-
(payload.debtWithInterest10kBasis || 0) * Number(
|
|
158
|
+
(payload.debtWithInterest10kBasis || 0) * Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
160
159
|
this.debtWithInterestInUSD = payload.debtWithInterestInUSD || 0;
|
|
161
160
|
this.withdrawFee = payload.withdrawFee || 0;
|
|
162
161
|
this.addLiqCount = payload.addLiqCount || 0;
|
|
@@ -164,17 +163,17 @@ class ChartsPoolData {
|
|
|
164
163
|
this.removeLiqCount = payload.removeLiqCount || 0;
|
|
165
164
|
this.removedLiquidity = payload.removedLiquidity || 0;
|
|
166
165
|
this.depositAPY1DAverage =
|
|
167
|
-
(payload.depositAPY1DAverage || 0) / Number(
|
|
166
|
+
(payload.depositAPY1DAverage || 0) / Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
168
167
|
this.depositAPY1DAverageChange =
|
|
169
|
-
(payload.depositAPY1DAverage10kBasis || 0) * Number(
|
|
168
|
+
(payload.depositAPY1DAverage10kBasis || 0) * Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
170
169
|
this.depositAPY7DAverage =
|
|
171
|
-
(payload.depositAPY7DAverage || 0) / Number(
|
|
170
|
+
(payload.depositAPY7DAverage || 0) / Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
172
171
|
this.depositAPY30DAverage =
|
|
173
|
-
(payload.depositAPY30DAverage || 0) / Number(
|
|
172
|
+
(payload.depositAPY30DAverage || 0) / Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
174
173
|
this.uniqueLPs = payload.uniqueLPs || 0;
|
|
175
174
|
this.oldUniqueLPs = payload.uniqueLPsOld || 0;
|
|
176
175
|
this.uniqueLPsChange =
|
|
177
|
-
(payload.uniqueLPs10kBasis || 0) * Number(
|
|
176
|
+
(payload.uniqueLPs10kBasis || 0) * Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
178
177
|
}
|
|
179
178
|
}
|
|
180
179
|
exports.ChartsPoolData = ChartsPoolData;
|
|
@@ -204,9 +203,9 @@ class UserPoolData {
|
|
|
204
203
|
this.underlyingToken = (payload.underlyingToken || "").toLowerCase();
|
|
205
204
|
this.dieselToken = (payload.dieselToken || "").toLowerCase();
|
|
206
205
|
this.depositAPY =
|
|
207
|
-
(0, formatter_1.rayToNumber)(payload.depositAPY_RAY || 0) * Number(
|
|
206
|
+
(0, formatter_1.rayToNumber)(payload.depositAPY_RAY || 0) * Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
208
207
|
this.depositAPYRay = (0, formatter_1.toBigInt)(payload.depositAPY_RAY || 0);
|
|
209
|
-
this.lmAPY = (payload.lmAPY || 0) / Number(
|
|
208
|
+
this.lmAPY = (payload.lmAPY || 0) / Number(sdk_gov_1.PERCENTAGE_DECIMALS || 0);
|
|
210
209
|
this.providedLiquidity = (0, formatter_1.toBigInt)(payload.liqValue || 0);
|
|
211
210
|
this.providedLiquidityInUSD = payload.liqValueInUSD;
|
|
212
211
|
this.dieselBalance = (0, formatter_1.toBigInt)(payload.dieselBalanceBI || 0);
|
package/lib/core/priceOracle.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PriceOracleData = void 0;
|
|
4
|
-
const
|
|
4
|
+
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
5
5
|
const formatter_1 = require("../utils/formatter");
|
|
6
6
|
class PriceOracleData {
|
|
7
7
|
_prices = {};
|
|
@@ -17,10 +17,10 @@ class PriceOracleData {
|
|
|
17
17
|
return this.convertFromUSD(this.convertToUSD(amount, from), to);
|
|
18
18
|
}
|
|
19
19
|
convertFromUSD(amount, token) {
|
|
20
|
-
return (amount * 10n ** BigInt((0,
|
|
20
|
+
return (amount * 10n ** BigInt((0, sdk_gov_1.getDecimals)(token))) / this.getPrice(token);
|
|
21
21
|
}
|
|
22
22
|
convertToUSD(amount, token) {
|
|
23
|
-
return (amount * this.getPrice(token)) / 10n ** BigInt((0,
|
|
23
|
+
return (amount * this.getPrice(token)) / 10n ** BigInt((0, sdk_gov_1.getDecimals)(token));
|
|
24
24
|
}
|
|
25
25
|
getPrice(token) {
|
|
26
26
|
const price = this._prices[token.toLowerCase()];
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
import { NetworkType, SupportedContract, SupportedToken } from "@gearbox-protocol/sdk-gov";
|
|
1
2
|
import { providers } from "ethers";
|
|
2
|
-
import { SupportedContract } from "../contracts/contracts";
|
|
3
3
|
import { MultiCall } from "../pathfinder/core";
|
|
4
|
-
import { SupportedToken } from "../tokens/token";
|
|
5
|
-
import { NetworkType } from "./chains";
|
|
6
4
|
import { CreditAccountData } from "./creditAccount";
|
|
7
5
|
import { CreditManagerData } from "./creditManager";
|
|
8
6
|
export interface Rewards {
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
+
import { MCall, NetworkType, SupportedContract, SupportedToken } from "@gearbox-protocol/sdk-gov";
|
|
1
2
|
import { BigNumber, providers } from "ethers";
|
|
2
|
-
import { SupportedContract } from "../contracts/contracts";
|
|
3
|
-
import { SupportedToken } from "../tokens/token";
|
|
4
3
|
import { IConvexV1BaseRewardPoolAdapterInterface } from "../types/@gearbox-protocol/integrations-v2/contracts/interfaces/convex/IConvexV1BaseRewardPoolAdapter.sol/IConvexV1BaseRewardPoolAdapter";
|
|
5
|
-
import { MCall } from "../utils/multicall";
|
|
6
|
-
import { NetworkType } from "./chains";
|
|
7
4
|
import { CreditAccountData } from "./creditAccount";
|
|
8
5
|
import { CreditManagerData } from "./creditManager";
|
|
9
6
|
import { AdapterWithType, Rewards } from "./rewardClaimer";
|
package/lib/core/rewardConvex.js
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RewardConvex = void 0;
|
|
4
|
+
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
4
5
|
const apy_1 = require("../apy");
|
|
5
|
-
const adapters_1 = require("../contracts/adapters");
|
|
6
|
-
const contracts_1 = require("../contracts/contracts");
|
|
7
|
-
const token_1 = require("../tokens/token");
|
|
8
6
|
const types_1 = require("../types");
|
|
9
7
|
const formatter_1 = require("../utils/formatter");
|
|
10
|
-
const multicall_1 = require("../utils/multicall");
|
|
11
8
|
class RewardConvex {
|
|
12
9
|
static poolInterface = types_1.IConvexV1BaseRewardPoolAdapter__factory.createInterface();
|
|
13
10
|
static async findRewards(ca, cm, network, provider) {
|
|
14
11
|
const { calls, distribution } = RewardConvex.prepareMultiCalls(ca.addr, cm, network);
|
|
15
12
|
const mcalls = calls;
|
|
16
13
|
mcalls.push({
|
|
17
|
-
address:
|
|
14
|
+
address: sdk_gov_1.tokenDataByNetwork[network].CVX,
|
|
18
15
|
interface: types_1.IConvexToken__factory.createInterface(),
|
|
19
16
|
method: "totalSupply()",
|
|
20
17
|
});
|
|
21
|
-
const rewards = await (0,
|
|
18
|
+
const rewards = await (0, sdk_gov_1.multicall)(mcalls, provider);
|
|
22
19
|
const totalSupply = rewards.pop();
|
|
23
20
|
const results = RewardConvex.parseResults(rewards, distribution);
|
|
24
21
|
results.forEach(r => {
|
|
@@ -27,14 +24,14 @@ class RewardConvex {
|
|
|
27
24
|
return results;
|
|
28
25
|
}
|
|
29
26
|
static findAdapters(cm) {
|
|
30
|
-
const convexPools = Object.entries(
|
|
31
|
-
.filter(([_, params]) => params.type ===
|
|
27
|
+
const convexPools = Object.entries(sdk_gov_1.contractParams)
|
|
28
|
+
.filter(([_, params]) => params.type === sdk_gov_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL)
|
|
32
29
|
.map(([contract]) => contract);
|
|
33
30
|
return Object.entries(cm.adapters)
|
|
34
31
|
.map(([contract, adapter]) => ({
|
|
35
32
|
adapter,
|
|
36
33
|
contractAddress: contract,
|
|
37
|
-
contract:
|
|
34
|
+
contract: sdk_gov_1.contractsByAddress[contract.toLowerCase()],
|
|
38
35
|
}))
|
|
39
36
|
.filter(a => convexPools.includes(a.contract));
|
|
40
37
|
}
|
|
@@ -55,7 +52,7 @@ class RewardConvex {
|
|
|
55
52
|
contract: a.contract,
|
|
56
53
|
token: "CRV",
|
|
57
54
|
});
|
|
58
|
-
const params =
|
|
55
|
+
const params = sdk_gov_1.contractParams[a.contract];
|
|
59
56
|
for (let er of params.extraRewards) {
|
|
60
57
|
calls.push({
|
|
61
58
|
address: er.poolAddress[network],
|
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
3
4
|
const chai_1 = require("chai");
|
|
4
5
|
const ethers_1 = require("ethers");
|
|
5
|
-
const contracts_1 = require("../contracts/contracts");
|
|
6
|
-
const constants_1 = require("./constants");
|
|
7
6
|
const rewardConvex_1 = require("./rewardConvex");
|
|
8
|
-
const ADAPTER_CONVEX_3CRV_POOL =
|
|
9
|
-
const ADAPTER_CURVE_FRAX_POOL =
|
|
10
|
-
const ADAPTER_CONVEX_FRAX3CRV_POOL =
|
|
11
|
-
const CREDIT_ACCOUNT =
|
|
7
|
+
const ADAPTER_CONVEX_3CRV_POOL = sdk_gov_1.DUMB_ADDRESS;
|
|
8
|
+
const ADAPTER_CURVE_FRAX_POOL = sdk_gov_1.DUMB_ADDRESS2;
|
|
9
|
+
const ADAPTER_CONVEX_FRAX3CRV_POOL = sdk_gov_1.DUMB_ADDRESS3;
|
|
10
|
+
const CREDIT_ACCOUNT = sdk_gov_1.DUMB_ADDRESS4;
|
|
12
11
|
describe("RewardConvex test", () => {
|
|
13
12
|
it("findAdapters find convex adapters correctly", () => {
|
|
14
13
|
const cm = {
|
|
15
14
|
adapters: {
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
15
|
+
[sdk_gov_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL]: ADAPTER_CONVEX_3CRV_POOL,
|
|
16
|
+
[sdk_gov_1.contractsByNetwork.Mainnet.CURVE_FRAX_POOL]: ADAPTER_CURVE_FRAX_POOL,
|
|
17
|
+
[sdk_gov_1.contractsByNetwork.Arbitrum.CONVEX_FRAX3CRV_POOL]: ADAPTER_CONVEX_FRAX3CRV_POOL,
|
|
19
18
|
},
|
|
20
19
|
};
|
|
21
20
|
const expectedResult = [
|
|
22
21
|
{
|
|
23
22
|
contract: "CONVEX_3CRV_POOL",
|
|
24
|
-
contractAddress:
|
|
23
|
+
contractAddress: sdk_gov_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL,
|
|
25
24
|
adapter: ADAPTER_CONVEX_3CRV_POOL,
|
|
26
25
|
},
|
|
27
26
|
// {
|
|
@@ -36,14 +35,14 @@ describe("RewardConvex test", () => {
|
|
|
36
35
|
it("prepareMultiCalls prepares multicall data correctly", () => {
|
|
37
36
|
const cm = {
|
|
38
37
|
adapters: {
|
|
39
|
-
[
|
|
40
|
-
[
|
|
41
|
-
[
|
|
38
|
+
[sdk_gov_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL]: ADAPTER_CONVEX_3CRV_POOL,
|
|
39
|
+
[sdk_gov_1.contractsByNetwork.Mainnet.CURVE_FRAX_POOL]: ADAPTER_CURVE_FRAX_POOL,
|
|
40
|
+
[sdk_gov_1.contractsByNetwork.Arbitrum.CONVEX_FRAX3CRV_POOL]: ADAPTER_CONVEX_FRAX3CRV_POOL,
|
|
42
41
|
},
|
|
43
42
|
};
|
|
44
43
|
const calls = [
|
|
45
44
|
{
|
|
46
|
-
address:
|
|
45
|
+
address: sdk_gov_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL,
|
|
47
46
|
interface: rewardConvex_1.RewardConvex.poolInterface,
|
|
48
47
|
method: "earned(address)",
|
|
49
48
|
params: [CREDIT_ACCOUNT],
|
|
@@ -65,7 +64,7 @@ describe("RewardConvex test", () => {
|
|
|
65
64
|
const distribution = [
|
|
66
65
|
{
|
|
67
66
|
adapter: ADAPTER_CONVEX_3CRV_POOL,
|
|
68
|
-
contractAddress:
|
|
67
|
+
contractAddress: sdk_gov_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL,
|
|
69
68
|
contract: "CONVEX_3CRV_POOL",
|
|
70
69
|
token: "CRV",
|
|
71
70
|
},
|
|
@@ -94,7 +93,7 @@ describe("RewardConvex test", () => {
|
|
|
94
93
|
const distribution = [
|
|
95
94
|
{
|
|
96
95
|
adapter: ADAPTER_CONVEX_3CRV_POOL,
|
|
97
|
-
contractAddress:
|
|
96
|
+
contractAddress: sdk_gov_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL,
|
|
98
97
|
contract: "CONVEX_3CRV_POOL",
|
|
99
98
|
token: "CRV",
|
|
100
99
|
},
|