@gearbox-protocol/sdk 13.6.0-kyc.7 → 13.6.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/dev/AccountOpener.js +5 -45
- package/dist/cjs/dev/logSplitterTransport.js +10 -1
- package/dist/cjs/plugins/adapters/abi/actionAbi.js +1 -1
- package/dist/cjs/plugins/adapters/abi/conctructorAbi.js +1 -1
- package/dist/cjs/plugins/adapters/createAdapter.js +1 -1
- package/dist/cjs/plugins/adapters/types.js +1 -1
- package/dist/cjs/plugins/apy/ApyPlugin.js +266 -0
- package/dist/cjs/plugins/apy/apy-cache.js +120 -0
- package/dist/cjs/plugins/apy/apy-parser.js +169 -0
- package/dist/cjs/{sdk/market/kyc/securitize → plugins/apy}/constants.js +6 -3
- package/dist/cjs/{sdk/market/kyc/securitize → plugins/apy}/index.js +14 -6
- package/dist/cjs/{sdk/market/kyc/securitize/types.js → plugins/apy/pool-apy-types.js} +2 -2
- package/dist/cjs/plugins/apy/pool-apy-utils.js +141 -0
- package/dist/cjs/rewards/rewards/extra-apy.js +10 -8
- package/dist/cjs/sdk/GearboxSDK.js +5 -52
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +16 -324
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +1 -7
- package/dist/cjs/sdk/base/TokensMeta.js +43 -32
- package/dist/cjs/sdk/base/token-types.js +0 -9
- package/dist/cjs/sdk/chain/chains.js +32 -17
- package/dist/cjs/sdk/constants/address-provider.js +0 -3
- package/dist/cjs/sdk/market/MarketRegister.js +116 -70
- package/dist/cjs/sdk/market/MarketSuite.js +0 -3
- package/dist/cjs/sdk/market/index.js +0 -2
- package/dist/cjs/sdk/market/pool/PoolSuite.js +0 -3
- package/dist/cjs/sdk/market/pool/PoolV310Contract.js +2 -11
- package/dist/cjs/sdk/market/pool/index.js +0 -2
- package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -3
- package/dist/cjs/sdk/options.js +1 -7
- package/dist/cjs/sdk/pools/PoolService.js +12 -104
- package/dist/cjs/sdk/utils/viem/index.js +0 -2
- package/dist/cjs/sdk/utils/viem/simulateWithPriceUpdates.js +39 -2
- package/dist/esm/dev/AccountOpener.js +6 -47
- package/dist/esm/dev/logSplitterTransport.js +10 -1
- package/dist/esm/plugins/adapters/abi/actionAbi.js +1 -1
- package/dist/esm/plugins/adapters/abi/conctructorAbi.js +1 -1
- package/dist/esm/plugins/adapters/createAdapter.js +1 -1
- package/dist/esm/plugins/adapters/types.js +1 -1
- package/dist/esm/plugins/apy/ApyPlugin.js +255 -0
- package/dist/esm/plugins/apy/apy-cache.js +86 -0
- package/dist/esm/plugins/apy/apy-parser.js +143 -0
- package/dist/esm/plugins/apy/constants.js +6 -0
- package/dist/esm/plugins/apy/index.js +7 -0
- package/dist/esm/plugins/apy/pool-apy-utils.js +113 -0
- package/dist/esm/rewards/rewards/extra-apy.js +10 -8
- package/dist/esm/sdk/GearboxSDK.js +6 -56
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +17 -328
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +1 -7
- package/dist/esm/sdk/base/TokensMeta.js +45 -32
- package/dist/esm/sdk/base/token-types.js +0 -6
- package/dist/esm/sdk/chain/chains.js +32 -17
- package/dist/esm/sdk/constants/address-provider.js +0 -2
- package/dist/esm/sdk/market/MarketRegister.js +118 -74
- package/dist/esm/sdk/market/MarketSuite.js +0 -3
- 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 -11
- package/dist/esm/sdk/market/pool/index.js +0 -1
- package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -3
- package/dist/esm/sdk/options.js +1 -7
- package/dist/esm/sdk/pools/PoolService.js +13 -109
- package/dist/esm/sdk/utils/viem/index.js +0 -1
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +41 -2
- package/dist/types/dev/logSplitterTransport.d.ts +3 -1
- package/dist/types/plugins/adapters/types.d.ts +2 -2
- package/dist/types/plugins/apy/ApyPlugin.d.ts +46 -0
- package/dist/types/plugins/apy/apy-cache.d.ts +28 -0
- package/dist/types/plugins/apy/apy-parser.d.ts +5 -0
- package/dist/types/plugins/apy/constants.d.ts +2 -0
- package/dist/types/plugins/apy/index.d.ts +7 -0
- package/dist/types/plugins/apy/pool-apy-types.d.ts +41 -0
- package/dist/types/plugins/apy/pool-apy-utils.d.ts +73 -0
- package/dist/types/plugins/apy/types.d.ts +37 -0
- package/dist/types/rewards/rewards/api.d.ts +10 -1
- package/dist/types/rewards/rewards/common.d.ts +0 -10
- package/dist/types/rewards/rewards/extra-apy.d.ts +4 -6
- package/dist/types/sdk/GearboxSDK.d.ts +0 -7
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +2 -52
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
- package/dist/types/sdk/accounts/types.d.ts +13 -93
- package/dist/types/sdk/base/TokensMeta.d.ts +3 -14
- package/dist/types/sdk/base/token-types.d.ts +4 -44
- package/dist/types/sdk/base/types.d.ts +11 -116
- package/dist/types/sdk/chain/chains.d.ts +5 -5
- package/dist/types/sdk/constants/address-provider.d.ts +0 -1
- package/dist/types/sdk/market/MarketRegister.d.ts +9 -6
- package/dist/types/sdk/market/MarketSuite.d.ts +0 -2
- package/dist/types/sdk/market/index.d.ts +0 -1
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +2 -3
- package/dist/types/sdk/market/oracle/types.d.ts +10 -3
- 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 -1
- package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +1 -1
- package/dist/types/sdk/market/types.d.ts +1 -1
- package/dist/types/sdk/options.d.ts +0 -1
- package/dist/types/sdk/pools/PoolService.d.ts +8 -8
- package/dist/types/sdk/pools/types.d.ts +1 -1
- package/dist/types/sdk/types/state-human.d.ts +0 -2
- package/dist/types/sdk/types/state.d.ts +0 -5
- package/dist/types/sdk/utils/viem/index.d.ts +0 -1
- package/package.json +2 -3
- package/dist/cjs/abi/kyc/iDSRegistryService.js +0 -70
- package/dist/cjs/abi/kyc/iDSToken.js +0 -71
- package/dist/cjs/abi/kyc/iKYCCompressor.js +0 -196
- package/dist/cjs/abi/kyc/iKYCFactory.js +0 -122
- package/dist/cjs/abi/kyc/iKYCUnderlying.js +0 -401
- package/dist/cjs/abi/kyc/iSecuritizeDegenNFT.js +0 -326
- package/dist/cjs/abi/kyc/iSecuritizeKYCFactory.js +0 -319
- package/dist/cjs/plugins/pools-history/Pools7DAgoPlugin.js +0 -108
- package/dist/cjs/plugins/pools-history/index.js +0 -24
- package/dist/cjs/sdk/market/kyc/KYCRegistry.js +0 -269
- package/dist/cjs/sdk/market/kyc/index.js +0 -26
- package/dist/cjs/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +0 -244
- package/dist/cjs/sdk/market/kyc/types.js +0 -34
- package/dist/cjs/sdk/utils/viem/executeDelegatedMulticalls.js +0 -38
- package/dist/esm/abi/kyc/iDSRegistryService.js +0 -46
- package/dist/esm/abi/kyc/iDSToken.js +0 -47
- package/dist/esm/abi/kyc/iKYCCompressor.js +0 -172
- package/dist/esm/abi/kyc/iKYCFactory.js +0 -98
- package/dist/esm/abi/kyc/iKYCUnderlying.js +0 -377
- package/dist/esm/abi/kyc/iSecuritizeDegenNFT.js +0 -302
- package/dist/esm/abi/kyc/iSecuritizeKYCFactory.js +0 -295
- package/dist/esm/plugins/pools-history/Pools7DAgoPlugin.js +0 -90
- package/dist/esm/plugins/pools-history/index.js +0 -2
- package/dist/esm/sdk/market/kyc/KYCRegistry.js +0 -253
- package/dist/esm/sdk/market/kyc/index.js +0 -3
- package/dist/esm/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +0 -220
- package/dist/esm/sdk/market/kyc/securitize/constants.js +0 -4
- package/dist/esm/sdk/market/kyc/securitize/index.js +0 -3
- package/dist/esm/sdk/market/kyc/types.js +0 -9
- package/dist/esm/sdk/utils/viem/executeDelegatedMulticalls.js +0 -14
- package/dist/types/abi/kyc/iDSRegistryService.d.ts +0 -71
- package/dist/types/abi/kyc/iDSToken.d.ts +0 -67
- package/dist/types/abi/kyc/iKYCCompressor.d.ts +0 -228
- package/dist/types/abi/kyc/iKYCFactory.d.ts +0 -139
- package/dist/types/abi/kyc/iKYCUnderlying.d.ts +0 -548
- package/dist/types/abi/kyc/iSecuritizeDegenNFT.d.ts +0 -404
- package/dist/types/abi/kyc/iSecuritizeKYCFactory.d.ts +0 -376
- package/dist/types/plugins/pools-history/Pools7DAgoPlugin.d.ts +0 -20
- package/dist/types/plugins/pools-history/index.d.ts +0 -2
- package/dist/types/plugins/pools-history/types.d.ts +0 -9
- package/dist/types/sdk/market/kyc/KYCRegistry.d.ts +0 -52
- package/dist/types/sdk/market/kyc/index.d.ts +0 -3
- package/dist/types/sdk/market/kyc/securitize/SecuritizeKYCFactory.d.ts +0 -428
- package/dist/types/sdk/market/kyc/securitize/constants.d.ts +0 -1
- package/dist/types/sdk/market/kyc/securitize/index.d.ts +0 -3
- package/dist/types/sdk/market/kyc/securitize/types.d.ts +0 -127
- package/dist/types/sdk/market/kyc/types.d.ts +0 -170
- package/dist/types/sdk/utils/viem/executeDelegatedMulticalls.d.ts +0 -28
- /package/dist/cjs/plugins/{pools-history → apy}/package.json +0 -0
- /package/dist/cjs/plugins/{pools-history → apy}/types.js +0 -0
- /package/dist/esm/plugins/{pools-history → apy}/package.json +0 -0
- /package/dist/esm/plugins/{pools-history/types.js → apy/pool-apy-types.js} +0 -0
- /package/dist/esm/{sdk/market/kyc/securitize → plugins/apy}/types.js +0 -0
|
@@ -0,0 +1,169 @@
|
|
|
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 apy_parser_exports = {};
|
|
20
|
+
__export(apy_parser_exports, {
|
|
21
|
+
numberToAPY: () => numberToAPY,
|
|
22
|
+
parseGearStats: () => parseGearStats,
|
|
23
|
+
parseNetworkApy: () => parseNetworkApy
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(apy_parser_exports);
|
|
26
|
+
var import_sdk = require("../../sdk/index.js");
|
|
27
|
+
function numberToAPY(baseApy) {
|
|
28
|
+
return Math.round(baseApy * Number(import_sdk.PERCENTAGE_FACTOR));
|
|
29
|
+
}
|
|
30
|
+
function parseGearStats(output) {
|
|
31
|
+
const d = output.gearApy?.status === "ok" ? output.gearApy.data : void 0;
|
|
32
|
+
if (!d) return null;
|
|
33
|
+
return {
|
|
34
|
+
base: numberToAPY(d.base ?? 0),
|
|
35
|
+
crv: numberToAPY(d.crv ?? 0),
|
|
36
|
+
gear: numberToAPY(d.gear ?? 0),
|
|
37
|
+
gearPrice: d.gearPrice ?? 0
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function parseNetworkApy(apyResp, poolResp) {
|
|
41
|
+
const baseAPYList = {};
|
|
42
|
+
const extraCollateralAPYList = {};
|
|
43
|
+
const basePointsList = {};
|
|
44
|
+
const extraCollateralPointsList = {};
|
|
45
|
+
const tokenExtraRewardsList = {};
|
|
46
|
+
const apyData = apyResp?.status === "ok" ? apyResp.data : void 0;
|
|
47
|
+
for (const d of apyData ?? []) {
|
|
48
|
+
const tokenAddress = d.address.toLowerCase();
|
|
49
|
+
const tokenSymbol = d.symbol;
|
|
50
|
+
const apy = d.rewards.apy?.[0];
|
|
51
|
+
if (apy) {
|
|
52
|
+
baseAPYList[tokenAddress] = numberToAPY(apy.value ?? 0);
|
|
53
|
+
}
|
|
54
|
+
const points = d.rewards.points?.[0];
|
|
55
|
+
if (points) {
|
|
56
|
+
basePointsList[tokenAddress] = {
|
|
57
|
+
address: tokenAddress,
|
|
58
|
+
symbol: tokenSymbol,
|
|
59
|
+
rewards: points.rewards.map((p) => ({
|
|
60
|
+
...p,
|
|
61
|
+
multiplier: p.multiplier === "soon" ? p.multiplier : BigInt(p.multiplier || 0)
|
|
62
|
+
})),
|
|
63
|
+
debtRewards: points.debtRewards?.map((p) => ({
|
|
64
|
+
...p,
|
|
65
|
+
cm: (p.cm || "").toLowerCase(),
|
|
66
|
+
multiplier: p.multiplier === "soon" ? p.multiplier : BigInt(p.multiplier || 0)
|
|
67
|
+
}))
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const extraRewards = d.rewards.extraRewards;
|
|
71
|
+
if (extraRewards && extraRewards.length > 0) {
|
|
72
|
+
tokenExtraRewardsList[tokenAddress] = extraRewards.map((r) => ({
|
|
73
|
+
address: tokenAddress,
|
|
74
|
+
symbol: r.rewardSymbol,
|
|
75
|
+
rewardToken: r.rewardToken.toLowerCase(),
|
|
76
|
+
rewardSymbol: r.rewardSymbol,
|
|
77
|
+
token: r.rewardToken.toLowerCase(),
|
|
78
|
+
finished: BigInt(r.finished || 0),
|
|
79
|
+
duration: BigInt(r.duration || 0),
|
|
80
|
+
reward: BigInt(r.reward || 0),
|
|
81
|
+
balance: BigInt(r.balance || 0)
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
const ecApy = d.rewards.extraCollateralAPY;
|
|
85
|
+
if (ecApy && ecApy.length > 0) {
|
|
86
|
+
for (const ea of ecApy) {
|
|
87
|
+
const pool = ea.pool.toLowerCase();
|
|
88
|
+
if (!extraCollateralAPYList[pool]) extraCollateralAPYList[pool] = {};
|
|
89
|
+
extraCollateralAPYList[pool][tokenAddress] = {
|
|
90
|
+
...ea,
|
|
91
|
+
address: tokenAddress,
|
|
92
|
+
symbol: tokenSymbol,
|
|
93
|
+
pool,
|
|
94
|
+
value: numberToAPY(ea.value ?? 0)
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const ecPoints = d.rewards.extraCollateralPoints;
|
|
99
|
+
if (ecPoints && ecPoints.length > 0) {
|
|
100
|
+
for (const ea of ecPoints) {
|
|
101
|
+
const pool = ea.pool.toLowerCase();
|
|
102
|
+
if (!extraCollateralPointsList[pool])
|
|
103
|
+
extraCollateralPointsList[pool] = {};
|
|
104
|
+
extraCollateralPointsList[pool][tokenAddress] = {
|
|
105
|
+
address: tokenAddress,
|
|
106
|
+
symbol: tokenSymbol,
|
|
107
|
+
rewards: ea.rewards.map((p) => ({
|
|
108
|
+
...p,
|
|
109
|
+
multiplier: p.multiplier === "soon" ? p.multiplier : BigInt(p.multiplier || 0)
|
|
110
|
+
})),
|
|
111
|
+
debtRewards: ea.debtRewards?.map((p) => ({
|
|
112
|
+
...p,
|
|
113
|
+
cm: (p.cm || "").toLowerCase(),
|
|
114
|
+
multiplier: p.multiplier === "soon" ? p.multiplier : BigInt(p.multiplier || 0)
|
|
115
|
+
}))
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const poolRewardsList = {};
|
|
121
|
+
const poolExternalAPYList = {};
|
|
122
|
+
const poolExtraAPYList = {};
|
|
123
|
+
const poolData = poolResp?.status === "ok" ? poolResp.data : void 0;
|
|
124
|
+
for (const r of poolData ?? []) {
|
|
125
|
+
const pool = (r.pool || "").toLowerCase();
|
|
126
|
+
const points = r.rewards.points;
|
|
127
|
+
if (points && points.length > 0) {
|
|
128
|
+
poolRewardsList[pool] = points.map((p) => ({
|
|
129
|
+
...p,
|
|
130
|
+
token: p.token.toLowerCase(),
|
|
131
|
+
pool,
|
|
132
|
+
amount: BigInt(p.amount || 0)
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
const externalAPY = r.rewards.externalAPY;
|
|
136
|
+
if (externalAPY && externalAPY.length > 0) {
|
|
137
|
+
poolExternalAPYList[pool] = externalAPY.map((ex) => ({ ...ex, pool }));
|
|
138
|
+
}
|
|
139
|
+
const extraAPY = r.rewards.extraAPY;
|
|
140
|
+
if (extraAPY && extraAPY.length > 0) {
|
|
141
|
+
poolExtraAPYList[extraAPY[0].token.toLowerCase()] = extraAPY.map((ex) => ({
|
|
142
|
+
...ex,
|
|
143
|
+
token: ex.token.toLowerCase(),
|
|
144
|
+
rewardToken: ex.rewardToken.toLowerCase()
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const allResponses = [apyResp, poolResp];
|
|
149
|
+
const allErrors = allResponses.filter((r) => r?.status === "error");
|
|
150
|
+
if (allResponses.length > 0 && allErrors.length === allResponses.length) {
|
|
151
|
+
return void 0;
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
apyList: Object.keys(baseAPYList).length > 0 ? baseAPYList : void 0,
|
|
155
|
+
extraCollateralAPYList: Object.keys(extraCollateralAPYList).length > 0 ? extraCollateralAPYList : void 0,
|
|
156
|
+
pointsList: Object.keys(basePointsList).length > 0 ? basePointsList : void 0,
|
|
157
|
+
extraCollateralPointsList: Object.keys(extraCollateralPointsList).length > 0 ? extraCollateralPointsList : void 0,
|
|
158
|
+
poolRewardsList: Object.keys(poolRewardsList).length > 0 ? poolRewardsList : void 0,
|
|
159
|
+
tokenExtraRewardsList: Object.keys(tokenExtraRewardsList).length > 0 ? tokenExtraRewardsList : void 0,
|
|
160
|
+
poolExternalAPYList: Object.keys(poolExternalAPYList).length > 0 ? poolExternalAPYList : void 0,
|
|
161
|
+
poolExtraAPYList: Object.keys(poolExtraAPYList).length > 0 ? poolExtraAPYList : void 0
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
165
|
+
0 && (module.exports = {
|
|
166
|
+
numberToAPY,
|
|
167
|
+
parseGearStats,
|
|
168
|
+
parseNetworkApy
|
|
169
|
+
});
|
|
@@ -18,11 +18,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var constants_exports = {};
|
|
20
20
|
__export(constants_exports, {
|
|
21
|
-
|
|
21
|
+
APY_STATE_CACHE_URL: () => APY_STATE_CACHE_URL,
|
|
22
|
+
DEFAULT_APY_INTERVAL_MS: () => DEFAULT_APY_INTERVAL_MS
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(constants_exports);
|
|
24
|
-
const
|
|
25
|
+
const APY_STATE_CACHE_URL = "https://state-cache.gearbox.foundation/apy-server/latest.json";
|
|
26
|
+
const DEFAULT_APY_INTERVAL_MS = 10 * 60 * 1e3;
|
|
25
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
28
|
0 && (module.exports = {
|
|
27
|
-
|
|
29
|
+
APY_STATE_CACHE_URL,
|
|
30
|
+
DEFAULT_APY_INTERVAL_MS
|
|
28
31
|
});
|
|
@@ -13,14 +13,22 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
13
|
};
|
|
14
14
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var
|
|
17
|
-
module.exports = __toCommonJS(
|
|
18
|
-
__reExport(
|
|
19
|
-
__reExport(
|
|
20
|
-
__reExport(
|
|
16
|
+
var apy_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(apy_exports);
|
|
18
|
+
__reExport(apy_exports, require("./ApyPlugin.js"), module.exports);
|
|
19
|
+
__reExport(apy_exports, require("./apy-cache.js"), module.exports);
|
|
20
|
+
__reExport(apy_exports, require("./apy-parser.js"), module.exports);
|
|
21
|
+
__reExport(apy_exports, require("./constants.js"), module.exports);
|
|
22
|
+
__reExport(apy_exports, require("./pool-apy-types.js"), module.exports);
|
|
23
|
+
__reExport(apy_exports, require("./pool-apy-utils.js"), module.exports);
|
|
24
|
+
__reExport(apy_exports, require("./types.js"), module.exports);
|
|
21
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22
26
|
0 && (module.exports = {
|
|
27
|
+
...require("./ApyPlugin.js"),
|
|
28
|
+
...require("./apy-cache.js"),
|
|
29
|
+
...require("./apy-parser.js"),
|
|
23
30
|
...require("./constants.js"),
|
|
24
|
-
...require("./
|
|
31
|
+
...require("./pool-apy-types.js"),
|
|
32
|
+
...require("./pool-apy-utils.js"),
|
|
25
33
|
...require("./types.js")
|
|
26
34
|
});
|
|
@@ -12,5 +12,5 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
12
12
|
return to;
|
|
13
13
|
};
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var
|
|
16
|
-
module.exports = __toCommonJS(
|
|
15
|
+
var pool_apy_types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(pool_apy_types_exports);
|
|
@@ -0,0 +1,141 @@
|
|
|
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_apy_utils_exports = {};
|
|
20
|
+
__export(pool_apy_utils_exports, {
|
|
21
|
+
calculatePoolFullAPY: () => calculatePoolFullAPY,
|
|
22
|
+
calculatePoolFullAPY7DAgo: () => calculatePoolFullAPY7DAgo,
|
|
23
|
+
calculatePoolPoints: () => calculatePoolPoints,
|
|
24
|
+
calculateSupplyApy7d: () => calculateSupplyApy7d,
|
|
25
|
+
getPoolExtraAPY: () => getPoolExtraAPY
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(pool_apy_utils_exports);
|
|
28
|
+
var import_constants = require("../../sdk/constants/index.js");
|
|
29
|
+
var import_formatter = require("../../sdk/utils/formatter.js");
|
|
30
|
+
const SCALE = 1000000n;
|
|
31
|
+
const WEEKS_PER_YEAR = 54n;
|
|
32
|
+
function getPoolExtraAPY(lookupAddresses, poolExtraAPYList) {
|
|
33
|
+
if (!poolExtraAPYList) return [];
|
|
34
|
+
const result = [];
|
|
35
|
+
for (const addr of lookupAddresses) {
|
|
36
|
+
const extra = poolExtraAPYList[addr.toLowerCase()];
|
|
37
|
+
if (extra) {
|
|
38
|
+
result.push(...extra);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
function calculateSupplyApy7d(currentDieselRate, currentSupplyRate, dieselRate7DAgo) {
|
|
44
|
+
if (dieselRate7DAgo > currentDieselRate) {
|
|
45
|
+
return (0, import_formatter.rayToNumber)(currentSupplyRate * SCALE) / Number(import_constants.PERCENTAGE_FACTOR);
|
|
46
|
+
}
|
|
47
|
+
const apy = (currentDieselRate * import_constants.RAY / dieselRate7DAgo - import_constants.RAY) * WEEKS_PER_YEAR;
|
|
48
|
+
return (0, import_formatter.rayToNumber)(apy * SCALE) / Number(import_constants.PERCENTAGE_FACTOR);
|
|
49
|
+
}
|
|
50
|
+
function calculatePoolFullAPY({
|
|
51
|
+
depositAPY,
|
|
52
|
+
underlyingAPY,
|
|
53
|
+
extraAPY,
|
|
54
|
+
currentExternalList
|
|
55
|
+
}) {
|
|
56
|
+
const baseAPY = [
|
|
57
|
+
{ type: "supplyAPY", apy: depositAPY },
|
|
58
|
+
...underlyingAPY > 0 ? [
|
|
59
|
+
{
|
|
60
|
+
type: "tokenYield",
|
|
61
|
+
apy: Number(underlyingAPY) / Number(import_constants.PERCENTAGE_FACTOR)
|
|
62
|
+
}
|
|
63
|
+
] : []
|
|
64
|
+
];
|
|
65
|
+
const filteredExtra = [...extraAPY ?? []].filter((r) => r.apy > 0);
|
|
66
|
+
const baseAPYTotal = baseAPY.reduce((s, r) => s + (r.apy || 0), 0);
|
|
67
|
+
const extraAPYTotal = filteredExtra.reduce((s, r) => s + (r.apy || 0), 0);
|
|
68
|
+
const total = baseAPYTotal + extraAPYTotal;
|
|
69
|
+
const externalAPY = resolveExternalAPY(currentExternalList, total);
|
|
70
|
+
return {
|
|
71
|
+
totalAPY: total,
|
|
72
|
+
baseAPY,
|
|
73
|
+
extraAPY: filteredExtra,
|
|
74
|
+
extraAPYTotal,
|
|
75
|
+
externalAPY
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function resolveExternalAPY(list, baseTotal) {
|
|
79
|
+
const first = list?.[0];
|
|
80
|
+
if (!first) return void 0;
|
|
81
|
+
return {
|
|
82
|
+
...first,
|
|
83
|
+
totalValue: baseTotal + first.value
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function calculatePoolFullAPY7DAgo({
|
|
87
|
+
supplyAPY7DAgo,
|
|
88
|
+
depositAPY,
|
|
89
|
+
poolAPY
|
|
90
|
+
}) {
|
|
91
|
+
const {
|
|
92
|
+
baseAPY = [],
|
|
93
|
+
extraAPYTotal = 0,
|
|
94
|
+
extraAPY = [],
|
|
95
|
+
externalAPY
|
|
96
|
+
} = poolAPY ?? {};
|
|
97
|
+
const base = [
|
|
98
|
+
{ apy: supplyAPY7DAgo || depositAPY, type: "supplyAPY" },
|
|
99
|
+
...baseAPY.filter((r) => r.type !== "supplyAPY")
|
|
100
|
+
];
|
|
101
|
+
const baseTotal = base.reduce((acc, r) => acc + r.apy, 0);
|
|
102
|
+
const total = baseTotal + extraAPYTotal;
|
|
103
|
+
return {
|
|
104
|
+
totalAPY: total,
|
|
105
|
+
extraAPYTotal,
|
|
106
|
+
baseAPY: base,
|
|
107
|
+
extraAPY,
|
|
108
|
+
externalAPY,
|
|
109
|
+
loading7DAgo: supplyAPY7DAgo === void 0
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function calculatePoolPoints({
|
|
113
|
+
poolTokenSymbol,
|
|
114
|
+
points,
|
|
115
|
+
tokensList
|
|
116
|
+
}) {
|
|
117
|
+
return points?.map(({ info, points: pts }) => {
|
|
118
|
+
const { decimals = 18 } = tokensList.get(info.token) || {};
|
|
119
|
+
const amount = (0, import_formatter.formatBN)(pts, decimals);
|
|
120
|
+
const { name = "Points", duration } = info ?? {};
|
|
121
|
+
return {
|
|
122
|
+
reward: info,
|
|
123
|
+
name,
|
|
124
|
+
amount,
|
|
125
|
+
tokenTitle: poolTokenSymbol,
|
|
126
|
+
fullTip: [
|
|
127
|
+
`${amount} ${name}`,
|
|
128
|
+
...duration ? [duration] : [],
|
|
129
|
+
...poolTokenSymbol ? [poolTokenSymbol] : []
|
|
130
|
+
].join(" per ")
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
135
|
+
0 && (module.exports = {
|
|
136
|
+
calculatePoolFullAPY,
|
|
137
|
+
calculatePoolFullAPY7DAgo,
|
|
138
|
+
calculatePoolPoints,
|
|
139
|
+
calculateSupplyApy7d,
|
|
140
|
+
getPoolExtraAPY
|
|
141
|
+
});
|
|
@@ -82,11 +82,13 @@ class PoolPointsAPI {
|
|
|
82
82
|
tokensList
|
|
83
83
|
}) {
|
|
84
84
|
const r = pools.reduce((acc, p) => {
|
|
85
|
-
const
|
|
85
|
+
const poolAddress = p.pool.pool.address.toLowerCase();
|
|
86
|
+
const pointsInfo = poolRewards[poolAddress] || [];
|
|
86
87
|
const poolPointsList = pointsInfo.reduce(
|
|
87
88
|
(acc2, pointsInfo2) => {
|
|
88
|
-
const {
|
|
89
|
-
const
|
|
89
|
+
const { addr: tokenAddress } = tokensList.get(pointsInfo2.token) || {};
|
|
90
|
+
const tokenAddressLower = (tokenAddress || "").toLowerCase();
|
|
91
|
+
const tokenBalance = totalTokenBalances[tokenAddressLower];
|
|
90
92
|
const points = PoolPointsAPI.getPoolTokenPoints(
|
|
91
93
|
tokenBalance,
|
|
92
94
|
p,
|
|
@@ -104,22 +106,22 @@ class PoolPointsAPI {
|
|
|
104
106
|
},
|
|
105
107
|
[]
|
|
106
108
|
);
|
|
107
|
-
acc[
|
|
109
|
+
acc[poolAddress] = poolPointsList;
|
|
108
110
|
return acc;
|
|
109
111
|
}, {});
|
|
110
112
|
return r;
|
|
111
113
|
}
|
|
112
114
|
static getPoolTokenPoints(tokenBalanceInPool, pool, tokensList, pointsInfo) {
|
|
113
|
-
if (pool.expectedLiquidity <= 0) return 0n;
|
|
115
|
+
if (pool.pool.pool.expectedLiquidity <= 0) return 0n;
|
|
114
116
|
if (pointsInfo.estimation === "relative" && !tokenBalanceInPool)
|
|
115
117
|
return null;
|
|
116
|
-
const { decimals = 18 } = tokensList
|
|
118
|
+
const { decimals = 18 } = tokensList.get(pointsInfo.token) || {};
|
|
117
119
|
const targetFactor = 10n ** BigInt(decimals);
|
|
118
120
|
const defaultPoints = pointsInfo.amount * targetFactor / import_sdk.PERCENTAGE_FACTOR;
|
|
119
121
|
if (pointsInfo.estimation === "absolute") return defaultPoints;
|
|
120
|
-
const { decimals: underlyingDecimals = 18 } = tokensList
|
|
122
|
+
const { decimals: underlyingDecimals = 18 } = tokensList.get(pool.pool.pool.underlying) || {};
|
|
121
123
|
const underlyingFactor = 10n ** BigInt(underlyingDecimals);
|
|
122
|
-
const points = (tokenBalanceInPool?.balance || 0n) * defaultPoints / (pool.expectedLiquidity * targetFactor / underlyingFactor);
|
|
124
|
+
const points = (tokenBalanceInPool?.balance || 0n) * defaultPoints / (pool.pool.pool.expectedLiquidity * targetFactor / underlyingFactor);
|
|
123
125
|
return import_common_utils.BigIntMath.min(points, defaultPoints);
|
|
124
126
|
}
|
|
125
127
|
}
|
|
@@ -27,7 +27,6 @@ var import_base = require("./base/index.js");
|
|
|
27
27
|
var import_chain = require("./chain/index.js");
|
|
28
28
|
var import_constants = require("./constants/index.js");
|
|
29
29
|
var import_core = require("./core/index.js");
|
|
30
|
-
var import_kyc = require("./market/kyc/index.js");
|
|
31
30
|
var import_MarketRegister = require("./market/MarketRegister.js");
|
|
32
31
|
var import_pricefeeds = require("./market/pricefeeds/index.js");
|
|
33
32
|
var import_plugins = require("./plugins/index.js");
|
|
@@ -87,7 +86,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
87
86
|
#addressProvider;
|
|
88
87
|
#attachConfig;
|
|
89
88
|
#marketRegister;
|
|
90
|
-
#kyc;
|
|
91
89
|
#priceFeeds;
|
|
92
90
|
/**
|
|
93
91
|
* Gas limit applied to read-only `eth_call` requests.
|
|
@@ -132,7 +130,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
132
130
|
ignoreUpdateablePrices,
|
|
133
131
|
ignoreMarkets,
|
|
134
132
|
marketConfigurators: mcs,
|
|
135
|
-
kycFactories: kfs,
|
|
136
133
|
strictContractTypes,
|
|
137
134
|
gasLimit
|
|
138
135
|
} = options;
|
|
@@ -142,7 +139,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
142
139
|
addressProvider = import_constants.ADDRESS_PROVIDER_V310;
|
|
143
140
|
}
|
|
144
141
|
const marketConfigurators = mcs ?? import_utils.TypedObjectUtils.keys(client.chain.defaultMarketConfigurators);
|
|
145
|
-
const kycFactories = kfs ?? client.chain.kycFactories;
|
|
146
142
|
return new GearboxSDK({
|
|
147
143
|
client,
|
|
148
144
|
logger,
|
|
@@ -155,7 +151,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
155
151
|
ignoreUpdateablePrices,
|
|
156
152
|
ignoreMarkets,
|
|
157
153
|
marketConfigurators,
|
|
158
|
-
kycFactories,
|
|
159
154
|
redstone,
|
|
160
155
|
pyth
|
|
161
156
|
});
|
|
@@ -195,7 +190,7 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
195
190
|
plugin.sdk = this;
|
|
196
191
|
}
|
|
197
192
|
if (options.gasLimit !== null) {
|
|
198
|
-
this.gasLimit = options.gasLimit ||
|
|
193
|
+
this.gasLimit = options.gasLimit || (0, import_chain.getChain)(this.networkType).gasLimit;
|
|
199
194
|
}
|
|
200
195
|
}
|
|
201
196
|
async #attach(opts) {
|
|
@@ -205,7 +200,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
205
200
|
ignoreUpdateablePrices,
|
|
206
201
|
ignoreMarkets,
|
|
207
202
|
marketConfigurators,
|
|
208
|
-
kycFactories,
|
|
209
203
|
redstone,
|
|
210
204
|
pyth
|
|
211
205
|
} = opts;
|
|
@@ -216,7 +210,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
216
210
|
chainId: this.chainId,
|
|
217
211
|
addressProvider,
|
|
218
212
|
marketConfigurators,
|
|
219
|
-
kycFactories,
|
|
220
213
|
blockNumber,
|
|
221
214
|
ignoreMarkets
|
|
222
215
|
},
|
|
@@ -251,34 +244,10 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
251
244
|
);
|
|
252
245
|
await this.#addressProvider.syncState(this.currentBlock);
|
|
253
246
|
this.#marketRegister = new import_MarketRegister.MarketRegister(this, ignoreMarkets);
|
|
254
|
-
this.#
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
);
|
|
259
|
-
} else {
|
|
260
|
-
const delegated = [
|
|
261
|
-
...this.#marketRegister.getLoadMulticalls(marketConfigurators),
|
|
262
|
-
...this.#kyc.getLoadMulticalls(marketConfigurators, kycFactories)
|
|
263
|
-
];
|
|
264
|
-
let txs = [];
|
|
265
|
-
if (!ignoreUpdateablePrices) {
|
|
266
|
-
const updatables = await this.#priceFeeds.getPartialUpdatablePriceFeeds(
|
|
267
|
-
marketConfigurators
|
|
268
|
-
);
|
|
269
|
-
const updates = await this.#priceFeeds.generatePriceFeedsUpdateTxs(updatables);
|
|
270
|
-
txs = updates.txs;
|
|
271
|
-
}
|
|
272
|
-
this.logger?.debug(
|
|
273
|
-
{ configurators: marketConfigurators },
|
|
274
|
-
`calling getMarkets with ${txs.length} price updates in block ${this.currentBlock}`
|
|
275
|
-
);
|
|
276
|
-
await (0, import_viem2.executeDelegatedMulticalls)(this.client, delegated, {
|
|
277
|
-
priceUpdates: txs,
|
|
278
|
-
blockNumber: this.currentBlock,
|
|
279
|
-
gas: this.gasLimit
|
|
280
|
-
});
|
|
281
|
-
}
|
|
247
|
+
await this.#marketRegister.loadMarkets(
|
|
248
|
+
marketConfigurators,
|
|
249
|
+
ignoreUpdateablePrices
|
|
250
|
+
);
|
|
282
251
|
const pluginsList = import_utils.TypedObjectUtils.entries(this.plugins);
|
|
283
252
|
const pluginResponse = await Promise.allSettled(
|
|
284
253
|
pluginsList.map(([name, plugin]) => {
|
|
@@ -324,15 +293,12 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
324
293
|
);
|
|
325
294
|
this.#marketRegister = new import_MarketRegister.MarketRegister(this, ignoreMarkets);
|
|
326
295
|
this.#marketRegister.hydrate(state.markets);
|
|
327
|
-
this.#kyc = new import_kyc.KYCRegistry(this);
|
|
328
|
-
this.#kyc.setState(state.kyc);
|
|
329
296
|
this.#attachConfig = {
|
|
330
297
|
...opts,
|
|
331
298
|
addressProvider: this.addressProvider.address,
|
|
332
299
|
marketConfigurators: this.marketRegister.marketConfigurators.map(
|
|
333
300
|
(m) => m.address
|
|
334
301
|
),
|
|
335
|
-
kycFactories: this.kyc.factories.map((f) => f.address),
|
|
336
302
|
blockNumber: this.currentBlock
|
|
337
303
|
};
|
|
338
304
|
for (const [name, plugin] of import_utils.TypedObjectUtils.entries(this.plugins)) {
|
|
@@ -416,7 +382,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
416
382
|
addressProviderV3: this.addressProvider.stateHuman(raw)
|
|
417
383
|
},
|
|
418
384
|
tokens: this.tokensMeta.values(),
|
|
419
|
-
kyc: this.kyc.stateHuman(raw),
|
|
420
385
|
plugins: Object.fromEntries(
|
|
421
386
|
import_utils.TypedObjectUtils.entries(this.plugins).map(([name, plugin]) => [
|
|
422
387
|
name,
|
|
@@ -442,7 +407,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
442
407
|
timestamp: this.timestamp,
|
|
443
408
|
addressProvider: this.addressProvider.state,
|
|
444
409
|
markets: this.marketRegister.state,
|
|
445
|
-
kyc: this.kyc.state,
|
|
446
410
|
plugins: Object.fromEntries(
|
|
447
411
|
import_utils.TypedObjectUtils.entries(this.plugins).map(([name, plugin]) => [
|
|
448
412
|
name,
|
|
@@ -639,17 +603,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
|
|
|
639
603
|
}
|
|
640
604
|
return this.#marketRegister;
|
|
641
605
|
}
|
|
642
|
-
/**
|
|
643
|
-
* KYC register for KYC-wrapped underlying tokens and factories.
|
|
644
|
-
*
|
|
645
|
-
* @throws If the SDK has not been attached or hydrated yet.
|
|
646
|
-
**/
|
|
647
|
-
get kyc() {
|
|
648
|
-
if (this.#kyc === void 0) {
|
|
649
|
-
throw ERR_NOT_ATTACHED;
|
|
650
|
-
}
|
|
651
|
-
return this.#kyc;
|
|
652
|
-
}
|
|
653
606
|
/**
|
|
654
607
|
* Resolves the appropriate router contract for a given credit manager,
|
|
655
608
|
* credit facade, or explicit version range.
|