@gearbox-protocol/sdk 7.11.0-next.3 → 7.11.0
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/adapters/AdaptersPlugin.js +3 -2
- package/dist/cjs/bots/BotsPlugin.js +17 -29
- package/dist/cjs/dev/AccountsCounterPlugin.js +10 -19
- package/dist/cjs/dev/createTransport.js +2 -1
- package/dist/cjs/sdk/GearboxSDK.js +3 -13
- package/dist/cjs/sdk/chain/chains.js +21 -10
- package/dist/cjs/sdk/constants/address-provider.js +2 -1
- package/dist/cjs/sdk/constants/addresses.js +8 -4
- package/dist/cjs/sdk/constants/networks.js +5 -2
- package/dist/cjs/sdk/plugins/V300StalenessPeriodPlugin.js +1 -3
- package/dist/cjs/sdk/router/RouterV300Contract.js +2 -1
- package/dist/cjs/sdk/sdk-gov-legacy/contracts/contracts.js +74 -37
- package/dist/cjs/sdk/sdk-gov-legacy/tokens/token.js +4 -2
- package/dist/cjs/sdk/sdk-gov-legacy/tokens/tokenData.js +2 -1
- package/dist/cjs/sdk/sdk-legacy/core/endpoint.js +2 -1
- 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/index.js +2 -0
- package/dist/cjs/{pools7DAgo/types.js → sdk/sdk-legacy/pathfinder/core.js} +2 -2
- package/dist/cjs/{pools7DAgo → sdk/sdk-legacy/pathfinder}/index.js +4 -6
- package/dist/cjs/sdk/utils/viem/simulateWithPriceUpdates.js +1 -0
- package/dist/cjs/zappers/ZappersPlugin.js +4 -13
- package/dist/esm/adapters/AdaptersPlugin.js +3 -2
- package/dist/esm/bots/BotsPlugin.js +17 -29
- package/dist/esm/dev/AccountsCounterPlugin.js +10 -19
- package/dist/esm/dev/createTransport.js +2 -1
- package/dist/esm/sdk/GearboxSDK.js +3 -13
- package/dist/esm/sdk/chain/chains.js +22 -10
- package/dist/esm/sdk/constants/address-provider.js +2 -1
- package/dist/esm/sdk/constants/addresses.js +8 -4
- package/dist/esm/sdk/constants/networks.js +5 -2
- package/dist/esm/sdk/plugins/V300StalenessPeriodPlugin.js +1 -3
- package/dist/esm/sdk/router/RouterV300Contract.js +2 -1
- package/dist/esm/sdk/sdk-gov-legacy/contracts/contracts.js +74 -37
- package/dist/esm/sdk/sdk-gov-legacy/tokens/token.js +4 -2
- package/dist/esm/sdk/sdk-gov-legacy/tokens/tokenData.js +2 -1
- package/dist/esm/sdk/sdk-legacy/core/endpoint.js +2 -1
- 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/index.js +1 -0
- package/dist/esm/sdk/sdk-legacy/pathfinder/index.js +1 -0
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -0
- package/dist/esm/zappers/ZappersPlugin.js +4 -13
- package/dist/types/adapters/AdaptersPlugin.d.ts +4 -5
- package/dist/types/bots/BotsPlugin.d.ts +3 -5
- package/dist/types/bots/types.d.ts +2 -2
- package/dist/types/dev/AccountsCounterPlugin.d.ts +2 -4
- package/dist/types/sdk/GearboxSDK.d.ts +3 -4
- package/dist/types/sdk/chain/chains.d.ts +2 -2
- package/dist/types/sdk/plugins/V300StalenessPeriodPlugin.d.ts +2 -3
- package/dist/types/sdk/plugins/types.d.ts +15 -33
- 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/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/dist/types/zappers/ZappersPlugin.d.ts +4 -5
- package/package.json +1 -1
- package/dist/cjs/degenDistributors/DegenDistributorsPlugin.js +0 -110
- package/dist/cjs/degenDistributors/index.js +0 -24
- package/dist/cjs/degenDistributors/package.json +0 -1
- package/dist/cjs/degenDistributors/types.js +0 -16
- package/dist/cjs/pools7DAgo/Pools7DAgoPlugin.js +0 -116
- package/dist/cjs/pools7DAgo/package.json +0 -1
- package/dist/esm/degenDistributors/DegenDistributorsPlugin.js +0 -86
- package/dist/esm/degenDistributors/index.js +0 -2
- package/dist/esm/degenDistributors/package.json +0 -1
- package/dist/esm/pools7DAgo/Pools7DAgoPlugin.js +0 -99
- package/dist/esm/pools7DAgo/index.js +0 -2
- package/dist/esm/pools7DAgo/package.json +0 -1
- package/dist/esm/pools7DAgo/types.js +0 -0
- package/dist/types/degenDistributors/DegenDistributorsPlugin.d.ts +0 -22
- package/dist/types/degenDistributors/index.d.ts +0 -2
- package/dist/types/degenDistributors/types.d.ts +0 -4
- package/dist/types/pools7DAgo/Pools7DAgoPlugin.d.ts +0 -22
- package/dist/types/pools7DAgo/index.d.ts +0 -2
- package/dist/types/pools7DAgo/types.d.ts +0 -9
- /package/dist/esm/{degenDistributors/types.js → sdk/sdk-legacy/pathfinder/core.js} +0 -0
|
@@ -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,
|
|
@@ -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"),
|
|
@@ -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 core_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(core_exports);
|
|
@@ -13,12 +13,10 @@ 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(pools7DAgo_exports, require("./types.js"), module.exports);
|
|
16
|
+
var pathfinder_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(pathfinder_exports);
|
|
18
|
+
__reExport(pathfinder_exports, require("./core.js"), module.exports);
|
|
20
19
|
// Annotate the CommonJS export names for ESM import in node:
|
|
21
20
|
0 && (module.exports = {
|
|
22
|
-
...require("./
|
|
23
|
-
...require("./types.js")
|
|
21
|
+
...require("./core.js")
|
|
24
22
|
});
|
|
@@ -26,16 +26,10 @@ var import_sdk = require("../sdk/index.js");
|
|
|
26
26
|
class ZappersPlugin extends import_sdk.SDKConstruct {
|
|
27
27
|
#zappers;
|
|
28
28
|
version = 1;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// }
|
|
32
|
-
async syncState() {
|
|
33
|
-
await this.load();
|
|
29
|
+
async attach() {
|
|
30
|
+
await this.loadZappers();
|
|
34
31
|
}
|
|
35
|
-
async
|
|
36
|
-
if (!force && this.loaded) {
|
|
37
|
-
return this.state;
|
|
38
|
-
}
|
|
32
|
+
async loadZappers() {
|
|
39
33
|
this.#zappers = new import_sdk.AddressMap(void 0, "zappers");
|
|
40
34
|
const [pcAddr] = this.sdk.addressProvider.mustGetLatest(
|
|
41
35
|
import_sdk.AP_PERIPHERY_COMPRESSOR,
|
|
@@ -72,7 +66,6 @@ class ZappersPlugin extends import_sdk.SDKConstruct {
|
|
|
72
66
|
}
|
|
73
67
|
}
|
|
74
68
|
this.#loadZapperTokens();
|
|
75
|
-
return this.state;
|
|
76
69
|
}
|
|
77
70
|
get zappers() {
|
|
78
71
|
if (!this.#zappers) {
|
|
@@ -80,9 +73,6 @@ class ZappersPlugin extends import_sdk.SDKConstruct {
|
|
|
80
73
|
}
|
|
81
74
|
return this.#zappers;
|
|
82
75
|
}
|
|
83
|
-
get loaded() {
|
|
84
|
-
return !!this.#zappers;
|
|
85
|
-
}
|
|
86
76
|
stateHuman(_) {
|
|
87
77
|
return this.zappers.values().flatMap(
|
|
88
78
|
(l) => l.flatMap((z) => ({
|
|
@@ -96,6 +86,7 @@ class ZappersPlugin extends import_sdk.SDKConstruct {
|
|
|
96
86
|
}
|
|
97
87
|
get state() {
|
|
98
88
|
return {
|
|
89
|
+
version: this.version,
|
|
99
90
|
zappers: this.zappers.asRecord()
|
|
100
91
|
};
|
|
101
92
|
}
|
|
@@ -25,7 +25,6 @@ import { YearnV2RouterAdapterContract } from "./YearnV2AdapterContract.js";
|
|
|
25
25
|
class AdaptersPlugin extends SDKConstruct {
|
|
26
26
|
name = "Adapters";
|
|
27
27
|
version = 1;
|
|
28
|
-
loaded = true;
|
|
29
28
|
createContract(data) {
|
|
30
29
|
const args = data;
|
|
31
30
|
const adapterType = bytes32ToString(
|
|
@@ -94,7 +93,9 @@ class AdaptersPlugin extends SDKConstruct {
|
|
|
94
93
|
return {};
|
|
95
94
|
}
|
|
96
95
|
get state() {
|
|
97
|
-
return {
|
|
96
|
+
return {
|
|
97
|
+
version: this.version
|
|
98
|
+
};
|
|
98
99
|
}
|
|
99
100
|
hydrate(_) {
|
|
100
101
|
}
|
|
@@ -25,25 +25,25 @@ class UnsupportedBotVersionError extends Error {
|
|
|
25
25
|
class BotsPlugin extends SDKConstruct {
|
|
26
26
|
#logger;
|
|
27
27
|
version = 1;
|
|
28
|
-
#botsByMarket;
|
|
28
|
+
#botsByMarket = new AddressMap();
|
|
29
29
|
constructor(sdk) {
|
|
30
30
|
super(sdk);
|
|
31
31
|
this.#logger = sdk.logger?.child?.({ name: "BotsPlugin" }) ?? sdk.logger;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
async attach() {
|
|
34
|
+
await this.#load();
|
|
35
|
+
}
|
|
36
36
|
async syncState() {
|
|
37
|
-
await this
|
|
37
|
+
await this.#load();
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
return
|
|
39
|
+
botsByMarketConfigurator(mc) {
|
|
40
|
+
return this.#botsByMarket.get(mc) ?? [];
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.#botsByMarket
|
|
42
|
+
get allBots() {
|
|
43
|
+
return this.#botsByMarket.values().flat();
|
|
44
|
+
}
|
|
45
|
+
async #load() {
|
|
46
|
+
this.#botsByMarket.clear();
|
|
47
47
|
const [pcAddr] = this.sdk.addressProvider.mustGetLatest(
|
|
48
48
|
AP_PERIPHERY_COMPRESSOR,
|
|
49
49
|
VERSION_RANGE_310
|
|
@@ -68,7 +68,6 @@ class BotsPlugin extends SDKConstruct {
|
|
|
68
68
|
const marketBotData = botsData[i];
|
|
69
69
|
this.#loadStateMarketState(mc, marketBotData);
|
|
70
70
|
}
|
|
71
|
-
return this.state;
|
|
72
71
|
}
|
|
73
72
|
#loadStateMarketState(mc, state) {
|
|
74
73
|
const bots = state.map((state2) => this.#createBot(mc, state2)).sort((a, b) => a.minHealthFactor - b.minHealthFactor);
|
|
@@ -80,39 +79,28 @@ class BotsPlugin extends SDKConstruct {
|
|
|
80
79
|
bots[i].botType = BOT_TYPES[i];
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
|
-
this
|
|
82
|
+
this.#botsByMarket.upsert(mc, bots);
|
|
84
83
|
}
|
|
85
84
|
stateHuman(raw) {
|
|
86
85
|
return {
|
|
87
86
|
bots: Object.fromEntries(
|
|
88
|
-
this
|
|
87
|
+
this.#botsByMarket.entries().map(([mc, bots]) => [
|
|
89
88
|
this.labelAddress(mc),
|
|
90
89
|
bots.map((b) => b.stateHuman(raw))
|
|
91
90
|
])
|
|
92
91
|
)
|
|
93
92
|
};
|
|
94
93
|
}
|
|
95
|
-
get botsByMarket() {
|
|
96
|
-
if (!this.#botsByMarket) {
|
|
97
|
-
throw new Error("bots plugin not loaded");
|
|
98
|
-
}
|
|
99
|
-
return this.#botsByMarket;
|
|
100
|
-
}
|
|
101
|
-
botsByMarketConfigurator(mc) {
|
|
102
|
-
return this.botsByMarket.get(mc) ?? [];
|
|
103
|
-
}
|
|
104
|
-
get allBots() {
|
|
105
|
-
return this.botsByMarket.values().flat();
|
|
106
|
-
}
|
|
107
94
|
get state() {
|
|
108
95
|
return {
|
|
96
|
+
version: this.version,
|
|
109
97
|
bots: TypedObjectUtils.fromEntries(
|
|
110
|
-
this
|
|
98
|
+
this.#botsByMarket.entries().map(([mc, bots]) => [mc, bots.map((b) => b.state)])
|
|
111
99
|
)
|
|
112
100
|
};
|
|
113
101
|
}
|
|
114
102
|
hydrate(state) {
|
|
115
|
-
this.#botsByMarket
|
|
103
|
+
this.#botsByMarket.clear();
|
|
116
104
|
for (const [mc, botStates] of TypedObjectUtils.entries(state.bots)) {
|
|
117
105
|
this.#loadStateMarketState(mc, botStates);
|
|
118
106
|
}
|
|
@@ -9,30 +9,21 @@ import {
|
|
|
9
9
|
VERSION_RANGE_310
|
|
10
10
|
} from "../sdk/index.js";
|
|
11
11
|
class AccountsCounterPlugin extends SDKConstruct {
|
|
12
|
-
#accounts;
|
|
12
|
+
#accounts = new AddressMap();
|
|
13
13
|
version = 1;
|
|
14
14
|
async attach() {
|
|
15
|
-
await this
|
|
15
|
+
await this.#load();
|
|
16
16
|
}
|
|
17
17
|
async syncState() {
|
|
18
|
-
await this
|
|
18
|
+
await this.#load();
|
|
19
19
|
}
|
|
20
20
|
get accounts() {
|
|
21
|
-
if (!this.#accounts) {
|
|
22
|
-
throw new Error("AccountsCounterPlugin is not loaded");
|
|
23
|
-
}
|
|
24
21
|
return this.#accounts;
|
|
25
22
|
}
|
|
26
|
-
get loaded() {
|
|
27
|
-
return !!this.#accounts;
|
|
28
|
-
}
|
|
29
23
|
forCreditManager(addr) {
|
|
30
|
-
return this
|
|
24
|
+
return this.#accounts.mustGet(addr);
|
|
31
25
|
}
|
|
32
|
-
async load(
|
|
33
|
-
if (!force && this.loaded) {
|
|
34
|
-
return this.state;
|
|
35
|
-
}
|
|
26
|
+
async #load() {
|
|
36
27
|
const [compressor] = this.sdk.addressProvider.mustGetLatest(
|
|
37
28
|
AP_CREDIT_ACCOUNT_COMPRESSOR,
|
|
38
29
|
VERSION_RANGE_310
|
|
@@ -75,23 +66,23 @@ class AccountsCounterPlugin extends SDKConstruct {
|
|
|
75
66
|
),
|
|
76
67
|
allowFailure: false
|
|
77
68
|
});
|
|
78
|
-
this.#accounts
|
|
69
|
+
this.#accounts.clear();
|
|
79
70
|
for (let i = 0; i < cms.length; i++) {
|
|
80
71
|
const cm = cms[i];
|
|
81
72
|
const [reverting, nonReverting] = [count[2 * i], count[2 * i + 1]];
|
|
82
73
|
this.#accounts.upsert(cm.creditManager.address, reverting + nonReverting);
|
|
83
74
|
}
|
|
84
|
-
return this.state;
|
|
85
75
|
}
|
|
86
76
|
get state() {
|
|
87
77
|
return {
|
|
88
|
-
|
|
78
|
+
version: this.version,
|
|
79
|
+
accounts: this.#accounts.asRecord()
|
|
89
80
|
};
|
|
90
81
|
}
|
|
91
82
|
hydrate(state) {
|
|
92
|
-
this.#accounts
|
|
83
|
+
this.#accounts.clear();
|
|
93
84
|
for (const [addr, count] of TypedObjectUtils.entries(state.accounts)) {
|
|
94
|
-
this
|
|
85
|
+
this.#accounts.upsert(addr, count);
|
|
95
86
|
}
|
|
96
87
|
}
|
|
97
88
|
}
|
|
@@ -242,12 +242,6 @@ class GearboxSDK {
|
|
|
242
242
|
for (const [name, plugin] of TypedObjectUtils.entries(this.plugins)) {
|
|
243
243
|
const pluginState = state.plugins[name];
|
|
244
244
|
if (plugin.hydrate && pluginState) {
|
|
245
|
-
if (!pluginState.loaded) {
|
|
246
|
-
this.logger?.debug(
|
|
247
|
-
`skipping ${re}hydrating plugin ${name} state: not loaded`
|
|
248
|
-
);
|
|
249
|
-
continue;
|
|
250
|
-
}
|
|
251
245
|
if (pluginState.version !== plugin.version) {
|
|
252
246
|
throw new PluginStateVersionError(plugin, pluginState);
|
|
253
247
|
}
|
|
@@ -270,7 +264,7 @@ class GearboxSDK {
|
|
|
270
264
|
/**
|
|
271
265
|
* Rehydrate existing SDK from new state without re-creating instance
|
|
272
266
|
*/
|
|
273
|
-
|
|
267
|
+
rehydrate(state) {
|
|
274
268
|
if (!this.#attachConfig) {
|
|
275
269
|
throw new Error("cannot rehydrate, attach config is not set");
|
|
276
270
|
}
|
|
@@ -279,10 +273,6 @@ class GearboxSDK {
|
|
|
279
273
|
redstone: this.#attachConfig.redstone
|
|
280
274
|
};
|
|
281
275
|
this.#hydrate(opts, state);
|
|
282
|
-
await this.#hooks.triggerHooks("rehydrate", {
|
|
283
|
-
blockNumber: state.currentBlock,
|
|
284
|
-
timestamp: state.timestamp
|
|
285
|
-
});
|
|
286
276
|
}
|
|
287
277
|
/**
|
|
288
278
|
* Converts contract call into some human-friendly string
|
|
@@ -345,7 +335,7 @@ class GearboxSDK {
|
|
|
345
335
|
plugins: Object.fromEntries(
|
|
346
336
|
TypedObjectUtils.entries(this.plugins).map(([name, plugin]) => [
|
|
347
337
|
name,
|
|
348
|
-
plugin.
|
|
338
|
+
plugin.stateHuman?.(raw) ?? {}
|
|
349
339
|
])
|
|
350
340
|
),
|
|
351
341
|
...this.marketRegister.stateHuman(raw)
|
|
@@ -363,7 +353,7 @@ class GearboxSDK {
|
|
|
363
353
|
plugins: Object.fromEntries(
|
|
364
354
|
TypedObjectUtils.entries(this.plugins).map(([name, plugin]) => [
|
|
365
355
|
name,
|
|
366
|
-
plugin.
|
|
356
|
+
plugin.state
|
|
367
357
|
])
|
|
368
358
|
)
|
|
369
359
|
};
|