@gearbox-protocol/sdk 16.3.2 → 16.4.0-next.10
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/index.js +3 -2
- package/dist/cjs/dev/kycUtils.js +18 -35
- package/dist/cjs/dev/midasUtils.js +40 -11
- package/dist/cjs/dev/securitizeUtils.js +14 -10
- package/dist/cjs/dev/withdrawalUtils.js +3 -6
- package/dist/cjs/model/errors/index.js +2 -0
- package/dist/cjs/model/errors/operation-errors.js +18 -0
- package/dist/cjs/model/index.js +2 -0
- package/dist/cjs/onchain/accounts/CreditAccountsServiceV310.js +0 -1
- package/dist/cjs/onchain/accounts/intents/borrow.js +139 -0
- package/dist/cjs/onchain/accounts/intents/collateral-valuation.js +41 -0
- package/dist/cjs/onchain/accounts/intents/guards.js +15 -3
- package/dist/cjs/onchain/accounts/intents/index.js +107 -20
- package/dist/cjs/onchain/accounts/intents/leverage-band.js +2 -12
- package/dist/cjs/onchain/accounts/intents/maxBorrow.js +89 -0
- package/dist/cjs/onchain/accounts/intents/maxWithdrawCollateral.js +15 -41
- package/dist/cjs/onchain/accounts/intents/open-strategy.js +6 -45
- package/dist/cjs/onchain/accounts/intents/realize.js +54 -2
- package/dist/cjs/onchain/accounts/intents/tail.js +1 -1
- package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/cjs/onchain/accounts/intents/utils/common.js +19 -0
- package/dist/cjs/onchain/accounts/intents/utils/credit-account-slice.js +21 -0
- package/dist/cjs/onchain/accounts/intents/utils/index.js +2 -0
- package/dist/cjs/onchain/accounts/intents/utils/price-impact.js +3 -3
- package/dist/cjs/onchain/accounts/intents/withdraw-limits.js +97 -0
- package/dist/cjs/onchain/core/createAddressProvider.js +2 -5
- package/dist/cjs/onchain/index.js +6 -0
- package/dist/cjs/onchain/market/adapters/abi/conctructorAbi.js +1 -1
- package/dist/cjs/onchain/market/adapters/contracts/MidasGatewayAdapterContract.js +11 -3
- package/dist/cjs/onchain/positions/calcHealthFactor.js +3 -3
- package/dist/cjs/onchain/preview/index.js +2 -0
- package/dist/cjs/onchain/preview/preview/index.js +2 -0
- package/dist/cjs/onchain/preview/preview/midasGreenlistsAccount.js +17 -0
- package/dist/cjs/onchain/preview/preview/previewOpenStrategyPosition.js +13 -16
- package/dist/cjs/onchain/preview/preview/previewOperation.js +19 -11
- package/dist/cjs/onchain/preview/preview/replayMulticall.js +4 -3
- package/dist/cjs/onchain/validation/bundles/checkCollateralFunding.js +3 -3
- package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +4 -3
- package/dist/cjs/onchain/validation/bundles/checkMidasAccountGreenlist.js +44 -0
- package/dist/cjs/onchain/validation/bundles/checkRWAOpening.js +16 -7
- package/dist/cjs/onchain/validation/bundles/index.js +2 -0
- package/dist/cjs/onchain/validation/checkOperation.js +0 -1
- package/dist/cjs/onchain/validation/checks/checkReservePriceLimited.js +30 -0
- package/dist/cjs/onchain/validation/checks/index.js +2 -0
- package/dist/cjs/onchain/validation/index.js +4 -0
- package/dist/cjs/sdk/execute/ExecuteApi.js +65 -5
- package/dist/cjs/sdk/prepare/PrepareApi.js +89 -14
- package/dist/esm/dev/index.js +3 -3
- package/dist/esm/dev/kycUtils.js +17 -33
- package/dist/esm/dev/midasUtils.js +39 -12
- package/dist/esm/dev/securitizeUtils.js +15 -11
- package/dist/esm/dev/withdrawalUtils.js +3 -6
- package/dist/esm/model/errors/index.js +2 -2
- package/dist/esm/model/errors/operation-errors.js +17 -1
- package/dist/esm/model/index.js +2 -2
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +0 -1
- package/dist/esm/onchain/accounts/intents/borrow.js +137 -0
- package/dist/esm/onchain/accounts/intents/collateral-valuation.js +40 -0
- package/dist/esm/onchain/accounts/intents/guards.js +15 -3
- package/dist/esm/onchain/accounts/intents/index.js +107 -20
- package/dist/esm/onchain/accounts/intents/leverage-band.js +2 -12
- package/dist/esm/onchain/accounts/intents/maxBorrow.js +87 -0
- package/dist/esm/onchain/accounts/intents/maxWithdrawCollateral.js +15 -41
- package/dist/esm/onchain/accounts/intents/open-strategy.js +6 -45
- package/dist/esm/onchain/accounts/intents/realize.js +54 -2
- package/dist/esm/onchain/accounts/intents/tail.js +1 -1
- package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/esm/onchain/accounts/intents/utils/common.js +19 -1
- package/dist/esm/onchain/accounts/intents/utils/credit-account-slice.js +21 -1
- package/dist/esm/onchain/accounts/intents/utils/index.js +3 -3
- package/dist/esm/onchain/accounts/intents/utils/price-impact.js +3 -3
- package/dist/esm/onchain/accounts/intents/withdraw-limits.js +95 -0
- package/dist/esm/onchain/core/createAddressProvider.js +2 -5
- package/dist/esm/onchain/index.js +4 -1
- package/dist/esm/onchain/market/adapters/abi/conctructorAbi.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/MidasGatewayAdapterContract.js +11 -3
- package/dist/esm/onchain/positions/calcHealthFactor.js +3 -3
- package/dist/esm/onchain/preview/index.js +2 -1
- package/dist/esm/onchain/preview/preview/index.js +2 -1
- package/dist/esm/onchain/preview/preview/midasGreenlistsAccount.js +16 -0
- package/dist/esm/onchain/preview/preview/previewOpenStrategyPosition.js +14 -17
- package/dist/esm/onchain/preview/preview/previewOperation.js +19 -11
- package/dist/esm/onchain/preview/preview/replayMulticall.js +4 -3
- package/dist/esm/onchain/validation/bundles/checkCollateralFunding.js +3 -3
- package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +4 -3
- package/dist/esm/onchain/validation/bundles/checkMidasAccountGreenlist.js +43 -0
- package/dist/esm/onchain/validation/bundles/checkRWAOpening.js +16 -7
- package/dist/esm/onchain/validation/bundles/index.js +2 -1
- package/dist/esm/onchain/validation/checkOperation.js +0 -1
- package/dist/esm/onchain/validation/checks/checkReservePriceLimited.js +29 -0
- package/dist/esm/onchain/validation/checks/index.js +2 -1
- package/dist/esm/onchain/validation/index.js +3 -1
- package/dist/esm/sdk/execute/ExecuteApi.js +65 -5
- package/dist/esm/sdk/prepare/PrepareApi.js +89 -14
- package/dist/types/dev/index.d.ts +3 -3
- package/dist/types/dev/kycUtils.d.ts +1 -5
- package/dist/types/dev/midasUtils.d.ts +11 -1
- package/dist/types/model/errors/index.d.ts +2 -2
- package/dist/types/model/errors/operation-errors.d.ts +54 -1
- package/dist/types/model/index.d.ts +3 -3
- package/dist/types/model/previews.d.ts +25 -19
- package/dist/types/onchain/accounts/index.d.ts +4 -3
- package/dist/types/onchain/accounts/intents/borrow.d.ts +141 -0
- package/dist/types/onchain/accounts/intents/collateral-valuation.d.ts +42 -0
- package/dist/types/onchain/accounts/intents/guards.d.ts +18 -2
- package/dist/types/onchain/accounts/intents/index.d.ts +102 -14
- package/dist/types/onchain/accounts/intents/maxBorrow.d.ts +54 -0
- package/dist/types/onchain/accounts/intents/maxWithdrawCollateral.d.ts +3 -8
- package/dist/types/onchain/accounts/intents/open-strategy.d.ts +3 -17
- package/dist/types/onchain/accounts/intents/testing/sdk-mock.d.ts +2 -0
- package/dist/types/onchain/accounts/intents/tests/open-strategy.fixtures.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/types.d.ts +41 -5
- package/dist/types/onchain/accounts/intents/utils/common.d.ts +15 -1
- package/dist/types/onchain/accounts/intents/utils/credit-account-slice.d.ts +14 -1
- package/dist/types/onchain/accounts/intents/utils/index.d.ts +3 -3
- package/dist/types/onchain/accounts/intents/withdraw-limits.d.ts +80 -0
- package/dist/types/onchain/index.d.ts +8 -4
- package/dist/types/onchain/market/adapters/contracts/MidasGatewayAdapterContract.d.ts +8 -2
- package/dist/types/onchain/preview/index.d.ts +2 -1
- package/dist/types/onchain/preview/preview/index.d.ts +2 -1
- package/dist/types/onchain/preview/preview/midasGreenlistsAccount.d.ts +13 -0
- package/dist/types/onchain/preview/preview/previewOpenStrategyPosition.d.ts +5 -3
- package/dist/types/onchain/preview/preview/replayMulticall.d.ts +8 -7
- package/dist/types/onchain/validation/bundles/checkCreditOperation.d.ts +2 -2
- package/dist/types/onchain/validation/bundles/checkMidasAccountGreenlist.d.ts +22 -0
- package/dist/types/onchain/validation/bundles/checkRWAOpening.d.ts +6 -4
- package/dist/types/onchain/validation/bundles/index.d.ts +3 -2
- package/dist/types/onchain/validation/checks/checkDebtLimits.d.ts +2 -2
- package/dist/types/onchain/validation/checks/checkReservePriceLimited.d.ts +31 -0
- package/dist/types/onchain/validation/checks/index.d.ts +2 -1
- package/dist/types/onchain/validation/index.d.ts +4 -2
- package/dist/types/onchain/validation/raise.d.ts +2 -2
- package/dist/types/sdk/execute/index.d.ts +2 -2
- package/dist/types/sdk/execute/types.d.ts +48 -6
- package/dist/types/sdk/index.d.ts +5 -4
- package/dist/types/sdk/prepare/PrepareApi.d.ts +16 -4
- package/dist/types/sdk/prepare/index.d.ts +4 -3
- package/dist/types/sdk/prepare/types.d.ts +199 -65
- package/package.json +1 -1
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import { BigIntMath } from "../../utils/bigint-math.js";
|
|
2
|
-
import
|
|
2
|
+
import "../../constants/math.js";
|
|
3
3
|
import "../../utils/index.js";
|
|
4
4
|
import { eq } from "./utils/common.js";
|
|
5
|
+
import { collateralValuation } from "./collateral-valuation.js";
|
|
5
6
|
//#region src/onchain/accounts/intents/maxWithdrawCollateral.ts
|
|
6
7
|
/**
|
|
7
8
|
* Largest amount of one collateral the account can withdraw while its health
|
|
8
9
|
* factor stays at or above `targetHF`.
|
|
9
10
|
*
|
|
10
11
|
* This is the collateral check solved for one balance, and it counts what that
|
|
11
|
-
* check counts
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* Collateral is valued at the protocol safe price (`min` of the two feeds,
|
|
15
|
-
* 0 when there is no reserve), the way the facade values a call that hands
|
|
16
|
-
* funds over; the underlying is exempt and is valued at the main feed, as
|
|
17
|
-
* `CreditManagerV3._safeConvertToUSD` does. The debt is valued at the main
|
|
18
|
-
* feed, as the check does. Zero debt frees the whole balance.
|
|
12
|
+
* check counts — see {@link collateralValuation} for it, safe prices included.
|
|
13
|
+
* The debt is valued at the main feed, as the check does. Zero debt frees the
|
|
14
|
+
* whole balance.
|
|
19
15
|
*
|
|
20
16
|
* Rounding always favours the account, so the answer clears the check rather
|
|
21
17
|
* than landing a wei short of it.
|
|
@@ -26,49 +22,27 @@ import { eq } from "./utils/common.js";
|
|
|
26
22
|
**/
|
|
27
23
|
function maxWithdrawCollateral(props) {
|
|
28
24
|
const { creditAccount, sdk, token, targetHF } = props;
|
|
29
|
-
const { market, creditManager } = sdk.marketRegister.findCreditManager(creditAccount.creditManager);
|
|
30
|
-
const { priceOracle } = market;
|
|
31
|
-
const { pqk } = market.pool;
|
|
32
|
-
const underlying = market.pool.underlying;
|
|
33
25
|
const target = creditAccount.tokens.find((t) => eq(t.token, token));
|
|
34
26
|
if (!target || target.balance <= 10n) return 0n;
|
|
35
27
|
if (creditAccount.totalDebt === 0n) return target.balance;
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
/** What a holding backs, in the check's units: USD × PERCENTAGE_FACTOR. */
|
|
39
|
-
const weigh = (t) => {
|
|
40
|
-
const lt = BigInt(creditManager.liquidationThresholds.get(t.token) ?? 0);
|
|
41
|
-
const weighted = (eq(t.token, underlying) ? usd(priceOracle, t.token, t.balance) ?? 0n : priceOracle.safeConvertMinUSD(t.token, t.balance).value) * lt;
|
|
42
|
-
if (t.quota === 0n) return weighted;
|
|
43
|
-
return BigIntMath.min(quotaUsd(t) * PERCENTAGE_FACTOR, weighted);
|
|
44
|
-
};
|
|
45
|
-
/** A quota is underlying-denominated, and a closed market backs nothing. */
|
|
46
|
-
const quotaUsd = (t) => pqk.hasActiveQuota(t.token) ? usd(priceOracle, underlying, t.quota) ?? 0n : 0n;
|
|
47
|
-
let otherMoney = 0n;
|
|
28
|
+
const valuation = collateralValuation(creditAccount, sdk);
|
|
29
|
+
let otherValue = 0n;
|
|
48
30
|
for (const t of creditAccount.tokens) {
|
|
49
|
-
if (eq(t.token, token) || !counts(t)) continue;
|
|
50
|
-
|
|
31
|
+
if (eq(t.token, token) || !valuation.counts(t)) continue;
|
|
32
|
+
otherValue += valuation.weigh(t);
|
|
51
33
|
}
|
|
52
|
-
const borrowed =
|
|
34
|
+
const borrowed = valuation.mainUsd(valuation.underlying, creditAccount.totalDebt);
|
|
53
35
|
if (borrowed === void 0 || borrowed <= 0n) return 0n;
|
|
54
36
|
const required = borrowed * targetHF;
|
|
55
|
-
if (required <=
|
|
56
|
-
const shortfall = required -
|
|
57
|
-
if (target.quota > 0n &&
|
|
58
|
-
const targetLt =
|
|
59
|
-
const targetUsd =
|
|
37
|
+
if (required <= otherValue) return target.balance;
|
|
38
|
+
const shortfall = required - otherValue;
|
|
39
|
+
if (target.quota > 0n && valuation.quotaValue(target) < shortfall) return 0n;
|
|
40
|
+
const targetLt = valuation.lt(target.token);
|
|
41
|
+
const targetUsd = valuation.checkedUsd(target);
|
|
60
42
|
if (targetLt === 0n || targetUsd === 0n) return 0n;
|
|
61
43
|
const keptUsd = BigIntMath.ceilDiv(shortfall, targetLt);
|
|
62
44
|
const kept = BigIntMath.ceilDiv(target.balance * keptUsd, targetUsd);
|
|
63
45
|
return kept >= target.balance ? 0n : target.balance - kept;
|
|
64
46
|
}
|
|
65
|
-
/** USD value at the main feed, or `undefined` when the token has no price. */
|
|
66
|
-
function usd(oracle, token, amount) {
|
|
67
|
-
try {
|
|
68
|
-
return oracle.convertToUSD(token, amount);
|
|
69
|
-
} catch {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
47
|
//#endregion
|
|
74
48
|
export { maxWithdrawCollateral };
|
|
@@ -3,17 +3,13 @@ import "../../../model/index.js";
|
|
|
3
3
|
import { IntentPreviewError } from "../../validation/raise.js";
|
|
4
4
|
import { assertCanBorrow, assertCollateralised, assertGrowthAllowed, assertMarketOperable, assertQuotaAvailable } from "./guards.js";
|
|
5
5
|
import { assertDebtLimits, assertLeverageAtLeastOne, debtForLeverage } from "./math.js";
|
|
6
|
+
import { unopenedAccountSlice } from "./utils/credit-account-slice.js";
|
|
6
7
|
import { collectPriceImpact } from "./utils/price-impact.js";
|
|
7
8
|
import { getQuotasForUpdate } from "./utils/quotas-for-update.js";
|
|
8
9
|
import { createRouterPaths } from "./utils/router-path.js";
|
|
9
10
|
import "./utils/index.js";
|
|
10
11
|
//#region src/onchain/accounts/intents/open-strategy.ts
|
|
11
12
|
/**
|
|
12
|
-
* Stand-in account address, used when the opening creates its own account:
|
|
13
|
-
* nothing exists on chain until the tx lands.
|
|
14
|
-
*/
|
|
15
|
-
const NO_ACCOUNT = "0x0000000000000000000000000000000000000000";
|
|
16
|
-
/**
|
|
17
13
|
* Builds the state opening a leveraged position out of wallet collateral would
|
|
18
14
|
* reach.
|
|
19
15
|
*
|
|
@@ -26,7 +22,6 @@ const NO_ACCOUNT = "0x0000000000000000000000000000000000000000";
|
|
|
26
22
|
* `sdk.accounts.openCA`.
|
|
27
23
|
*/
|
|
28
24
|
async function buildOpenStrategyState(props) {
|
|
29
|
-
if (props.empty) return emptyOpenState(props);
|
|
30
25
|
const { sdk, creditManager, collateral, targetToken, leverage, slippage = 0, quotaReserve, leftoverBalances = [], creditAccount: existing } = props;
|
|
31
26
|
assertLeverageAtLeastOne(leverage);
|
|
32
27
|
const suite = sdk.marketRegister.findCreditManager(creditManager);
|
|
@@ -37,16 +32,11 @@ async function buildOpenStrategyState(props) {
|
|
|
37
32
|
const margin = collateral.reduce((acc, a) => acc + convert(a.token, underlying, a.balance), 0n);
|
|
38
33
|
if (margin <= 0n) throw new IntentPreviewError(insufficientBalance(), "openStrategy: collateral is worth nothing in underlying");
|
|
39
34
|
const debt = debtForLeverage(margin, leverage);
|
|
40
|
-
const account = existing ?? {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
enabledTokensMask: 0n,
|
|
46
|
-
totalDebtUSD: 0n,
|
|
47
|
-
totalDebt: 0n,
|
|
48
|
-
tokens: []
|
|
49
|
-
};
|
|
35
|
+
const account = existing ?? unopenedAccountSlice({
|
|
36
|
+
creditManager,
|
|
37
|
+
creditFacade: suite.creditFacade.address,
|
|
38
|
+
underlying
|
|
39
|
+
});
|
|
50
40
|
assertDebtLimits(sdk, debt, suite.creditFacade, underlying);
|
|
51
41
|
assertCanBorrow(sdk, suite, debt);
|
|
52
42
|
const paths = createRouterPaths({
|
|
@@ -110,35 +100,6 @@ async function buildOpenStrategyState(props) {
|
|
|
110
100
|
creditAccount: existing?.creditAccount
|
|
111
101
|
};
|
|
112
102
|
}
|
|
113
|
-
/**
|
|
114
|
-
* The opening that holds an account and nothing else.
|
|
115
|
-
*
|
|
116
|
-
* Taken before the walk rather than threaded through it: the router has no
|
|
117
|
-
* guard for an empty basket and would still make its `eth_call`, and every
|
|
118
|
-
* assertion below reads amounts that are not there.
|
|
119
|
-
*/
|
|
120
|
-
async function emptyOpenState(props) {
|
|
121
|
-
const { sdk, creditManager } = props;
|
|
122
|
-
assertMarketOperable(sdk.marketRegister.findCreditManager(creditManager));
|
|
123
|
-
const snapshot = {
|
|
124
|
-
creditManager,
|
|
125
|
-
assets: [],
|
|
126
|
-
quotas: [],
|
|
127
|
-
totalDebt: 0n,
|
|
128
|
-
totalValue: 0n
|
|
129
|
-
};
|
|
130
|
-
const { assets: _assets, quotas: _quotas, ...projection } = sdk.positions.projection(snapshot, { availableLiquidityChange: 0n });
|
|
131
|
-
return {
|
|
132
|
-
...projection,
|
|
133
|
-
currentPrice: sdk.positions.currentPrice(snapshot),
|
|
134
|
-
priceImpact: void 0,
|
|
135
|
-
averageAssets: [],
|
|
136
|
-
minAssets: [],
|
|
137
|
-
averageQuota: [],
|
|
138
|
-
minQuota: [],
|
|
139
|
-
calls: []
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
103
|
/** Collateral plus the borrowed underlying, folded into one balance per token. */
|
|
143
104
|
function mergeExpectedBalances(collateral, underlying, debt) {
|
|
144
105
|
const merged = /* @__PURE__ */ new Map();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PERCENTAGE_FACTOR_1KK } from "../../constants/math.js";
|
|
1
2
|
import { insufficientBalance } from "../../../model/errors/operation-errors.js";
|
|
2
3
|
import { multipleDelayedWithdrawals, noDelayedRoute, withdrawalInProgress } from "../../../model/errors/prepare-errors.js";
|
|
3
4
|
import "../../../model/index.js";
|
|
@@ -11,6 +12,7 @@ import { collectPriceImpact } from "./utils/price-impact.js";
|
|
|
11
12
|
import { clearedQuotas, getQuotasForUpdate, quotasAfterUpdate } from "./utils/quotas-for-update.js";
|
|
12
13
|
import { createRouterPaths } from "./utils/router-path.js";
|
|
13
14
|
import { buildAddCollateralOperation, buildClaimDelayedWithdrawalOperation, buildCloseSwapOperation, buildDecreaseDebtOperation, buildIncreaseDebtOperation, buildQuotaUpdateOperation, buildStartDelayedWithdrawalOperation, buildSwapOperation, buildUnwrapRwaCollateralOperation, buildWithdrawCollateralOperation, buildWrapRwaCollateralOperation, instantOutput } from "./operations.js";
|
|
15
|
+
import { withdrawLimits } from "./withdraw-limits.js";
|
|
14
16
|
//#region src/onchain/accounts/intents/realize.ts
|
|
15
17
|
/**
|
|
16
18
|
* Turns a plan into operations: the one place that talks to the router, knows
|
|
@@ -71,6 +73,26 @@ async function realize(steps, props) {
|
|
|
71
73
|
let raised = 0n;
|
|
72
74
|
/** The request, before the walk's end state can be attached to it. */
|
|
73
75
|
let delayed;
|
|
76
|
+
/** Oracle value in the underlying of what routed legs and requests spend and return. */
|
|
77
|
+
const traded = {
|
|
78
|
+
spentUnd: 0n,
|
|
79
|
+
returnedUnd: 0n,
|
|
80
|
+
priced: true
|
|
81
|
+
};
|
|
82
|
+
const trade = (spent, returned) => {
|
|
83
|
+
const underlyingValue = (legs) => {
|
|
84
|
+
let sum = 0n;
|
|
85
|
+
for (const { token, amount } of legs) {
|
|
86
|
+
if (amount === 0n) continue;
|
|
87
|
+
const value = price(token, underlying, amount);
|
|
88
|
+
if (value <= 0n) traded.priced = false;
|
|
89
|
+
sum += value;
|
|
90
|
+
}
|
|
91
|
+
return sum;
|
|
92
|
+
};
|
|
93
|
+
traded.spentUnd += underlyingValue(spent);
|
|
94
|
+
traded.returnedUnd += underlyingValue(returned);
|
|
95
|
+
};
|
|
74
96
|
/**
|
|
75
97
|
* Set by a `clearQuotas` step, which settles the quotas mid-walk instead of
|
|
76
98
|
* at the end — and settles them at none, whatever the balances turn out to be.
|
|
@@ -172,6 +194,13 @@ async function realize(steps, props) {
|
|
|
172
194
|
...swap,
|
|
173
195
|
amountOut: leg.amount
|
|
174
196
|
});
|
|
197
|
+
trade([{
|
|
198
|
+
token: step.from,
|
|
199
|
+
amount
|
|
200
|
+
}], [{
|
|
201
|
+
token: step.to,
|
|
202
|
+
amount: leg.amount
|
|
203
|
+
}]);
|
|
175
204
|
raised = leg.minAmount;
|
|
176
205
|
break;
|
|
177
206
|
}
|
|
@@ -197,6 +226,13 @@ async function realize(steps, props) {
|
|
|
197
226
|
})),
|
|
198
227
|
amountOut: leg.amount
|
|
199
228
|
});
|
|
229
|
+
trade(balances.map((a) => ({
|
|
230
|
+
token: a.token,
|
|
231
|
+
amount: a.balance
|
|
232
|
+
})), [{
|
|
233
|
+
token: underlying,
|
|
234
|
+
amount: leg.amount
|
|
235
|
+
}]);
|
|
200
236
|
}
|
|
201
237
|
}
|
|
202
238
|
raised = ledger.balanceOf(underlying);
|
|
@@ -241,6 +277,13 @@ async function realize(steps, props) {
|
|
|
241
277
|
amount: toTargetDecimals(queued.amount, queued.token, asset.underlying, sdk)
|
|
242
278
|
} : void 0
|
|
243
279
|
};
|
|
280
|
+
trade([{
|
|
281
|
+
token: preview.token,
|
|
282
|
+
amount: preview.amountIn
|
|
283
|
+
}], [...preview.outputs.filter((o) => !o.isDelayed).map((o) => ({
|
|
284
|
+
token: o.token,
|
|
285
|
+
amount: o.amount
|
|
286
|
+
})), ...delayed.claim ? [delayed.claim] : []]);
|
|
244
287
|
raised = instantOutput(preview.outputs)?.amount ?? 0n;
|
|
245
288
|
break;
|
|
246
289
|
}
|
|
@@ -319,19 +362,28 @@ async function realize(steps, props) {
|
|
|
319
362
|
totalValue: projected.totalValue
|
|
320
363
|
};
|
|
321
364
|
const projection = sdk.positions.projection(snapshot, { availableLiquidityChange: creditAccount.totalDebt - debt });
|
|
322
|
-
|
|
365
|
+
const settled = {
|
|
323
366
|
...snapshot,
|
|
324
367
|
assets,
|
|
325
368
|
totalValue: floor.totalValue
|
|
326
|
-
}
|
|
369
|
+
};
|
|
370
|
+
assertCollateralised(sdk.positions.healthFactor(settled, { safePrices: withdrawsCollateral }), withdrawsCollateral, () => ({
|
|
371
|
+
atMainPrices: sdk.positions.healthFactor(settled, { safePrices: false }),
|
|
372
|
+
withdrawable: toTokenAmount(sdk, underlying, withdrawLimits({
|
|
373
|
+
creditAccount,
|
|
374
|
+
sdk
|
|
375
|
+
}).safePartial)
|
|
376
|
+
}));
|
|
327
377
|
const priceImpact = await collectPriceImpact(probes, {
|
|
328
378
|
totalValue: projected.totalValue,
|
|
329
379
|
netValue: projected.totalValue - debt,
|
|
330
380
|
toUnderlying: (from, amount) => price(from, underlying, amount)
|
|
331
381
|
});
|
|
382
|
+
const executionCost = traded.priced && traded.spentUnd > 0n ? PERCENTAGE_FACTOR_1KK * (traded.returnedUnd - traded.spentUnd) / traded.spentUnd : void 0;
|
|
332
383
|
const state = {
|
|
333
384
|
...projection,
|
|
334
385
|
priceImpact,
|
|
386
|
+
executionCost,
|
|
335
387
|
currentPrice: sdk.positions.currentPrice(snapshot)
|
|
336
388
|
};
|
|
337
389
|
return {
|
|
@@ -7,8 +7,8 @@ import { toTargetDecimals } from "./utils/common.js";
|
|
|
7
7
|
import { createOraclePaths } from "./utils/router-path.js";
|
|
8
8
|
import { planFinishClaimOnly, planFinishCloseAccount, planFinishDecreaseLeverage, planFinishWithdraw } from "./plan.js";
|
|
9
9
|
import { instantOutput } from "./operations.js";
|
|
10
|
-
import { realize } from "./realize.js";
|
|
11
10
|
import { accountView } from "./view.js";
|
|
11
|
+
import { realize } from "./realize.js";
|
|
12
12
|
//#region src/onchain/accounts/intents/tail.ts
|
|
13
13
|
/**
|
|
14
14
|
* The second half of a delayed intent: the claim, then whatever the intent
|
|
@@ -203,6 +203,7 @@ function buildMockSdk(args) {
|
|
|
203
203
|
liquidationThresholds,
|
|
204
204
|
collateralTokens,
|
|
205
205
|
feeInterest: args.feeInterest ?? 0,
|
|
206
|
+
maxEnabledTokens: args.maxEnabledTokens ?? 4,
|
|
206
207
|
maxLeverage: (collateral, targetHF) => calcMaxLeverage(liquidationThresholds.get(collateral) ?? 0, targetHF)
|
|
207
208
|
},
|
|
208
209
|
creditFacade: {
|
|
@@ -2,6 +2,24 @@ import { AddressMap } from "../../../utils/AddressMap.js";
|
|
|
2
2
|
//#region src/onchain/accounts/intents/utils/common.ts
|
|
3
3
|
/** Case-insensitive address equality. */
|
|
4
4
|
const eq = (a, b) => a.toLowerCase() === b.toLowerCase();
|
|
5
|
+
/**
|
|
6
|
+
* The suite and market behind a credit manager, or nothing where the register
|
|
7
|
+
* has no entry for it.
|
|
8
|
+
*
|
|
9
|
+
* For the reads a form calls on every keystroke, including before the SDK has
|
|
10
|
+
* finished attaching: a question the register cannot answer yet is not an
|
|
11
|
+
* error. Everything that prepares a transaction wants the throw instead.
|
|
12
|
+
*/
|
|
13
|
+
function resolveCreditManager(sdk, creditManager) {
|
|
14
|
+
try {
|
|
15
|
+
return {
|
|
16
|
+
suite: sdk.marketRegister.findCreditManager(creditManager),
|
|
17
|
+
market: sdk.marketRegister.findByCreditManager(creditManager)
|
|
18
|
+
};
|
|
19
|
+
} catch {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
5
23
|
function toTargetDecimals(fromAmount, fromToken, toToken, sdk) {
|
|
6
24
|
const fromDecimals = sdk.tokensMeta.get(fromToken)?.decimals ?? 18;
|
|
7
25
|
const toDecimals = sdk.tokensMeta.get(toToken)?.decimals ?? 18;
|
|
@@ -37,4 +55,4 @@ function toRouterCaSlice(creditAccount, expectedBalances = []) {
|
|
|
37
55
|
};
|
|
38
56
|
}
|
|
39
57
|
//#endregion
|
|
40
|
-
export { eq, toRouterCaSlice, toTargetDecimals };
|
|
58
|
+
export { eq, resolveCreditManager, toRouterCaSlice, toTargetDecimals };
|
|
@@ -26,6 +26,26 @@ function toCreditAccountSlice(ca) {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
+
* The slice a flow that has no account yet quotes against.
|
|
30
|
+
*
|
|
31
|
+
* Nothing of it exists on chain until the transaction lands, and nothing has
|
|
32
|
+
* to: the pathfinder is asked about the credit manager, and every balance the
|
|
33
|
+
* flow reasons about is one the transaction itself puts there. The zero
|
|
34
|
+
* address stands in for the account so the shape is complete.
|
|
35
|
+
*/
|
|
36
|
+
function unopenedAccountSlice(args) {
|
|
37
|
+
return {
|
|
38
|
+
creditAccount: "0x0000000000000000000000000000000000000000",
|
|
39
|
+
creditManager: args.creditManager.toLowerCase(),
|
|
40
|
+
creditFacade: args.creditFacade.toLowerCase(),
|
|
41
|
+
underlying: args.underlying.toLowerCase(),
|
|
42
|
+
enabledTokensMask: 0n,
|
|
43
|
+
totalDebtUSD: 0n,
|
|
44
|
+
totalDebt: 0n,
|
|
45
|
+
tokens: []
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
29
49
|
* Reads an account by address and narrows it to {@link CreditAccountSlice}.
|
|
30
50
|
*
|
|
31
51
|
* The shared read model's `StrategyPosition` carries neither `tokens` nor
|
|
@@ -40,4 +60,4 @@ async function fetchCreditAccountSlice(sdk, creditAccount) {
|
|
|
40
60
|
return toCreditAccountSlice(data);
|
|
41
61
|
}
|
|
42
62
|
//#endregion
|
|
43
|
-
export { fetchCreditAccountSlice, toCreditAccountSlice };
|
|
63
|
+
export { fetchCreditAccountSlice, toCreditAccountSlice, unopenedAccountSlice };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { eq, toRouterCaSlice, toTargetDecimals } from "./common.js";
|
|
1
|
+
import { eq, resolveCreditManager, toRouterCaSlice, toTargetDecimals } from "./common.js";
|
|
2
2
|
import { isPhantomToken, isRedemptionPhantomToken, pickFattestNonPhantomToken, rankAccountTokens } from "./pick-token.js";
|
|
3
3
|
import { adjustStateToSnapshot } from "./adjust-state-to-snapshot.js";
|
|
4
4
|
import { assembleOperationCalls } from "./assemble-operation-calls.js";
|
|
5
5
|
import { calcBorrowedAmountPlusInterestAndFees } from "./borrowed-amount-plus-interest-and-fees.js";
|
|
6
|
-
import { fetchCreditAccountSlice, toCreditAccountSlice } from "./credit-account-slice.js";
|
|
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
9
|
import { clearedQuotas, getQuotasForUpdate, quotasAfterUpdate } 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, startProbe, toCreditAccountSlice, toRouterCaSlice, toTargetDecimals };
|
|
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 };
|
|
@@ -18,12 +18,12 @@ function probeBasket(balances, oracle) {
|
|
|
18
18
|
if (usd > 0n) basketWad += usd * WAD / PRICE_DECIMALS;
|
|
19
19
|
}
|
|
20
20
|
if (basketWad <= 0n) return;
|
|
21
|
-
const probeWad = PROBE_UNIT_USD_WAD;
|
|
22
21
|
const scaled = balances.map((asset) => ({
|
|
23
22
|
token: asset.token,
|
|
24
|
-
balance: asset.balance *
|
|
23
|
+
balance: asset.balance * PROBE_UNIT_USD_WAD / basketWad
|
|
25
24
|
}));
|
|
26
|
-
|
|
25
|
+
const probeWad = scaled.reduce((sum, a) => sum + oracle.safeConvertToUSD(a.token, a.balance).value * WAD / PRICE_DECIMALS, 0n);
|
|
26
|
+
if (probeWad <= 0n) return;
|
|
27
27
|
return {
|
|
28
28
|
balances: scaled,
|
|
29
29
|
basketWad,
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { BigIntMath } from "../../utils/bigint-math.js";
|
|
2
|
+
import "../../utils/index.js";
|
|
3
|
+
import { MIN_HEALTH_FACTOR_FACADE } from "../../validation/helpers/health-factor-limits.js";
|
|
4
|
+
import "../../validation/index.js";
|
|
5
|
+
import { eq } from "./utils/common.js";
|
|
6
|
+
import { maxProportionalWithdrawal } from "./math.js";
|
|
7
|
+
import { collateralValuation } from "./collateral-valuation.js";
|
|
8
|
+
import { accountView } from "./view.js";
|
|
9
|
+
//#region src/onchain/accounts/intents/withdraw-limits.ts
|
|
10
|
+
/**
|
|
11
|
+
* Every limit a `WITHDRAW` answers to, in underlying units.
|
|
12
|
+
*
|
|
13
|
+
* The one place they are assembled, so the figure a form is offered and the
|
|
14
|
+
* figure the collateral guard names when it turns a withdrawal down cannot
|
|
15
|
+
* drift apart: `CreditAccountOperationsService` reports this, and the guard
|
|
16
|
+
* quotes it back.
|
|
17
|
+
*
|
|
18
|
+
* @param props - Account slice, the SDK holding its market, and optionally the
|
|
19
|
+
* collateral the withdrawal would be funded from
|
|
20
|
+
* @returns The three limits, see {@link WithdrawCeilings}
|
|
21
|
+
**/
|
|
22
|
+
function withdrawLimits(props) {
|
|
23
|
+
const { creditAccount, sdk } = props;
|
|
24
|
+
const view = accountView(creditAccount, sdk);
|
|
25
|
+
const partial = maxProportionalWithdrawal(view, view.debtLimits);
|
|
26
|
+
const safe = maxSafeWithdrawal({
|
|
27
|
+
...props,
|
|
28
|
+
targetHF: BigInt(MIN_HEALTH_FACTOR_FACADE)
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
partial,
|
|
32
|
+
safePartial: BigIntMath.min(partial, safe),
|
|
33
|
+
exit: view.collateral > 0n ? view.collateral : 0n
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Largest proportional withdrawal the safe-price collateral check still clears,
|
|
38
|
+
* in underlying units.
|
|
39
|
+
*
|
|
40
|
+
* A withdrawal hands funds over, so the facade weighs the account it leaves
|
|
41
|
+
* behind at safe prices rather than main ones — see {@link collateralValuation}.
|
|
42
|
+
* That is a second limit on top of the facade's `debtLimits`, and the two are
|
|
43
|
+
* independent: a caller wanting the amount a form may actually offer takes the
|
|
44
|
+
* lesser of this and `maxProportionalWithdrawal`.
|
|
45
|
+
*
|
|
46
|
+
* The arithmetic is the check solved for the amount. Taking `W` out at fixed
|
|
47
|
+
* leverage repays `dD = D·W/C`, so `W·TVL/C` of value is sold out of the source
|
|
48
|
+
* token; each dollar of that sale costs the check the source's threshold times
|
|
49
|
+
* its safe-to-main price ratio, while the repayment relieves `targetHF` per
|
|
50
|
+
* dollar of debt. Both terms are linear in `W`, which is why one division
|
|
51
|
+
* answers instead of a search — and why the answer is exact rather than a
|
|
52
|
+
* bound, as long as the plan really does fund itself from `sourceToken`.
|
|
53
|
+
*
|
|
54
|
+
* Two consequences worth stating, because they surprise:
|
|
55
|
+
*
|
|
56
|
+
* - An account whose collateral is entirely a token the reserve feed marks
|
|
57
|
+
* down cannot withdraw at all once it is under the threshold. A proportional
|
|
58
|
+
* withdrawal scales collateral and debt together, so it leaves the safe-price
|
|
59
|
+
* factor exactly where it found it — no amount climbs back over.
|
|
60
|
+
* - Leaving entirely is never refused for this reason: the exit settles the
|
|
61
|
+
* debt instead of shrinking it, and a check with no debt to divide by has
|
|
62
|
+
* nothing to refuse.
|
|
63
|
+
*
|
|
64
|
+
* @returns Amount in underlying units. The account's net value when safe prices
|
|
65
|
+
* do not limit the withdrawal at all, so the caller's `min` is a no-op; `0n`
|
|
66
|
+
* when the account already sits below `targetHF` at safe prices, and only the
|
|
67
|
+
* exit is left
|
|
68
|
+
**/
|
|
69
|
+
function maxSafeWithdrawal(props) {
|
|
70
|
+
const { creditAccount, sdk, targetHF } = props;
|
|
71
|
+
const view = accountView(creditAccount, sdk);
|
|
72
|
+
if (view.collateral <= 0n) return 0n;
|
|
73
|
+
if (view.debt === 0n) return view.collateral;
|
|
74
|
+
const valuation = collateralValuation(creditAccount, sdk);
|
|
75
|
+
const source = props.sourceToken ?? view.fattest();
|
|
76
|
+
const holding = source === void 0 ? void 0 : creditAccount.tokens.find((t) => eq(t.token, source));
|
|
77
|
+
if (!holding) return view.collateral;
|
|
78
|
+
let total = 0n;
|
|
79
|
+
for (const t of creditAccount.tokens) if (valuation.counts(t)) total += valuation.weigh(t);
|
|
80
|
+
const debtUsd = valuation.mainUsd(valuation.underlying, view.debt);
|
|
81
|
+
if (debtUsd === void 0 || debtUsd <= 0n) return view.collateral;
|
|
82
|
+
const slack = total - debtUsd * targetHF;
|
|
83
|
+
if (slack < 0n) return 0n;
|
|
84
|
+
const sourceMainUsd = valuation.mainUsd(holding.token, holding.balance);
|
|
85
|
+
if (sourceMainUsd === void 0 || sourceMainUsd <= 0n) return view.collateral;
|
|
86
|
+
const sourceRate = valuation.lt(holding.token) * valuation.checkedUsd(holding);
|
|
87
|
+
const tvlUsd = valuation.mainUsd(valuation.underlying, view.collateral + view.debt);
|
|
88
|
+
if (tvlUsd === void 0) return view.collateral;
|
|
89
|
+
const drain = sourceRate * tvlUsd - targetHF * debtUsd * sourceMainUsd;
|
|
90
|
+
if (drain <= 0n) return view.collateral;
|
|
91
|
+
const limit = view.collateral * slack * sourceMainUsd / drain;
|
|
92
|
+
return limit < view.collateral ? limit : view.collateral;
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
export { maxSafeWithdrawal, withdrawLimits };
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
2
|
-
import
|
|
2
|
+
import "../constants/address-provider.js";
|
|
3
3
|
import { isV310 } from "../constants/versions.js";
|
|
4
4
|
import "../constants/index.js";
|
|
5
5
|
import { hexEq } from "../utils/hex.js";
|
|
6
6
|
import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
|
|
7
7
|
//#region src/onchain/core/createAddressProvider.ts
|
|
8
|
-
const OVERRIDE_ADDRESSES = {
|
|
9
|
-
[AP_PRICE_FEED_COMPRESSOR]: { 311: "0x1fA2637B9fab0CD14290A7EE908DDc9688a15120" },
|
|
10
|
-
[AP_MARKET_COMPRESSOR]: { 311: "0x0C27F242f6e9F2A9AD3261bE6e439De3B948bcA2" }
|
|
11
|
-
} };
|
|
8
|
+
const OVERRIDE_ADDRESSES = {};
|
|
12
9
|
async function createAddressProvider(sdk, address) {
|
|
13
10
|
let v;
|
|
14
11
|
if (hexEq(address, "0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38")) v = 310n;
|
|
@@ -212,6 +212,7 @@ import { checkPoolPaused } from "./validation/checks/checkPoolPaused.js";
|
|
|
212
212
|
import { checkPoolSunset } from "./validation/checks/checkPoolSunset.js";
|
|
213
213
|
import { checkQuotaCount } from "./validation/checks/checkQuotaCount.js";
|
|
214
214
|
import { checkQuotaLimit } from "./validation/checks/checkQuotaLimit.js";
|
|
215
|
+
import { checkReservePriceLimited } from "./validation/checks/checkReservePriceLimited.js";
|
|
215
216
|
import { checkAccountQuotas } from "./validation/bundles/checkAccountQuotas.js";
|
|
216
217
|
import { checkWalletAllowance } from "./validation/bundles/checkWalletAllowance.js";
|
|
217
218
|
import { checkWalletBalance } from "./validation/bundles/checkWalletBalance.js";
|
|
@@ -221,6 +222,7 @@ import { checkIncreaseDebt } from "./validation/bundles/checkIncreaseDebt.js";
|
|
|
221
222
|
import { checkIncreaseQuota } from "./validation/bundles/checkIncreaseQuota.js";
|
|
222
223
|
import { checkMarket } from "./validation/bundles/checkMarket.js";
|
|
223
224
|
import { checkObtained } from "./validation/bundles/checkObtained.js";
|
|
225
|
+
import { checkMidasAccountGreenlist } from "./validation/bundles/checkMidasAccountGreenlist.js";
|
|
224
226
|
import { checkRWAOpenRequirements } from "./validation/bundles/checkRWAOpenRequirements.js";
|
|
225
227
|
import { checkRWAOpening } from "./validation/bundles/checkRWAOpening.js";
|
|
226
228
|
import { checkCreditOperation } from "./validation/bundles/checkCreditOperation.js";
|
|
@@ -291,6 +293,7 @@ import { classifyCloseOrRepay, isCloseOrRepay } from "./preview/preview/detectCl
|
|
|
291
293
|
import { detectDelayedClaim, resolveDelayedClaimIntent } from "./preview/preview/detectDelayedClaim.js";
|
|
292
294
|
import { detectDelayedOperation } from "./preview/preview/detectDelayedOperation.js";
|
|
293
295
|
import { estimateClaimableAt } from "./preview/preview/estimateClaimableAt.js";
|
|
296
|
+
import { midasGreenlistsAccount } from "./preview/preview/midasGreenlistsAccount.js";
|
|
294
297
|
import { previewAdjustStrategyPosition } from "./preview/preview/previewAdjustStrategyPosition.js";
|
|
295
298
|
import { previewExitOrRepayStrategyPosition } from "./preview/preview/previewExitOrRepayStrategyPosition.js";
|
|
296
299
|
import { makeReplayState, replayInnerOperations } from "./preview/preview/replayInnerOperations.js";
|
|
@@ -298,4 +301,4 @@ import { replayMulticall } from "./preview/preview/replayMulticall.js";
|
|
|
298
301
|
import { previewOperation } from "./preview/preview/previewOperation.js";
|
|
299
302
|
import "./preview/index.js";
|
|
300
303
|
import "./types/index.js";
|
|
301
|
-
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, CreditAccountState, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, 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, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, 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, 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, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkRWAOpenRequirements, checkRWAOpening, 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, fetchRedstonePayloads, 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, 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, usdToNumber, watchBlocksAsync };
|
|
304
|
+
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, CreditAccountState, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, 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, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, 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, 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, fetchRedstonePayloads, 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, usdToNumber, watchBlocksAsync };
|
|
@@ -19,7 +19,7 @@ const adapterConstructorAbi = {
|
|
|
19
19
|
["INFINIFI_GATEWAY"]: { 310: BASIC_ADAPTER_ABI },
|
|
20
20
|
["LIDO_V1"]: { 310: BASIC_ADAPTER_ABI },
|
|
21
21
|
["LIDO_WSTETH_V1"]: { 310: BASIC_ADAPTER_ABI },
|
|
22
|
-
["MIDAS_GATEWAY"]: { 311:
|
|
22
|
+
["MIDAS_GATEWAY"]: { 311: BASIC_ADAPTER_ABI },
|
|
23
23
|
["MIDAS_REDEMPTION_VAULT"]: {
|
|
24
24
|
310: BASIC_ADAPTER_ABI,
|
|
25
25
|
311: BASIC_ADAPTER_ABI
|
|
@@ -169,13 +169,21 @@ var MidasGatewayAdapterContract = class extends AbstractAdapterContract {
|
|
|
169
169
|
return { redeemer };
|
|
170
170
|
}
|
|
171
171
|
/**
|
|
172
|
+
* Whether `calldata` is `receiveGreenlist()`, the call that grants the
|
|
173
|
+
* Midas greenlisted role to the credit account.
|
|
174
|
+
*/
|
|
175
|
+
isReceiveGreenlist(calldata) {
|
|
176
|
+
return calldata === receiveGreenlistCalldata;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
172
179
|
* `receiveGreenlist()` is prepended by `prependMidasReceiveGreenlist`
|
|
173
180
|
* before the balance bracket when the multicall mints a permissioned
|
|
174
|
-
* mToken: it only
|
|
175
|
-
* so it is legal outside a bracket and
|
|
181
|
+
* mToken: it only grants the Midas greenlisted role to the credit
|
|
182
|
+
* account and is balance-neutral, so it is legal outside a bracket and
|
|
183
|
+
* leaves balances untouched.
|
|
176
184
|
*/
|
|
177
185
|
replayOutOfBracketCall(_balances, calldata) {
|
|
178
|
-
return calldata
|
|
186
|
+
return this.isReceiveGreenlist(calldata);
|
|
179
187
|
}
|
|
180
188
|
applyBalanceChanges(balances, decoded) {
|
|
181
189
|
switch (decoded.functionName) {
|