@gearbox-protocol/sdk 13.3.0-next.3 → 13.3.1
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/dist/cjs/common-utils/charts/credit-manager-payload.js +16 -0
- package/dist/cjs/common-utils/charts/credit-manager.js +134 -0
- package/dist/cjs/common-utils/charts/credit-session.js +257 -0
- package/dist/cjs/common-utils/charts/credit-sessions-payload.js +16 -0
- package/dist/cjs/common-utils/charts/graph-payload.js +16 -0
- package/dist/cjs/common-utils/charts/index.js +36 -0
- package/dist/cjs/common-utils/charts/pool-payload.js +16 -0
- package/dist/cjs/common-utils/charts/pool.js +199 -0
- package/dist/cjs/common-utils/charts/token-data.js +91 -0
- package/dist/cjs/common-utils/index.js +4 -0
- package/dist/cjs/common-utils/static/index.js +28 -0
- package/dist/cjs/common-utils/static/migration-config.js +16 -0
- package/dist/cjs/common-utils/static/pool-config.js +16 -0
- package/dist/cjs/common-utils/static/strategy.js +16 -0
- package/dist/cjs/common-utils/static/trading-pair.js +16 -0
- package/dist/cjs/common-utils/utils/{assetsMath.js → assets-math.js} +13 -13
- package/dist/cjs/common-utils/utils/{bigintMath.js → bigint-math.js} +3 -3
- package/dist/cjs/common-utils/utils/creditAccount/{calcHealthFactor.js → calc-health-factor.js} +9 -9
- package/dist/cjs/common-utils/utils/creditAccount/{calcOverallAPY.js → calc-overall-apy.js} +8 -8
- package/dist/cjs/common-utils/utils/creditAccount/{calcQuotaBorrowRate.js → calc-quota-borrow-rate.js} +3 -3
- package/dist/cjs/common-utils/utils/creditAccount/{calcRelativeBaseBorrowRate.js → calc-relative-base-borrow-rate.js} +3 -3
- package/dist/cjs/common-utils/utils/creditAccount/debt.js +4 -4
- package/dist/cjs/common-utils/utils/creditAccount/{getTimeToLiquidation.js → get-time-to-liquidation.js} +3 -3
- package/dist/cjs/common-utils/utils/creditAccount/index.js +16 -16
- package/dist/cjs/common-utils/utils/creditAccount/{liquidationPrice.js → liquidation-price.js} +3 -3
- package/dist/cjs/common-utils/utils/creditAccount/{quotaUtils.js → quota-utils.js} +8 -8
- package/dist/cjs/common-utils/utils/creditAccount/sort.js +3 -3
- package/dist/cjs/common-utils/utils/index.js +6 -8
- package/dist/cjs/common-utils/utils/{priceMath.js → price-math.js} +3 -3
- package/dist/cjs/dev/AccountOpener.js +5 -45
- package/dist/cjs/plugins/zappers/ZappersPlugin.js +144 -0
- package/dist/cjs/{sdk/market/ZapperRegister.js → plugins/zappers/extraZappers.js} +6 -110
- package/dist/cjs/plugins/zappers/index.js +26 -0
- package/dist/cjs/plugins/zappers/package.json +1 -0
- package/dist/cjs/rewards/apy/index.js +24 -0
- package/dist/cjs/rewards/apy/output-details.js +16 -0
- package/dist/cjs/rewards/apy/output.js +16 -0
- package/dist/cjs/rewards/index.js +24 -0
- package/dist/cjs/rewards/package.json +1 -0
- package/dist/cjs/rewards/rewards/api.js +226 -0
- package/dist/cjs/rewards/rewards/apy.js +177 -0
- package/dist/cjs/rewards/rewards/common.js +16 -0
- package/dist/cjs/rewards/rewards/extra-apy.js +132 -0
- package/dist/cjs/rewards/rewards/index.js +28 -0
- package/dist/cjs/rewards/rewards/merkl-api.js +52 -0
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +104 -462
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +5 -16
- package/dist/cjs/sdk/base/ChainContractsRegister.js +1 -1
- package/dist/cjs/sdk/base/TokensMeta.js +32 -255
- package/dist/cjs/sdk/base/index.js +0 -2
- package/dist/cjs/sdk/chain/chains.js +1 -2
- package/dist/cjs/sdk/constants/index.js +2 -0
- package/dist/cjs/sdk/{base/token-types.js → constants/phantom-tokens.js} +3 -9
- package/dist/cjs/sdk/market/MarketRegister.js +2 -2
- package/dist/cjs/sdk/market/MarketSuite.js +0 -6
- package/dist/cjs/sdk/market/index.js +1 -3
- package/dist/cjs/sdk/market/pool/PoolSuite.js +0 -3
- package/dist/cjs/sdk/market/pool/PoolV310Contract.js +2 -17
- package/dist/cjs/sdk/market/pool/index.js +0 -4
- package/dist/cjs/sdk/pools/AbstractPoolService.js +137 -0
- package/dist/cjs/{abi/iStateSerializer.js → sdk/pools/PoolServiceV310.js} +8 -14
- package/dist/cjs/sdk/pools/createPoolService.js +35 -0
- package/dist/cjs/sdk/pools/index.js +4 -2
- package/dist/cjs/sdk/utils/AddressMap.js +1 -1
- package/dist/cjs/sdk/utils/viem/sendRawTx.js +0 -16
- package/dist/esm/common-utils/charts/credit-manager.js +115 -0
- package/dist/esm/common-utils/charts/credit-session.js +233 -0
- package/dist/esm/common-utils/charts/credit-sessions-payload.js +0 -0
- package/dist/esm/common-utils/charts/graph-payload.js +0 -0
- package/dist/esm/common-utils/charts/index.js +8 -0
- package/dist/esm/common-utils/charts/pool-payload.js +0 -0
- package/dist/esm/common-utils/charts/pool.js +179 -0
- package/dist/esm/common-utils/charts/token-data.js +67 -0
- package/dist/esm/common-utils/index.js +2 -0
- package/dist/esm/common-utils/static/index.js +4 -0
- package/dist/esm/common-utils/static/migration-config.js +0 -0
- package/dist/esm/common-utils/static/pool-config.js +0 -0
- package/dist/esm/common-utils/static/strategy.js +0 -0
- package/dist/esm/common-utils/static/trading-pair.js +0 -0
- package/dist/esm/common-utils/utils/{assetsMath.js → assets-math.js} +2 -2
- package/dist/esm/common-utils/utils/creditAccount/{calcHealthFactor.js → calc-health-factor.js} +2 -2
- package/dist/esm/common-utils/utils/creditAccount/{calcOverallAPY.js → calc-overall-apy.js} +1 -1
- package/dist/esm/common-utils/utils/creditAccount/debt.js +2 -2
- package/dist/esm/common-utils/utils/creditAccount/index.js +8 -8
- package/dist/esm/common-utils/utils/creditAccount/{quotaUtils.js → quota-utils.js} +1 -1
- package/dist/esm/common-utils/utils/creditAccount/sort.js +1 -1
- package/dist/esm/common-utils/utils/index.js +3 -4
- package/dist/esm/dev/AccountOpener.js +6 -47
- package/dist/esm/plugins/zappers/ZappersPlugin.js +126 -0
- package/dist/esm/{sdk/market/ZapperRegister.js → plugins/zappers/extraZappers.js} +2 -109
- package/dist/esm/plugins/zappers/index.js +3 -0
- package/dist/esm/plugins/zappers/package.json +1 -0
- package/dist/esm/plugins/zappers/types.js +0 -0
- package/dist/esm/rewards/apy/index.js +2 -0
- package/dist/esm/rewards/apy/output-details.js +0 -0
- package/dist/esm/rewards/apy/output.js +0 -0
- package/dist/esm/rewards/index.js +2 -0
- package/dist/esm/rewards/package.json +1 -0
- package/dist/esm/rewards/rewards/api.js +204 -0
- package/dist/esm/rewards/rewards/apy.js +160 -0
- package/dist/esm/rewards/rewards/common.js +0 -0
- package/dist/esm/rewards/rewards/extra-apy.js +101 -0
- package/dist/esm/rewards/rewards/index.js +4 -0
- package/dist/esm/rewards/rewards/merkl-api.js +18 -0
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +104 -462
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +5 -16
- package/dist/esm/sdk/base/ChainContractsRegister.js +1 -1
- package/dist/esm/sdk/base/TokensMeta.js +32 -261
- package/dist/esm/sdk/base/index.js +0 -1
- package/dist/esm/sdk/chain/chains.js +1 -2
- package/dist/esm/sdk/constants/index.js +1 -0
- package/dist/esm/sdk/{base/token-types.js → constants/phantom-tokens.js} +0 -4
- package/dist/esm/sdk/market/MarketRegister.js +2 -2
- package/dist/esm/sdk/market/MarketSuite.js +0 -6
- package/dist/esm/sdk/market/index.js +0 -1
- package/dist/esm/sdk/market/pool/PoolSuite.js +0 -3
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +2 -17
- package/dist/esm/sdk/market/pool/index.js +0 -2
- package/dist/esm/sdk/pools/AbstractPoolService.js +113 -0
- package/dist/esm/sdk/pools/PoolServiceV310.js +6 -0
- package/dist/esm/sdk/pools/createPoolService.js +11 -0
- package/dist/esm/sdk/pools/index.js +2 -1
- package/dist/esm/sdk/utils/AddressMap.js +1 -1
- package/dist/esm/sdk/utils/viem/sendRawTx.js +1 -19
- package/dist/types/common-utils/charts/credit-manager-payload.d.ts +50 -0
- package/dist/types/common-utils/charts/credit-manager.d.ts +48 -0
- package/dist/types/common-utils/charts/credit-session.d.ts +111 -0
- package/dist/types/common-utils/charts/credit-sessions-payload.d.ts +111 -0
- package/dist/types/common-utils/charts/graph-payload.d.ts +10 -0
- package/dist/types/common-utils/charts/index.d.ts +8 -0
- package/dist/types/common-utils/charts/pool-payload.d.ts +111 -0
- package/dist/types/common-utils/charts/pool.d.ts +91 -0
- package/dist/types/common-utils/charts/token-data.d.ts +20 -0
- package/dist/types/common-utils/index.d.ts +2 -0
- package/dist/types/common-utils/static/index.d.ts +4 -0
- package/dist/types/common-utils/static/migration-config.d.ts +10 -0
- package/dist/types/common-utils/static/pool-config.d.ts +11 -0
- package/dist/types/common-utils/static/strategy.d.ts +78 -0
- package/dist/types/common-utils/static/trading-pair.d.ts +15 -0
- package/dist/types/common-utils/utils/creditAccount/index.d.ts +8 -8
- package/dist/types/common-utils/utils/index.d.ts +3 -4
- package/dist/types/plugins/zappers/ZappersPlugin.d.ts +18 -0
- package/dist/types/plugins/zappers/extraZappers.d.ts +6 -0
- package/dist/types/plugins/zappers/index.d.ts +3 -0
- package/dist/types/plugins/zappers/types.d.ts +12 -0
- package/dist/types/rewards/apy/index.d.ts +2 -0
- package/dist/types/rewards/apy/output-details.d.ts +96 -0
- package/dist/types/rewards/apy/output.d.ts +22 -0
- package/dist/types/rewards/index.d.ts +2 -0
- package/dist/types/rewards/rewards/api.d.ts +49 -0
- package/dist/types/rewards/rewards/apy.d.ts +41 -0
- package/dist/types/rewards/rewards/common.d.ts +16 -0
- package/dist/types/rewards/rewards/extra-apy.d.ts +30 -0
- package/dist/types/rewards/rewards/index.d.ts +4 -0
- package/dist/types/rewards/rewards/merkl-api.d.ts +45 -0
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +27 -123
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
- package/dist/types/sdk/accounts/types.d.ts +8 -108
- package/dist/types/sdk/base/TokensMeta.d.ts +18 -34
- package/dist/types/sdk/base/index.d.ts +0 -1
- package/dist/types/sdk/base/types.d.ts +1 -0
- package/dist/types/sdk/chain/chains.d.ts +1 -1
- package/dist/types/sdk/constants/index.d.ts +1 -0
- package/dist/types/sdk/constants/phantom-tokens.d.ts +2 -0
- package/dist/types/sdk/market/MarketRegister.d.ts +2 -2
- package/dist/types/sdk/market/MarketSuite.d.ts +0 -3
- package/dist/types/sdk/market/index.d.ts +0 -1
- package/dist/types/sdk/market/pool/PoolSuite.d.ts +0 -2
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +2 -6
- package/dist/types/sdk/market/pool/index.d.ts +0 -2
- package/dist/types/sdk/pools/AbstractPoolService.d.ts +9 -0
- package/dist/types/sdk/pools/PoolServiceV310.d.ts +4 -0
- package/dist/types/sdk/pools/createPoolService.d.ts +3 -0
- package/dist/types/sdk/pools/index.d.ts +2 -1
- package/dist/types/sdk/pools/types.d.ts +63 -84
- package/dist/types/sdk/utils/AddressMap.d.ts +1 -1
- package/dist/types/sdk/utils/viem/sendRawTx.d.ts +1 -5
- package/package.json +6 -1
- package/dist/cjs/abi/310/iSecuritizeDegenNFT.js +0 -263
- package/dist/cjs/abi/310/iSecuritizeKYCFactory.js +0 -278
- package/dist/cjs/common-utils/utils/endpoints.js +0 -65
- package/dist/cjs/sdk/market/pool/SecuritizeKYCFactory.js +0 -97
- package/dist/cjs/sdk/pools/PoolService.js +0 -391
- package/dist/esm/abi/310/iSecuritizeDegenNFT.js +0 -239
- package/dist/esm/abi/310/iSecuritizeKYCFactory.js +0 -254
- package/dist/esm/abi/iStateSerializer.js +0 -12
- package/dist/esm/common-utils/utils/endpoints.js +0 -41
- package/dist/esm/sdk/market/pool/SecuritizeKYCFactory.js +0 -73
- package/dist/esm/sdk/pools/PoolService.js +0 -371
- package/dist/types/abi/310/iSecuritizeDegenNFT.d.ts +0 -324
- package/dist/types/abi/310/iSecuritizeKYCFactory.d.ts +0 -322
- package/dist/types/abi/iStateSerializer.d.ts +0 -11
- package/dist/types/common-utils/utils/endpoints.d.ts +0 -27
- package/dist/types/sdk/base/token-types.d.ts +0 -33
- package/dist/types/sdk/market/ZapperRegister.d.ts +0 -17
- package/dist/types/sdk/market/pool/SecuritizeKYCFactory.d.ts +0 -345
- package/dist/types/sdk/market/types.d.ts +0 -10
- package/dist/types/sdk/pools/PoolService.d.ts +0 -14
- /package/dist/cjs/{sdk/market → plugins/zappers}/types.js +0 -0
- /package/dist/esm/{sdk/market/types.js → common-utils/charts/credit-manager-payload.js} +0 -0
- /package/dist/esm/common-utils/utils/{bigintMath.js → bigint-math.js} +0 -0
- /package/dist/esm/common-utils/utils/creditAccount/{calcQuotaBorrowRate.js → calc-quota-borrow-rate.js} +0 -0
- /package/dist/esm/common-utils/utils/creditAccount/{calcRelativeBaseBorrowRate.js → calc-relative-base-borrow-rate.js} +0 -0
- /package/dist/esm/common-utils/utils/creditAccount/{getTimeToLiquidation.js → get-time-to-liquidation.js} +0 -0
- /package/dist/esm/common-utils/utils/creditAccount/{liquidationPrice.js → liquidation-price.js} +0 -0
- /package/dist/esm/common-utils/utils/{priceMath.js → price-math.js} +0 -0
- /package/dist/types/common-utils/utils/{assetsMath.d.ts → assets-math.d.ts} +0 -0
- /package/dist/types/common-utils/utils/{bigintMath.d.ts → bigint-math.d.ts} +0 -0
- /package/dist/types/common-utils/utils/creditAccount/{calcHealthFactor.d.ts → calc-health-factor.d.ts} +0 -0
- /package/dist/types/common-utils/utils/creditAccount/{calcOverallAPY.d.ts → calc-overall-apy.d.ts} +0 -0
- /package/dist/types/common-utils/utils/creditAccount/{calcQuotaBorrowRate.d.ts → calc-quota-borrow-rate.d.ts} +0 -0
- /package/dist/types/common-utils/utils/creditAccount/{calcRelativeBaseBorrowRate.d.ts → calc-relative-base-borrow-rate.d.ts} +0 -0
- /package/dist/types/common-utils/utils/creditAccount/{getTimeToLiquidation.d.ts → get-time-to-liquidation.d.ts} +0 -0
- /package/dist/types/common-utils/utils/creditAccount/{liquidationPrice.d.ts → liquidation-price.d.ts} +0 -0
- /package/dist/types/common-utils/utils/creditAccount/{quotaUtils.d.ts → quota-utils.d.ts} +0 -0
- /package/dist/types/common-utils/utils/{priceMath.d.ts → price-math.d.ts} +0 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var pool_exports = {};
|
|
20
|
+
__export(pool_exports, {
|
|
21
|
+
ChartsPoolData: () => ChartsPoolData,
|
|
22
|
+
UserPoolData: () => UserPoolData
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(pool_exports);
|
|
25
|
+
var import_sdk = require("../../sdk/index.js");
|
|
26
|
+
class ChartsPoolData {
|
|
27
|
+
address;
|
|
28
|
+
underlyingToken;
|
|
29
|
+
dieselToken;
|
|
30
|
+
version;
|
|
31
|
+
name;
|
|
32
|
+
marketConfigurator;
|
|
33
|
+
addLiqCount;
|
|
34
|
+
addedLiquidity;
|
|
35
|
+
removeLiqCount;
|
|
36
|
+
removedLiquidity;
|
|
37
|
+
earned7D;
|
|
38
|
+
earned7DInUSD;
|
|
39
|
+
utilization;
|
|
40
|
+
dieselRate;
|
|
41
|
+
dieselRateRay;
|
|
42
|
+
depositAPY;
|
|
43
|
+
depositAPYRay;
|
|
44
|
+
borrowAPY;
|
|
45
|
+
borrowAPYRay;
|
|
46
|
+
lmAPY;
|
|
47
|
+
lmRewardAll;
|
|
48
|
+
availableLiquidity;
|
|
49
|
+
availableLiquidityChange;
|
|
50
|
+
availableLiquidityInUSD;
|
|
51
|
+
caLockedValue;
|
|
52
|
+
caLockedValueChange;
|
|
53
|
+
caLockedValueInUSD;
|
|
54
|
+
expectedLiquidity;
|
|
55
|
+
expectedLiquidityChange;
|
|
56
|
+
expectedLiquidityInUSD;
|
|
57
|
+
expectedLiqWeekAgo;
|
|
58
|
+
expectedLiquidityLimit;
|
|
59
|
+
expectedLiquidityLimitInUSD;
|
|
60
|
+
totalBorrowed;
|
|
61
|
+
totalBorrowedChange;
|
|
62
|
+
totalBorrowedInUSD;
|
|
63
|
+
debtWithInterest;
|
|
64
|
+
debtWithInterestChange;
|
|
65
|
+
debtWithInterestInUSD;
|
|
66
|
+
debtWithInterestOld;
|
|
67
|
+
oldAvailableLiquidity;
|
|
68
|
+
oldCALockedValue;
|
|
69
|
+
oldExpectedLiquidity;
|
|
70
|
+
oldTotalBorrowed;
|
|
71
|
+
withdrawFee;
|
|
72
|
+
depositAPY1DAverage;
|
|
73
|
+
depositAPY1DAverageChange;
|
|
74
|
+
depositAPY7DAverage;
|
|
75
|
+
depositAPY30DAverage;
|
|
76
|
+
oldUniqueLPs;
|
|
77
|
+
uniqueLPs;
|
|
78
|
+
uniqueLPsChange;
|
|
79
|
+
constructor(payload) {
|
|
80
|
+
this.address = (payload.addr || "").toLowerCase();
|
|
81
|
+
this.underlyingToken = (payload.underlyingToken || "").toLowerCase();
|
|
82
|
+
this.dieselToken = (payload.dieselToken || "").toLowerCase();
|
|
83
|
+
this.version = payload.version || 1;
|
|
84
|
+
this.name = payload.name || "";
|
|
85
|
+
this.marketConfigurator = (payload.market || "").toLowerCase();
|
|
86
|
+
this.earned7D = payload.earned7D || 0;
|
|
87
|
+
this.earned7DInUSD = payload.earned7DInUSD || 0;
|
|
88
|
+
this.dieselRate = (0, import_sdk.rayToNumber)(payload.dieselRate_RAY || 0);
|
|
89
|
+
this.dieselRateRay = (0, import_sdk.toBigInt)(payload.dieselRate_RAY || 0);
|
|
90
|
+
this.depositAPY = (0, import_sdk.rayToNumber)(payload.depositAPY_RAY || 0) * Number(import_sdk.PERCENTAGE_DECIMALS);
|
|
91
|
+
this.depositAPYRay = (0, import_sdk.toBigInt)(payload.depositAPY_RAY);
|
|
92
|
+
this.borrowAPY = (0, import_sdk.rayToNumber)(payload.borrowAPY_RAY || 0) * Number(import_sdk.PERCENTAGE_DECIMALS);
|
|
93
|
+
this.borrowAPYRay = (0, import_sdk.toBigInt)(payload.borrowAPY_RAY || 0);
|
|
94
|
+
this.lmAPY = (payload.lmAPY || 0) / Number(import_sdk.PERCENTAGE_DECIMALS);
|
|
95
|
+
this.lmRewardAll = (payload.lmRewardAll || []).map((r) => ({
|
|
96
|
+
apy: (r.apy || 0) / Number(import_sdk.PERCENTAGE_DECIMALS),
|
|
97
|
+
token: (r.token || "").toLowerCase()
|
|
98
|
+
}));
|
|
99
|
+
const expected = (0, import_sdk.toBigInt)(payload.expectedLiquidity || 0);
|
|
100
|
+
const available = (0, import_sdk.toBigInt)(payload.availableLiquidity || 0);
|
|
101
|
+
this.availableLiquidity = available;
|
|
102
|
+
this.oldAvailableLiquidity = (0, import_sdk.toBigInt)(payload.availableLiquidityOld || 0);
|
|
103
|
+
this.availableLiquidityChange = (payload.availableLiquidity10kBasis || 0) * Number(import_sdk.PERCENTAGE_DECIMALS);
|
|
104
|
+
this.availableLiquidityInUSD = payload.availableLiquidityInUSD || 0;
|
|
105
|
+
this.utilization = ChartsPoolData.calculateUtilization(expected, available);
|
|
106
|
+
this.caLockedValue = payload.caLockedValue || 0;
|
|
107
|
+
this.oldCALockedValue = payload.caLockedValueOld || 0;
|
|
108
|
+
this.caLockedValueChange = (payload.caLockedValue10kBasis || 0) * Number(import_sdk.PERCENTAGE_DECIMALS);
|
|
109
|
+
this.caLockedValueInUSD = payload.caLockedValueUSD || 0;
|
|
110
|
+
this.expectedLiquidity = (0, import_sdk.toBigInt)(payload.expectedLiquidity || 0);
|
|
111
|
+
this.oldExpectedLiquidity = (0, import_sdk.toBigInt)(payload.expectedLiquidityOld || 0);
|
|
112
|
+
this.expectedLiquidityChange = (payload.expectedLiquidity10kBasis || 0) * Number(import_sdk.PERCENTAGE_DECIMALS);
|
|
113
|
+
this.expectedLiquidityInUSD = payload.expectedLiquidityInUSD || 0;
|
|
114
|
+
this.expectedLiqWeekAgo = payload.expectedLiqWeekAgo || 0;
|
|
115
|
+
this.expectedLiquidityLimit = (0, import_sdk.toBigInt)(payload.expectedLiquidityLimit || 0);
|
|
116
|
+
this.expectedLiquidityLimitInUSD = payload.expectedLiquidityLimitInUSD || 0;
|
|
117
|
+
this.totalBorrowed = (0, import_sdk.toBigInt)(payload.totalBorrowed || 0);
|
|
118
|
+
this.oldTotalBorrowed = (0, import_sdk.toBigInt)(payload.totalBorrowedOld || 0);
|
|
119
|
+
this.totalBorrowedChange = (payload.totalBorrowed10kBasis || 0) * Number(import_sdk.PERCENTAGE_DECIMALS);
|
|
120
|
+
this.totalBorrowedInUSD = payload.totalBorrowedInUSD || 0;
|
|
121
|
+
this.debtWithInterest = (0, import_sdk.toBigInt)(payload.debtWithInterest || 0);
|
|
122
|
+
this.debtWithInterestOld = (0, import_sdk.toBigInt)(payload.debtWithInterestOld || 0);
|
|
123
|
+
this.debtWithInterestChange = (payload.debtWithInterest10kBasis || 0) * Number(import_sdk.PERCENTAGE_DECIMALS);
|
|
124
|
+
this.debtWithInterestInUSD = payload.debtWithInterestInUSD || 0;
|
|
125
|
+
this.withdrawFee = payload.withdrawFee || 0;
|
|
126
|
+
this.addLiqCount = payload.addLiqCount || 0;
|
|
127
|
+
this.addedLiquidity = payload.addedLiquidity || 0;
|
|
128
|
+
this.removeLiqCount = payload.removeLiqCount || 0;
|
|
129
|
+
this.removedLiquidity = payload.removedLiquidity || 0;
|
|
130
|
+
this.depositAPY1DAverage = (payload.depositAPY1DAverage || 0) / Number(import_sdk.PERCENTAGE_DECIMALS);
|
|
131
|
+
this.depositAPY1DAverageChange = (payload.depositAPY1DAverage10kBasis || 0) * Number(import_sdk.PERCENTAGE_DECIMALS);
|
|
132
|
+
this.depositAPY7DAverage = (payload.depositAPY7DAverage || 0) / Number(import_sdk.PERCENTAGE_DECIMALS);
|
|
133
|
+
this.depositAPY30DAverage = (payload.depositAPY30DAverage || 0) / Number(import_sdk.PERCENTAGE_DECIMALS);
|
|
134
|
+
this.uniqueLPs = payload.uniqueLPs || 0;
|
|
135
|
+
this.oldUniqueLPs = payload.uniqueLPsOld || 0;
|
|
136
|
+
this.uniqueLPsChange = (payload.uniqueLPs10kBasis || 0) * Number(import_sdk.PERCENTAGE_DECIMALS);
|
|
137
|
+
}
|
|
138
|
+
static calculateUtilization(expected, available) {
|
|
139
|
+
if (expected === 0n) return 0;
|
|
140
|
+
const borrowed = expected - available;
|
|
141
|
+
const u = Number(borrowed * import_sdk.PERCENTAGE_FACTOR / expected) / Number(import_sdk.PERCENTAGE_DECIMALS);
|
|
142
|
+
return Math.max(0, u);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
class UserPoolData {
|
|
146
|
+
id;
|
|
147
|
+
address;
|
|
148
|
+
dieselToken;
|
|
149
|
+
underlyingToken;
|
|
150
|
+
marketConfigurator;
|
|
151
|
+
depositAPY;
|
|
152
|
+
depositAPYRay;
|
|
153
|
+
lmRewardAll;
|
|
154
|
+
providedLiquidity;
|
|
155
|
+
providedLiquidityInUSD;
|
|
156
|
+
dieselBalance;
|
|
157
|
+
dieselBalanceInUSD;
|
|
158
|
+
userRewards;
|
|
159
|
+
pnlInNativeToken;
|
|
160
|
+
pnlInUSD;
|
|
161
|
+
addedLiq;
|
|
162
|
+
addLiqCount;
|
|
163
|
+
removeLiqCount;
|
|
164
|
+
removedLiq;
|
|
165
|
+
constructor(payload) {
|
|
166
|
+
this.id = (payload.pool || "").toLowerCase();
|
|
167
|
+
this.address = (payload.pool || "").toLowerCase();
|
|
168
|
+
this.underlyingToken = (payload.underlyingToken || "").toLowerCase();
|
|
169
|
+
this.dieselToken = (payload.dieselToken || "").toLowerCase();
|
|
170
|
+
this.marketConfigurator = (payload.market || "").toLowerCase();
|
|
171
|
+
this.depositAPY = (0, import_sdk.rayToNumber)(payload.depositAPY_RAY || 0) * Number(import_sdk.PERCENTAGE_DECIMALS);
|
|
172
|
+
this.depositAPYRay = (0, import_sdk.toBigInt)(payload.depositAPY_RAY || 0);
|
|
173
|
+
this.lmRewardAll = (payload.lmRewardAll || []).map((r) => ({
|
|
174
|
+
apy: (r.apy || 0) / Number(import_sdk.PERCENTAGE_DECIMALS),
|
|
175
|
+
token: (r.token || "").toLowerCase()
|
|
176
|
+
}));
|
|
177
|
+
this.providedLiquidity = (0, import_sdk.toBigInt)(payload.liqValue || 0);
|
|
178
|
+
this.providedLiquidityInUSD = payload.liqValueInUSD;
|
|
179
|
+
this.dieselBalance = (0, import_sdk.toBigInt)(payload.dieselBalanceBI || 0);
|
|
180
|
+
this.dieselBalanceInUSD = payload.dieselBalance;
|
|
181
|
+
this.userRewards = (payload.userRewards || []).map((r) => ({
|
|
182
|
+
token: (r.rewardToken || "").toLowerCase(),
|
|
183
|
+
pool: (r.pool || "").toLowerCase(),
|
|
184
|
+
lmRewards: (0, import_sdk.toBigInt)(r.lmRewards || 0),
|
|
185
|
+
lmRewardsInUSD: r.lmRewardsInUSD
|
|
186
|
+
}));
|
|
187
|
+
this.pnlInNativeToken = payload.liqPnlInNativeToken;
|
|
188
|
+
this.pnlInUSD = payload.liqPnlInUSD;
|
|
189
|
+
this.addedLiq = payload.addedLiq;
|
|
190
|
+
this.addLiqCount = payload.addLiqCount;
|
|
191
|
+
this.removeLiqCount = payload.removeLiqCount;
|
|
192
|
+
this.removedLiq = payload.removedLiq;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
196
|
+
0 && (module.exports = {
|
|
197
|
+
ChartsPoolData,
|
|
198
|
+
UserPoolData
|
|
199
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var token_data_exports = {};
|
|
20
|
+
__export(token_data_exports, {
|
|
21
|
+
TokenData: () => TokenData
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(token_data_exports);
|
|
24
|
+
const HUMAN_READABLE_TITLES = {
|
|
25
|
+
USDC_e: "USDC.e",
|
|
26
|
+
dUSDC_eV3: "dUSDC.eV3",
|
|
27
|
+
sdUSDC_eV3: "sdUSDC.eV3",
|
|
28
|
+
sdWETHV3_OLD: "sdWETHV3 Old",
|
|
29
|
+
PT_rsETH_26SEP2024: "pt.rsETH(26.09.24)",
|
|
30
|
+
PT_sUSDe_26DEC2024: "pt.sUSDe(26.12.24)",
|
|
31
|
+
PT_eETH_26DEC2024: "pt.eETH(26.12.24)",
|
|
32
|
+
PT_ezETH_26DEC2024: "pt.ezETH(26.12.24)",
|
|
33
|
+
PT_eBTC_26DEC2024: "pt.eBTC(26.12.24)",
|
|
34
|
+
PT_LBTC_27MAR2025: "pt.LBTC(27.03.25)",
|
|
35
|
+
PT_cornLBTC_26DEC2024: "pt.c.LBTC(26.12.24)",
|
|
36
|
+
PT_corn_eBTC_27MAR2025: "pt.c.eBTC(27.03.25)",
|
|
37
|
+
PT_corn_pumpBTC_26DEC2024: "pt.c.pumpBTC(26.12.24)",
|
|
38
|
+
PT_sUSDe_27MAR2025: "pt.sUSDe(27.03.25)",
|
|
39
|
+
PT_sUSDe_29MAY2025: "pt.sUSDe(29.05.25)",
|
|
40
|
+
PT_beraSTONE_10APR2025: "pt.beraSTONE(10.04.25)",
|
|
41
|
+
PT_uptBTC_14AUG2025: "pt.uptBTC(14.08.25)",
|
|
42
|
+
PT_sUSDX_1SEP2025: "pt.sUSDX(1.09.25)",
|
|
43
|
+
PT_sUSDf_25SEP2025: "pt.sUSDf(25.09.25)",
|
|
44
|
+
"PT-sUSDf-29JAN2026": "pt.sUSDf(29.01.26)",
|
|
45
|
+
PT_USDf_29JAN2026: "pt.USDf(29.01.26)",
|
|
46
|
+
stkcvxllamathena_v3_1: "stkcvxllamathena",
|
|
47
|
+
stkcvxRLUSDUSDC_v3_1: "stkcvxRLUSDUSDC",
|
|
48
|
+
"PT-wstUSR-25SEP2025": "pt.wstUSR(25.09.25)",
|
|
49
|
+
"PT-yUSD-27NOV2025": "pt.yUSD(27.11.25)",
|
|
50
|
+
"PT-pUSDe-16OCT2025": "pt.pUSDe(16.10.25)",
|
|
51
|
+
"PT-USDe-15JAN2026": "pt.USDe(15.01.26)",
|
|
52
|
+
"PT-sUSDe-15JAN2026": "pt.sUSDe(15.01.26)",
|
|
53
|
+
"PT-syrupUSDT-29JAN2026": "pt.syrupUSDT(29.01.26)",
|
|
54
|
+
"PT-USDai-19MAR2026": "pt.USDai(19.03.26)",
|
|
55
|
+
"PT-sUSDai-19MAR2026": "pt.sUSDai(19.03.26)",
|
|
56
|
+
"LP-syrupUSDT-29JAN2026": "lp.syrupUSDT(29.01.26)",
|
|
57
|
+
["0xab7d50fc2486a1ac06516e2ece9dadc95ba8cd20".toLowerCase()]: "cp0xLRT\xA0\u2192\xA0wstETH",
|
|
58
|
+
["0x6252467c2fefb61cb55180282943139baeea36c5".toLowerCase()]: "rstETH\xA0\u2192\xA0wstETH",
|
|
59
|
+
["0xd412ca00d177eba2843348f9c50dd17bfce32c40".toLowerCase()]: "pzETH\xA0\u2192\xA0wstETH",
|
|
60
|
+
["0x26c98674e623647f11909791593fa3b6e9406c67".toLowerCase()]: "steak7LRT\xA0\u2192\xA0wstETH",
|
|
61
|
+
["0x9fb930eacadad079683a4758424a53b9b3692775".toLowerCase()]: "Re7LRT\xA0\u2192\xA0wstETH",
|
|
62
|
+
["0xd7f1A4e3aba92a9D20987C752Bd4a6cc759D7738".toLowerCase()]: "hgETH\xA0\u2192\xA0rsETH",
|
|
63
|
+
["0xd2a72aa2d3f2815673f4bb887559c333d7f1f34f".toLowerCase()]: "mEDGE\xA0\u2192\xA0USDC",
|
|
64
|
+
ETHPlus: "ETH+"
|
|
65
|
+
};
|
|
66
|
+
class TokenData {
|
|
67
|
+
address;
|
|
68
|
+
title;
|
|
69
|
+
symbol;
|
|
70
|
+
name;
|
|
71
|
+
decimals;
|
|
72
|
+
icon;
|
|
73
|
+
isPhantom;
|
|
74
|
+
constructor(payload) {
|
|
75
|
+
const address = payload.addr.toLowerCase();
|
|
76
|
+
this.address = address;
|
|
77
|
+
this.title = HUMAN_READABLE_TITLES[payload.symbol] || HUMAN_READABLE_TITLES[address] || payload.title || payload.symbol;
|
|
78
|
+
this.symbol = payload.symbol;
|
|
79
|
+
this.name = payload.name;
|
|
80
|
+
this.decimals = payload.decimals;
|
|
81
|
+
this.icon = TokenData.getTokenIcon(payload.symbol);
|
|
82
|
+
this.isPhantom = payload.isPhantom ?? false;
|
|
83
|
+
}
|
|
84
|
+
static getTokenIcon(symbol) {
|
|
85
|
+
return `https://static.gearbox.finance/tokens/${symbol.toLowerCase()}.svg`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
+
0 && (module.exports = {
|
|
90
|
+
TokenData
|
|
91
|
+
});
|
|
@@ -15,8 +15,12 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var common_utils_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(common_utils_exports);
|
|
18
|
+
__reExport(common_utils_exports, require("./charts/index.js"), module.exports);
|
|
19
|
+
__reExport(common_utils_exports, require("./static/index.js"), module.exports);
|
|
18
20
|
__reExport(common_utils_exports, require("./utils/index.js"), module.exports);
|
|
19
21
|
// Annotate the CommonJS export names for ESM import in node:
|
|
20
22
|
0 && (module.exports = {
|
|
23
|
+
...require("./charts/index.js"),
|
|
24
|
+
...require("./static/index.js"),
|
|
21
25
|
...require("./utils/index.js")
|
|
22
26
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var static_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(static_exports);
|
|
18
|
+
__reExport(static_exports, require("./migration-config.js"), module.exports);
|
|
19
|
+
__reExport(static_exports, require("./pool-config.js"), module.exports);
|
|
20
|
+
__reExport(static_exports, require("./strategy.js"), module.exports);
|
|
21
|
+
__reExport(static_exports, require("./trading-pair.js"), module.exports);
|
|
22
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
23
|
+
0 && (module.exports = {
|
|
24
|
+
...require("./migration-config.js"),
|
|
25
|
+
...require("./pool-config.js"),
|
|
26
|
+
...require("./strategy.js"),
|
|
27
|
+
...require("./trading-pair.js")
|
|
28
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var migration_config_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(migration_config_exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var pool_config_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(pool_config_exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var strategy_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(strategy_exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var trading_pair_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(trading_pair_exports);
|
|
@@ -16,14 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var assets_math_exports = {};
|
|
20
|
+
__export(assets_math_exports, {
|
|
21
21
|
AssetUtils: () => AssetUtils
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
var
|
|
23
|
+
module.exports = __toCommonJS(assets_math_exports);
|
|
24
|
+
var import_bigint_math = require("./bigint-math.js");
|
|
25
25
|
var import_sort = require("./creditAccount/sort.js");
|
|
26
|
-
var
|
|
26
|
+
var import_price_math = require("./price-math.js");
|
|
27
27
|
class AssetUtils {
|
|
28
28
|
constructor() {
|
|
29
29
|
}
|
|
@@ -120,10 +120,10 @@ class AssetUtils {
|
|
|
120
120
|
const unwrappedPrice = prices[unwrappedAddress] || 0n;
|
|
121
121
|
const wrappedToken = tokensList[wrappedAddress];
|
|
122
122
|
const wrappedPrice = prices[wrappedAddress] || 0n;
|
|
123
|
-
const unwrappedInWrapped =
|
|
124
|
-
|
|
123
|
+
const unwrappedInWrapped = import_price_math.PriceUtils.convertByPrice(
|
|
124
|
+
import_price_math.PriceUtils.calcTotalPrice(
|
|
125
125
|
unwrappedPrice,
|
|
126
|
-
|
|
126
|
+
import_bigint_math.BigIntMath.max(0n, unwrappedAmount),
|
|
127
127
|
unwrappedToken.decimals
|
|
128
128
|
),
|
|
129
129
|
{
|
|
@@ -133,7 +133,7 @@ class AssetUtils {
|
|
|
133
133
|
);
|
|
134
134
|
assetsRecord[wrappedAddress] = {
|
|
135
135
|
token: wrappedAddress,
|
|
136
|
-
balance:
|
|
136
|
+
balance: import_bigint_math.BigIntMath.max(0n, wrappedAmount) + unwrappedInWrapped
|
|
137
137
|
};
|
|
138
138
|
delete assetsRecord[unwrappedAddress];
|
|
139
139
|
return [Object.values(assetsRecord), unwrappedInWrapped, wrappedAmount];
|
|
@@ -157,7 +157,7 @@ class AssetUtils {
|
|
|
157
157
|
const resRecord = b.reduce((acc, bAsset) => {
|
|
158
158
|
const aAsset = acc[bAsset.token];
|
|
159
159
|
const { balance: amount = 0n } = aAsset || {};
|
|
160
|
-
const amountSum =
|
|
160
|
+
const amountSum = import_bigint_math.BigIntMath.max(0n, bAsset.balance) + import_bigint_math.BigIntMath.max(0n, amount);
|
|
161
161
|
const aOrB = aAsset || bAsset;
|
|
162
162
|
acc[bAsset.token] = {
|
|
163
163
|
...aOrB,
|
|
@@ -184,7 +184,7 @@ class AssetUtils {
|
|
|
184
184
|
return a.map((asset) => {
|
|
185
185
|
const bAsset = bRecord[asset.token];
|
|
186
186
|
const { balance: bAmount = 0n } = bAsset || {};
|
|
187
|
-
const amountSum =
|
|
187
|
+
const amountSum = import_bigint_math.BigIntMath.max(0n, asset.balance) + import_bigint_math.BigIntMath.max(0n, bAmount);
|
|
188
188
|
return { ...asset, balance: amountSum };
|
|
189
189
|
});
|
|
190
190
|
}
|
|
@@ -205,8 +205,8 @@ class AssetUtils {
|
|
|
205
205
|
return a.map((asset) => {
|
|
206
206
|
const bAsset = bRecord[asset.token];
|
|
207
207
|
const { balance: bAmount = 0n } = bAsset || {};
|
|
208
|
-
const amountSub =
|
|
209
|
-
return { ...asset, balance:
|
|
208
|
+
const amountSub = import_bigint_math.BigIntMath.max(0n, asset.balance) - import_bigint_math.BigIntMath.max(0n, bAmount);
|
|
209
|
+
return { ...asset, balance: import_bigint_math.BigIntMath.max(0n, amountSub) };
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
212
|
}
|
|
@@ -16,11 +16,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var bigint_math_exports = {};
|
|
20
|
+
__export(bigint_math_exports, {
|
|
21
21
|
BigIntMath: () => BigIntMath
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(bigint_math_exports);
|
|
24
24
|
class BigIntMath {
|
|
25
25
|
constructor() {
|
|
26
26
|
}
|
package/dist/cjs/common-utils/utils/creditAccount/{calcHealthFactor.js → calc-health-factor.js}
RENAMED
|
@@ -16,14 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var calc_health_factor_exports = {};
|
|
20
|
+
__export(calc_health_factor_exports, {
|
|
21
21
|
calcHealthFactor: () => calcHealthFactor
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(calc_health_factor_exports);
|
|
24
24
|
var import_sdk = require("../../../sdk/index.js");
|
|
25
|
-
var
|
|
26
|
-
var
|
|
25
|
+
var import_bigint_math = require("../bigint-math.js");
|
|
26
|
+
var import_price_math = require("../price-math.js");
|
|
27
27
|
const MAX_UINT16 = 65535;
|
|
28
28
|
function calcHealthFactor({
|
|
29
29
|
assets,
|
|
@@ -43,7 +43,7 @@ function calcHealthFactor({
|
|
|
43
43
|
const tokenDecimals = tokensList[tokenAddress]?.decimals || 18;
|
|
44
44
|
const lt = liquidationThresholds[tokenAddress] || 0n;
|
|
45
45
|
const price = prices[tokenAddress] || 0n;
|
|
46
|
-
const tokenMoney =
|
|
46
|
+
const tokenMoney = import_price_math.PriceUtils.calcTotalPrice(
|
|
47
47
|
price,
|
|
48
48
|
amount,
|
|
49
49
|
tokenDecimals
|
|
@@ -52,17 +52,17 @@ function calcHealthFactor({
|
|
|
52
52
|
const { isActive = false } = quotasInfo?.[tokenAddress] || {};
|
|
53
53
|
const quota = quotas[tokenAddress];
|
|
54
54
|
const quotaBalance = isActive ? quota?.balance || 0n : 0n;
|
|
55
|
-
const quotaMoney =
|
|
55
|
+
const quotaMoney = import_price_math.PriceUtils.calcTotalPrice(
|
|
56
56
|
underlyingPrice,
|
|
57
57
|
quotaBalance,
|
|
58
58
|
underlyingDecimals
|
|
59
59
|
);
|
|
60
|
-
const money = quota ?
|
|
60
|
+
const money = quota ? import_bigint_math.BigIntMath.min(quotaMoney, tokenLtMoney) : tokenLtMoney;
|
|
61
61
|
return acc + money;
|
|
62
62
|
},
|
|
63
63
|
0n
|
|
64
64
|
);
|
|
65
|
-
const borrowedMoney =
|
|
65
|
+
const borrowedMoney = import_price_math.PriceUtils.calcTotalPrice(
|
|
66
66
|
underlyingPrice || import_sdk.PRICE_DECIMALS,
|
|
67
67
|
debt,
|
|
68
68
|
underlyingDecimals
|
|
@@ -16,13 +16,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var calc_overall_apy_exports = {};
|
|
20
|
+
__export(calc_overall_apy_exports, {
|
|
21
21
|
calcOverallAPY: () => calcOverallAPY
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(calc_overall_apy_exports);
|
|
24
24
|
var import_sdk = require("../../../sdk/index.js");
|
|
25
|
-
var
|
|
25
|
+
var import_price_math = require("../price-math.js");
|
|
26
26
|
function calcOverallAPY({
|
|
27
27
|
caAssets,
|
|
28
28
|
lpAPY,
|
|
@@ -45,12 +45,12 @@ function calcOverallAPY({
|
|
|
45
45
|
const apy = lpAPY[tokenAddress] || 0;
|
|
46
46
|
const tokenDecimals = tokensList[tokenAddress]?.decimals || 18;
|
|
47
47
|
const price = prices[tokenAddress] || 0n;
|
|
48
|
-
const money =
|
|
48
|
+
const money = import_price_math.PriceUtils.calcTotalPrice(price, amount, tokenDecimals);
|
|
49
49
|
const apyMoney = money * BigInt(apy);
|
|
50
50
|
const { rate: quotaAPY = 0n, isActive = false } = quotaRates?.[tokenAddress] || {};
|
|
51
51
|
const { balance: quotaBalance = 0n } = quotas[tokenAddress] || {};
|
|
52
52
|
const quotaAmount = isActive ? quotaBalance : 0n;
|
|
53
|
-
const quotaMoney =
|
|
53
|
+
const quotaMoney = import_price_math.PriceUtils.calcTotalPrice(
|
|
54
54
|
underlyingPrice || 0n,
|
|
55
55
|
quotaAmount,
|
|
56
56
|
underlyingTokenDecimals
|
|
@@ -61,13 +61,13 @@ function calcOverallAPY({
|
|
|
61
61
|
},
|
|
62
62
|
0n
|
|
63
63
|
);
|
|
64
|
-
const debtMoney =
|
|
64
|
+
const debtMoney = import_price_math.PriceUtils.calcTotalPrice(
|
|
65
65
|
underlyingPrice || 0n,
|
|
66
66
|
debt,
|
|
67
67
|
underlyingTokenDecimals
|
|
68
68
|
);
|
|
69
69
|
const debtAPYMoney = debtMoney * BigInt(baseRateWithFee);
|
|
70
|
-
const yourAssetsMoney =
|
|
70
|
+
const yourAssetsMoney = import_price_math.PriceUtils.calcTotalPrice(
|
|
71
71
|
underlyingPrice || import_sdk.PRICE_DECIMALS,
|
|
72
72
|
totalValue - debt,
|
|
73
73
|
underlyingTokenDecimals
|
|
@@ -16,11 +16,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var calc_quota_borrow_rate_exports = {};
|
|
20
|
+
__export(calc_quota_borrow_rate_exports, {
|
|
21
21
|
calcQuotaBorrowRate: () => calcQuotaBorrowRate
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(calc_quota_borrow_rate_exports);
|
|
24
24
|
function calcQuotaBorrowRate({
|
|
25
25
|
quotas,
|
|
26
26
|
quotaRates
|
|
@@ -16,11 +16,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var calc_relative_base_borrow_rate_exports = {};
|
|
20
|
+
__export(calc_relative_base_borrow_rate_exports, {
|
|
21
21
|
calcRelativeBaseBorrowRate: () => calcRelativeBaseBorrowRate
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(calc_relative_base_borrow_rate_exports);
|
|
24
24
|
function calcRelativeBaseBorrowRate({
|
|
25
25
|
debt,
|
|
26
26
|
baseRateWithFee,
|
|
@@ -23,11 +23,11 @@ __export(debt_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(debt_exports);
|
|
25
25
|
var import_sdk = require("../../../sdk/index.js");
|
|
26
|
-
var
|
|
27
|
-
var
|
|
26
|
+
var import_bigint_math = require("../bigint-math.js");
|
|
27
|
+
var import_price_math = require("../price-math.js");
|
|
28
28
|
function calcMaxDebtIncrease(healthFactor, debt, underlyingLT, minHf = Number(import_sdk.PERCENTAGE_FACTOR)) {
|
|
29
29
|
const result = debt * BigInt(healthFactor - minHf) / BigInt(minHf - underlyingLT);
|
|
30
|
-
return
|
|
30
|
+
return import_bigint_math.BigIntMath.max(0n, result);
|
|
31
31
|
}
|
|
32
32
|
function calcMaxLendingDebt({
|
|
33
33
|
assets,
|
|
@@ -42,7 +42,7 @@ function calcMaxLendingDebt({
|
|
|
42
42
|
const tokenDecimals = tokensList[tokenAddress]?.decimals || 18;
|
|
43
43
|
const lt = liquidationThresholds[tokenAddress] || 0n;
|
|
44
44
|
const price = prices[tokenAddress] || 0n;
|
|
45
|
-
const tokenMoney =
|
|
45
|
+
const tokenMoney = import_price_math.PriceUtils.calcTotalPrice(
|
|
46
46
|
price,
|
|
47
47
|
amount,
|
|
48
48
|
tokenDecimals
|
|
@@ -16,11 +16,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var get_time_to_liquidation_exports = {};
|
|
20
|
+
__export(get_time_to_liquidation_exports, {
|
|
21
21
|
getTimeToLiquidation: () => getTimeToLiquidation
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(get_time_to_liquidation_exports);
|
|
24
24
|
var import_sdk = require("../../../sdk/index.js");
|
|
25
25
|
function getTimeToLiquidation({
|
|
26
26
|
healthFactor,
|