@gearbox-protocol/sdk 17.8.0 → 17.10.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/dev/AccountOpener.js +3 -3
- package/dist/cjs/model/index.js +1 -0
- package/dist/cjs/onchain/accounts/index.js +1 -0
- package/dist/cjs/onchain/accounts/intents/realize.js +7 -2
- package/dist/cjs/onchain/accounts/intents/testing/market.js +5 -1
- package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/cjs/onchain/accounts/intents/utils/index.js +1 -0
- package/dist/cjs/onchain/accounts/intents/utils/quotas-for-update.js +30 -0
- package/dist/cjs/onchain/accounts/quota-utils.js +6 -0
- package/dist/cjs/onchain/chain/chains.js +12 -0
- package/dist/cjs/onchain/chain/index.js +1 -0
- package/dist/cjs/onchain/index.js +2 -0
- package/dist/cjs/sdk/GearboxSDK.js +8 -1
- package/dist/cjs/sdk/index.js +6 -0
- package/dist/cjs/sdk/liquidations/LiquidationsNamespace.js +10 -0
- package/dist/cjs/sdk/rewards/RewardsNamespace.js +51 -0
- package/dist/cjs/{rewards → sdk/rewards}/errors.js +1 -1
- package/dist/cjs/{rewards → sdk/rewards}/helpers.js +4 -4
- package/dist/cjs/sdk/rewards/index.js +6 -0
- package/dist/cjs/{rewards → sdk/rewards}/merkl-api.js +3 -3
- package/dist/cjs/{rewards → sdk/rewards}/toMerklRewards.js +6 -6
- package/dist/cjs/{rewards → sdk/rewards}/toTurtleRewards.js +7 -7
- package/dist/cjs/{rewards → sdk/rewards}/turtle-api.js +3 -3
- package/dist/cjs/sdk/rewards/types.js +1 -0
- package/dist/esm/dev/AccountOpener.js +2 -2
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/history/trace/extractTransfers.js +1 -1
- package/dist/esm/model/index.js +1 -0
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/onchain/accounts/index.js +2 -2
- package/dist/esm/onchain/accounts/intents/realize.js +8 -3
- package/dist/esm/onchain/accounts/intents/testing/market.js +5 -1
- package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/esm/onchain/accounts/intents/utils/index.js +2 -2
- package/dist/esm/onchain/accounts/intents/utils/quotas-for-update.js +31 -2
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/onchain/accounts/quota-utils.js +6 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/onchain/base/TokensMeta.js +3 -3
- package/dist/esm/onchain/chain/chains.js +12 -1
- package/dist/esm/onchain/chain/index.js +2 -2
- package/dist/esm/onchain/core/createAddressProvider.js +1 -1
- package/dist/esm/onchain/index.js +3 -3
- package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/onchain/market/rwa/createDegenNFT.js +1 -1
- package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/onchain/preview/preview/previewPoolPositionOperation.js +2 -2
- package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/esm/sdk/GearboxSDK.js +8 -1
- package/dist/esm/sdk/index.js +4 -1
- package/dist/esm/sdk/liquidations/LiquidationsNamespace.js +10 -0
- package/dist/esm/{rewards/RewardsService.js → sdk/rewards/RewardsNamespace.js} +15 -12
- package/dist/esm/{rewards → sdk/rewards}/errors.js +1 -1
- package/dist/esm/{rewards → sdk/rewards}/helpers.js +4 -4
- package/dist/esm/sdk/rewards/index.js +3 -0
- package/dist/esm/{rewards → sdk/rewards}/merkl-api.js +1 -1
- package/dist/esm/{rewards → sdk/rewards}/toMerklRewards.js +1 -1
- package/dist/esm/{rewards → sdk/rewards}/toTurtleRewards.js +1 -1
- package/dist/esm/{rewards → sdk/rewards}/turtle-api.js +1 -1
- package/dist/esm/sdk/rewards/types.js +1 -0
- package/dist/types/model/errors/liquidation-errors.d.ts +4 -0
- package/dist/types/model/errors/operation-errors.d.ts +10 -0
- package/dist/types/model/errors/oracle-errors.d.ts +2 -0
- package/dist/types/model/index.d.ts +2 -1
- package/dist/types/{rewards/types.d.ts → model/rewards.d.ts} +4 -9
- package/dist/types/onchain/accounts/index.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/testing/market.d.ts +4 -0
- package/dist/types/onchain/accounts/intents/utils/index.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/utils/quotas-for-update.d.ts +7 -1
- package/dist/types/onchain/accounts/quota-utils.d.ts +6 -1
- package/dist/types/onchain/chain/chains.d.ts +15 -1
- package/dist/types/onchain/chain/index.d.ts +2 -2
- package/dist/types/onchain/index.d.ts +3 -3
- package/dist/types/sdk/GearboxSDK.d.ts +6 -0
- package/dist/types/sdk/index.d.ts +8 -2
- package/dist/types/sdk/liquidations/LiquidationsNamespace.d.ts +5 -1
- package/dist/types/sdk/liquidations/index.d.ts +2 -2
- package/dist/types/sdk/liquidations/types.d.ts +12 -2
- package/dist/types/sdk/rewards/RewardsNamespace.d.ts +24 -0
- package/dist/types/{rewards → sdk/rewards}/errors.d.ts +3 -3
- package/dist/types/{rewards → sdk/rewards}/helpers.d.ts +5 -4
- package/dist/types/sdk/rewards/index.d.ts +6 -0
- package/dist/types/{rewards → sdk/rewards}/merkl-api.d.ts +3 -3
- package/dist/types/{rewards → sdk/rewards}/toMerklRewards.d.ts +4 -2
- package/dist/types/{rewards → sdk/rewards}/toTurtleRewards.d.ts +4 -2
- package/dist/types/{rewards → sdk/rewards}/turtle-api.d.ts +3 -3
- package/dist/types/sdk/rewards/types.d.ts +35 -0
- package/dist/types/sdk/types.d.ts +9 -0
- package/package.json +1 -6
- package/dist/cjs/rewards/RewardsService.js +0 -48
- package/dist/cjs/rewards/index.js +0 -6
- package/dist/cjs/rewards/package.json +0 -1
- package/dist/esm/rewards/index.js +0 -3
- package/dist/esm/rewards/package.json +0 -1
- package/dist/types/rewards/RewardsService.d.ts +0 -29
- package/dist/types/rewards/index.d.ts +0 -6
- /package/dist/cjs/{rewards/types.js → model/rewards.js} +0 -0
- /package/dist/esm/{rewards/types.js → model/rewards.js} +0 -0
|
@@ -7,7 +7,7 @@ import "./credit-account-compressor/index.js";
|
|
|
7
7
|
import { CreditAccountsServiceV310 } from "./CreditAccountsServiceV310.js";
|
|
8
8
|
import { isPhantomToken } from "./intents/utils/pick-token.js";
|
|
9
9
|
import { fetchCreditAccountSlice, toCreditAccountSlice } from "./intents/utils/credit-account-slice.js";
|
|
10
|
-
import { calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota } from "./quota-utils.js";
|
|
10
|
+
import { DIRECT_TRANSFERS_QUOTA, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota } from "./quota-utils.js";
|
|
11
11
|
import { CreditAccountOperationsService } from "./intents/index.js";
|
|
12
12
|
import { LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./liquidations/constants.js";
|
|
13
13
|
import { LiquidationsService } from "./liquidations/LiquidationsService.js";
|
|
@@ -25,4 +25,4 @@ import { toWithdrawalStatus } from "./withdrawal-compressor/types.js";
|
|
|
25
25
|
import { WithdrawalCompressorV313Contract } from "./withdrawal-compressor/WithdrawalCompressorV313Contract.js";
|
|
26
26
|
import { createWithdrawalCompressor } from "./withdrawal-compressor/createWithdrawalCompressor.js";
|
|
27
27
|
import "./withdrawal-compressor/index.js";
|
|
28
|
-
export { AbstractWithdrawalCompressorContract, AccountBotsService, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LiquidationsService, MultichainLiquidationsService, PeripheryCompressorV310Contract, RedemptionLoggerV310Contract, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, fetchCreditAccountSlice, getWithdrawalCompressorAddress, iCreditAccountAbi, isPhantomToken, roundUpQuota, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
|
|
28
|
+
export { AbstractWithdrawalCompressorContract, AccountBotsService, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DIRECT_TRANSFERS_QUOTA, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LiquidationsService, MultichainLiquidationsService, PeripheryCompressorV310Contract, RedemptionLoggerV310Contract, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, fetchCreditAccountSlice, getWithdrawalCompressorAddress, iCreditAccountAbi, isPhantomToken, roundUpQuota, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getDirectTransferToken } from "../../chain/chains.js";
|
|
1
2
|
import { PERCENTAGE_FACTOR_1KK } from "../../constants/math.js";
|
|
2
3
|
import { insufficientBalance } from "../../../model/errors/operation-errors.js";
|
|
3
4
|
import { multipleDelayedWithdrawals, noDelayedRoute, withdrawalInProgress } from "../../../model/errors/prepare-errors.js";
|
|
@@ -9,7 +10,7 @@ import { isRedemptionPhantomToken } from "./utils/pick-token.js";
|
|
|
9
10
|
import { assertCanBorrow, assertCollateralised, assertGrowthAllowed, assertQuotaAvailable } from "./guards.js";
|
|
10
11
|
import { OperationLedger } from "./utils/ledger.js";
|
|
11
12
|
import { collectPriceImpact } from "./utils/price-impact.js";
|
|
12
|
-
import { clearedQuotas, getQuotasForUpdate, quotasAfterUpdate } from "./utils/quotas-for-update.js";
|
|
13
|
+
import { clearedQuotas, getQuotasForUpdate, quotasAfterUpdate, withDirectTransferQuota } from "./utils/quotas-for-update.js";
|
|
13
14
|
import { createRouterPaths } from "./utils/router-path.js";
|
|
14
15
|
import { buildAddCollateralOperation, buildClaimDelayedWithdrawalOperation, buildCloseSwapOperation, buildDecreaseDebtOperation, buildIncreaseDebtOperation, buildQuotaUpdateOperation, buildStartDelayedWithdrawalOperation, buildSwapOperation, buildUnwrapRwaCollateralOperation, buildWithdrawCollateralOperation, buildWrapRwaCollateralOperation, instantOutput } from "./operations.js";
|
|
15
16
|
import { withdrawLimits } from "./withdraw-limits.js";
|
|
@@ -106,6 +107,8 @@ async function realize(steps, props) {
|
|
|
106
107
|
* judge the closing collateral check at safe prices.
|
|
107
108
|
*/
|
|
108
109
|
let withdrawsCollateral = false;
|
|
110
|
+
/** Token a sold collateral later transfers to the account; needs a quota. */
|
|
111
|
+
let directTransfer;
|
|
109
112
|
const amountOf = (a) => typeof a === "bigint" ? a : min(raised, a.max ?? raised);
|
|
110
113
|
const assertHolds = (token, amount, what) => {
|
|
111
114
|
const held = ledger.balanceOf(token);
|
|
@@ -178,6 +181,7 @@ async function realize(steps, props) {
|
|
|
178
181
|
raised = amountOut;
|
|
179
182
|
break;
|
|
180
183
|
}
|
|
184
|
+
directTransfer ??= getDirectTransferToken(step.from, sdk.networkType);
|
|
181
185
|
const held = ledger.balanceOf(step.from);
|
|
182
186
|
const leg = await paths.swap({
|
|
183
187
|
tokenIn: step.from,
|
|
@@ -258,6 +262,7 @@ async function realize(steps, props) {
|
|
|
258
262
|
const asset = await delayedConfig(sdk, creditAccount, step.token);
|
|
259
263
|
if (ledger.balanceOf(asset.withdrawalPhantomToken) > 0n) throw new IntentPreviewError(withdrawalInProgress(toTokenAmount(sdk, asset.withdrawalPhantomToken, ledger.balanceOf(asset.withdrawalPhantomToken))), `request: ${asset.withdrawalPhantomToken} already holds a pending withdrawal`);
|
|
260
264
|
assertHolds(step.token, step.amount + step.reserve, "request");
|
|
265
|
+
if (step.record.type !== "CLOSE_ACCOUNT") directTransfer ??= getDirectTransferToken(step.token, sdk.networkType);
|
|
261
266
|
const preview = await sdk.accounts.previewDelayedWithdrawal({
|
|
262
267
|
creditAccount: creditAccount.creditAccount,
|
|
263
268
|
token: step.token,
|
|
@@ -329,7 +334,7 @@ async function realize(steps, props) {
|
|
|
329
334
|
const floor = ledger.snapshot();
|
|
330
335
|
const { assets, debt } = floor;
|
|
331
336
|
const projected = expected.snapshot();
|
|
332
|
-
const quotas = cleared ?? getQuotasForUpdate({
|
|
337
|
+
const quotas = cleared ?? withDirectTransferQuota(getQuotasForUpdate({
|
|
333
338
|
assetsBefore: creditAccount.tokens,
|
|
334
339
|
assetsAfter: assets,
|
|
335
340
|
initialQuotas: creditAccount.tokens,
|
|
@@ -339,7 +344,7 @@ async function realize(steps, props) {
|
|
|
339
344
|
quotas: market.pool.pqk.quotas,
|
|
340
345
|
maxDebt: suite.creditFacade.maxDebt,
|
|
341
346
|
convert: price
|
|
342
|
-
});
|
|
347
|
+
}), debt > 0n ? directTransfer : void 0, creditAccount.tokens, market.pool.pqk.quotas, suite.creditManager.maxEnabledTokens, suite.creditManager.collateralTokens);
|
|
343
348
|
const quotasAfter = quotasAfterUpdate(creditAccount.tokens, quotas.desiredQuota);
|
|
344
349
|
const quoted = Object.values(quotasAfter);
|
|
345
350
|
const snapshot = {
|
|
@@ -90,7 +90,10 @@ function buildMarketSdk(extras) {
|
|
|
90
90
|
...extras?.extraDecimals
|
|
91
91
|
},
|
|
92
92
|
quotas: extras?.quotas ?? QUOTAS,
|
|
93
|
-
liquidationThresholds:
|
|
93
|
+
liquidationThresholds: {
|
|
94
|
+
...LIQUIDATION_THRESHOLDS,
|
|
95
|
+
...extras?.extraLiquidationThresholds
|
|
96
|
+
},
|
|
94
97
|
maxDebt: MAX_DEBT,
|
|
95
98
|
minDebt: extras?.minDebt,
|
|
96
99
|
creditManager: CREDIT_MANAGER,
|
|
@@ -102,6 +105,7 @@ function buildMarketSdk(extras) {
|
|
|
102
105
|
phantoms: extras?.phantoms,
|
|
103
106
|
creditAccounts: extras?.creditAccounts,
|
|
104
107
|
delayed: extras?.delayed,
|
|
108
|
+
maxEnabledTokens: extras?.maxEnabledTokens,
|
|
105
109
|
facadePaused: extras?.facadePaused,
|
|
106
110
|
poolPaused: extras?.poolPaused,
|
|
107
111
|
expirationDate: extras?.expirationDate,
|
|
@@ -6,6 +6,6 @@ import { calcBorrowedAmountPlusInterestAndFees } from "./borrowed-amount-plus-in
|
|
|
6
6
|
import { fetchCreditAccountSlice, toCreditAccountSlice, unopenedAccountSlice } from "./credit-account-slice.js";
|
|
7
7
|
import { OperationLedger } from "./ledger.js";
|
|
8
8
|
import { collectPriceImpact, lossRate, startProbe } from "./price-impact.js";
|
|
9
|
-
import { clearedQuotas, getQuotasForUpdate, quotasAfterUpdate } from "./quotas-for-update.js";
|
|
9
|
+
import { clearedQuotas, getQuotasForUpdate, quotasAfterUpdate, withDirectTransferQuota } from "./quotas-for-update.js";
|
|
10
10
|
import { createOraclePaths, createRouterPaths } from "./router-path.js";
|
|
11
|
-
export { OperationLedger, adjustStateToSnapshot, assembleOperationCalls, calcBorrowedAmountPlusInterestAndFees, clearedQuotas, collectPriceImpact, createOraclePaths, createRouterPaths, eq, fetchCreditAccountSlice, getQuotasForUpdate, isPhantomToken, isRedemptionPhantomToken, lossRate, pickFattestNonPhantomToken, quotasAfterUpdate, rankAccountTokens, resolveCreditManager, startProbe, toCreditAccountSlice, toRouterCaSlice, toTargetDecimals, unopenedAccountSlice };
|
|
11
|
+
export { OperationLedger, adjustStateToSnapshot, assembleOperationCalls, calcBorrowedAmountPlusInterestAndFees, clearedQuotas, collectPriceImpact, createOraclePaths, createRouterPaths, eq, fetchCreditAccountSlice, getQuotasForUpdate, isPhantomToken, isRedemptionPhantomToken, lossRate, pickFattestNonPhantomToken, quotasAfterUpdate, rankAccountTokens, resolveCreditManager, startProbe, toCreditAccountSlice, toRouterCaSlice, toTargetDecimals, unopenedAccountSlice, withDirectTransferQuota };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MIN_INT96 } from "../../../constants/math.js";
|
|
2
2
|
import { TypedObjectUtils } from "../../../utils/mappers.js";
|
|
3
|
-
import { calcQuotaUpdate } from "../../quota-utils.js";
|
|
3
|
+
import { DIRECT_TRANSFERS_QUOTA, calcQuotaUpdate } from "../../quota-utils.js";
|
|
4
4
|
//#region src/onchain/accounts/intents/utils/quotas-for-update.ts
|
|
5
5
|
function getQuotasForUpdate({ assetsBefore, assetsAfter, initialQuotas, quotaReserve = 0, liquidationThresholds: liquidationThresholdsMap, quotas: quotasMap, maxDebt, underlyingToken, convert }) {
|
|
6
6
|
const underlyingTokenLc = underlyingToken.toLowerCase();
|
|
@@ -78,6 +78,35 @@ function clearedQuotas(initialQuotas) {
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
|
+
* Raises `directTransfer`'s quota to at least {@link DIRECT_TRANSFERS_QUOTA};
|
|
82
|
+
* skips a token absent from the credit manager, one the pool can't quote, or
|
|
83
|
+
* one the account has no free enabled token slot for.
|
|
84
|
+
*/
|
|
85
|
+
function withDirectTransferQuota(update, directTransfer, initialQuotas, quotas, maxEnabledTokens, collateralTokens) {
|
|
86
|
+
if (!directTransfer) return update;
|
|
87
|
+
const token = directTransfer.toLowerCase();
|
|
88
|
+
const quota = quotas.get(token);
|
|
89
|
+
const initial = initialQuotas.find((q) => q.token.toLowerCase() === token)?.quota ?? 0n;
|
|
90
|
+
const change = DIRECT_TRANSFERS_QUOTA - initial;
|
|
91
|
+
if (!collateralTokens.some((t) => t.toLowerCase() === token) || !quota?.isActive || quota.limit - quota.totalQuoted < change || (update.desiredQuota[token]?.balance ?? initial) >= DIRECT_TRANSFERS_QUOTA || Object.keys(quotasAfterUpdate(initialQuotas, update.desiredQuota)).length >= maxEnabledTokens) return update;
|
|
92
|
+
const rest = (list) => list.filter((a) => a.token !== token);
|
|
93
|
+
const entry = {
|
|
94
|
+
token,
|
|
95
|
+
balance: change
|
|
96
|
+
};
|
|
97
|
+
return {
|
|
98
|
+
desiredQuota: {
|
|
99
|
+
...update.desiredQuota,
|
|
100
|
+
[token]: {
|
|
101
|
+
token,
|
|
102
|
+
balance: DIRECT_TRANSFERS_QUOTA
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
quotaIncrease: change > 0n ? [...rest(update.quotaIncrease), entry] : rest(update.quotaIncrease),
|
|
106
|
+
quotaDecrease: change < 0n ? [...rest(update.quotaDecrease), entry] : rest(update.quotaDecrease)
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
81
110
|
* The quotas the account stands at once an update lands: the ones it came with,
|
|
82
111
|
* with the ones the update names written over them.
|
|
83
112
|
*
|
|
@@ -166,4 +195,4 @@ function constructAssetRecord(a) {
|
|
|
166
195
|
}, {});
|
|
167
196
|
}
|
|
168
197
|
//#endregion
|
|
169
|
-
export { clearedQuotas, getQuotasForUpdate, quotasAfterUpdate };
|
|
198
|
+
export { clearedQuotas, getQuotasForUpdate, quotasAfterUpdate, withDirectTransferQuota };
|
|
@@ -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
|
import { skipLiquidatableAccount } from "./skipLiquidatableAccount.js";
|
|
24
24
|
//#region src/onchain/accounts/liquidations/LiquidationsService.ts
|
|
25
25
|
/**
|
|
@@ -2,6 +2,11 @@ import { BigIntMath } from "../utils/bigint-math.js";
|
|
|
2
2
|
import { MIN_INT96, PERCENTAGE_FACTOR } from "../constants/math.js";
|
|
3
3
|
//#region src/onchain/accounts/quota-utils.ts
|
|
4
4
|
/**
|
|
5
|
+
* Quota that keeps a directly transferred token enabled, so a liquidation
|
|
6
|
+
* counts it.
|
|
7
|
+
*/
|
|
8
|
+
const DIRECT_TRANSFERS_QUOTA = PERCENTAGE_FACTOR;
|
|
9
|
+
/**
|
|
5
10
|
* Rounds quota deltas to protocol precision step (`PERCENTAGE_FACTOR`).
|
|
6
11
|
*
|
|
7
12
|
* The `MIN_INT96` sentinel is preserved as-is because it encodes
|
|
@@ -137,4 +142,4 @@ function getSingleQuotaChange(token, unsafeMaxQuotaIncrease, props) {
|
|
|
137
142
|
};
|
|
138
143
|
}
|
|
139
144
|
//#endregion
|
|
140
|
-
export { calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota };
|
|
145
|
+
export { DIRECT_TRANSFERS_QUOTA, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
2
1
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
3
2
|
import "../../base/index.js";
|
|
4
3
|
import { sdkErr, sdkOk } from "../../../model/result.js";
|
|
5
4
|
import "../../../model/index.js";
|
|
6
5
|
import { decodeDelayedIntent } from "./intent-codec.js";
|
|
6
|
+
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
7
7
|
//#region src/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.ts
|
|
8
8
|
const abi = iRedemptionLoggerV310Abi;
|
|
9
9
|
/**
|
|
@@ -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/onchain/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/onchain/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/onchain/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 { SdkRWADataNotLoadedError } from "../core/errors.js";
|
|
11
11
|
import { executeMulticallBatches } from "../utils/viem/executeMulticallBatches.js";
|
|
12
12
|
//#region src/onchain/base/TokensMeta.ts
|
|
@@ -77,6 +77,7 @@ const chains = {
|
|
|
77
77
|
"0x238a700eD6165261Cf8b2e544ba797BC11e466Ba",
|
|
78
78
|
"0x7433806912Eae67919e66aea853d46Fa0aef98A8"
|
|
79
79
|
]),
|
|
80
|
+
directTransfers: AddressMap.fromRecord({ "0x7433806912Eae67919e66aea853d46Fa0aef98A8": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" }),
|
|
80
81
|
legacyStrategyTargets: AddressMap.fromRecord({
|
|
81
82
|
"0x1293a69e4ad4a93293a06b6303104be35bdd83af": "0x1a711a5bc48b5c1352c1882fa65dc14b5b9e829d",
|
|
82
83
|
"0x29350a3c2627fb78c7e915cd59af754edf8998c5": "0xe1d9b789da5b5375eacf66f036022b019a2af307",
|
|
@@ -544,6 +545,16 @@ function isSunsetStrategy(creditManager, network) {
|
|
|
544
545
|
return !!chains[network].sunsetStrategies?.has(creditManager);
|
|
545
546
|
}
|
|
546
547
|
/**
|
|
548
|
+
* Token a collateral's sale later transfers directly to the credit account,
|
|
549
|
+
* or `undefined` when the collateral is not in the table.
|
|
550
|
+
*
|
|
551
|
+
* @param collateral - Collateral token address.
|
|
552
|
+
* @param network - Chain id or {@link NetworkType} label.
|
|
553
|
+
**/
|
|
554
|
+
function getDirectTransferToken(collateral, network) {
|
|
555
|
+
return getChain(network).directTransfers?.get(collateral);
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
547
558
|
* Hardcoded target collateral of a legacy credit manager, or `undefined` when
|
|
548
559
|
* the manager is not in the table and the on-chain rule should apply.
|
|
549
560
|
*
|
|
@@ -565,4 +576,4 @@ function getAccountTargetCollateral(creditAccount, network) {
|
|
|
565
576
|
return getChain(network).accountTargetCollaterals?.get(creditAccount);
|
|
566
577
|
}
|
|
567
578
|
//#endregion
|
|
568
|
-
export { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getLegacyStrategyTarget, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds };
|
|
579
|
+
export { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getDirectTransferToken, 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, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds } from "./chains.js";
|
|
1
|
+
import { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getDirectTransferToken, 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, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds };
|
|
3
|
+
export { NetworkType, SUPPORTED_NETWORKS, chains, detectNetwork, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getDirectTransferToken, getLegacyStrategyTarget, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
2
1
|
import "../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/onchain/core/createAddressProvider.ts
|
|
8
8
|
const OVERRIDE_ADDRESSES = {};
|
|
@@ -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, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds } from "./chain/chains.js";
|
|
10
|
+
import { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getDirectTransferToken, 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";
|
|
@@ -242,7 +242,7 @@ import { raise } from "./validation/raise.js";
|
|
|
242
242
|
import "./validation/index.js";
|
|
243
243
|
import { isPhantomToken } from "./accounts/intents/utils/pick-token.js";
|
|
244
244
|
import { fetchCreditAccountSlice, toCreditAccountSlice } from "./accounts/intents/utils/credit-account-slice.js";
|
|
245
|
-
import { calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota } from "./accounts/quota-utils.js";
|
|
245
|
+
import { DIRECT_TRANSFERS_QUOTA, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota } from "./accounts/quota-utils.js";
|
|
246
246
|
import { CreditAccountOperationsService } from "./accounts/intents/index.js";
|
|
247
247
|
import { LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./accounts/liquidations/constants.js";
|
|
248
248
|
import { LiquidationsService } from "./accounts/liquidations/LiquidationsService.js";
|
|
@@ -305,4 +305,4 @@ import { replayMulticall } from "./preview/preview/replayMulticall.js";
|
|
|
305
305
|
import { previewOperation } from "./preview/preview/previewOperation.js";
|
|
306
306
|
import "./preview/index.js";
|
|
307
307
|
import "./types/index.js";
|
|
308
|
-
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_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, ConstantPriceFeedContract, Construct, ContractParseError, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountState, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CreditSuiteStrategy, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EXECUTE_BYTES_SELECTOR, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, 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_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_INT96, MIN_SAFE_HEALTH_FACTOR_FORM, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, 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, PriceFeedRegistry, PriceOracleV310Contract, PriceUpdatesCache, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_COMPRESSOR_ADDRESS, 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, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, SimulateWithPriceUpdatesError, SimulationError, StakingRewardsAdapterContract, TokensMeta, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TypedObjectUtils, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatablePriceFeedRegistry, 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, amountOf, assetsMap, attachOptionsSchema, botPermissionsToString, bpsToRay, buildDelayedStrategyPositionOperationPreview, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkMidasAccountGreenlist, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkRWAOpenRequirements, checkRWAOpening, checkReservePriceLimited, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, childLogger, classifyCloseOrRepay, classifyCurveOperation, classifyInnerOperations, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectDelayedClaim, detectDelayedOperation, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateClaimableAt, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, filterDust, filterDustUSD, findCallTo, findCallWithInput, findCuratorMarketConfigurator, findExecuteBytes, 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, isCloseOrRepay, isDust, isLPPriceFeed, isPhantomToken, isPoolOperation, isPublicNetwork, isRWAFactory, isRWAOperation, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, makeReplayState, mellowDvvAdapterAbi, midasGreenlistsAccount, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parsePosNegAmount, parseRWAFactoryOperationCalldata, percentFmt, pickStrategyTargetCollateral, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, raise, rayToBps, rayToNumber, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, resolveProtocolCall, retry, rewardsFromTransfers, roundUpQuota, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, soleNonUnderlyingCollateral, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toToken, toTokenAmount, toWithdrawalStatus, updatableDependencies, usdToNumber, watchBlocksAsync };
|
|
308
|
+
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_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, ConstantPriceFeedContract, Construct, ContractParseError, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountState, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CreditSuiteStrategy, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DIRECT_TRANSFERS_QUOTA, DUST_THRESHOLD, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EXECUTE_BYTES_SELECTOR, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, 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_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_INT96, MIN_SAFE_HEALTH_FACTOR_FORM, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, 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, PriceFeedRegistry, PriceOracleV310Contract, PriceUpdatesCache, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_COMPRESSOR_ADDRESS, 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, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, SimulateWithPriceUpdatesError, SimulationError, StakingRewardsAdapterContract, TokensMeta, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TypedObjectUtils, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatablePriceFeedRegistry, 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, amountOf, assetsMap, attachOptionsSchema, botPermissionsToString, bpsToRay, buildDelayedStrategyPositionOperationPreview, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkMidasAccountGreenlist, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkRWAOpenRequirements, checkRWAOpening, checkReservePriceLimited, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, childLogger, classifyCloseOrRepay, classifyCurveOperation, classifyInnerOperations, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectDelayedClaim, detectDelayedOperation, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateClaimableAt, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, filterDust, filterDustUSD, findCallTo, findCallWithInput, findCuratorMarketConfigurator, findExecuteBytes, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getDirectTransferToken, 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, isCloseOrRepay, isDust, isLPPriceFeed, isPhantomToken, isPoolOperation, isPublicNetwork, isRWAFactory, isRWAOperation, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, makeReplayState, mellowDvvAdapterAbi, midasGreenlistsAccount, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parsePosNegAmount, parseRWAFactoryOperationCalldata, percentFmt, pickStrategyTargetCollateral, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, raise, rayToBps, rayToNumber, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, resolveProtocolCall, retry, rewardsFromTransfers, roundUpQuota, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, soleNonUnderlyingCollateral, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toToken, toTokenAmount, toWithdrawalStatus, updatableDependencies, usdToNumber, watchBlocksAsync };
|
|
@@ -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/onchain/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";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
2
1
|
import { iCreditFacadeMulticallV310Abi, iCreditFacadeV310Abi } from "../../../abi/310/generated.js";
|
|
3
2
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
4
3
|
import "../../base/index.js";
|
|
4
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
5
5
|
//#region src/onchain/market/credit/CreditFacadeV310BaseContract.ts
|
|
6
6
|
const abi = [
|
|
7
7
|
...iCreditFacadeV310Abi,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
2
1
|
import { iPoolV310Abi } from "../../../abi/310/generated.js";
|
|
3
2
|
import { AddressMap } from "../../utils/AddressMap.js";
|
|
4
3
|
import { RAY } from "../../constants/math.js";
|
|
@@ -8,6 +7,7 @@ import "../../utils/index.js";
|
|
|
8
7
|
import { SdkRWADataNotLoadedError } from "../../core/errors.js";
|
|
9
8
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
10
9
|
import "../../base/index.js";
|
|
10
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
11
11
|
//#region src/onchain/market/pool/PoolV310Contract.ts
|
|
12
12
|
const abi = [...iPoolV310Abi, ...iPausableAbi];
|
|
13
13
|
var PoolV310Contract = class extends BaseContract {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { iVersionAbi } from "../../../abi/iVersion.js";
|
|
2
1
|
import { bytes32ToString } from "../../utils/bytes32ToString.js";
|
|
3
2
|
import "../../utils/index.js";
|
|
3
|
+
import { iVersionAbi } from "../../../abi/iVersion.js";
|
|
4
4
|
import { iMidasDegenNFTAbi } from "../../../abi/rwa/iMidasDegenNFT.js";
|
|
5
5
|
import { DEGEN_NFT_MIDAS } from "./midas/constants.js";
|
|
6
6
|
import { MidasDegenNFT } from "./midas/MidasDegenNFT.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iethZapperAbi } from "../../../abi/iETHZapper.js";
|
|
2
1
|
import { ZapperContract } from "./ZapperContract.js";
|
|
2
|
+
import { iethZapperAbi } from "../../../abi/iETHZapper.js";
|
|
3
3
|
//#region src/onchain/market/zapper/IETHZapperContract.ts
|
|
4
4
|
const abi = iethZapperAbi;
|
|
5
5
|
var IETHZapperContract = class extends ZapperContract {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
2
1
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
3
2
|
import "../../base/index.js";
|
|
4
3
|
import { sdkErr, sdkOk } from "../../../model/result.js";
|
|
5
4
|
import "../../../model/index.js";
|
|
5
|
+
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
6
6
|
//#region src/onchain/market/zapper/ZapperContract.ts
|
|
7
7
|
/**
|
|
8
8
|
* Base contract for every Gearbox zapper. Specialized zappers (e.g.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ierc20Abi } from "../../../abi/iERC20.js";
|
|
2
|
-
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
3
1
|
import { iPoolV310Abi } from "../../../abi/310/generated.js";
|
|
2
|
+
import { ierc20Abi } from "../../../abi/iERC20.js";
|
|
4
3
|
import { sdkErr, sdkOk } from "../../../model/result.js";
|
|
5
4
|
import "../../../model/index.js";
|
|
5
|
+
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
6
6
|
//#region src/onchain/preview/preview/previewPoolPositionOperation.ts
|
|
7
7
|
function previewRead(operation) {
|
|
8
8
|
switch (operation.operation) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { errorAbis } from "../../../abi/errors.js";
|
|
2
|
-
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
3
2
|
import { generateCastTraceCall } from "./cast.js";
|
|
3
|
+
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
4
4
|
import { simulateMulticall } from "./simulateMulticall.js";
|
|
5
5
|
import { BaseError, CallExecutionError, ContractFunctionRevertedError, decodeFunctionData, decodeFunctionResult, encodeFunctionData, parseAbi } from "viem";
|
|
6
6
|
import { getAction, parseAccount } from "viem/utils";
|
|
@@ -18,6 +18,8 @@ import { PositionsNamespace } from "./positions/PositionsNamespace.js";
|
|
|
18
18
|
import "./positions/index.js";
|
|
19
19
|
import { PreviewNamespace } from "./preview/PreviewNamespace.js";
|
|
20
20
|
import "./preview/index.js";
|
|
21
|
+
import { RewardsNamespace } from "./rewards/RewardsNamespace.js";
|
|
22
|
+
import "./rewards/index.js";
|
|
21
23
|
//#region src/sdk/GearboxSDK.ts
|
|
22
24
|
/**
|
|
23
25
|
* Default {@link GearboxSDKOptions.maxStateAgeSeconds}: the fastest poll an
|
|
@@ -75,6 +77,10 @@ var GearboxSDK = class {
|
|
|
75
77
|
**/
|
|
76
78
|
preview;
|
|
77
79
|
/**
|
|
80
|
+
* Namespace for claimable rewards. Absent in `offchain` mode.
|
|
81
|
+
**/
|
|
82
|
+
rewards;
|
|
83
|
+
/**
|
|
78
84
|
* The banners the backend attaches to a pool opportunity or a strategy
|
|
79
85
|
* position, see {@link Notice}. Top-level because the subject is either
|
|
80
86
|
* kind of entity, so neither namespace owns it. Backend-only, hence gated
|
|
@@ -93,7 +99,7 @@ var GearboxSDK = class {
|
|
|
93
99
|
/** One sync in flight per chain: concurrent stale reads join it. */
|
|
94
100
|
#syncing = /* @__PURE__ */ new Map();
|
|
95
101
|
constructor(options) {
|
|
96
|
-
const { mode, networks, onchain, offchain, attach, logger, maxOffchainLagSeconds = 120, maxStateAgeSeconds = 30 } = options;
|
|
102
|
+
const { mode, networks, onchain, offchain, attach, rewards, logger, maxOffchainLagSeconds = 120, maxStateAgeSeconds = 30 } = options;
|
|
97
103
|
this.mode = mode;
|
|
98
104
|
this.networks = [...networks];
|
|
99
105
|
this.#attachOptions = attach;
|
|
@@ -139,6 +145,7 @@ var GearboxSDK = class {
|
|
|
139
145
|
this.positions = new PositionsNamespace(this.#onchain, this.#offchain, namespaceOptions);
|
|
140
146
|
this.liquidations = this.#onchain ? new LiquidationsNamespace(this.#onchain, namespaceOptions) : void 0;
|
|
141
147
|
this.preview = this.#onchain ? new PreviewNamespace(this.#onchain, namespaceOptions) : void 0;
|
|
148
|
+
this.rewards = this.#onchain ? new RewardsNamespace(this.#onchain, rewards, namespaceOptions) : void 0;
|
|
142
149
|
const backend = this.#offchain;
|
|
143
150
|
this.notices = backend ? (subject) => backend.notices.list(subject) : void 0;
|
|
144
151
|
}
|
package/dist/esm/sdk/index.js
CHANGED
|
@@ -25,6 +25,9 @@ import { PositionsNamespace } from "./positions/PositionsNamespace.js";
|
|
|
25
25
|
import "./positions/index.js";
|
|
26
26
|
import { PreviewNamespace } from "./preview/PreviewNamespace.js";
|
|
27
27
|
import "./preview/index.js";
|
|
28
|
+
import { MerklRequestFailedError, TurtleRequestFailedError } from "./rewards/errors.js";
|
|
29
|
+
import { RewardsNamespace } from "./rewards/RewardsNamespace.js";
|
|
30
|
+
import "./rewards/index.js";
|
|
28
31
|
import { DEFAULT_MAX_STATE_AGE, GearboxSDK } from "./GearboxSDK.js";
|
|
29
32
|
import "./types.js";
|
|
30
|
-
export { AbstractNamespace, AllSourcesFailedError, AnalyticsNamespace, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, ExecuteApi, GearboxSDK, LiquidationsNamespace, MissingSourceError, NoSourceServedError, OpportunitiesNamespace, PositionsNamespace, PrepareApi, PreviewNamespace, SourceChainMismatchError, SourceUnavailableError, assertSameChains, creditAccountNotEmpty, creditAccountNotFound, everyChainFailed, filterResponse, mergeChainList, mergeChainOne, noStrategyTargetCollateral, unexpectedFailure };
|
|
33
|
+
export { AbstractNamespace, AllSourcesFailedError, AnalyticsNamespace, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, ExecuteApi, GearboxSDK, LiquidationsNamespace, MerklRequestFailedError, MissingSourceError, NoSourceServedError, OpportunitiesNamespace, PositionsNamespace, PrepareApi, PreviewNamespace, RewardsNamespace, SourceChainMismatchError, SourceUnavailableError, TurtleRequestFailedError, assertSameChains, creditAccountNotEmpty, creditAccountNotFound, everyChainFailed, filterResponse, mergeChainList, mergeChainOne, noStrategyTargetCollateral, unexpectedFailure };
|
|
@@ -48,6 +48,16 @@ var LiquidationsNamespace = class {
|
|
|
48
48
|
const sdk = this.#onchain.chain(props.details.chainId);
|
|
49
49
|
return checkLiquidation(sdk, props, options);
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* {@inheritDoc ILiquidations.isEmergencyLiquidator}
|
|
53
|
+
**/
|
|
54
|
+
isEmergencyLiquidator(props) {
|
|
55
|
+
try {
|
|
56
|
+
return this.#onchain.chain(props.chainId).marketRegister.findByCreditManager(props.creditManager).isEmergencyLiquidator(props.liquidator);
|
|
57
|
+
} catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
51
61
|
};
|
|
52
62
|
//#endregion
|
|
53
63
|
export { LiquidationsNamespace };
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import { MultichainConstruct } from "
|
|
2
|
-
import "
|
|
1
|
+
import { MultichainConstruct } from "../../onchain/base/MultichainConstruct.js";
|
|
2
|
+
import "../../onchain/index.js";
|
|
3
3
|
import { fetchMerklUserRewards } from "./merkl-api.js";
|
|
4
4
|
import { toMerklRewards } from "./toMerklRewards.js";
|
|
5
5
|
import { toTurtleRewards } from "./toTurtleRewards.js";
|
|
6
6
|
import { fetchTurtleWalletRewards, readTurtleClaimed } from "./turtle-api.js";
|
|
7
7
|
import { getAddress } from "viem";
|
|
8
|
-
//#region src/rewards/
|
|
9
|
-
|
|
8
|
+
//#region src/sdk/rewards/RewardsNamespace.ts
|
|
9
|
+
/**
|
|
10
|
+
* {@inheritDoc IRewards}
|
|
11
|
+
**/
|
|
12
|
+
var RewardsNamespace = class extends MultichainConstruct {
|
|
10
13
|
#keys;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
#ensureFresh;
|
|
15
|
+
constructor(onchain, keys, options) {
|
|
16
|
+
super(onchain);
|
|
17
|
+
this.#keys = keys ?? {};
|
|
18
|
+
this.#ensureFresh = options.ensureFresh;
|
|
14
19
|
}
|
|
15
20
|
/**
|
|
16
|
-
*
|
|
17
|
-
* organisation's Turtle streams — across the chains the handle carries.
|
|
18
|
-
* A chain is `status: "error"` only when every source failed on it; a chain
|
|
19
|
-
* with nothing to claim is a `"success"` with no rewards.
|
|
21
|
+
* {@inheritDoc IRewards.list}
|
|
20
22
|
**/
|
|
21
23
|
async list(wallet, chainIds) {
|
|
24
|
+
await this.#ensureFresh?.(chainIds);
|
|
22
25
|
const { merklApiKey, turtleApiKey } = this.#keys;
|
|
23
26
|
const user = getAddress(wallet);
|
|
24
27
|
const turtle = turtleApiKey ? fetchTurtleWalletRewards(user, turtleApiKey) : void 0;
|
|
@@ -44,4 +47,4 @@ var RewardsService = class extends MultichainConstruct {
|
|
|
44
47
|
}
|
|
45
48
|
};
|
|
46
49
|
//#endregion
|
|
47
|
-
export {
|
|
50
|
+
export { RewardsNamespace };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AddressMap } from "
|
|
2
|
-
import { toBigInt } from "
|
|
3
|
-
import "
|
|
1
|
+
import { AddressMap } from "../../onchain/utils/AddressMap.js";
|
|
2
|
+
import { toBigInt } from "../../onchain/utils/formatter.js";
|
|
3
|
+
import "../../onchain/index.js";
|
|
4
4
|
import { formatUnits, isAddress } from "viem";
|
|
5
|
-
//#region src/rewards/helpers.ts
|
|
5
|
+
//#region src/sdk/rewards/helpers.ts
|
|
6
6
|
/**
|
|
7
7
|
* The pool a source names, and its share token. A v3.1 pool is its own
|
|
8
8
|
* ERC-4626 share token, so its address is the only token a campaign can name;
|