@gearbox-protocol/sdk 7.10.1-next.1 → 7.10.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/sdk/GearboxSDK.js +1 -5
- package/dist/cjs/sdk/chain/chains.js +8 -9
- package/dist/cjs/sdk/sdk-legacy/gearboxRewards/api.js +159 -94
- package/dist/cjs/sdk/sdk-legacy/gearboxRewards/apy.js +1 -1
- package/dist/cjs/sdk/sdk-legacy/gearboxRewards/extraAPY.js +0 -4
- package/dist/cjs/sdk/sdk-legacy/index.js +2 -0
- package/dist/cjs/sdk/sdk-legacy/pathfinder/core.js +16 -0
- package/dist/cjs/sdk/sdk-legacy/pathfinder/index.js +22 -0
- package/dist/esm/sdk/GearboxSDK.js +1 -5
- package/dist/esm/sdk/chain/chains.js +8 -9
- package/dist/esm/sdk/sdk-legacy/gearboxRewards/api.js +159 -94
- package/dist/esm/sdk/sdk-legacy/gearboxRewards/apy.js +1 -1
- package/dist/esm/sdk/sdk-legacy/gearboxRewards/extraAPY.js +0 -4
- package/dist/esm/sdk/sdk-legacy/index.js +1 -0
- package/dist/esm/sdk/sdk-legacy/pathfinder/core.js +0 -0
- package/dist/esm/sdk/sdk-legacy/pathfinder/index.js +1 -0
- package/dist/types/sdk/GearboxSDK.d.ts +3 -4
- package/dist/types/sdk/sdk-legacy/gearboxRewards/api.d.ts +27 -16
- package/dist/types/sdk/sdk-legacy/gearboxRewards/apy.d.ts +15 -9
- package/dist/types/sdk/sdk-legacy/gearboxRewards/extraAPY.d.ts +3 -2
- package/dist/types/sdk/sdk-legacy/index.d.ts +1 -0
- package/dist/types/sdk/sdk-legacy/pathfinder/core.d.ts +14 -0
- package/dist/types/sdk/sdk-legacy/pathfinder/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -266,7 +266,7 @@ class GearboxSDK {
|
|
|
266
266
|
/**
|
|
267
267
|
* Rehydrate existing SDK from new state without re-creating instance
|
|
268
268
|
*/
|
|
269
|
-
|
|
269
|
+
rehydrate(state) {
|
|
270
270
|
if (!this.#attachConfig) {
|
|
271
271
|
throw new Error("cannot rehydrate, attach config is not set");
|
|
272
272
|
}
|
|
@@ -275,10 +275,6 @@ class GearboxSDK {
|
|
|
275
275
|
redstone: this.#attachConfig.redstone
|
|
276
276
|
};
|
|
277
277
|
this.#hydrate(opts, state);
|
|
278
|
-
await this.#hooks.triggerHooks("rehydrate", {
|
|
279
|
-
blockNumber: state.currentBlock,
|
|
280
|
-
timestamp: state.timestamp
|
|
281
|
-
});
|
|
282
278
|
}
|
|
283
279
|
/**
|
|
284
280
|
* Converts contract call into some human-friendly string
|
|
@@ -30,6 +30,7 @@ module.exports = __toCommonJS(chains_exports);
|
|
|
30
30
|
var import_viem = require("viem");
|
|
31
31
|
var import_chains = require("viem/chains");
|
|
32
32
|
var import_zod = require("zod");
|
|
33
|
+
var import_utils = require("../utils/index.js");
|
|
33
34
|
const SUPPORTED_NETWORKS = [
|
|
34
35
|
"Mainnet",
|
|
35
36
|
"Arbitrum",
|
|
@@ -232,10 +233,6 @@ const chains = {
|
|
|
232
233
|
// TODO: has no block explorer API
|
|
233
234
|
})
|
|
234
235
|
};
|
|
235
|
-
const networkByChainId = Object.values(chains).reduce((acc, chain) => {
|
|
236
|
-
acc[chain.id] = chain.network;
|
|
237
|
-
return acc;
|
|
238
|
-
}, {});
|
|
239
236
|
function getChain(chainIdOrNetworkType) {
|
|
240
237
|
const network = typeof chainIdOrNetworkType === "string" ? chainIdOrNetworkType : getNetworkType(Number(chainIdOrNetworkType));
|
|
241
238
|
const chain = chains[network];
|
|
@@ -245,13 +242,15 @@ function getChain(chainIdOrNetworkType) {
|
|
|
245
242
|
return chain;
|
|
246
243
|
}
|
|
247
244
|
function getNetworkType(chainId) {
|
|
248
|
-
const network
|
|
249
|
-
|
|
250
|
-
|
|
245
|
+
for (const [network, chain] of import_utils.TypedObjectUtils.entries(chains)) {
|
|
246
|
+
if (chain.id === Number(chainId)) {
|
|
247
|
+
return network;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
throw new Error(`Unsupported network with chainId ${chainId}`);
|
|
251
251
|
}
|
|
252
252
|
function isSupportedNetwork(chainId) {
|
|
253
|
-
|
|
254
|
-
return !!networkByChainId[chainId];
|
|
253
|
+
return Object.values(chains).some((c) => c.id === chainId);
|
|
255
254
|
}
|
|
256
255
|
function isPublicNetwork(networkOrChainId) {
|
|
257
256
|
return Object.values(chains).some((c) => {
|
|
@@ -41,48 +41,10 @@ var import_endpoint = require("../core/endpoint.js");
|
|
|
41
41
|
var import_math = require("../utils/math.js");
|
|
42
42
|
var import_merklAPI = require("./merklAPI.js");
|
|
43
43
|
class GearboxRewardsApi {
|
|
44
|
-
static async
|
|
45
|
-
provider,
|
|
46
|
-
account,
|
|
47
|
-
currentTokenData,
|
|
48
|
-
network,
|
|
49
|
-
airdropDistributorAddress,
|
|
50
|
-
reportError
|
|
51
|
-
}) {
|
|
52
|
-
if (!airdropDistributorAddress) return [];
|
|
53
|
-
const [claimedRespUnsafe, merkleDataRespUnsafe] = await Promise.allSettled([
|
|
54
|
-
this.getClaimed({ airdropDistributorAddress, provider, account }),
|
|
55
|
-
this.getMerkle(provider, airdropDistributorAddress, network, account)
|
|
56
|
-
]);
|
|
57
|
-
const claimedResp = this.extractFulfilled(claimedRespUnsafe, reportError, "getLmRewardsV2") || 0n;
|
|
58
|
-
const merkleDataResp = this.extractFulfilled(
|
|
59
|
-
merkleDataRespUnsafe,
|
|
60
|
-
reportError,
|
|
61
|
-
"getLmRewardsV2"
|
|
62
|
-
);
|
|
63
|
-
const amountOnContract = this.getAmountOnContract({
|
|
64
|
-
account,
|
|
65
|
-
merkleData: merkleDataResp
|
|
66
|
-
});
|
|
67
|
-
const diff = amountOnContract - claimedResp;
|
|
68
|
-
const availableToClaimV2 = import_math.BigIntMath.max(0n, diff);
|
|
69
|
-
const rewards = [
|
|
70
|
-
{
|
|
71
|
-
amount: availableToClaimV2,
|
|
72
|
-
type: "merkleV2",
|
|
73
|
-
rewardToken: currentTokenData.GEAR,
|
|
74
|
-
rewardTokenDecimals: 18,
|
|
75
|
-
rewardTokenSymbol: "GEAR"
|
|
76
|
-
}
|
|
77
|
-
];
|
|
78
|
-
return rewards;
|
|
79
|
-
}
|
|
80
|
-
static async getLmRewardsV3({
|
|
44
|
+
static async getLmRewardsInfo({
|
|
81
45
|
pools,
|
|
82
|
-
tokensList,
|
|
83
46
|
provider,
|
|
84
|
-
|
|
85
|
-
reportError
|
|
47
|
+
tokensList
|
|
86
48
|
}) {
|
|
87
49
|
const poolByStakedDiesel = Object.values(pools).reduce((acc, p) => {
|
|
88
50
|
p.stakedDieselToken.forEach((t) => {
|
|
@@ -93,85 +55,155 @@ class GearboxRewardsApi {
|
|
|
93
55
|
});
|
|
94
56
|
return acc;
|
|
95
57
|
}, {});
|
|
96
|
-
const
|
|
97
|
-
|
|
58
|
+
const poolByDiesel = Object.values(pools).reduce(
|
|
59
|
+
(acc, p) => {
|
|
60
|
+
acc[p.dieselToken] = p.address;
|
|
61
|
+
return acc;
|
|
62
|
+
},
|
|
63
|
+
{}
|
|
64
|
+
);
|
|
65
|
+
const poolByItsToken = { ...poolByStakedDiesel, ...poolByDiesel };
|
|
66
|
+
const poolStakedTokens = import_utils.TypedObjectUtils.keys(poolByStakedDiesel);
|
|
67
|
+
const allPoolTokens = import_utils.TypedObjectUtils.keys(poolByItsToken);
|
|
68
|
+
const farmInfoCalls = poolStakedTokens.map((address) => ({
|
|
98
69
|
address,
|
|
99
70
|
abi: import_iFarmingPool.iFarmingPoolAbi,
|
|
100
71
|
functionName: "farmInfo",
|
|
101
72
|
args: []
|
|
102
73
|
}));
|
|
103
|
-
const
|
|
74
|
+
const farmSupplyCalls = allPoolTokens.map((address) => ({
|
|
104
75
|
address,
|
|
105
|
-
abi:
|
|
106
|
-
functionName: "
|
|
76
|
+
abi: import_iFarmingPool.iFarmingPoolAbi,
|
|
77
|
+
functionName: "totalSupply",
|
|
107
78
|
args: []
|
|
108
79
|
}));
|
|
109
|
-
const
|
|
80
|
+
const rewardTokenCalls = poolStakedTokens.map((address) => ({
|
|
110
81
|
address,
|
|
111
|
-
abi:
|
|
112
|
-
functionName: "
|
|
113
|
-
args: [
|
|
82
|
+
abi: POOL_REWARDS_ABI,
|
|
83
|
+
functionName: "rewardsToken",
|
|
84
|
+
args: []
|
|
114
85
|
}));
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
]
|
|
121
|
-
const safeResponse = this.extractFulfilled(response, reportError, "v3Rewards") || [];
|
|
86
|
+
const mc = await provider.multicall({
|
|
87
|
+
allowFailure: false,
|
|
88
|
+
contracts: [...farmInfoCalls, ...farmSupplyCalls, ...rewardTokenCalls]
|
|
89
|
+
});
|
|
90
|
+
const mcResponse = mc;
|
|
91
|
+
const [...restMCResponse] = mcResponse;
|
|
122
92
|
const farmInfoCallsEnd = farmInfoCalls.length;
|
|
123
|
-
const farmInfo =
|
|
93
|
+
const farmInfo = restMCResponse.slice(
|
|
124
94
|
0,
|
|
125
95
|
farmInfoCallsEnd
|
|
126
96
|
);
|
|
127
|
-
const
|
|
128
|
-
const
|
|
97
|
+
const farmSupplyCallsEnd = farmInfoCallsEnd + farmSupplyCalls.length;
|
|
98
|
+
const farmSupply = restMCResponse.slice(
|
|
129
99
|
farmInfoCallsEnd,
|
|
130
|
-
|
|
100
|
+
farmSupplyCallsEnd
|
|
131
101
|
);
|
|
132
|
-
const
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
102
|
+
const rewardTokenCallsEnd = farmSupplyCallsEnd + rewardTokenCalls.length;
|
|
103
|
+
const rewardTokens = restMCResponse.slice(
|
|
104
|
+
farmSupplyCallsEnd,
|
|
105
|
+
rewardTokenCallsEnd
|
|
136
106
|
);
|
|
137
|
-
const
|
|
138
|
-
(
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return {
|
|
145
|
-
pool,
|
|
146
|
-
poolToken: address,
|
|
147
|
-
rewardToken,
|
|
148
|
-
rewardTokenDecimals: tokensList[rewardToken]?.decimals || 18,
|
|
149
|
-
rewardTokenSymbol: tokensList[rewardToken]?.symbol || "unknown",
|
|
150
|
-
amount: farmed ?? 0n,
|
|
151
|
-
type: "stakedV3"
|
|
152
|
-
};
|
|
153
|
-
}
|
|
107
|
+
const infoByPool = poolStakedTokens.reduce(
|
|
108
|
+
(acc, p, index) => {
|
|
109
|
+
const info = farmInfo[index];
|
|
110
|
+
if (info) acc[p] = info;
|
|
111
|
+
return acc;
|
|
112
|
+
},
|
|
113
|
+
{}
|
|
154
114
|
);
|
|
155
|
-
const
|
|
156
|
-
(acc,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
acc.zero.push(r);
|
|
115
|
+
const rewardTokenPool = poolStakedTokens.reduce(
|
|
116
|
+
(acc, p, index) => {
|
|
117
|
+
const token = rewardTokens[index];
|
|
118
|
+
if (token) {
|
|
119
|
+
acc[p] = token.toLowerCase();
|
|
161
120
|
}
|
|
162
121
|
return acc;
|
|
163
122
|
},
|
|
164
|
-
{
|
|
123
|
+
{}
|
|
124
|
+
);
|
|
125
|
+
const stakedTokenRewards = allPoolTokens.reduce(
|
|
126
|
+
(acc, pool) => {
|
|
127
|
+
const info = infoByPool[pool];
|
|
128
|
+
const token = rewardTokenPool[pool];
|
|
129
|
+
const tokenData = tokensList[token];
|
|
130
|
+
const baseReward = info && tokenData ? {
|
|
131
|
+
pool: poolByItsToken[pool],
|
|
132
|
+
duration: BigInt(info.duration),
|
|
133
|
+
finished: BigInt(info.finished),
|
|
134
|
+
reward: info.reward,
|
|
135
|
+
balance: info.balance,
|
|
136
|
+
symbol: tokenData.symbol
|
|
137
|
+
} : void 0;
|
|
138
|
+
if (baseReward) acc.base[pool] = baseReward;
|
|
139
|
+
acc.all[pool] = [...baseReward ? [baseReward] : []];
|
|
140
|
+
return acc;
|
|
141
|
+
},
|
|
142
|
+
{ base: {}, all: {} }
|
|
165
143
|
);
|
|
166
|
-
|
|
144
|
+
const rewardPoolsSupply = allPoolTokens.reduce(
|
|
145
|
+
(acc, address, i) => {
|
|
146
|
+
acc[address] = farmSupply[i] || 0n;
|
|
147
|
+
return acc;
|
|
148
|
+
},
|
|
149
|
+
{}
|
|
150
|
+
);
|
|
151
|
+
return {
|
|
152
|
+
rewardPoolsInfo: stakedTokenRewards.all,
|
|
153
|
+
baseRewardPoolsInfo: stakedTokenRewards.base,
|
|
154
|
+
rewardPoolsSupply
|
|
155
|
+
};
|
|
167
156
|
}
|
|
168
|
-
static async
|
|
157
|
+
static async getLmRewardsV2({
|
|
158
|
+
provider,
|
|
159
|
+
account,
|
|
160
|
+
currentTokenData,
|
|
161
|
+
network,
|
|
162
|
+
airdropDistributorAddress
|
|
163
|
+
}) {
|
|
164
|
+
if (!airdropDistributorAddress) return { rewards: [] };
|
|
165
|
+
const [claimedResp, merkleDataResp] = await Promise.all([
|
|
166
|
+
this.getClaimed({ airdropDistributorAddress, provider, account }),
|
|
167
|
+
this.getMerkle(provider, airdropDistributorAddress, network, account)
|
|
168
|
+
]);
|
|
169
|
+
const amountOnContract = this.getAmountOnContract({
|
|
170
|
+
account,
|
|
171
|
+
merkleData: merkleDataResp
|
|
172
|
+
});
|
|
173
|
+
const diff = amountOnContract - claimedResp;
|
|
174
|
+
const availableToClaimV2 = import_math.BigIntMath.max(0n, diff);
|
|
175
|
+
const rewards = [
|
|
176
|
+
{
|
|
177
|
+
amount: availableToClaimV2,
|
|
178
|
+
type: "merkleV2",
|
|
179
|
+
rewardToken: currentTokenData.GEAR,
|
|
180
|
+
rewardTokenDecimals: 18,
|
|
181
|
+
rewardTokenSymbol: "GEAR"
|
|
182
|
+
}
|
|
183
|
+
];
|
|
184
|
+
return { rewards };
|
|
185
|
+
}
|
|
186
|
+
static async getLmRewardsV3({
|
|
169
187
|
pools,
|
|
188
|
+
baseRewardPoolsInfo,
|
|
189
|
+
currentTokenData,
|
|
190
|
+
tokensList,
|
|
191
|
+
provider,
|
|
170
192
|
account,
|
|
171
193
|
network,
|
|
172
194
|
reportError
|
|
173
195
|
}) {
|
|
174
|
-
const
|
|
196
|
+
const poolTokens = Object.keys(baseRewardPoolsInfo);
|
|
197
|
+
const [gearboxLmResponse, merkleXYZLMResponse] = await Promise.allSettled([
|
|
198
|
+
provider.multicall({
|
|
199
|
+
allowFailure: false,
|
|
200
|
+
contracts: poolTokens.map((address) => ({
|
|
201
|
+
address,
|
|
202
|
+
abi: import_iFarmingPool.iFarmingPoolAbi,
|
|
203
|
+
functionName: "farmed",
|
|
204
|
+
args: [account]
|
|
205
|
+
}))
|
|
206
|
+
}),
|
|
175
207
|
import_axios.default.get(
|
|
176
208
|
import_merklAPI.MerkleXYZApi.getUserRewardsUrl({
|
|
177
209
|
params: {
|
|
@@ -181,10 +213,15 @@ class GearboxRewardsApi {
|
|
|
181
213
|
})
|
|
182
214
|
)
|
|
183
215
|
]);
|
|
216
|
+
const gearboxLm = this.extractFulfilled(
|
|
217
|
+
gearboxLmResponse,
|
|
218
|
+
reportError,
|
|
219
|
+
"v3Rewards"
|
|
220
|
+
) || [];
|
|
184
221
|
const merkleXYZLm = this.extractFulfilled(
|
|
185
222
|
merkleXYZLMResponse,
|
|
186
223
|
reportError,
|
|
187
|
-
"
|
|
224
|
+
"merkleRewards"
|
|
188
225
|
)?.data;
|
|
189
226
|
const poolByItsToken = Object.values(pools).reduce((acc, p) => {
|
|
190
227
|
p.stakedDieselToken.forEach((t) => {
|
|
@@ -222,7 +259,34 @@ class GearboxRewardsApi {
|
|
|
222
259
|
});
|
|
223
260
|
return acc;
|
|
224
261
|
}, {});
|
|
225
|
-
|
|
262
|
+
const gearboxLmRewards = poolTokens.map((address, i) => {
|
|
263
|
+
const info = baseRewardPoolsInfo[address];
|
|
264
|
+
const rewardToken = currentTokenData[info.symbol];
|
|
265
|
+
return {
|
|
266
|
+
pool: info.pool,
|
|
267
|
+
poolToken: address,
|
|
268
|
+
rewardToken,
|
|
269
|
+
rewardTokenDecimals: tokensList[rewardToken]?.decimals || 18,
|
|
270
|
+
rewardTokenSymbol: info.symbol,
|
|
271
|
+
amount: gearboxLm[i] || 0n,
|
|
272
|
+
type: "stakedV3"
|
|
273
|
+
};
|
|
274
|
+
});
|
|
275
|
+
const { zero, nonZero } = gearboxLmRewards.reduce(
|
|
276
|
+
(acc, r) => {
|
|
277
|
+
const amount = r.amount || 0n;
|
|
278
|
+
if (amount > 0n) {
|
|
279
|
+
acc.nonZero.push(r);
|
|
280
|
+
} else {
|
|
281
|
+
acc.zero.push(r);
|
|
282
|
+
}
|
|
283
|
+
return acc;
|
|
284
|
+
},
|
|
285
|
+
{ nonZero: [], zero: [] }
|
|
286
|
+
);
|
|
287
|
+
return {
|
|
288
|
+
rewards: [...nonZero, ...Object.values(extraRewards), zero]
|
|
289
|
+
};
|
|
226
290
|
}
|
|
227
291
|
static extractFulfilled(r, reportError, description) {
|
|
228
292
|
if (r.status === "fulfilled") {
|
|
@@ -327,7 +391,8 @@ class GearboxRewardsApi {
|
|
|
327
391
|
account,
|
|
328
392
|
merkleData
|
|
329
393
|
}) {
|
|
330
|
-
const {
|
|
394
|
+
const { claims = {} } = merkleData || {};
|
|
395
|
+
const { amount } = claims[(0, import_viem.getAddress)(account)] || {};
|
|
331
396
|
return BigInt(amount || 0);
|
|
332
397
|
}
|
|
333
398
|
}
|
|
@@ -37,7 +37,7 @@ class GearboxRewardsApy {
|
|
|
37
37
|
if (!isV3 || !stakedDieselToken) return [];
|
|
38
38
|
const info = rewardPoolsInfo[stakedDieselToken];
|
|
39
39
|
if (!info) return [];
|
|
40
|
-
const extra =
|
|
40
|
+
const extra = info.map(
|
|
41
41
|
(inf) => this.getPoolSingleExtraLmAPY_V3({
|
|
42
42
|
...restProps,
|
|
43
43
|
stakedDieselToken,
|
|
@@ -109,10 +109,6 @@ class GearboxRewardsExtraApy {
|
|
|
109
109
|
const points = pointsInfo.estimation === "absolute" ? defaultPoints : (tokenBalanceInPool?.balance || 0n) * defaultPoints / (pool.expectedLiquidity * targetFactor / underlyingFactor);
|
|
110
110
|
return import_math.BigIntMath.min(points, defaultPoints);
|
|
111
111
|
}
|
|
112
|
-
static getPoolPointsTip(poolRewards, pool, token) {
|
|
113
|
-
const p = poolRewards[pool]?.[token];
|
|
114
|
-
return p;
|
|
115
|
-
}
|
|
116
112
|
}
|
|
117
113
|
// Annotate the CommonJS export names for ESM import in node:
|
|
118
114
|
0 && (module.exports = {
|
|
@@ -26,6 +26,7 @@ __reExport(sdk_legacy_exports, require("./core/pool.js"), module.exports);
|
|
|
26
26
|
__reExport(sdk_legacy_exports, require("./core/strategy.js"), module.exports);
|
|
27
27
|
__reExport(sdk_legacy_exports, require("./core/transactions.js"), module.exports);
|
|
28
28
|
__reExport(sdk_legacy_exports, require("./gearboxRewards/index.js"), module.exports);
|
|
29
|
+
__reExport(sdk_legacy_exports, require("./pathfinder/index.js"), module.exports);
|
|
29
30
|
__reExport(sdk_legacy_exports, require("./payload/creditAccount.js"), module.exports);
|
|
30
31
|
__reExport(sdk_legacy_exports, require("./payload/creditManager.js"), module.exports);
|
|
31
32
|
__reExport(sdk_legacy_exports, require("./payload/creditSession.js"), module.exports);
|
|
@@ -47,6 +48,7 @@ __reExport(sdk_legacy_exports, require("./utils/index.js"), module.exports);
|
|
|
47
48
|
...require("./core/strategy.js"),
|
|
48
49
|
...require("./core/transactions.js"),
|
|
49
50
|
...require("./gearboxRewards/index.js"),
|
|
51
|
+
...require("./pathfinder/index.js"),
|
|
50
52
|
...require("./payload/creditAccount.js"),
|
|
51
53
|
...require("./payload/creditManager.js"),
|
|
52
54
|
...require("./payload/creditSession.js"),
|
|
@@ -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 core_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(core_exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
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 pathfinder_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(pathfinder_exports);
|
|
18
|
+
__reExport(pathfinder_exports, require("./core.js"), module.exports);
|
|
19
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require("./core.js")
|
|
22
|
+
});
|
|
@@ -264,7 +264,7 @@ class GearboxSDK {
|
|
|
264
264
|
/**
|
|
265
265
|
* Rehydrate existing SDK from new state without re-creating instance
|
|
266
266
|
*/
|
|
267
|
-
|
|
267
|
+
rehydrate(state) {
|
|
268
268
|
if (!this.#attachConfig) {
|
|
269
269
|
throw new Error("cannot rehydrate, attach config is not set");
|
|
270
270
|
}
|
|
@@ -273,10 +273,6 @@ class GearboxSDK {
|
|
|
273
273
|
redstone: this.#attachConfig.redstone
|
|
274
274
|
};
|
|
275
275
|
this.#hydrate(opts, state);
|
|
276
|
-
await this.#hooks.triggerHooks("rehydrate", {
|
|
277
|
-
blockNumber: state.currentBlock,
|
|
278
|
-
timestamp: state.timestamp
|
|
279
|
-
});
|
|
280
276
|
}
|
|
281
277
|
/**
|
|
282
278
|
* Converts contract call into some human-friendly string
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
worldchain
|
|
14
14
|
} from "viem/chains";
|
|
15
15
|
import { z } from "zod";
|
|
16
|
+
import { TypedObjectUtils } from "../utils/index.js";
|
|
16
17
|
const SUPPORTED_NETWORKS = [
|
|
17
18
|
"Mainnet",
|
|
18
19
|
"Arbitrum",
|
|
@@ -215,10 +216,6 @@ const chains = {
|
|
|
215
216
|
// TODO: has no block explorer API
|
|
216
217
|
})
|
|
217
218
|
};
|
|
218
|
-
const networkByChainId = Object.values(chains).reduce((acc, chain) => {
|
|
219
|
-
acc[chain.id] = chain.network;
|
|
220
|
-
return acc;
|
|
221
|
-
}, {});
|
|
222
219
|
function getChain(chainIdOrNetworkType) {
|
|
223
220
|
const network = typeof chainIdOrNetworkType === "string" ? chainIdOrNetworkType : getNetworkType(Number(chainIdOrNetworkType));
|
|
224
221
|
const chain = chains[network];
|
|
@@ -228,13 +225,15 @@ function getChain(chainIdOrNetworkType) {
|
|
|
228
225
|
return chain;
|
|
229
226
|
}
|
|
230
227
|
function getNetworkType(chainId) {
|
|
231
|
-
const network
|
|
232
|
-
|
|
233
|
-
|
|
228
|
+
for (const [network, chain] of TypedObjectUtils.entries(chains)) {
|
|
229
|
+
if (chain.id === Number(chainId)) {
|
|
230
|
+
return network;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
throw new Error(`Unsupported network with chainId ${chainId}`);
|
|
234
234
|
}
|
|
235
235
|
function isSupportedNetwork(chainId) {
|
|
236
|
-
|
|
237
|
-
return !!networkByChainId[chainId];
|
|
236
|
+
return Object.values(chains).some((c) => c.id === chainId);
|
|
238
237
|
}
|
|
239
238
|
function isPublicNetwork(networkOrChainId) {
|
|
240
239
|
return Object.values(chains).some((c) => {
|
|
@@ -8,48 +8,10 @@ import { GearboxBackendApi } from "../core/endpoint.js";
|
|
|
8
8
|
import { BigIntMath } from "../utils/math.js";
|
|
9
9
|
import { MerkleXYZApi } from "./merklAPI.js";
|
|
10
10
|
class GearboxRewardsApi {
|
|
11
|
-
static async
|
|
12
|
-
provider,
|
|
13
|
-
account,
|
|
14
|
-
currentTokenData,
|
|
15
|
-
network,
|
|
16
|
-
airdropDistributorAddress,
|
|
17
|
-
reportError
|
|
18
|
-
}) {
|
|
19
|
-
if (!airdropDistributorAddress) return [];
|
|
20
|
-
const [claimedRespUnsafe, merkleDataRespUnsafe] = await Promise.allSettled([
|
|
21
|
-
this.getClaimed({ airdropDistributorAddress, provider, account }),
|
|
22
|
-
this.getMerkle(provider, airdropDistributorAddress, network, account)
|
|
23
|
-
]);
|
|
24
|
-
const claimedResp = this.extractFulfilled(claimedRespUnsafe, reportError, "getLmRewardsV2") || 0n;
|
|
25
|
-
const merkleDataResp = this.extractFulfilled(
|
|
26
|
-
merkleDataRespUnsafe,
|
|
27
|
-
reportError,
|
|
28
|
-
"getLmRewardsV2"
|
|
29
|
-
);
|
|
30
|
-
const amountOnContract = this.getAmountOnContract({
|
|
31
|
-
account,
|
|
32
|
-
merkleData: merkleDataResp
|
|
33
|
-
});
|
|
34
|
-
const diff = amountOnContract - claimedResp;
|
|
35
|
-
const availableToClaimV2 = BigIntMath.max(0n, diff);
|
|
36
|
-
const rewards = [
|
|
37
|
-
{
|
|
38
|
-
amount: availableToClaimV2,
|
|
39
|
-
type: "merkleV2",
|
|
40
|
-
rewardToken: currentTokenData.GEAR,
|
|
41
|
-
rewardTokenDecimals: 18,
|
|
42
|
-
rewardTokenSymbol: "GEAR"
|
|
43
|
-
}
|
|
44
|
-
];
|
|
45
|
-
return rewards;
|
|
46
|
-
}
|
|
47
|
-
static async getLmRewardsV3({
|
|
11
|
+
static async getLmRewardsInfo({
|
|
48
12
|
pools,
|
|
49
|
-
tokensList,
|
|
50
13
|
provider,
|
|
51
|
-
|
|
52
|
-
reportError
|
|
14
|
+
tokensList
|
|
53
15
|
}) {
|
|
54
16
|
const poolByStakedDiesel = Object.values(pools).reduce((acc, p) => {
|
|
55
17
|
p.stakedDieselToken.forEach((t) => {
|
|
@@ -60,85 +22,155 @@ class GearboxRewardsApi {
|
|
|
60
22
|
});
|
|
61
23
|
return acc;
|
|
62
24
|
}, {});
|
|
63
|
-
const
|
|
64
|
-
|
|
25
|
+
const poolByDiesel = Object.values(pools).reduce(
|
|
26
|
+
(acc, p) => {
|
|
27
|
+
acc[p.dieselToken] = p.address;
|
|
28
|
+
return acc;
|
|
29
|
+
},
|
|
30
|
+
{}
|
|
31
|
+
);
|
|
32
|
+
const poolByItsToken = { ...poolByStakedDiesel, ...poolByDiesel };
|
|
33
|
+
const poolStakedTokens = TypedObjectUtils.keys(poolByStakedDiesel);
|
|
34
|
+
const allPoolTokens = TypedObjectUtils.keys(poolByItsToken);
|
|
35
|
+
const farmInfoCalls = poolStakedTokens.map((address) => ({
|
|
65
36
|
address,
|
|
66
37
|
abi: iFarmingPoolAbi,
|
|
67
38
|
functionName: "farmInfo",
|
|
68
39
|
args: []
|
|
69
40
|
}));
|
|
70
|
-
const
|
|
41
|
+
const farmSupplyCalls = allPoolTokens.map((address) => ({
|
|
71
42
|
address,
|
|
72
|
-
abi:
|
|
73
|
-
functionName: "
|
|
43
|
+
abi: iFarmingPoolAbi,
|
|
44
|
+
functionName: "totalSupply",
|
|
74
45
|
args: []
|
|
75
46
|
}));
|
|
76
|
-
const
|
|
47
|
+
const rewardTokenCalls = poolStakedTokens.map((address) => ({
|
|
77
48
|
address,
|
|
78
|
-
abi:
|
|
79
|
-
functionName: "
|
|
80
|
-
args: [
|
|
49
|
+
abi: POOL_REWARDS_ABI,
|
|
50
|
+
functionName: "rewardsToken",
|
|
51
|
+
args: []
|
|
81
52
|
}));
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
]
|
|
88
|
-
const safeResponse = this.extractFulfilled(response, reportError, "v3Rewards") || [];
|
|
53
|
+
const mc = await provider.multicall({
|
|
54
|
+
allowFailure: false,
|
|
55
|
+
contracts: [...farmInfoCalls, ...farmSupplyCalls, ...rewardTokenCalls]
|
|
56
|
+
});
|
|
57
|
+
const mcResponse = mc;
|
|
58
|
+
const [...restMCResponse] = mcResponse;
|
|
89
59
|
const farmInfoCallsEnd = farmInfoCalls.length;
|
|
90
|
-
const farmInfo =
|
|
60
|
+
const farmInfo = restMCResponse.slice(
|
|
91
61
|
0,
|
|
92
62
|
farmInfoCallsEnd
|
|
93
63
|
);
|
|
94
|
-
const
|
|
95
|
-
const
|
|
64
|
+
const farmSupplyCallsEnd = farmInfoCallsEnd + farmSupplyCalls.length;
|
|
65
|
+
const farmSupply = restMCResponse.slice(
|
|
96
66
|
farmInfoCallsEnd,
|
|
97
|
-
|
|
67
|
+
farmSupplyCallsEnd
|
|
98
68
|
);
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
69
|
+
const rewardTokenCallsEnd = farmSupplyCallsEnd + rewardTokenCalls.length;
|
|
70
|
+
const rewardTokens = restMCResponse.slice(
|
|
71
|
+
farmSupplyCallsEnd,
|
|
72
|
+
rewardTokenCallsEnd
|
|
103
73
|
);
|
|
104
|
-
const
|
|
105
|
-
(
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return {
|
|
112
|
-
pool,
|
|
113
|
-
poolToken: address,
|
|
114
|
-
rewardToken,
|
|
115
|
-
rewardTokenDecimals: tokensList[rewardToken]?.decimals || 18,
|
|
116
|
-
rewardTokenSymbol: tokensList[rewardToken]?.symbol || "unknown",
|
|
117
|
-
amount: farmed ?? 0n,
|
|
118
|
-
type: "stakedV3"
|
|
119
|
-
};
|
|
120
|
-
}
|
|
74
|
+
const infoByPool = poolStakedTokens.reduce(
|
|
75
|
+
(acc, p, index) => {
|
|
76
|
+
const info = farmInfo[index];
|
|
77
|
+
if (info) acc[p] = info;
|
|
78
|
+
return acc;
|
|
79
|
+
},
|
|
80
|
+
{}
|
|
121
81
|
);
|
|
122
|
-
const
|
|
123
|
-
(acc,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
acc.zero.push(r);
|
|
82
|
+
const rewardTokenPool = poolStakedTokens.reduce(
|
|
83
|
+
(acc, p, index) => {
|
|
84
|
+
const token = rewardTokens[index];
|
|
85
|
+
if (token) {
|
|
86
|
+
acc[p] = token.toLowerCase();
|
|
128
87
|
}
|
|
129
88
|
return acc;
|
|
130
89
|
},
|
|
131
|
-
{
|
|
90
|
+
{}
|
|
91
|
+
);
|
|
92
|
+
const stakedTokenRewards = allPoolTokens.reduce(
|
|
93
|
+
(acc, pool) => {
|
|
94
|
+
const info = infoByPool[pool];
|
|
95
|
+
const token = rewardTokenPool[pool];
|
|
96
|
+
const tokenData = tokensList[token];
|
|
97
|
+
const baseReward = info && tokenData ? {
|
|
98
|
+
pool: poolByItsToken[pool],
|
|
99
|
+
duration: BigInt(info.duration),
|
|
100
|
+
finished: BigInt(info.finished),
|
|
101
|
+
reward: info.reward,
|
|
102
|
+
balance: info.balance,
|
|
103
|
+
symbol: tokenData.symbol
|
|
104
|
+
} : void 0;
|
|
105
|
+
if (baseReward) acc.base[pool] = baseReward;
|
|
106
|
+
acc.all[pool] = [...baseReward ? [baseReward] : []];
|
|
107
|
+
return acc;
|
|
108
|
+
},
|
|
109
|
+
{ base: {}, all: {} }
|
|
132
110
|
);
|
|
133
|
-
|
|
111
|
+
const rewardPoolsSupply = allPoolTokens.reduce(
|
|
112
|
+
(acc, address, i) => {
|
|
113
|
+
acc[address] = farmSupply[i] || 0n;
|
|
114
|
+
return acc;
|
|
115
|
+
},
|
|
116
|
+
{}
|
|
117
|
+
);
|
|
118
|
+
return {
|
|
119
|
+
rewardPoolsInfo: stakedTokenRewards.all,
|
|
120
|
+
baseRewardPoolsInfo: stakedTokenRewards.base,
|
|
121
|
+
rewardPoolsSupply
|
|
122
|
+
};
|
|
134
123
|
}
|
|
135
|
-
static async
|
|
124
|
+
static async getLmRewardsV2({
|
|
125
|
+
provider,
|
|
126
|
+
account,
|
|
127
|
+
currentTokenData,
|
|
128
|
+
network,
|
|
129
|
+
airdropDistributorAddress
|
|
130
|
+
}) {
|
|
131
|
+
if (!airdropDistributorAddress) return { rewards: [] };
|
|
132
|
+
const [claimedResp, merkleDataResp] = await Promise.all([
|
|
133
|
+
this.getClaimed({ airdropDistributorAddress, provider, account }),
|
|
134
|
+
this.getMerkle(provider, airdropDistributorAddress, network, account)
|
|
135
|
+
]);
|
|
136
|
+
const amountOnContract = this.getAmountOnContract({
|
|
137
|
+
account,
|
|
138
|
+
merkleData: merkleDataResp
|
|
139
|
+
});
|
|
140
|
+
const diff = amountOnContract - claimedResp;
|
|
141
|
+
const availableToClaimV2 = BigIntMath.max(0n, diff);
|
|
142
|
+
const rewards = [
|
|
143
|
+
{
|
|
144
|
+
amount: availableToClaimV2,
|
|
145
|
+
type: "merkleV2",
|
|
146
|
+
rewardToken: currentTokenData.GEAR,
|
|
147
|
+
rewardTokenDecimals: 18,
|
|
148
|
+
rewardTokenSymbol: "GEAR"
|
|
149
|
+
}
|
|
150
|
+
];
|
|
151
|
+
return { rewards };
|
|
152
|
+
}
|
|
153
|
+
static async getLmRewardsV3({
|
|
136
154
|
pools,
|
|
155
|
+
baseRewardPoolsInfo,
|
|
156
|
+
currentTokenData,
|
|
157
|
+
tokensList,
|
|
158
|
+
provider,
|
|
137
159
|
account,
|
|
138
160
|
network,
|
|
139
161
|
reportError
|
|
140
162
|
}) {
|
|
141
|
-
const
|
|
163
|
+
const poolTokens = Object.keys(baseRewardPoolsInfo);
|
|
164
|
+
const [gearboxLmResponse, merkleXYZLMResponse] = await Promise.allSettled([
|
|
165
|
+
provider.multicall({
|
|
166
|
+
allowFailure: false,
|
|
167
|
+
contracts: poolTokens.map((address) => ({
|
|
168
|
+
address,
|
|
169
|
+
abi: iFarmingPoolAbi,
|
|
170
|
+
functionName: "farmed",
|
|
171
|
+
args: [account]
|
|
172
|
+
}))
|
|
173
|
+
}),
|
|
142
174
|
axios.get(
|
|
143
175
|
MerkleXYZApi.getUserRewardsUrl({
|
|
144
176
|
params: {
|
|
@@ -148,10 +180,15 @@ class GearboxRewardsApi {
|
|
|
148
180
|
})
|
|
149
181
|
)
|
|
150
182
|
]);
|
|
183
|
+
const gearboxLm = this.extractFulfilled(
|
|
184
|
+
gearboxLmResponse,
|
|
185
|
+
reportError,
|
|
186
|
+
"v3Rewards"
|
|
187
|
+
) || [];
|
|
151
188
|
const merkleXYZLm = this.extractFulfilled(
|
|
152
189
|
merkleXYZLMResponse,
|
|
153
190
|
reportError,
|
|
154
|
-
"
|
|
191
|
+
"merkleRewards"
|
|
155
192
|
)?.data;
|
|
156
193
|
const poolByItsToken = Object.values(pools).reduce((acc, p) => {
|
|
157
194
|
p.stakedDieselToken.forEach((t) => {
|
|
@@ -189,7 +226,34 @@ class GearboxRewardsApi {
|
|
|
189
226
|
});
|
|
190
227
|
return acc;
|
|
191
228
|
}, {});
|
|
192
|
-
|
|
229
|
+
const gearboxLmRewards = poolTokens.map((address, i) => {
|
|
230
|
+
const info = baseRewardPoolsInfo[address];
|
|
231
|
+
const rewardToken = currentTokenData[info.symbol];
|
|
232
|
+
return {
|
|
233
|
+
pool: info.pool,
|
|
234
|
+
poolToken: address,
|
|
235
|
+
rewardToken,
|
|
236
|
+
rewardTokenDecimals: tokensList[rewardToken]?.decimals || 18,
|
|
237
|
+
rewardTokenSymbol: info.symbol,
|
|
238
|
+
amount: gearboxLm[i] || 0n,
|
|
239
|
+
type: "stakedV3"
|
|
240
|
+
};
|
|
241
|
+
});
|
|
242
|
+
const { zero, nonZero } = gearboxLmRewards.reduce(
|
|
243
|
+
(acc, r) => {
|
|
244
|
+
const amount = r.amount || 0n;
|
|
245
|
+
if (amount > 0n) {
|
|
246
|
+
acc.nonZero.push(r);
|
|
247
|
+
} else {
|
|
248
|
+
acc.zero.push(r);
|
|
249
|
+
}
|
|
250
|
+
return acc;
|
|
251
|
+
},
|
|
252
|
+
{ nonZero: [], zero: [] }
|
|
253
|
+
);
|
|
254
|
+
return {
|
|
255
|
+
rewards: [...nonZero, ...Object.values(extraRewards), zero]
|
|
256
|
+
};
|
|
193
257
|
}
|
|
194
258
|
static extractFulfilled(r, reportError, description) {
|
|
195
259
|
if (r.status === "fulfilled") {
|
|
@@ -294,7 +358,8 @@ class GearboxRewardsApi {
|
|
|
294
358
|
account,
|
|
295
359
|
merkleData
|
|
296
360
|
}) {
|
|
297
|
-
const {
|
|
361
|
+
const { claims = {} } = merkleData || {};
|
|
362
|
+
const { amount } = claims[getAddress(account)] || {};
|
|
298
363
|
return BigInt(amount || 0);
|
|
299
364
|
}
|
|
300
365
|
}
|
|
@@ -20,7 +20,7 @@ class GearboxRewardsApy {
|
|
|
20
20
|
if (!isV3 || !stakedDieselToken) return [];
|
|
21
21
|
const info = rewardPoolsInfo[stakedDieselToken];
|
|
22
22
|
if (!info) return [];
|
|
23
|
-
const extra =
|
|
23
|
+
const extra = info.map(
|
|
24
24
|
(inf) => this.getPoolSingleExtraLmAPY_V3({
|
|
25
25
|
...restProps,
|
|
26
26
|
stakedDieselToken,
|
|
@@ -76,10 +76,6 @@ class GearboxRewardsExtraApy {
|
|
|
76
76
|
const points = pointsInfo.estimation === "absolute" ? defaultPoints : (tokenBalanceInPool?.balance || 0n) * defaultPoints / (pool.expectedLiquidity * targetFactor / underlyingFactor);
|
|
77
77
|
return BigIntMath.min(points, defaultPoints);
|
|
78
78
|
}
|
|
79
|
-
static getPoolPointsTip(poolRewards, pool, token) {
|
|
80
|
-
const p = poolRewards[pool]?.[token];
|
|
81
|
-
return p;
|
|
82
|
-
}
|
|
83
79
|
}
|
|
84
80
|
export {
|
|
85
81
|
GearboxRewardsExtraApy
|
|
@@ -9,6 +9,7 @@ export * from "./core/pool.js";
|
|
|
9
9
|
export * from "./core/strategy.js";
|
|
10
10
|
export * from "./core/transactions.js";
|
|
11
11
|
export * from "./gearboxRewards/index.js";
|
|
12
|
+
export * from "./pathfinder/index.js";
|
|
12
13
|
export * from "./payload/creditAccount.js";
|
|
13
14
|
export * from "./payload/creditManager.js";
|
|
14
15
|
export * from "./payload/creditSession.js";
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core.js";
|
|
@@ -60,7 +60,6 @@ export interface SyncStateOptions {
|
|
|
60
60
|
}
|
|
61
61
|
export type SDKHooks = {
|
|
62
62
|
syncState: [SyncStateOptions];
|
|
63
|
-
rehydrate: [SyncStateOptions];
|
|
64
63
|
};
|
|
65
64
|
export declare class GearboxSDK<const Plugins extends PluginsMap = {}> {
|
|
66
65
|
#private;
|
|
@@ -84,8 +83,8 @@ export declare class GearboxSDK<const Plugins extends PluginsMap = {}> {
|
|
|
84
83
|
* Token metadata such as symbol and decimals
|
|
85
84
|
*/
|
|
86
85
|
readonly tokensMeta: TokensMeta;
|
|
87
|
-
addHook: <K extends
|
|
88
|
-
removeHook: <K extends
|
|
86
|
+
addHook: <K extends "syncState">(hookName: K, fn: (...args: SDKHooks[K]) => void | Promise<void>) => void;
|
|
87
|
+
removeHook: <K extends "syncState">(hookName: K, fn: (...args: SDKHooks[K]) => void | Promise<void>) => void;
|
|
89
88
|
static attach<const Plugins extends PluginsMap>(options: SDKOptions<Plugins> & Partial<NetworkOptions> & ConnectionOptions & TransportOptions): Promise<GearboxSDK<Plugins>>;
|
|
90
89
|
static hydrate<const Plugins extends PluginsMap>(options: HydrateOptions<Plugins> & ConnectionOptions & TransportOptions, state: GearboxState<Plugins>): GearboxSDK<Plugins>;
|
|
91
90
|
private constructor();
|
|
@@ -97,7 +96,7 @@ export declare class GearboxSDK<const Plugins extends PluginsMap = {}> {
|
|
|
97
96
|
/**
|
|
98
97
|
* Rehydrate existing SDK from new state without re-creating instance
|
|
99
98
|
*/
|
|
100
|
-
rehydrate(state: GearboxState<Plugins>):
|
|
99
|
+
rehydrate(state: GearboxState<Plugins>): void;
|
|
101
100
|
/**
|
|
102
101
|
* Converts contract call into some human-friendly string
|
|
103
102
|
* This method is safe and should not throw
|
|
@@ -40,25 +40,28 @@ export interface MerkleDistributorInfo {
|
|
|
40
40
|
proof: Array<Address>;
|
|
41
41
|
}>;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
reportError?: ReportHandler;
|
|
43
|
+
export interface FarmInfo {
|
|
44
|
+
pool: Address;
|
|
45
|
+
finished: bigint;
|
|
46
|
+
duration: bigint;
|
|
47
|
+
reward: bigint;
|
|
48
|
+
balance: bigint;
|
|
49
|
+
symbol: SupportedToken;
|
|
51
50
|
}
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
type ReportHandler = (e: unknown, description?: string) => void;
|
|
52
|
+
export interface GetLmRewardsInfoProps {
|
|
53
|
+
pools: Record<Address, PoolData_Legacy>;
|
|
54
54
|
tokensList: Record<Address, TokenData>;
|
|
55
|
-
account: Address;
|
|
56
55
|
provider: PublicClient;
|
|
57
|
-
reportError?: ReportHandler;
|
|
58
56
|
}
|
|
59
|
-
export interface
|
|
57
|
+
export interface GetLmRewardsProps {
|
|
60
58
|
pools: Record<Address, PoolData_Legacy>;
|
|
59
|
+
baseRewardPoolsInfo: Record<string, FarmInfo>;
|
|
60
|
+
currentTokenData: Record<SupportedToken, Address>;
|
|
61
|
+
tokensList: Record<Address, TokenData>;
|
|
61
62
|
account: Address;
|
|
63
|
+
provider: PublicClient;
|
|
64
|
+
airdropDistributorAddress: Address | undefined;
|
|
62
65
|
network: NetworkType;
|
|
63
66
|
reportError?: ReportHandler;
|
|
64
67
|
}
|
|
@@ -75,9 +78,17 @@ export interface ClaimLmRewardsV3Props {
|
|
|
75
78
|
signer: WalletClient;
|
|
76
79
|
}
|
|
77
80
|
export declare class GearboxRewardsApi {
|
|
78
|
-
static
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
static getLmRewardsInfo({ pools, provider, tokensList, }: GetLmRewardsInfoProps): Promise<{
|
|
82
|
+
rewardPoolsInfo: Record<string, FarmInfo[]>;
|
|
83
|
+
baseRewardPoolsInfo: Record<string, FarmInfo>;
|
|
84
|
+
rewardPoolsSupply: Record<string, bigint>;
|
|
85
|
+
}>;
|
|
86
|
+
static getLmRewardsV2({ provider, account, currentTokenData, network, airdropDistributorAddress, }: GetLmRewardsProps): Promise<{
|
|
87
|
+
rewards: GearboxLmReward[];
|
|
88
|
+
}>;
|
|
89
|
+
static getLmRewardsV3({ pools, baseRewardPoolsInfo, currentTokenData, tokensList, provider, account, network, reportError, }: GetLmRewardsProps): Promise<{
|
|
90
|
+
rewards: (GearboxLmReward | GearboxLmReward[])[];
|
|
91
|
+
}>;
|
|
81
92
|
private static extractFulfilled;
|
|
82
93
|
static claimLmRewardsV2({ signer, account, provider, network, airdropDistributorAddress, }: ClaimLmRewardsV2Props): Promise<`0x${string}`>;
|
|
83
94
|
static claimLmRewardsV3({ reward, signer, account, }: ClaimLmRewardsV3Props): Promise<`0x${string}`>;
|
|
@@ -3,13 +3,19 @@ import type { Asset } from "../../router/index.js";
|
|
|
3
3
|
import type { SupportedToken } from "../../sdk-gov-legacy/index.js";
|
|
4
4
|
import type { PoolData_Legacy } from "../core/pool.js";
|
|
5
5
|
import type { TokenData } from "../tokens/tokenData.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
import type { FarmInfo } from "./api.js";
|
|
7
|
+
interface CalculateV3PoolLmAPYProps {
|
|
8
|
+
currentTimestamp: number;
|
|
9
|
+
info: FarmInfo;
|
|
10
|
+
supply: {
|
|
11
|
+
decimals: number;
|
|
12
|
+
amount: bigint;
|
|
13
|
+
price: bigint;
|
|
14
|
+
};
|
|
15
|
+
reward: {
|
|
16
|
+
decimals: number;
|
|
17
|
+
price: bigint;
|
|
18
|
+
};
|
|
13
19
|
}
|
|
14
20
|
export interface ExtraRewardApy {
|
|
15
21
|
token: Address;
|
|
@@ -23,7 +29,7 @@ interface GetPoolExtraAPY_V3Props {
|
|
|
23
29
|
stakedDieselToken: Address | undefined;
|
|
24
30
|
pool: PoolData_Legacy;
|
|
25
31
|
prices: Record<Address, bigint>;
|
|
26
|
-
rewardPoolsInfo: Record<Address, Array<FarmInfo
|
|
32
|
+
rewardPoolsInfo: Record<Address, Array<FarmInfo>>;
|
|
27
33
|
rewardPoolsSupply: Record<Address, bigint>;
|
|
28
34
|
tokensList: Record<Address, TokenData>;
|
|
29
35
|
currentTokenData: Record<SupportedToken, Address>;
|
|
@@ -41,7 +47,7 @@ interface GetCAExtraAPYProps {
|
|
|
41
47
|
export declare class GearboxRewardsApy {
|
|
42
48
|
static getPoolExtraAPY_V3({ rewardPoolsInfo, stakedDieselToken, ...restProps }: GetPoolExtraAPY_V3Props): Array<ExtraRewardApy>;
|
|
43
49
|
private static getPoolSingleExtraLmAPY_V3;
|
|
44
|
-
|
|
50
|
+
static calculateAPY_V3({ info, supply, reward, currentTimestamp, }: CalculateV3PoolLmAPYProps): number;
|
|
45
51
|
static getCAExtraAPY_V3({ rewardInfo, assets, ...restProps }: GetCAExtraAPYProps): Array<ExtraRewardApy>;
|
|
46
52
|
private static getCASingleExtraAPY_V3;
|
|
47
53
|
}
|
|
@@ -8,9 +8,11 @@ export interface PoolPointsInfo {
|
|
|
8
8
|
token: Address;
|
|
9
9
|
symbol: string;
|
|
10
10
|
amount: bigint;
|
|
11
|
-
duration: string;
|
|
11
|
+
duration: string | undefined;
|
|
12
12
|
name: string;
|
|
13
|
+
type: string;
|
|
13
14
|
estimation: "absolute" | "relative";
|
|
15
|
+
condition: "deposit" | "cross-chain-deposit" | "holding";
|
|
14
16
|
}
|
|
15
17
|
type PartialPool = Pick<PoolData_Legacy, "expectedLiquidity" | "underlyingToken" | "address">;
|
|
16
18
|
export interface GetPointsByPoolProps {
|
|
@@ -29,6 +31,5 @@ export declare class GearboxRewardsExtraApy {
|
|
|
29
31
|
private static getTokenTotal;
|
|
30
32
|
static getPointsByPool({ poolRewards, totalTokenBalances, pools, tokensList, }: GetPointsByPoolProps): Record<`0x${string}`, Asset[]>;
|
|
31
33
|
private static getPoolTokenPoints;
|
|
32
|
-
static getPoolPointsTip(poolRewards: Record<Address, Record<Address, PoolPointsInfo>>, pool: Address, token: Address): PoolPointsInfo;
|
|
33
34
|
}
|
|
34
35
|
export {};
|
|
@@ -9,6 +9,7 @@ export * from "./core/pool.js";
|
|
|
9
9
|
export * from "./core/strategy.js";
|
|
10
10
|
export * from "./core/transactions.js";
|
|
11
11
|
export * from "./gearboxRewards/index.js";
|
|
12
|
+
export * from "./pathfinder/index.js";
|
|
12
13
|
export * from "./payload/creditAccount.js";
|
|
13
14
|
export * from "./payload/creditManager.js";
|
|
14
15
|
export * from "./payload/creditSession.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { MultiCall } from "../../types/index.js";
|
|
3
|
+
export interface PathFinderResult {
|
|
4
|
+
amount: bigint;
|
|
5
|
+
minAmount: bigint;
|
|
6
|
+
calls: MultiCall[];
|
|
7
|
+
}
|
|
8
|
+
export interface PathFinderOpenStrategyResult extends PathFinderResult {
|
|
9
|
+
balances: Record<Address, bigint>;
|
|
10
|
+
minBalances: Record<Address, bigint>;
|
|
11
|
+
}
|
|
12
|
+
export interface PathFinderCloseResult extends PathFinderResult {
|
|
13
|
+
underlyingBalance: bigint;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core.js";
|