@gearbox-protocol/sdk 15.1.0-next.24 → 15.1.0-next.26
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/model/charts.js +20 -34
- package/dist/cjs/model/opportunities.schema.js +15 -13
- package/dist/cjs/sdk/OnchainSDK.js +16 -0
- package/dist/cjs/sdk/accounts/intents/guards.js +1 -7
- package/dist/cjs/sdk/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/cjs/sdk/accounts/intents/utils/pick-token.js +2 -2
- package/dist/cjs/sdk/base/TokensMeta.js +33 -1
- package/dist/cjs/sdk/base/index.js +1 -0
- package/dist/cjs/sdk/base/token-types.js +13 -0
- package/dist/cjs/sdk/chain/chains.js +9 -12
- package/dist/cjs/sdk/chain/index.js +0 -1
- package/dist/cjs/sdk/index.js +1 -2
- package/dist/cjs/sdk/market/MarketSuite.js +11 -5
- package/dist/cjs/sdk/market/credit/CreditSuite.js +14 -3
- package/dist/cjs/sdk/market/credit/collateralUtils.js +2 -14
- package/dist/cjs/sdk/market/credit/index.js +0 -1
- package/dist/cjs/sdk/market/index.js +0 -1
- package/dist/cjs/sdk/market/strategyName.js +4 -6
- package/dist/cjs/sdk/positions/PositionsService.js +1 -1
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/model/charts.js +20 -34
- package/dist/esm/model/opportunities.schema.js +15 -13
- package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/sdk/OnchainSDK.js +16 -0
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/sdk/accounts/intents/guards.js +1 -7
- package/dist/esm/sdk/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/esm/sdk/accounts/intents/utils/pick-token.js +1 -1
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/sdk/base/TokensMeta.js +36 -4
- package/dist/esm/sdk/base/index.js +2 -2
- package/dist/esm/sdk/base/token-types.js +13 -1
- package/dist/esm/sdk/chain/chains.js +10 -12
- package/dist/esm/sdk/chain/detectNetwork.js +1 -1
- package/dist/esm/sdk/chain/index.js +2 -2
- package/dist/esm/sdk/core/createAddressProvider.js +1 -1
- package/dist/esm/sdk/index.js +4 -4
- package/dist/esm/sdk/market/MarketSuite.js +11 -5
- package/dist/esm/sdk/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/sdk/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/sdk/market/credit/CreditSuite.js +14 -3
- package/dist/esm/sdk/market/credit/collateralUtils.js +2 -13
- package/dist/esm/sdk/market/credit/index.js +2 -2
- package/dist/esm/sdk/market/index.js +2 -2
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/sdk/market/strategyName.js +4 -6
- package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/sdk/pools/PoolService.js +1 -1
- package/dist/esm/sdk/positions/PositionsService.js +1 -1
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/types/model/charts.d.ts +16 -23
- package/dist/types/model/charts.schema.d.ts +24 -52
- package/dist/types/model/opportunities.d.ts +18 -4
- package/dist/types/model/opportunities.schema.d.ts +101 -38
- package/dist/types/model/primitives.d.ts +4 -0
- package/dist/types/new-sdk/opportunities/types.d.ts +1 -1
- package/dist/types/new-sdk/positions/types.d.ts +1 -1
- package/dist/types/sdk/base/TokensMeta.d.ts +31 -2
- package/dist/types/sdk/base/index.d.ts +3 -3
- package/dist/types/sdk/base/token-types.d.ts +14 -1
- package/dist/types/sdk/chain/chains.d.ts +3 -11
- package/dist/types/sdk/chain/index.d.ts +2 -2
- package/dist/types/sdk/index.d.ts +5 -5
- package/dist/types/sdk/market/credit/CreditSuite.d.ts +7 -1
- package/dist/types/sdk/market/credit/collateralUtils.d.ts +1 -7
- package/dist/types/sdk/market/credit/index.d.ts +2 -2
- package/dist/types/sdk/market/index.d.ts +2 -2
- package/dist/types/sdk/market/strategyName.d.ts +3 -5
- package/package.json +1 -1
package/dist/esm/model/charts.js
CHANGED
|
@@ -28,11 +28,10 @@ const CHART_RANGES = [
|
|
|
28
28
|
**/
|
|
29
29
|
const POOL_OPPORTUNITY_CHART_METRICS = [
|
|
30
30
|
"depositApy",
|
|
31
|
-
"
|
|
31
|
+
"depositApyAvg7d",
|
|
32
32
|
"dieselRate",
|
|
33
33
|
"supplied",
|
|
34
|
-
"borrowed"
|
|
35
|
-
"availableLiquidity"
|
|
34
|
+
"borrowed"
|
|
36
35
|
];
|
|
37
36
|
/**
|
|
38
37
|
* Every metric a strategy opportunity can chart.
|
|
@@ -41,8 +40,10 @@ const POOL_OPPORTUNITY_CHART_METRICS = [
|
|
|
41
40
|
* chart draws; the two USD series are the same prices quoted in dollars.
|
|
42
41
|
**/
|
|
43
42
|
const STRATEGY_OPPORTUNITY_CHART_METRICS = [
|
|
44
|
-
"netApy",
|
|
45
43
|
"borrowApy",
|
|
44
|
+
"borrowApyAvg7d",
|
|
45
|
+
"quotaRate",
|
|
46
|
+
"liquidationThreshold",
|
|
46
47
|
"collateralApy",
|
|
47
48
|
"tvl",
|
|
48
49
|
"collateralPrice",
|
|
@@ -53,42 +54,32 @@ const STRATEGY_OPPORTUNITY_CHART_METRICS = [
|
|
|
53
54
|
* Every metric a pool position can chart.
|
|
54
55
|
*
|
|
55
56
|
* Nothing to do with {@link POOL_OPPORTUNITY_CHART_METRICS}: an opportunity charts what the
|
|
56
|
-
* pool did, a position charts what one wallet's deposit did in it. `mwr`
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* only zooms the visible slice and its first point is rarely zero.
|
|
57
|
+
* pool did, a position charts what one wallet's deposit did in it. `mwr` is the
|
|
58
|
+
* money-weighted return since the position opened, so it is sensitive to when
|
|
59
|
+
* deposits and withdrawals landed. It is anchored at inception, so a narrow
|
|
60
|
+
* `range` only zooms the visible slice and its first point is rarely zero.
|
|
61
61
|
**/
|
|
62
62
|
const POOL_POSITION_CHART_METRICS = [
|
|
63
|
-
"value",
|
|
64
63
|
"apy",
|
|
65
64
|
"pnl",
|
|
66
|
-
"mwr"
|
|
67
|
-
"twr",
|
|
68
|
-
"underlyingPrice"
|
|
65
|
+
"mwr"
|
|
69
66
|
];
|
|
70
67
|
/**
|
|
71
68
|
* Every metric a strategy position can chart.
|
|
72
69
|
*
|
|
73
|
-
* `
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* different ages.
|
|
70
|
+
* `netApy7d` is the trailing seven-day net yield, so it tracks the position's
|
|
71
|
+
* recent pace rather than its lifetime return and is comparable across
|
|
72
|
+
* positions of different ages.
|
|
77
73
|
**/
|
|
78
74
|
const STRATEGY_POSITION_CHART_METRICS = [
|
|
79
|
-
"totalValueUsd",
|
|
80
75
|
"totalValueUnderlying",
|
|
81
76
|
"debt",
|
|
82
77
|
"healthFactor",
|
|
83
|
-
"leverage",
|
|
84
78
|
"borrowApy",
|
|
85
|
-
"
|
|
79
|
+
"borrowApyAvg7d",
|
|
86
80
|
"pnl",
|
|
87
81
|
"mwr",
|
|
88
|
-
"
|
|
89
|
-
"twrApy",
|
|
90
|
-
"trailingApy7d",
|
|
91
|
-
"trailingApy30d"
|
|
82
|
+
"netApy7d"
|
|
92
83
|
];
|
|
93
84
|
/**
|
|
94
85
|
* Unit of every metric, the one place either side decides it.
|
|
@@ -99,31 +90,26 @@ const STRATEGY_POSITION_CHART_METRICS = [
|
|
|
99
90
|
**/
|
|
100
91
|
const CHART_METRIC_UNITS = {
|
|
101
92
|
depositApy: "bps",
|
|
93
|
+
depositApyAvg7d: "bps",
|
|
102
94
|
borrowApy: "bps",
|
|
103
|
-
|
|
95
|
+
borrowApyAvg7d: "bps",
|
|
96
|
+
quotaRate: "bps",
|
|
97
|
+
liquidationThreshold: "bps",
|
|
104
98
|
collateralApy: "bps",
|
|
105
99
|
supplied: "token",
|
|
106
100
|
borrowed: "token",
|
|
107
|
-
availableLiquidity: "token",
|
|
108
101
|
tvl: "token",
|
|
109
102
|
dieselRate: "ratio",
|
|
110
103
|
collateralPrice: "ratio",
|
|
111
104
|
collateralUsdPrice: "usd",
|
|
112
105
|
underlyingUsdPrice: "usd",
|
|
113
|
-
value: "token",
|
|
114
106
|
apy: "bps",
|
|
115
107
|
pnl: "token",
|
|
116
108
|
mwr: "bps",
|
|
117
|
-
twr: "bps",
|
|
118
|
-
underlyingPrice: "usd",
|
|
119
|
-
totalValueUsd: "usd",
|
|
120
109
|
totalValueUnderlying: "token",
|
|
121
110
|
debt: "token",
|
|
122
111
|
healthFactor: "bps",
|
|
123
|
-
|
|
124
|
-
twrApy: "bps",
|
|
125
|
-
trailingApy7d: "bps",
|
|
126
|
-
trailingApy30d: "bps"
|
|
112
|
+
netApy7d: "bps"
|
|
127
113
|
};
|
|
128
114
|
/**
|
|
129
115
|
* Reason a series could not be produced at all, which is not the same as a
|
|
@@ -65,6 +65,17 @@ const opportunityBaseSchema = z.object({
|
|
|
65
65
|
sunset: z.boolean()
|
|
66
66
|
});
|
|
67
67
|
/**
|
|
68
|
+
* {@link QuotaAsset}
|
|
69
|
+
**/
|
|
70
|
+
const quotaAssetSchema = z.object({
|
|
71
|
+
token: tokenSchema,
|
|
72
|
+
quotaRate: tolerance(bpsSchema, "bps"),
|
|
73
|
+
limit: amountSchema,
|
|
74
|
+
used: tolerance(amountSchema, "amount"),
|
|
75
|
+
allocationShare: tolerance(bpsSchema, "bps"),
|
|
76
|
+
allocatedDebt: tolerance(amountSchema, "amount")
|
|
77
|
+
});
|
|
78
|
+
/**
|
|
68
79
|
* {@link PoolOpportunity}
|
|
69
80
|
**/
|
|
70
81
|
const poolOpportunitySchema = z.object({
|
|
@@ -75,7 +86,8 @@ const poolOpportunitySchema = z.object({
|
|
|
75
86
|
availableLiquidity: tolerance(amountSchema, "amount"),
|
|
76
87
|
utilization: tolerance(bpsSchema, "bps"),
|
|
77
88
|
supplyApy: apyBreakdownSchema,
|
|
78
|
-
supplyApyAvg7D: offchainOnly(apyBreakdownSchema).optional()
|
|
89
|
+
supplyApyAvg7D: offchainOnly(apyBreakdownSchema).optional(),
|
|
90
|
+
quotaAssets: z.array(quotaAssetSchema)
|
|
79
91
|
});
|
|
80
92
|
/**
|
|
81
93
|
* {@link StrategyOpportunity}
|
|
@@ -100,7 +112,7 @@ const strategyOpportunitySchema = z.object({
|
|
|
100
112
|
availableLiquidity: tolerance(amountSchema, "amount"),
|
|
101
113
|
minDebt: amountSchema,
|
|
102
114
|
totalDebtLimit: amountSchema,
|
|
103
|
-
maxBorrowAmount: amountSchema,
|
|
115
|
+
maxBorrowAmount: tolerance(amountSchema, "amount"),
|
|
104
116
|
maxLeverage: leverageSchema
|
|
105
117
|
});
|
|
106
118
|
/**
|
|
@@ -169,15 +181,6 @@ const rateCurveSchema = z.object({
|
|
|
169
181
|
borrowingLimitUtilization: bpsSchema.nullable()
|
|
170
182
|
});
|
|
171
183
|
/**
|
|
172
|
-
* {@link QuotaAsset}
|
|
173
|
-
**/
|
|
174
|
-
const quotaAssetSchema = z.object({
|
|
175
|
-
token: tokenSchema,
|
|
176
|
-
quotaRate: bpsSchema,
|
|
177
|
-
limit: amountSchema,
|
|
178
|
-
used: amountSchema
|
|
179
|
-
});
|
|
180
|
-
/**
|
|
181
184
|
* {@link PriceFeedData}. Recursive: a composite feed lists the feeds it reads.
|
|
182
185
|
**/
|
|
183
186
|
const priceFeedDataSchema = z.object({
|
|
@@ -203,8 +206,7 @@ const priceFeedSummarySchema = z.object({
|
|
|
203
206
|
**/
|
|
204
207
|
const poolOpportunityDetailSchema = z.object({
|
|
205
208
|
...poolOpportunitySchema.shape,
|
|
206
|
-
rateCurve: rateCurveSchema
|
|
207
|
-
quotaAssets: z.array(quotaAssetSchema)
|
|
209
|
+
rateCurve: rateCurveSchema
|
|
208
210
|
});
|
|
209
211
|
/**
|
|
210
212
|
* {@link StrategyOpportunityDetail}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iZapperAbi } from "../../abi/iZapper.js";
|
|
2
1
|
import { iPoolV310Abi } from "../../abi/310/generated.js";
|
|
2
|
+
import { iZapperAbi } from "../../abi/iZapper.js";
|
|
3
3
|
import { asPreviewSimulationError } from "./errors.js";
|
|
4
4
|
//#region src/preview/simulate/simulatePoolOperation.ts
|
|
5
5
|
function previewRead(operation) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
2
1
|
import { iCreditFacadeV310Abi } from "../../abi/310/generated.js";
|
|
3
2
|
import { AddressMap } from "../../sdk/utils/AddressMap.js";
|
|
3
|
+
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
4
4
|
import "../../sdk/index.js";
|
|
5
5
|
import { UnexpectedFacadeEventOrderError } from "./errors.js";
|
|
6
6
|
import { getAddress, isAddressEqual, parseEventLogs } from "viem";
|
|
@@ -228,6 +228,21 @@ var OnchainSDK = class extends ChainContractsRegister {
|
|
|
228
228
|
...this.#withdrawalCompressor ? [this.#withdrawalCompressor.getLoadWithdrawableAssetsMulticall(force)] : [],
|
|
229
229
|
this.tokensMeta.getLoadTokenDataMulticall()
|
|
230
230
|
], { blockNumber: this.currentBlock });
|
|
231
|
+
this.#renameRedemptionPhantoms();
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Rewrites redemption phantom display symbols from the withdrawal
|
|
235
|
+
* compressor's source/target mapping. No-op when the compressor is missing
|
|
236
|
+
* or its assets cache has not been loaded.
|
|
237
|
+
**/
|
|
238
|
+
#renameRedemptionPhantoms() {
|
|
239
|
+
const compressor = this.#withdrawalCompressor;
|
|
240
|
+
if (!compressor?.state) return;
|
|
241
|
+
this.tokensMeta.renameRedemptionPhantoms(compressor.getWithdrawableAssets().map((a) => ({
|
|
242
|
+
phantom: a.withdrawalPhantomToken,
|
|
243
|
+
source: a.token,
|
|
244
|
+
target: a.underlying
|
|
245
|
+
})));
|
|
231
246
|
}
|
|
232
247
|
/**
|
|
233
248
|
* Restores SDK state from a previously serialised {@link GearboxState}
|
|
@@ -256,6 +271,7 @@ var OnchainSDK = class extends ChainContractsRegister {
|
|
|
256
271
|
this.#rwa.setState(state.rwa);
|
|
257
272
|
if (state.withdrawals) this.#withdrawalCompressor?.hydrate(state.withdrawals);
|
|
258
273
|
if (state.tokens) this.tokensMeta.hydrate(state.tokens);
|
|
274
|
+
this.#renameRedemptionPhantoms();
|
|
259
275
|
for (const [name, plugin] of TypedObjectUtils.entries(this.plugins)) {
|
|
260
276
|
const pluginState = state.plugins[name];
|
|
261
277
|
if (plugin.hydrate && pluginState) {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
2
|
-
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
3
1
|
import { AP_REWARDS_COMPRESSOR } from "../constants/address-provider.js";
|
|
4
2
|
import { ADDRESS_0X0 } from "../constants/addresses.js";
|
|
5
3
|
import { MAX_UINT256 } from "../constants/math.js";
|
|
@@ -10,6 +8,8 @@ import "../base/index.js";
|
|
|
10
8
|
import { AccountBotsService } from "./bots/AccountBotsService.js";
|
|
11
9
|
import "./bots/index.js";
|
|
12
10
|
import { rewardsCompressorAbi } from "../../abi/compressors/rewardsCompressor.js";
|
|
11
|
+
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
12
|
+
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
13
13
|
import { expectedBalanceDeltas } from "../market/credit/expectedBalanceDeltas.js";
|
|
14
14
|
import "../market/index.js";
|
|
15
15
|
import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
|
|
@@ -57,7 +57,7 @@ function assertCanBorrow(suite, amount) {
|
|
|
57
57
|
*/
|
|
58
58
|
function assertGrowthAllowed(args) {
|
|
59
59
|
const { sdk, suite, market, before, after } = args;
|
|
60
|
-
const forbidden = forbiddenTokens
|
|
60
|
+
const forbidden = suite.forbiddenTokens;
|
|
61
61
|
const underlying = market.pool.underlying;
|
|
62
62
|
for (const { token, balance } of after) {
|
|
63
63
|
if (balance <= (before.find((a) => eq(a.token, token))?.balance ?? 0n)) continue;
|
|
@@ -66,12 +66,6 @@ function assertGrowthAllowed(args) {
|
|
|
66
66
|
if (!market.pool.pqk.hasActiveQuota(token)) throw new IntentPreviewError("quotaLimitReached", `${token} takes no quota in this market, so it counts as no collateral`);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
/** Tokens the facade's mask flags, which is indexed by collateral position. */
|
|
70
|
-
function forbiddenTokens(suite) {
|
|
71
|
-
const mask = suite.creditFacade.forbiddenTokensMask;
|
|
72
|
-
if (mask === 0n) return [];
|
|
73
|
-
return suite.creditManager.collateralTokens.filter((_, i) => (mask & 1n << BigInt(i)) !== 0n);
|
|
74
|
-
}
|
|
75
69
|
/**
|
|
76
70
|
* The facade weighs the account against its debt at the end of every multicall
|
|
77
71
|
* and reverts if the collateral does not cover it, so a plan that lands the
|
|
@@ -177,6 +177,7 @@ function buildMockSdk(args) {
|
|
|
177
177
|
},
|
|
178
178
|
market,
|
|
179
179
|
isPaused: facadePaused || poolPaused,
|
|
180
|
+
forbiddenTokens: [...forbidden],
|
|
180
181
|
strategyTargetCollateral: args.strategyTargetCollateral ?? collateralTokens.find((t) => t !== args.underlying.toLowerCase()),
|
|
181
182
|
isExpired: expirationDate > 0 && expirationDate < (args.timestamp ?? 0)
|
|
182
183
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NON_STRATEGY_PHANTOM_TOKEN_TYPES } from "../../../
|
|
1
|
+
import { NON_STRATEGY_PHANTOM_TOKEN_TYPES } from "../../../base/token-types.js";
|
|
2
2
|
import { eq } from "./common.js";
|
|
3
3
|
import { convertAmount } from "./convert-amount.js";
|
|
4
4
|
//#region src/sdk/accounts/intents/utils/pick-token.ts
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
|
|
2
1
|
import { AddressSet } from "../../utils/AddressSet.js";
|
|
3
2
|
import { bytes32ToString } from "../../utils/bytes32ToString.js";
|
|
4
3
|
import { ADDRESS_0X0 } from "../../constants/addresses.js";
|
|
@@ -20,6 +19,7 @@ import { SecuritizeLiquidatorContract } from "../../market/rwa/securitize/Securi
|
|
|
20
19
|
import "../../market/rwa/securitize/index.js";
|
|
21
20
|
import "../../market/index.js";
|
|
22
21
|
import { LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./constants.js";
|
|
22
|
+
import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
|
|
23
23
|
//#region src/sdk/accounts/liquidations/LiquidationsService.ts
|
|
24
24
|
/**
|
|
25
25
|
* Service for discovering liquidatable credit accounts and previewing manual
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
2
1
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
3
2
|
import "../../base/index.js";
|
|
4
3
|
import { decodeDelayedIntent } from "./intent-codec.js";
|
|
4
|
+
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
5
5
|
import { InvalidDelayedIntentError } from "./errors.js";
|
|
6
6
|
//#region src/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.ts
|
|
7
7
|
const abi = iRedemptionLoggerV310Abi;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iWithdrawalCompressorV310Abi } from "../../../abi/IWithdrawalCompressorV310.js";
|
|
2
1
|
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
2
|
+
import { iWithdrawalCompressorV310Abi } from "../../../abi/IWithdrawalCompressorV310.js";
|
|
3
3
|
//#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.ts
|
|
4
4
|
const abi = iWithdrawalCompressorV310Abi;
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iWithdrawalCompressorV311Abi } from "../../../abi/IWithdrawalCompressorV311.js";
|
|
2
1
|
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
2
|
+
import { iWithdrawalCompressorV311Abi } from "../../../abi/IWithdrawalCompressorV311.js";
|
|
3
3
|
//#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.ts
|
|
4
4
|
const abi = iWithdrawalCompressorV311Abi;
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
2
1
|
import { encodeDelayedIntent } from "./intent-codec.js";
|
|
3
2
|
import { AbstractWithdrawalCompressorContract, iCreditAccountAbi, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
|
+
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
4
4
|
import { toWithdrawalStatus } from "./types.js";
|
|
5
5
|
//#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.ts
|
|
6
6
|
const abi = iWithdrawalCompressorV313Abi;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { iExpirableAbi } from "../../abi/iExpirable.js";
|
|
2
|
-
import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
|
|
3
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
4
1
|
import { AddressMap } from "../utils/AddressMap.js";
|
|
5
2
|
import { AddressSet } from "../utils/AddressSet.js";
|
|
6
3
|
import { bytes32ToString } from "../utils/bytes32ToString.js";
|
|
7
4
|
import { getAssetType } from "../chain/chains.js";
|
|
8
5
|
import { formatBN } from "../utils/formatter.js";
|
|
9
6
|
import "../utils/index.js";
|
|
7
|
+
import { iExpirableAbi } from "../../abi/iExpirable.js";
|
|
8
|
+
import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
|
|
9
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
10
10
|
import { executeMulticallBatches } from "../utils/viem/executeMulticallBatches.js";
|
|
11
11
|
//#region src/sdk/base/TokensMeta.ts
|
|
12
12
|
/**
|
|
@@ -40,10 +40,21 @@ var TokensMeta = class extends AddressMap {
|
|
|
40
40
|
...existing,
|
|
41
41
|
...v
|
|
42
42
|
};
|
|
43
|
+
if (v) {
|
|
44
|
+
const pretty = this.#prettyName(address);
|
|
45
|
+
if (pretty) v = {
|
|
46
|
+
...v,
|
|
47
|
+
symbol: pretty
|
|
48
|
+
};
|
|
49
|
+
}
|
|
43
50
|
super.upsert(address, v);
|
|
44
51
|
}
|
|
45
52
|
/**
|
|
46
|
-
* Returns the symbol
|
|
53
|
+
* Returns the display symbol for a token.
|
|
54
|
+
*
|
|
55
|
+
* This is not always the on-chain ERC-20 `symbol()`: curated pretty names
|
|
56
|
+
* and redemption phantom tokens (`"source -> target"`) replace it.
|
|
57
|
+
*
|
|
47
58
|
* @param token - Token address.
|
|
48
59
|
* @throws If the token is not in the registry.
|
|
49
60
|
*/
|
|
@@ -138,11 +149,32 @@ var TokensMeta = class extends AddressMap {
|
|
|
138
149
|
}
|
|
139
150
|
return meta.asset;
|
|
140
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Rewrites display symbols of redemption phantom tokens to
|
|
154
|
+
* `"${source} -> ${target}"`.
|
|
155
|
+
*
|
|
156
|
+
* @param renames - Phantom / source / target address triples.
|
|
157
|
+
**/
|
|
158
|
+
renameRedemptionPhantoms(renames) {
|
|
159
|
+
for (const { phantom, source, target } of renames) {
|
|
160
|
+
const meta = this.get(phantom);
|
|
161
|
+
if (!meta || !this.has(source) || !this.has(target)) continue;
|
|
162
|
+
this.upsert(phantom, {
|
|
163
|
+
...meta,
|
|
164
|
+
symbol: `${this.symbol(source)} -> ${this.symbol(target)}`
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
141
168
|
get #networkType() {
|
|
142
169
|
const { chain } = this.#client;
|
|
143
170
|
if ("network" in chain) return chain.network;
|
|
144
171
|
throw new Error(`chain ${chain.id} is not a Gearbox SDK chain`);
|
|
145
172
|
}
|
|
173
|
+
#prettyName(token) {
|
|
174
|
+
const { chain } = this.#client;
|
|
175
|
+
if (!("network" in chain)) return;
|
|
176
|
+
return chain.tokenPrettyNames?.get(token);
|
|
177
|
+
}
|
|
146
178
|
formatBN(arg0, arg1, arg2) {
|
|
147
179
|
const token = typeof arg0 === "object" ? arg0.token : arg0;
|
|
148
180
|
const amount = typeof arg0 === "object" ? arg0.balance : arg1;
|
|
@@ -5,6 +5,6 @@ import { BaseContract, ContractParseError } from "./BaseContract.js";
|
|
|
5
5
|
import { MissingSerializedParamsError } from "./errors.js";
|
|
6
6
|
import { MultichainConstruct } from "./MultichainConstruct.js";
|
|
7
7
|
import { SDKConstruct } from "./SDKConstruct.js";
|
|
8
|
-
import { PHANTOM_TOKEN_CONTRACT_TYPES, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND } from "./token-types.js";
|
|
8
|
+
import { NON_STRATEGY_PHANTOM_TOKEN_TYPES, PHANTOM_TOKEN_CONTRACT_TYPES, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND } from "./token-types.js";
|
|
9
9
|
import { VotingContractStatus } from "./types.js";
|
|
10
|
-
export { BaseContract, ChainContractsRegister, Construct, ContractParseError, MissingSerializedParamsError, MultichainConstruct, PHANTOM_TOKEN_CONTRACT_TYPES, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, SDKConstruct, TokensMeta, VotingContractStatus };
|
|
10
|
+
export { BaseContract, ChainContractsRegister, Construct, ContractParseError, MissingSerializedParamsError, MultichainConstruct, NON_STRATEGY_PHANTOM_TOKEN_TYPES, PHANTOM_TOKEN_CONTRACT_TYPES, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, SDKConstruct, TokensMeta, VotingContractStatus };
|
|
@@ -12,5 +12,17 @@ const PHANTOM_TOKEN_CONTRACT_TYPES = [
|
|
|
12
12
|
const RWA_UNDERLYING_DEFAULT = "RWA_UNDERLYING::DEFAULT";
|
|
13
13
|
const RWA_UNDERLYING_ON_DEMAND = "RWA_UNDERLYING::ON_DEMAND";
|
|
14
14
|
const RWA_ON_DEMAND_LP_MONOPOLIZED = "ON_DEMAND_LP::MONOPOLIZED";
|
|
15
|
+
/**
|
|
16
|
+
* Withdrawal and redemption phantom tokens that can never be acquired as a
|
|
17
|
+
* strategy target. Other `PHANTOM_TOKEN::*` types (Convex, Infrared, staking
|
|
18
|
+
* rewards) can.
|
|
19
|
+
*/
|
|
20
|
+
const NON_STRATEGY_PHANTOM_TOKEN_TYPES = [
|
|
21
|
+
"PHANTOM_TOKEN::INFINIFI_UNWIND",
|
|
22
|
+
"PHANTOM_TOKEN::MELLOW_WITHDRAWAL",
|
|
23
|
+
"PHANTOM_TOKEN::MIDAS_REDEMPTION",
|
|
24
|
+
"PHANTOM_TOKEN::SECURITIZE_RD",
|
|
25
|
+
"PHANTOM_TOKEN::UPSHIFT_WITHDRAW"
|
|
26
|
+
];
|
|
15
27
|
//#endregion
|
|
16
|
-
export { PHANTOM_TOKEN_CONTRACT_TYPES, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND };
|
|
28
|
+
export { NON_STRATEGY_PHANTOM_TOKEN_TYPES, PHANTOM_TOKEN_CONTRACT_TYPES, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND };
|
|
@@ -106,7 +106,15 @@ const chains = {
|
|
|
106
106
|
"0xb46edf298989F0F106EDD80E4ae8f59a13531dB4",
|
|
107
107
|
"0xd98e31C67c7C21f233C37c9AC9Ae656dcb0d5d25"
|
|
108
108
|
]),
|
|
109
|
-
sunsetStrategies: new AddressSet([
|
|
109
|
+
sunsetStrategies: new AddressSet([
|
|
110
|
+
"0x1840056a2bdbe949e017a3716e3fdd4a0d327bf0",
|
|
111
|
+
"0x187C5022002d45107dB72B0b59E72111f69Bd513",
|
|
112
|
+
"0x9fF97B167Dd442bd5f277098bf1154C5807D3566",
|
|
113
|
+
"0xa4c644f3180d10cd3b2121d455a2a88e1bda2928",
|
|
114
|
+
"0xb79d6544839d169869476589d2e54014a074317b",
|
|
115
|
+
"0xc307a074bd5aec2d6ad1d9b74465c24a59b490fd",
|
|
116
|
+
"0xf5edc34204e67e592bdcb84114571c9e4bd0bdf7"
|
|
117
|
+
]),
|
|
110
118
|
isPublic: true,
|
|
111
119
|
wellKnownToken: {
|
|
112
120
|
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
@@ -542,15 +550,5 @@ function getLegacyStrategyTarget(creditManager, network) {
|
|
|
542
550
|
function getAccountTargetCollateral(creditAccount, network) {
|
|
543
551
|
return getChain(network).accountTargetCollaterals?.get(creditAccount);
|
|
544
552
|
}
|
|
545
|
-
/**
|
|
546
|
-
* Curated display name of a token, or `undefined` when the token has none and
|
|
547
|
-
* its ticker symbol should be used instead.
|
|
548
|
-
*
|
|
549
|
-
* @param token - Token address.
|
|
550
|
-
* @param network - Chain id or {@link NetworkType} label.
|
|
551
|
-
**/
|
|
552
|
-
function getTokenPrettyName(token, network) {
|
|
553
|
-
return getChain(network).tokenPrettyNames?.get(token);
|
|
554
|
-
}
|
|
555
553
|
//#endregion
|
|
556
|
-
export { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getLegacyStrategyTarget, getNetworkType,
|
|
554
|
+
export { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getLegacyStrategyTarget, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getLegacyStrategyTarget, getNetworkType,
|
|
1
|
+
import { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getLegacyStrategyTarget, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds } from "./chains.js";
|
|
2
2
|
import { detectNetwork } from "./detectNetwork.js";
|
|
3
|
-
export { NetworkType, SUPPORTED_NETWORKS, chains, detectNetwork, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getLegacyStrategyTarget, getNetworkType,
|
|
3
|
+
export { NetworkType, SUPPORTED_NETWORKS, chains, detectNetwork, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getLegacyStrategyTarget, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
2
1
|
import { AP_MARKET_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR } from "../constants/address-provider.js";
|
|
3
2
|
import { isV310 } from "../constants/versions.js";
|
|
4
3
|
import "../constants/index.js";
|
|
5
4
|
import { hexEq } from "../utils/hex.js";
|
|
5
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
6
6
|
import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
|
|
7
7
|
//#region src/sdk/core/createAddressProvider.ts
|
|
8
8
|
const OVERRIDE_ADDRESSES = { Mainnet: {
|
package/dist/esm/sdk/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { BigIntMath } from "./utils/bigint-math.js";
|
|
|
7
7
|
import { bytes32ToString } from "./utils/bytes32ToString.js";
|
|
8
8
|
import { childLogger } from "./utils/childLogger.js";
|
|
9
9
|
import { createRawTx } from "./utils/createRawTx.js";
|
|
10
|
-
import { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getLegacyStrategyTarget, getNetworkType,
|
|
10
|
+
import { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getLegacyStrategyTarget, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds } from "./chain/chains.js";
|
|
11
11
|
import { detectNetwork } from "./chain/detectNetwork.js";
|
|
12
12
|
import "./chain/index.js";
|
|
13
13
|
import { etherscanApiUrl, etherscanUrl } from "./utils/etherscan.js";
|
|
@@ -38,7 +38,7 @@ import { BaseContract, ContractParseError } from "./base/BaseContract.js";
|
|
|
38
38
|
import { MissingSerializedParamsError } from "./base/errors.js";
|
|
39
39
|
import { MultichainConstruct } from "./base/MultichainConstruct.js";
|
|
40
40
|
import { SDKConstruct } from "./base/SDKConstruct.js";
|
|
41
|
-
import { PHANTOM_TOKEN_CONTRACT_TYPES, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND } from "./base/token-types.js";
|
|
41
|
+
import { NON_STRATEGY_PHANTOM_TOKEN_TYPES, PHANTOM_TOKEN_CONTRACT_TYPES, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND } from "./base/token-types.js";
|
|
42
42
|
import { VotingContractStatus } from "./base/types.js";
|
|
43
43
|
import "./base/index.js";
|
|
44
44
|
import { PeripheryCompressorV310Contract } from "./accounts/bots/PeripheryCompressorV310Contract.js";
|
|
@@ -134,7 +134,7 @@ import { CreditFacadeV310Contract } from "./market/credit/CreditFacadeV310Contra
|
|
|
134
134
|
import { DEFAULT_QUOTA_BUFFER_BPS, MAX_LEVERAGE_BUFFER_BPS, PARTIAL_LIQUIDATION_BUFFER_BPS, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, rayToBps, usdToNumber } from "./market/math.js";
|
|
135
135
|
import { CreditManagerV310Contract } from "./market/credit/CreditManagerV310Contract.js";
|
|
136
136
|
import { strategyName } from "./market/strategyName.js";
|
|
137
|
-
import {
|
|
137
|
+
import { dominantCollateral, isStrategyCollateral, pickStrategyTargetCollateral } from "./market/credit/collateralUtils.js";
|
|
138
138
|
import { CreditSuite } from "./market/credit/CreditSuite.js";
|
|
139
139
|
import { expectedBalanceDeltas } from "./market/credit/expectedBalanceDeltas.js";
|
|
140
140
|
import { simulateMulticall } from "./utils/viem/simulateMulticall.js";
|
|
@@ -238,4 +238,4 @@ import { OnchainSDK, STATE_VERSION } from "./OnchainSDK.js";
|
|
|
238
238
|
import { MultichainSDK } from "./MultichainSDK.js";
|
|
239
239
|
import { attachOptionsSchema, onchainSDKOptionsSchema } from "./options.js";
|
|
240
240
|
import "./types/index.js";
|
|
241
|
-
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AccountMigratorAdapterContract, AdapterType, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, IntentPreviewError, InvalidDelayedIntentError, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LidoV1AdapterContract, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, SimulateWithPriceUpdatesError, SimulationError, StakingRewardsAdapterContract, TokensMeta, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TypedObjectUtils, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UnsupportedZapperFunctionError, UpshiftVaultAdapterContract, VERSION_RANGE_310, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, assetsMap, attachOptionsSchema, botPermissionsToString, bytes32ToString, calcBorrowApy, calcBorrowRate, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcTimeToLiquidationMs, calcUtilization, chains, childLogger, classifyCurveOperation, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError,
|
|
241
|
+
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AccountMigratorAdapterContract, AdapterType, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, IntentPreviewError, InvalidDelayedIntentError, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LidoV1AdapterContract, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, SimulateWithPriceUpdatesError, SimulationError, StakingRewardsAdapterContract, TokensMeta, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TypedObjectUtils, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UnsupportedZapperFunctionError, UpshiftVaultAdapterContract, VERSION_RANGE_310, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, assetsMap, attachOptionsSchema, botPermissionsToString, bytes32ToString, calcBorrowApy, calcBorrowRate, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcTimeToLiquidationMs, calcUtilization, chains, childLogger, classifyCurveOperation, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, hasAdapterDeployParamsAbi, healthFactorBps, hexEq, hydrateAddressProvider, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCreditAccountAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isDust, isLPPriceFeed, isPublicNetwork, isRWAFactory, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parsePosNegAmount, percentFmt, pickStrategyTargetCollateral, rayToBps, rayToNumber, retry, rewardsFromTransfers, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toShares, toSharesUp, toSignificant, toWithdrawalStatus, usdToNumber, watchBlocksAsync };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AddressMap } from "../utils/AddressMap.js";
|
|
2
2
|
import { isRWAToken, isSunsetPool } from "../chain/chains.js";
|
|
3
|
+
import { PERCENTAGE_FACTOR } from "../constants/math.js";
|
|
3
4
|
import "../utils/index.js";
|
|
4
5
|
import { SDKConstruct } from "../base/SDKConstruct.js";
|
|
5
6
|
import "../base/index.js";
|
|
@@ -164,11 +165,16 @@ var MarketSuite = class extends SDKConstruct {
|
|
|
164
165
|
quotaAssets() {
|
|
165
166
|
const oracle = this.priceOracle;
|
|
166
167
|
const { underlying } = this;
|
|
167
|
-
|
|
168
|
+
const quotas = this.pool.pqk.quotas.entries();
|
|
169
|
+
const sumUsed = quotas.reduce((sum, [, quota]) => sum + quota.totalQuoted, 0n);
|
|
170
|
+
const { totalBorrowed } = this.pool.pool;
|
|
171
|
+
return quotas.map(([token, quota]) => ({
|
|
168
172
|
token: this.tokensMeta.mustGetToken(token),
|
|
169
173
|
quotaRate: quota.rate,
|
|
170
174
|
limit: oracle.toAmount(underlying, quota.limit),
|
|
171
|
-
used: oracle.toAmount(underlying, quota.totalQuoted)
|
|
175
|
+
used: oracle.toAmount(underlying, quota.totalQuoted),
|
|
176
|
+
allocationShare: sumUsed === 0n ? 0 : Number(quota.totalQuoted * PERCENTAGE_FACTOR / sumUsed),
|
|
177
|
+
allocatedDebt: oracle.toAmount(underlying, sumUsed === 0n ? 0n : totalBorrowed * quota.totalQuoted / sumUsed)
|
|
172
178
|
}));
|
|
173
179
|
}
|
|
174
180
|
/**
|
|
@@ -223,7 +229,8 @@ var MarketSuite = class extends SDKConstruct {
|
|
|
223
229
|
collateralTokens: this.collateralTokens,
|
|
224
230
|
paused: pool.isPaused,
|
|
225
231
|
rwa: this.rwa,
|
|
226
|
-
sunset: this.sunset
|
|
232
|
+
sunset: this.sunset,
|
|
233
|
+
quotaAssets: this.quotaAssets()
|
|
227
234
|
};
|
|
228
235
|
}
|
|
229
236
|
/**
|
|
@@ -232,8 +239,7 @@ var MarketSuite = class extends SDKConstruct {
|
|
|
232
239
|
poolOpportunityDetail() {
|
|
233
240
|
return {
|
|
234
241
|
...this.poolOpportunity(),
|
|
235
|
-
rateCurve: this.pool.rateCurve
|
|
236
|
-
quotaAssets: this.quotaAssets()
|
|
242
|
+
rateCurve: this.pool.rateCurve
|
|
237
243
|
};
|
|
238
244
|
}
|
|
239
245
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { accountMigratorAbi } from "../../../../abi/AccountMigrator.js";
|
|
2
1
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
2
|
+
import { accountMigratorAbi } from "../../../../abi/AccountMigrator.js";
|
|
3
3
|
//#region src/sdk/market/adapters/contracts/AccountMigratorAdapterContract.ts
|
|
4
4
|
const abi = accountMigratorAbi;
|
|
5
5
|
const protocolAbi = accountMigratorAbi;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ierc4626AdapterAbi } from "../../../../abi/ierc4626Adapter.js";
|
|
2
1
|
import { MissingSerializedParamsError } from "../../../base/errors.js";
|
|
3
2
|
import "../../../base/index.js";
|
|
3
|
+
import { ierc4626AdapterAbi } from "../../../../abi/ierc4626Adapter.js";
|
|
4
4
|
import { iERC4626Abi } from "../abi/targetContractAbi.js";
|
|
5
5
|
import { fnSigToName, swapFromTransfers } from "../transferHelpers.js";
|
|
6
6
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|