@gearbox-protocol/sdk 14.12.0-next.69 → 14.12.0-next.70
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/common-utils/charts/credit-session.js +0 -1
- package/dist/cjs/common-utils/index.js +1 -1
- package/dist/cjs/common-utils/utils/creditAccount/index.js +1 -1
- package/dist/cjs/common-utils/utils/creditAccount/quota-utils.js +0 -1
- package/dist/cjs/common-utils/utils/index.js +1 -1
- package/dist/cjs/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.js +1 -1
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +81 -66
- package/dist/cjs/sdk/accounts/index.js +2 -0
- package/dist/cjs/sdk/accounts/intents/index.js +388 -0
- package/dist/cjs/sdk/accounts/intents/intents/index.js +14 -0
- package/dist/cjs/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.fixtures.js +121 -0
- package/dist/cjs/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.js +15 -0
- package/dist/cjs/sdk/accounts/intents/intents/resume/close/close.fixtures.js +108 -0
- package/dist/cjs/sdk/accounts/intents/intents/resume/close/close.js +51 -0
- package/dist/cjs/sdk/accounts/intents/intents/resume/decrease-leverage/decrease-leverage.fixtures.js +130 -0
- package/dist/cjs/sdk/accounts/intents/intents/resume/decrease-leverage/decrease-leverage.js +83 -0
- package/dist/cjs/sdk/accounts/intents/intents/resume/deposit/deposit.fixtures.js +117 -0
- package/dist/cjs/sdk/accounts/intents/intents/resume/deposit/deposit.js +15 -0
- package/dist/cjs/sdk/accounts/intents/intents/resume/increase-leverage/increase-leverage.fixtures.js +95 -0
- package/dist/cjs/sdk/accounts/intents/intents/resume/increase-leverage/increase-leverage.js +15 -0
- package/dist/cjs/sdk/accounts/intents/intents/resume/index.js +13 -0
- package/dist/cjs/sdk/accounts/intents/intents/resume/withdraw/withdraw.fixtures.js +138 -0
- package/dist/cjs/sdk/accounts/intents/intents/resume/withdraw/withdraw.js +161 -0
- package/dist/cjs/sdk/accounts/intents/operations/add-collateral/index.js +17 -0
- package/dist/cjs/sdk/accounts/intents/operations/claim-delayed/index.js +54 -0
- package/dist/cjs/sdk/accounts/intents/operations/close-credit-account/index.js +26 -0
- package/dist/cjs/sdk/accounts/intents/operations/decrease-debt/index.js +12 -0
- package/dist/cjs/sdk/accounts/intents/operations/increase-debt/index.js +12 -0
- package/dist/cjs/sdk/accounts/intents/operations/index.js +27 -0
- package/dist/cjs/sdk/accounts/intents/operations/quota-update/index.js +22 -0
- package/dist/cjs/sdk/accounts/intents/operations/repay-credit-account/index.js +22 -0
- package/dist/cjs/sdk/accounts/intents/operations/start-delayed-withdrawal/index.js +18 -0
- package/dist/cjs/sdk/accounts/intents/operations/swap/index.js +18 -0
- package/dist/cjs/sdk/accounts/intents/operations/types.js +1 -0
- package/dist/cjs/sdk/accounts/intents/operations/unwrap-rwa-collateral/index.js +27 -0
- package/dist/cjs/sdk/accounts/intents/operations/withdraw-collateral/index.js +43 -0
- package/dist/cjs/sdk/accounts/intents/operations/wrap-rwa-collateral/index.js +27 -0
- package/dist/cjs/sdk/accounts/intents/quoters/close.js +58 -0
- package/dist/cjs/sdk/accounts/intents/quoters/index.js +7 -0
- package/dist/cjs/sdk/accounts/intents/quoters/swap.js +79 -0
- package/dist/cjs/sdk/accounts/intents/testing/expect.js +167 -0
- package/dist/cjs/sdk/accounts/intents/testing/resume.js +172 -0
- package/dist/cjs/sdk/accounts/intents/testing/sdk-mock.js +179 -0
- package/dist/cjs/sdk/accounts/intents/types.js +1 -0
- package/dist/cjs/sdk/accounts/intents/utils/assemble-operation-calls.js +7 -0
- package/dist/cjs/sdk/accounts/intents/utils/borrowed-amount-plus-interest-and-fees.js +13 -0
- package/dist/cjs/sdk/accounts/intents/utils/common.js +43 -0
- package/dist/cjs/sdk/accounts/intents/utils/convert-amount.js +37 -0
- package/dist/cjs/sdk/accounts/intents/utils/index.js +19 -0
- package/dist/cjs/sdk/accounts/intents/utils/quotas-for-update.js +122 -0
- package/dist/cjs/sdk/accounts/intents/utils/simulate-adjust-state.js +39 -0
- package/dist/cjs/sdk/accounts/intents/utils/simulate-assets.js +69 -0
- package/dist/cjs/sdk/accounts/intents/utils/with-quota-update.js +13 -0
- package/dist/cjs/sdk/index.js +2 -0
- package/dist/esm/common-utils/charts/credit-session.js +0 -1
- package/dist/esm/common-utils/index.js +1 -1
- package/dist/esm/common-utils/utils/creditAccount/index.js +1 -1
- package/dist/esm/common-utils/utils/creditAccount/quota-utils.js +0 -1
- package/dist/esm/common-utils/utils/index.js +1 -1
- package/dist/esm/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.js +1 -1
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +83 -68
- package/dist/esm/sdk/accounts/index.js +2 -1
- package/dist/esm/sdk/accounts/intents/index.js +387 -0
- package/dist/esm/sdk/accounts/intents/intents/index.js +8 -0
- package/dist/esm/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.fixtures.js +107 -0
- package/dist/esm/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.js +14 -0
- package/dist/esm/sdk/accounts/intents/intents/resume/close/close.fixtures.js +94 -0
- package/dist/esm/sdk/accounts/intents/intents/resume/close/close.js +50 -0
- package/dist/esm/sdk/accounts/intents/intents/resume/decrease-leverage/decrease-leverage.fixtures.js +114 -0
- package/dist/esm/sdk/accounts/intents/intents/resume/decrease-leverage/decrease-leverage.js +82 -0
- package/dist/esm/sdk/accounts/intents/intents/resume/deposit/deposit.fixtures.js +110 -0
- package/dist/esm/sdk/accounts/intents/intents/resume/deposit/deposit.js +14 -0
- package/dist/esm/sdk/accounts/intents/intents/resume/increase-leverage/increase-leverage.fixtures.js +88 -0
- package/dist/esm/sdk/accounts/intents/intents/resume/increase-leverage/increase-leverage.js +14 -0
- package/dist/esm/sdk/accounts/intents/intents/resume/index.js +7 -0
- package/dist/esm/sdk/accounts/intents/intents/resume/withdraw/withdraw.fixtures.js +121 -0
- package/dist/esm/sdk/accounts/intents/intents/resume/withdraw/withdraw.js +160 -0
- package/dist/esm/sdk/accounts/intents/operations/add-collateral/index.js +16 -0
- package/dist/esm/sdk/accounts/intents/operations/claim-delayed/index.js +52 -0
- package/dist/esm/sdk/accounts/intents/operations/close-credit-account/index.js +25 -0
- package/dist/esm/sdk/accounts/intents/operations/decrease-debt/index.js +11 -0
- package/dist/esm/sdk/accounts/intents/operations/increase-debt/index.js +11 -0
- package/dist/esm/sdk/accounts/intents/operations/index.js +14 -0
- package/dist/esm/sdk/accounts/intents/operations/quota-update/index.js +21 -0
- package/dist/esm/sdk/accounts/intents/operations/repay-credit-account/index.js +21 -0
- package/dist/esm/sdk/accounts/intents/operations/start-delayed-withdrawal/index.js +17 -0
- package/dist/esm/sdk/accounts/intents/operations/swap/index.js +17 -0
- package/dist/esm/sdk/accounts/intents/operations/types.js +1 -0
- package/dist/esm/sdk/accounts/intents/operations/unwrap-rwa-collateral/index.js +26 -0
- package/dist/esm/sdk/accounts/intents/operations/withdraw-collateral/index.js +42 -0
- package/dist/esm/sdk/accounts/intents/operations/wrap-rwa-collateral/index.js +26 -0
- package/dist/esm/sdk/accounts/intents/quoters/close.js +56 -0
- package/dist/esm/sdk/accounts/intents/quoters/index.js +3 -0
- package/dist/esm/sdk/accounts/intents/quoters/swap.js +77 -0
- package/dist/esm/sdk/accounts/intents/testing/expect.js +162 -0
- package/dist/esm/sdk/accounts/intents/testing/resume.js +157 -0
- package/dist/esm/sdk/accounts/intents/testing/sdk-mock.js +172 -0
- package/dist/esm/sdk/accounts/intents/types.js +1 -0
- package/dist/esm/sdk/accounts/intents/utils/assemble-operation-calls.js +6 -0
- package/dist/esm/sdk/accounts/intents/utils/borrowed-amount-plus-interest-and-fees.js +12 -0
- package/dist/esm/sdk/accounts/intents/utils/common.js +40 -0
- package/dist/esm/sdk/accounts/intents/utils/convert-amount.js +36 -0
- package/dist/esm/sdk/accounts/intents/utils/index.js +9 -0
- package/dist/esm/sdk/accounts/intents/utils/quotas-for-update.js +121 -0
- package/dist/esm/sdk/accounts/intents/utils/simulate-adjust-state.js +38 -0
- package/dist/esm/sdk/accounts/intents/utils/simulate-assets.js +68 -0
- package/dist/esm/sdk/accounts/intents/utils/with-quota-update.js +12 -0
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/sdk/base/TokensMeta.js +2 -2
- package/dist/esm/sdk/chain/detectNetwork.js +1 -1
- package/dist/esm/sdk/core/createAddressProvider.js +1 -1
- package/dist/esm/sdk/index.js +2 -1
- package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/sdk/pools/PoolService.js +1 -1
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/types/common-utils/index.d.ts +19 -19
- package/dist/types/common-utils/static/index.d.ts +1 -1
- package/dist/types/common-utils/utils/apy/index.d.ts +1 -1
- package/dist/types/common-utils/utils/creditAccount/calc-health-factor.d.ts +1 -1
- package/dist/types/common-utils/utils/creditAccount/calc-overall-apy.d.ts +1 -1
- package/dist/types/common-utils/utils/creditAccount/calc-quota-borrow-rate.d.ts +1 -1
- package/dist/types/common-utils/utils/creditAccount/debt.d.ts +1 -1
- package/dist/types/common-utils/utils/creditAccount/index.d.ts +1 -1
- package/dist/types/common-utils/utils/creditAccount/liquidation-price.d.ts +1 -1
- package/dist/types/common-utils/utils/creditAccount/quota-utils.d.ts +0 -1
- package/dist/types/common-utils/utils/creditAccount/sort.d.ts +1 -1
- package/dist/types/common-utils/utils/index.d.ts +3 -3
- package/dist/types/common-utils/utils/strategies/credit-managers/get-wallet-balances-allowed-on-cm.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/strategy-info/calculate-total-apy.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/strategy-info/calculate-total-points.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/strategy-info/types.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/tokens/add-amount-in-target.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/tokens/get-list-with-amount-in-target.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/types/credit-manager-data-legacy.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/types/strategies-cm-list.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/types/strategy-earnings.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/types/strategy.d.ts +1 -1
- package/dist/types/common-utils/utils/validation/validate-open-account.d.ts +1 -1
- package/dist/types/common-utils/utils/validation/validate-quota.d.ts +1 -1
- package/dist/types/plugins/apy/ApyPlugin.d.ts +1 -1
- package/dist/types/plugins/apy/pool-apy-utils.d.ts +1 -1
- package/dist/types/plugins/apy/strategy-data-source.d.ts +1 -1
- package/dist/types/plugins/apy/types.d.ts +1 -1
- package/dist/types/plugins/remote-configs/CustomConfigSource.d.ts +1 -1
- package/dist/types/plugins/remote-configs/RemoteConfigSource.d.ts +1 -1
- package/dist/types/plugins/remote-configs/RemoteConfigsPlugin.d.ts +1 -1
- package/dist/types/plugins/remote-configs/index.d.ts +1 -1
- package/dist/types/plugins/remote-configs/types.d.ts +1 -1
- package/dist/types/rewards/rewards/extra-apy.d.ts +1 -1
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +30 -10
- package/dist/types/sdk/accounts/index.d.ts +2 -1
- package/dist/types/sdk/accounts/intents/index.d.ts +22 -0
- package/dist/types/sdk/accounts/intents/intents/index.d.ts +8 -0
- package/dist/types/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.d.ts +13 -0
- package/dist/types/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.fixtures.d.ts +38 -0
- package/dist/types/sdk/accounts/intents/intents/resume/close/close.d.ts +26 -0
- package/dist/types/sdk/accounts/intents/intents/resume/close/close.fixtures.d.ts +63 -0
- package/dist/types/sdk/accounts/intents/intents/resume/decrease-leverage/decrease-leverage.d.ts +26 -0
- package/dist/types/sdk/accounts/intents/intents/resume/decrease-leverage/decrease-leverage.fixtures.d.ts +86 -0
- package/dist/types/sdk/accounts/intents/intents/resume/deposit/deposit.d.ts +13 -0
- package/dist/types/sdk/accounts/intents/intents/resume/deposit/deposit.fixtures.d.ts +48 -0
- package/dist/types/sdk/accounts/intents/intents/resume/increase-leverage/increase-leverage.d.ts +13 -0
- package/dist/types/sdk/accounts/intents/intents/resume/increase-leverage/increase-leverage.fixtures.d.ts +46 -0
- package/dist/types/sdk/accounts/intents/intents/resume/index.d.ts +7 -0
- package/dist/types/sdk/accounts/intents/intents/resume/withdraw/withdraw.d.ts +33 -0
- package/dist/types/sdk/accounts/intents/intents/resume/withdraw/withdraw.fixtures.d.ts +68 -0
- package/dist/types/sdk/accounts/intents/operations/add-collateral/index.d.ts +23 -0
- package/dist/types/sdk/accounts/intents/operations/claim-delayed/index.d.ts +55 -0
- package/dist/types/sdk/accounts/intents/operations/close-credit-account/index.d.ts +22 -0
- package/dist/types/sdk/accounts/intents/operations/decrease-debt/index.d.ts +18 -0
- package/dist/types/sdk/accounts/intents/operations/increase-debt/index.d.ts +18 -0
- package/dist/types/sdk/accounts/intents/operations/index.d.ts +14 -0
- package/dist/types/sdk/accounts/intents/operations/quota-update/index.d.ts +24 -0
- package/dist/types/sdk/accounts/intents/operations/repay-credit-account/index.d.ts +32 -0
- package/dist/types/sdk/accounts/intents/operations/start-delayed-withdrawal/index.d.ts +23 -0
- package/dist/types/sdk/accounts/intents/operations/swap/index.d.ts +28 -0
- package/dist/types/sdk/accounts/intents/operations/types.d.ts +21 -0
- package/dist/types/sdk/accounts/intents/operations/unwrap-rwa-collateral/index.d.ts +30 -0
- package/dist/types/sdk/accounts/intents/operations/withdraw-collateral/index.d.ts +36 -0
- package/dist/types/sdk/accounts/intents/operations/wrap-rwa-collateral/index.d.ts +30 -0
- package/dist/types/sdk/accounts/intents/quoters/close.d.ts +43 -0
- package/dist/types/sdk/accounts/intents/quoters/index.d.ts +3 -0
- package/dist/types/sdk/accounts/intents/quoters/swap.d.ts +43 -0
- package/dist/types/sdk/accounts/intents/testing/expect.d.ts +52 -0
- package/dist/types/sdk/accounts/intents/testing/resume.d.ts +84 -0
- package/dist/types/sdk/accounts/intents/testing/sdk-mock.d.ts +90 -0
- package/dist/types/sdk/accounts/intents/types.d.ts +75 -0
- package/dist/types/sdk/accounts/intents/utils/assemble-operation-calls.d.ts +10 -0
- package/dist/types/sdk/accounts/intents/utils/borrowed-amount-plus-interest-and-fees.d.ts +17 -0
- package/dist/types/sdk/accounts/intents/utils/common.d.ts +19 -0
- package/dist/types/sdk/accounts/intents/utils/convert-amount.d.ts +13 -0
- package/dist/types/sdk/accounts/intents/utils/index.d.ts +9 -0
- package/dist/types/sdk/accounts/intents/utils/quotas-for-update.d.ts +35 -0
- package/dist/types/sdk/accounts/intents/utils/simulate-adjust-state.d.ts +19 -0
- package/dist/types/sdk/accounts/intents/utils/simulate-assets.d.ts +21 -0
- package/dist/types/sdk/accounts/intents/utils/with-quota-update.d.ts +16 -0
- package/dist/types/sdk/accounts/types.d.ts +20 -0
- package/dist/types/sdk/index.d.ts +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { TypedObjectUtils } from "../../../utils/mappers.js";
|
|
2
|
+
import { calcQuotaUpdate } from "../../../../common-utils/utils/creditAccount/quota-utils.js";
|
|
3
|
+
//#region src/sdk/accounts/intents/utils/quotas-for-update.ts
|
|
4
|
+
function getQuotasForUpdate({ assetsBefore, assetsAfter, initialQuotas, quotaReserve = 0, liquidationThresholds: liquidationThresholdsMap, quotas: quotasMap, maxDebt, underlyingToken, convert }) {
|
|
5
|
+
const underlyingTokenLc = underlyingToken.toLowerCase();
|
|
6
|
+
const assetsBeforeLc = assetsBefore.map((a) => ({
|
|
7
|
+
...a,
|
|
8
|
+
token: a.token.toLowerCase()
|
|
9
|
+
}));
|
|
10
|
+
const assetsAfterLc = assetsAfter.map((a) => ({
|
|
11
|
+
...a,
|
|
12
|
+
token: a.token.toLowerCase()
|
|
13
|
+
}));
|
|
14
|
+
const { spend, obtain } = collectQuotaChange(assetsBeforeLc, assetsAfterLc);
|
|
15
|
+
const initialQuotasLc = initialQuotas.map((a) => {
|
|
16
|
+
const tokenLc = a.token.toLowerCase();
|
|
17
|
+
return [tokenLc, {
|
|
18
|
+
...a,
|
|
19
|
+
token: tokenLc
|
|
20
|
+
}];
|
|
21
|
+
});
|
|
22
|
+
const initialQuotasRecord = TypedObjectUtils.fromEntries(initialQuotasLc);
|
|
23
|
+
const liquidationThresholds = TypedObjectUtils.fromEntries(liquidationThresholdsMap.entries().map(([token, lt]) => [token.toLowerCase(), BigInt(lt)]));
|
|
24
|
+
const quotas = TypedObjectUtils.fromEntries(quotasMap.values().map((q) => {
|
|
25
|
+
const token = q.token.toLowerCase();
|
|
26
|
+
return [token, {
|
|
27
|
+
token,
|
|
28
|
+
rate: BigInt(q.rate),
|
|
29
|
+
quotaIncreaseFee: BigInt(q.quotaIncreaseFee),
|
|
30
|
+
totalQuoted: q.totalQuoted,
|
|
31
|
+
limit: q.limit,
|
|
32
|
+
isActive: q.isActive
|
|
33
|
+
}];
|
|
34
|
+
}));
|
|
35
|
+
const assetsWithAmountInTarget = getBalancesAfterWithFullySpent(assetsAfterLc, spend, initialQuotasRecord).map((a) => {
|
|
36
|
+
return {
|
|
37
|
+
...a,
|
|
38
|
+
amountInTarget: convert(a.token, underlyingTokenLc, a.balance)
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
const quotaResult = calcQuotaUpdate({
|
|
42
|
+
quotas,
|
|
43
|
+
initialQuotas: initialQuotasRecord,
|
|
44
|
+
assetsAfterUpdate: constructAssetRecord(assetsWithAmountInTarget),
|
|
45
|
+
allowedToObtain: constructAssetRecord(obtain),
|
|
46
|
+
allowedToSpend: constructAssetRecord(spend),
|
|
47
|
+
quotaReserve: BigInt(quotaReserve),
|
|
48
|
+
maxDebt,
|
|
49
|
+
liquidationThresholds,
|
|
50
|
+
calcModification: void 0
|
|
51
|
+
});
|
|
52
|
+
return filterQuotaUpdates(quotaResult.desiredQuota, quotaResult.quotaIncrease, quotaResult.quotaDecrease, [...new Set([...spend, ...obtain].map((q) => q.token)).values()]);
|
|
53
|
+
}
|
|
54
|
+
function collectQuotaChange(assetsBefore, assetsAfter) {
|
|
55
|
+
const before = new Map(assetsBefore.map((a) => [a.token, a.balance]));
|
|
56
|
+
const after = new Map(assetsAfter.map((a) => [a.token, a.balance]));
|
|
57
|
+
const tokens = /* @__PURE__ */ new Set([...before.keys(), ...after.keys()]);
|
|
58
|
+
const spend = [];
|
|
59
|
+
const obtain = [];
|
|
60
|
+
for (const token of tokens) {
|
|
61
|
+
const delta = (after.get(token) ?? 0n) - (before.get(token) ?? 0n);
|
|
62
|
+
if (delta > 0n) obtain.push({
|
|
63
|
+
token,
|
|
64
|
+
balance: delta
|
|
65
|
+
});
|
|
66
|
+
else if (delta < 0n) spend.push({
|
|
67
|
+
token,
|
|
68
|
+
balance: -delta
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
spend,
|
|
73
|
+
obtain
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* SDK `getSingleQuotaChange` requires `assetAfter` to emit quota decreases.
|
|
78
|
+
* Simulation drops zero balances, so fully spent collaterals (e.g. claim
|
|
79
|
+
* phantom) vanish — reinsert them with balance 0 when they still have
|
|
80
|
+
* initial quota so `calcQuotaUpdate` can zero / remove that quota.
|
|
81
|
+
*/
|
|
82
|
+
function getBalancesAfterWithFullySpent(assetsAfter, tokensSpend, initialQuotas) {
|
|
83
|
+
const assetsAfterRecord = new Map(assetsAfter.map((a) => [a.token, a]));
|
|
84
|
+
for (const s of tokensSpend) {
|
|
85
|
+
if (assetsAfterRecord.has(s.token)) continue;
|
|
86
|
+
if ((initialQuotas[s.token]?.quota ?? 0n) > 0n) assetsAfterRecord.set(s.token, {
|
|
87
|
+
token: s.token,
|
|
88
|
+
balance: 0n
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return [...assetsAfterRecord.values()];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Restricts quota updates to only tokens that were intended to change.
|
|
95
|
+
*/
|
|
96
|
+
function filterQuotaUpdates(desiredQuota, quotaIncrease, quotaDecrease, tokensToUpdate) {
|
|
97
|
+
if (tokensToUpdate.length === 0) return {
|
|
98
|
+
desiredQuota: {},
|
|
99
|
+
quotaIncrease: [],
|
|
100
|
+
quotaDecrease: []
|
|
101
|
+
};
|
|
102
|
+
const allowed = new Set(tokensToUpdate);
|
|
103
|
+
const restrictedDesired = {};
|
|
104
|
+
for (const token of tokensToUpdate) {
|
|
105
|
+
const asset = desiredQuota[token];
|
|
106
|
+
if (asset) restrictedDesired[token] = asset;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
desiredQuota: restrictedDesired,
|
|
110
|
+
quotaIncrease: quotaIncrease.filter((a) => allowed.has(a.token)),
|
|
111
|
+
quotaDecrease: quotaDecrease.filter((a) => allowed.has(a.token))
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function constructAssetRecord(a) {
|
|
115
|
+
return a.reduce((acc, asset) => {
|
|
116
|
+
acc[asset.token] = asset;
|
|
117
|
+
return acc;
|
|
118
|
+
}, {});
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { getQuotasForUpdate };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getQuotasForUpdate } from "./quotas-for-update.js";
|
|
2
|
+
import { simulateOperationAssets } from "./simulate-assets.js";
|
|
3
|
+
//#region src/sdk/accounts/intents/utils/simulate-adjust-state.ts
|
|
4
|
+
function simulateState(props) {
|
|
5
|
+
const market = props.sdk.marketRegister.findByCreditManager(props.creditAccount.creditManager);
|
|
6
|
+
const convert = (token, to, amount) => market.priceOracle.convert(token, to, amount);
|
|
7
|
+
const creditManager = props.sdk.marketRegister.findCreditManager(props.creditAccount.creditManager);
|
|
8
|
+
const { assets, totalValue, debt } = simulateOperationAssets({
|
|
9
|
+
initialAssets: props.creditAccount.tokens,
|
|
10
|
+
operations: props.operations,
|
|
11
|
+
underlyingToken: props.creditAccount.underlying,
|
|
12
|
+
debt: props.creditAccount.accountDebt,
|
|
13
|
+
convert
|
|
14
|
+
});
|
|
15
|
+
const quotaResult = getQuotasForUpdate({
|
|
16
|
+
assetsBefore: props.creditAccount.tokens,
|
|
17
|
+
assetsAfter: assets,
|
|
18
|
+
liquidationThresholds: creditManager.creditManager.liquidationThresholds,
|
|
19
|
+
quotas: market.pool.pqk.quotas,
|
|
20
|
+
initialQuotas: props.creditAccount.tokens,
|
|
21
|
+
quotaReserve: props.quotaReserve,
|
|
22
|
+
underlyingToken: props.creditAccount.underlying,
|
|
23
|
+
maxDebt: creditManager.creditFacade.maxDebt,
|
|
24
|
+
convert
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
state: {
|
|
28
|
+
kind: "adjust",
|
|
29
|
+
totalValue,
|
|
30
|
+
accountDebt: debt,
|
|
31
|
+
assets,
|
|
32
|
+
quotas: quotaResult.desiredQuota
|
|
33
|
+
},
|
|
34
|
+
quotaResult
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { simulateState };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { BigIntMath } from "../../../utils/bigint-math.js";
|
|
2
|
+
//#region src/sdk/accounts/intents/utils/simulate-assets.ts
|
|
3
|
+
/** Apply an op chain to CA token balances. Address keys are lowercased. */
|
|
4
|
+
function simulateOperationAssets({ initialAssets, operations, underlyingToken, debt, convert }) {
|
|
5
|
+
let debtAfter = debt;
|
|
6
|
+
const balances = /* @__PURE__ */ new Map();
|
|
7
|
+
for (const asset of initialAssets) {
|
|
8
|
+
const token = asset.token.toLowerCase();
|
|
9
|
+
balances.set(token, (balances.get(token) ?? 0n) + asset.balance);
|
|
10
|
+
}
|
|
11
|
+
const get = (token) => balances.get(token.toLowerCase()) ?? 0n;
|
|
12
|
+
const set = (token, balance) => {
|
|
13
|
+
const key = token.toLowerCase();
|
|
14
|
+
if (balance <= 0n) balances.delete(key);
|
|
15
|
+
else balances.set(key, balance);
|
|
16
|
+
};
|
|
17
|
+
for (const op of operations) switch (op.type) {
|
|
18
|
+
case "changeQuota":
|
|
19
|
+
case "closeCreditAccount":
|
|
20
|
+
case "repayCreditAccount": break;
|
|
21
|
+
case "increaseDebt":
|
|
22
|
+
debtAfter = debtAfter + op.amount;
|
|
23
|
+
set(underlyingToken, get(underlyingToken) + op.amount);
|
|
24
|
+
break;
|
|
25
|
+
case "decreaseDebt":
|
|
26
|
+
debtAfter = BigIntMath.max(0n, debtAfter - op.amount);
|
|
27
|
+
set(underlyingToken, get(underlyingToken) - op.amount);
|
|
28
|
+
break;
|
|
29
|
+
case "addCollateral":
|
|
30
|
+
set(op.token, get(op.token) + op.amount);
|
|
31
|
+
break;
|
|
32
|
+
case "withdrawCollateral":
|
|
33
|
+
set(op.token, get(op.token) - op.amount);
|
|
34
|
+
break;
|
|
35
|
+
case "swap":
|
|
36
|
+
for (const swapInput of op.from) set(swapInput.token, get(swapInput.token) - swapInput.balance);
|
|
37
|
+
set(op.tokenOut, get(op.tokenOut) + op.amountOut);
|
|
38
|
+
break;
|
|
39
|
+
case "wrapRwaCollateral":
|
|
40
|
+
set(op.tokenIn, get(op.tokenIn) - op.amount);
|
|
41
|
+
set(op.tokenOut, get(op.tokenOut) + op.amountOut);
|
|
42
|
+
break;
|
|
43
|
+
case "unwrapRwaCollateral":
|
|
44
|
+
set(op.tokenIn, get(op.tokenIn) - op.amount);
|
|
45
|
+
set(op.tokenOut, get(op.tokenOut) + op.amountOut);
|
|
46
|
+
break;
|
|
47
|
+
case "startDelayedWithdrawal":
|
|
48
|
+
set(op.token, get(op.token) - op.amountIn);
|
|
49
|
+
for (const out of op.outputs) set(out.token, get(out.token) + out.amount);
|
|
50
|
+
break;
|
|
51
|
+
case "claimDelayedWithdrawal":
|
|
52
|
+
set(op.withdrawalPhantomToken, get(op.withdrawalPhantomToken) - op.withdrawalTokenSpent);
|
|
53
|
+
for (const out of op.outputs) set(out.token, get(out.token) + out.amount);
|
|
54
|
+
}
|
|
55
|
+
const assets = [...balances.entries()].map(([token, balance]) => ({
|
|
56
|
+
token: token.toLowerCase(),
|
|
57
|
+
balance
|
|
58
|
+
}));
|
|
59
|
+
return {
|
|
60
|
+
assets,
|
|
61
|
+
totalValue: assets.reduce((acc, a) => {
|
|
62
|
+
return acc + convert(a.token, underlyingToken, a.balance);
|
|
63
|
+
}, 0n),
|
|
64
|
+
debt: debtAfter
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { simulateOperationAssets };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { buildQuotaUpdateOperation } from "../operations/quota-update/index.js";
|
|
2
|
+
import "../operations/index.js";
|
|
3
|
+
//#region src/sdk/accounts/intents/utils/with-quota-update.ts
|
|
4
|
+
function getOperationsWithQuotaUpdate({ operations: coreOps, state, creditAccount, sdk, options }) {
|
|
5
|
+
return state.quotaResult.quotaIncrease.length + state.quotaResult.quotaDecrease.length === 0 ? coreOps : [...coreOps, buildQuotaUpdateOperation({
|
|
6
|
+
update: state.quotaResult,
|
|
7
|
+
creditAccount,
|
|
8
|
+
sdk
|
|
9
|
+
}, options)];
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getOperationsWithQuotaUpdate };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
|
|
1
2
|
import { AddressSet } from "../../utils/AddressSet.js";
|
|
2
3
|
import { bytes32ToString } from "../../utils/bytes32ToString.js";
|
|
3
4
|
import { ADDRESS_0X0 } from "../../constants/addresses.js";
|
|
@@ -17,7 +18,6 @@ import { RWA_LIQUIDATOR_SECURITIZE } from "../../market/rwa/securitize/constants
|
|
|
17
18
|
import { SecuritizeLiquidatorContract } from "../../market/rwa/securitize/SecuritizeLiquidatorContract.js";
|
|
18
19
|
import "../../market/rwa/securitize/index.js";
|
|
19
20
|
import { LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./constants.js";
|
|
20
|
-
import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
|
|
21
21
|
//#region src/sdk/accounts/liquidations/LiquidationsService.ts
|
|
22
22
|
/**
|
|
23
23
|
* Service for discovering liquidatable credit accounts and previewing manual
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
1
2
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
2
3
|
import "../../base/index.js";
|
|
3
4
|
import { decodeDelayedIntent } from "./intent-codec.js";
|
|
4
|
-
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
5
5
|
import { InvalidDelayedIntentError } from "./errors.js";
|
|
6
6
|
//#region src/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.ts
|
|
7
7
|
const abi = iRedemptionLoggerV310Abi;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
2
1
|
import { iWithdrawalCompressorV310Abi } from "../../../abi/IWithdrawalCompressorV310.js";
|
|
2
|
+
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
3
|
//#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.ts
|
|
4
4
|
const abi = iWithdrawalCompressorV310Abi;
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
2
1
|
import { iWithdrawalCompressorV311Abi } from "../../../abi/IWithdrawalCompressorV311.js";
|
|
2
|
+
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
3
|
//#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.ts
|
|
4
4
|
const abi = iWithdrawalCompressorV311Abi;
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
1
2
|
import { encodeDelayedIntent } from "./intent-codec.js";
|
|
2
3
|
import { AbstractWithdrawalCompressorContract, iCreditAccountAbi, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
|
-
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
4
4
|
import { toWithdrawalStatus } from "./types.js";
|
|
5
5
|
//#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.ts
|
|
6
6
|
const abi = iWithdrawalCompressorV313Abi;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
|
|
2
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
1
3
|
import { AddressMap } from "../utils/AddressMap.js";
|
|
2
4
|
import { AddressSet } from "../utils/AddressSet.js";
|
|
3
5
|
import { bytes32ToString } from "../utils/bytes32ToString.js";
|
|
4
6
|
import { getAssetType } from "../chain/chains.js";
|
|
5
7
|
import { formatBN } from "../utils/formatter.js";
|
|
6
8
|
import "../utils/index.js";
|
|
7
|
-
import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
|
|
8
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
9
9
|
//#region src/sdk/base/TokensMeta.ts
|
|
10
10
|
/**
|
|
11
11
|
* Registry of token metadata (symbol, decimals, phantom type) keyed by address.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
1
2
|
import { AP_MARKET_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR } from "../constants/address-provider.js";
|
|
2
3
|
import { isV310 } from "../constants/versions.js";
|
|
3
4
|
import "../constants/index.js";
|
|
4
5
|
import { hexEq } from "../utils/hex.js";
|
|
5
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
6
6
|
import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
|
|
7
7
|
//#region src/sdk/core/createAddressProvider.ts
|
|
8
8
|
const OVERRIDE_ADDRESSES = { Mainnet: {
|
package/dist/esm/sdk/index.js
CHANGED
|
@@ -103,6 +103,7 @@ import { RWARegistry } from "./market/rwa/RWARegistry.js";
|
|
|
103
103
|
import { RWA_FACTORY_TYPES, isRWAFactory } from "./market/rwa/types.js";
|
|
104
104
|
import "./market/index.js";
|
|
105
105
|
import { CreditAccountsServiceV310 } from "./accounts/CreditAccountsServiceV310.js";
|
|
106
|
+
import { CreditAccountOperationsService } from "./accounts/intents/index.js";
|
|
106
107
|
import { DUST_THRESHOLD, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./accounts/liquidations/constants.js";
|
|
107
108
|
import { LiquidationsService } from "./accounts/liquidations/LiquidationsService.js";
|
|
108
109
|
import { MultichainLiquidationsService } from "./accounts/liquidations/MultichainLiquidationsService.js";
|
|
@@ -137,4 +138,4 @@ import { OnchainSDK, STATE_VERSION } from "./OnchainSDK.js";
|
|
|
137
138
|
import { MultichainSDK } from "./MultichainSDK.js";
|
|
138
139
|
import { attachOptionsSchema, onchainSDKOptionsSchema } from "./options.js";
|
|
139
140
|
import "./types/index.js";
|
|
140
|
-
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, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, Erc4626PriceFeedContract, ExternalPriceFeedContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InvalidDelayedIntentError, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainSDK, NATIVE_ADDRESS, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, 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, PendleTWAPPTPriceFeed, PlaceholderAdapterContract, PlaceholderContract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeRWAFactory, SimulateWithPriceUpdatesError, SimulationError, TokensMeta, TypedObjectUtils, UnsupportedZapperFunctionError, VERSION_RANGE_310, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodHex, additionalBorrowApyBps, assetsMap, attachOptionsSchema, borrowApyBps, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, decodeDelayedIntent, detectNetwork, encodeDelayedIntent, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, fetchPythPayloads, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, hexEq, hydrateAddressProvider, iCreditAccountAbi, isDust, isLPPriceFeed, isPublicNetwork, isRWAFactory, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, json_parse, json_stringify, maxLeverage, numberWithCommas, onchainSDKOptionsSchema, percentFmt, rayToBps, rayToNumber, retry, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, toAddress, toBN, toBigInt, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toWithdrawalStatus, usdToNumber, utilizationBps, watchBlocksAsync };
|
|
141
|
+
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, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, Erc4626PriceFeedContract, ExternalPriceFeedContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InvalidDelayedIntentError, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainSDK, NATIVE_ADDRESS, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, 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, PendleTWAPPTPriceFeed, PlaceholderAdapterContract, PlaceholderContract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeRWAFactory, SimulateWithPriceUpdatesError, SimulationError, TokensMeta, TypedObjectUtils, UnsupportedZapperFunctionError, VERSION_RANGE_310, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodHex, additionalBorrowApyBps, assetsMap, attachOptionsSchema, borrowApyBps, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, decodeDelayedIntent, detectNetwork, encodeDelayedIntent, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, fetchPythPayloads, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, hexEq, hydrateAddressProvider, iCreditAccountAbi, isDust, isLPPriceFeed, isPublicNetwork, isRWAFactory, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, json_parse, json_stringify, maxLeverage, numberWithCommas, onchainSDKOptionsSchema, percentFmt, rayToBps, rayToNumber, retry, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, toAddress, toBN, toBigInt, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toWithdrawalStatus, usdToNumber, utilizationBps, watchBlocksAsync };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
1
2
|
import { iCreditFacadeMulticallV310Abi, iCreditFacadeV310Abi } from "../../../abi/310/generated.js";
|
|
2
3
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
3
4
|
import "../../base/index.js";
|
|
4
|
-
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
5
5
|
//#region src/sdk/market/credit/CreditFacadeV310BaseContract.ts
|
|
6
6
|
const abi = [
|
|
7
7
|
...iCreditFacadeV310Abi,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
1
2
|
import { iPoolV310Abi } from "../../../abi/310/generated.js";
|
|
2
3
|
import { AddressMap } from "../../utils/AddressMap.js";
|
|
3
4
|
import { RAY } from "../../constants/math.js";
|
|
@@ -6,7 +7,6 @@ import { formatBN, formatBNvalue, percentFmt } from "../../utils/formatter.js";
|
|
|
6
7
|
import "../../utils/index.js";
|
|
7
8
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
8
9
|
import "../../base/index.js";
|
|
9
|
-
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
10
10
|
import { utilizationBps } from "../math.js";
|
|
11
11
|
//#region src/sdk/market/pool/PoolV310Contract.ts
|
|
12
12
|
const abi = [...iPoolV310Abi, ...iPausableAbi];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ZapperContract } from "./ZapperContract.js";
|
|
2
1
|
import { iethZapperAbi } from "../../../abi/iETHZapper.js";
|
|
2
|
+
import { ZapperContract } from "./ZapperContract.js";
|
|
3
3
|
//#region src/sdk/market/zapper/IETHZapperContract.ts
|
|
4
4
|
const abi = iethZapperAbi;
|
|
5
5
|
var IETHZapperContract = class extends ZapperContract {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
1
2
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
2
3
|
import "../../base/index.js";
|
|
3
|
-
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
4
4
|
import { UnsupportedZapperFunctionError } from "./errors.js";
|
|
5
5
|
//#region src/sdk/market/zapper/ZapperContract.ts
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AddressSet } from "../utils/AddressSet.js";
|
|
2
1
|
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
2
|
+
import { AddressSet } from "../utils/AddressSet.js";
|
|
3
3
|
import "../constants/addresses.js";
|
|
4
4
|
import "../constants/index.js";
|
|
5
5
|
import { hexEq } from "../utils/hex.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { errorAbis } from "../../../abi/errors.js";
|
|
2
|
-
import { generateCastTraceCall } from "./cast.js";
|
|
3
2
|
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
3
|
+
import { generateCastTraceCall } from "./cast.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";
|
|
@@ -1,22 +1,4 @@
|
|
|
1
1
|
import { BigIntMath } from "../sdk/utils/bigint-math.js";
|
|
2
|
-
import { AxiosCache } from "./axios-cache/AxiosCache.js";
|
|
3
|
-
import "./axios-cache/index.js";
|
|
4
|
-
import { BigNumberish, ChartsCreditManagerPayload } from "./charts/credit-manager-payload.js";
|
|
5
|
-
import { ChartsCreditManagerData } from "./charts/credit-manager.js";
|
|
6
|
-
import { AssetUtils, AssetWithAmountInTarget, AssetWithView, WrapResult } from "./utils/assets-math.js";
|
|
7
|
-
import { CreditSessionBalancePayload, CreditSessionFilteredPayload, CreditSessionPayload, CreditSessionsAggregatedStatsPayload, SecondaryStatus, UserCreditSessionsAggregatedStatsPayload } from "./charts/credit-sessions-payload.js";
|
|
8
|
-
import { CREDIT_SESSION_ID_BY_STATUS, CREDIT_SESSION_STATUS_BY_ID, CreditSession, CreditSessionAsset, CreditSessionFiltered, CreditSessionReward, CreditSessionSortFields, CreditSessionSortType, CreditSessionStatus, CreditSessionsAggregatedStats, UserCreditSessions, UserCreditSessionsBuilder } from "./charts/credit-session.js";
|
|
9
|
-
import { GraphPayload } from "./charts/graph-payload.js";
|
|
10
|
-
import { ChartsAggregatedPoolPayload, ChartsAggregatedStats, ChartsPoolDataPayload, UserPoolAggregatedStatsPayload, UserPoolPayload } from "./charts/pool-payload.js";
|
|
11
|
-
import { ChartsPoolData, UserPoolData } from "./charts/pool.js";
|
|
12
|
-
import { IconComposite, TokenData, TokenDataPayload, TokenIconCompositePreset, TokenIconLayerSource } from "./charts/token-data.js";
|
|
13
|
-
import "./charts/index.js";
|
|
14
|
-
import { TokenMigration, TokenMigrationConfigPayload } from "./static/migration-config.js";
|
|
15
|
-
import { PoolConfigPayload, TokenTypePool } from "./static/pool-config.js";
|
|
16
|
-
import { StrategyConfigPayload, StrategyMarketType, TokenTypeStrategy } from "./static/strategy.js";
|
|
17
|
-
import { TradingPairConfigPayload, TradingType } from "./static/trading-pair.js";
|
|
18
|
-
import "./static/index.js";
|
|
19
|
-
import { BONUS_APY_FROM_POINTS } from "./utils/apy/bonus-apy-from-points.js";
|
|
20
2
|
import { AppChains } from "./utils/strategies/types/chains.js";
|
|
21
3
|
import { StrategyCreditManagerView, StrategyDataSource, StrategyPoolView, StrategyTokenView } from "./utils/strategies/types/strategy-data-source.js";
|
|
22
4
|
import { CreditManagerDataSlice } from "./utils/strategies/types/credit-manager-data-legacy.js";
|
|
@@ -24,6 +6,7 @@ import { CuratorFilter } from "./utils/strategies/types/curator-filter.js";
|
|
|
24
6
|
import { GearboxSDKFullState, GearboxSDKFullStateByChain } from "./utils/strategies/types/sdk-state.js";
|
|
25
7
|
import { createLegacyStrategyDataSource } from "./utils/strategies/types/legacy-strategy-data-source.js";
|
|
26
8
|
import { APYListByNetwork, BasePointsList, ExtraCollateralPointsList, LocalDebtReward, LocalPointsInfo, LocalPointsReward, PointsList, StrategyCreditManagerLike, StrategyInfoLike } from "./utils/strategies/types/points-slices.js";
|
|
9
|
+
import { StrategyConfigPayload, StrategyMarketType, TokenTypeStrategy } from "./static/strategy.js";
|
|
27
10
|
import { ExtraCollateralConfig, ExtraCollaterals, NotValidatedStrategy, Strategy, StrategyRecord } from "./utils/strategies/types/strategy.js";
|
|
28
11
|
import { StrategiesCMListByChain } from "./utils/strategies/types/strategies-cm-list.js";
|
|
29
12
|
import { APYList, PricesRecord } from "./utils/strategies/types/strategy-data.js";
|
|
@@ -35,6 +18,24 @@ import { BestEarningsState, EarningsList, StrategyCMEarningsInfo, StrategyEarnin
|
|
|
35
18
|
import { IsTargetableProps } from "./utils/strategies/types/targetable.js";
|
|
36
19
|
import { GetStrategyPointsProps, StrategyLike, StrategyPointsResult, getStrategyPoints } from "./utils/strategies/points/get-strategy-points.js";
|
|
37
20
|
import { APYListSlice, CreditManagerSlice, GetStrategyInfoArgs, LinearModel, PoolSlice, PricesByChainSlice, QuotaSlice, StrategyInfoResult, StrategySlice, TokenSlice } from "./utils/strategies/strategy-info/types.js";
|
|
21
|
+
import { CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota } from "./utils/creditAccount/quota-utils.js";
|
|
22
|
+
import { AxiosCache } from "./axios-cache/AxiosCache.js";
|
|
23
|
+
import "./axios-cache/index.js";
|
|
24
|
+
import { BigNumberish, ChartsCreditManagerPayload } from "./charts/credit-manager-payload.js";
|
|
25
|
+
import { ChartsCreditManagerData } from "./charts/credit-manager.js";
|
|
26
|
+
import { AssetUtils, AssetWithAmountInTarget, AssetWithView, WrapResult } from "./utils/assets-math.js";
|
|
27
|
+
import { CreditSessionBalancePayload, CreditSessionFilteredPayload, CreditSessionPayload, CreditSessionsAggregatedStatsPayload, SecondaryStatus, UserCreditSessionsAggregatedStatsPayload } from "./charts/credit-sessions-payload.js";
|
|
28
|
+
import { CREDIT_SESSION_ID_BY_STATUS, CREDIT_SESSION_STATUS_BY_ID, CreditSession, CreditSessionAsset, CreditSessionFiltered, CreditSessionReward, CreditSessionSortFields, CreditSessionSortType, CreditSessionStatus, CreditSessionsAggregatedStats, UserCreditSessions, UserCreditSessionsBuilder } from "./charts/credit-session.js";
|
|
29
|
+
import { GraphPayload } from "./charts/graph-payload.js";
|
|
30
|
+
import { ChartsAggregatedPoolPayload, ChartsAggregatedStats, ChartsPoolDataPayload, UserPoolAggregatedStatsPayload, UserPoolPayload } from "./charts/pool-payload.js";
|
|
31
|
+
import { ChartsPoolData, UserPoolData } from "./charts/pool.js";
|
|
32
|
+
import { IconComposite, TokenData, TokenDataPayload, TokenIconCompositePreset, TokenIconLayerSource } from "./charts/token-data.js";
|
|
33
|
+
import "./charts/index.js";
|
|
34
|
+
import { TokenMigration, TokenMigrationConfigPayload } from "./static/migration-config.js";
|
|
35
|
+
import { PoolConfigPayload, TokenTypePool } from "./static/pool-config.js";
|
|
36
|
+
import { TradingPairConfigPayload, TradingType } from "./static/trading-pair.js";
|
|
37
|
+
import "./static/index.js";
|
|
38
|
+
import { BONUS_APY_FROM_POINTS } from "./utils/apy/bonus-apy-from-points.js";
|
|
38
39
|
import { calculateBorrowRateFromUtilization } from "./utils/apy/calculate-borrow-rate-from-utilization.js";
|
|
39
40
|
import { calculateEffectiveBorrowRate } from "./utils/apy/calculate-effective-borrow-rate.js";
|
|
40
41
|
import { CalculateBorrowRateSafelyProps, calculateSafeBorrowRate } from "./utils/apy/calculate-safe-borrow-rate.js";
|
|
@@ -51,7 +52,6 @@ import { CalcRelativeBaseBorrowRateProps, calcRelativeBaseBorrowRate } from "./u
|
|
|
51
52
|
import { CalcMaxLendingDebtProps, calcMaxDebtIncrease, calcMaxLendingDebt } from "./utils/creditAccount/debt.js";
|
|
52
53
|
import { TimeToLiquidationProps, getTimeToLiquidation } from "./utils/creditAccount/get-time-to-liquidation.js";
|
|
53
54
|
import { liquidationPrice } from "./utils/creditAccount/liquidation-price.js";
|
|
54
|
-
import { CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota } from "./utils/creditAccount/quota-utils.js";
|
|
55
55
|
import { amountAbcComparator, assetComparator, sortAssets, sortBalances, tokensAbcComparator } from "./utils/creditAccount/sort.js";
|
|
56
56
|
import { PriceUtils } from "./utils/price-math.js";
|
|
57
57
|
import { getDefaultAsset } from "./utils/strategies/assets/assets.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { StrategyConfigPayload, StrategyMarketType, TokenTypeStrategy } from "./strategy.js";
|
|
1
2
|
import { TokenMigration, TokenMigrationConfigPayload } from "./migration-config.js";
|
|
2
3
|
import { PoolConfigPayload, TokenTypePool } from "./pool-config.js";
|
|
3
|
-
import { StrategyConfigPayload, StrategyMarketType, TokenTypeStrategy } from "./strategy.js";
|
|
4
4
|
import { TradingPairConfigPayload, TradingType } from "./trading-pair.js";
|
|
5
5
|
export { PoolConfigPayload, StrategyConfigPayload, StrategyMarketType, TokenMigration, TokenMigrationConfigPayload, TokenTypePool, TokenTypeStrategy, TradingPairConfigPayload, TradingType };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BONUS_APY_FROM_POINTS } from "./bonus-apy-from-points.js";
|
|
2
1
|
import { CalculateEarningsProps, calculateEarnings } from "./calculate-earnings.js";
|
|
2
|
+
import { BONUS_APY_FROM_POINTS } from "./bonus-apy-from-points.js";
|
|
3
3
|
import { calculateBorrowRateFromUtilization } from "./calculate-borrow-rate-from-utilization.js";
|
|
4
4
|
import { calculateEffectiveBorrowRate } from "./calculate-effective-borrow-rate.js";
|
|
5
5
|
import { CalculateBorrowRateSafelyProps, calculateSafeBorrowRate } from "./calculate-safe-borrow-rate.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Asset } from "../../../sdk/base/types.js";
|
|
2
|
-
import "../../../sdk/index.js";
|
|
3
2
|
import { QuotaInfoIsActiveSlice, TokenDataSlice } from "./types.js";
|
|
3
|
+
import "../../../sdk/index.js";
|
|
4
4
|
import { Address } from "viem";
|
|
5
5
|
//#region src/common-utils/utils/creditAccount/calc-health-factor.d.ts
|
|
6
6
|
interface CalcHealthFactorProps {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Asset } from "../../../sdk/base/types.js";
|
|
2
|
-
import "../../../sdk/index.js";
|
|
3
2
|
import { QuotaInfoSlice, TokenDataSlice } from "./types.js";
|
|
3
|
+
import "../../../sdk/index.js";
|
|
4
4
|
import { Address } from "viem";
|
|
5
5
|
//#region src/common-utils/utils/creditAccount/calc-overall-apy.d.ts
|
|
6
6
|
interface CalcOverallAPYProps {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Asset } from "../../../sdk/base/types.js";
|
|
2
|
-
import "../../../sdk/index.js";
|
|
3
2
|
import { QuotaInfoSlice } from "./types.js";
|
|
3
|
+
import "../../../sdk/index.js";
|
|
4
4
|
import { Address } from "viem";
|
|
5
5
|
//#region src/common-utils/utils/creditAccount/calc-quota-borrow-rate.d.ts
|
|
6
6
|
interface CalcQuotaBorrowRateProps {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Asset } from "../../../sdk/base/types.js";
|
|
2
|
-
import "../../../sdk/index.js";
|
|
3
2
|
import { TokenDataSlice } from "./types.js";
|
|
3
|
+
import "../../../sdk/index.js";
|
|
4
4
|
import { Address } from "viem";
|
|
5
5
|
//#region src/common-utils/utils/creditAccount/debt.d.ts
|
|
6
6
|
interface CalcMaxLendingDebtProps {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota } from "./quota-utils.js";
|
|
1
2
|
import { CalcQuotaBorrowRateProps, calcQuotaBorrowRate } from "./calc-quota-borrow-rate.js";
|
|
2
3
|
import { CalcHealthFactorProps, calcHealthFactor } from "./calc-health-factor.js";
|
|
3
4
|
import { CalcOverallAPYProps, calcOverallAPY } from "./calc-overall-apy.js";
|
|
@@ -5,6 +6,5 @@ import { CalcRelativeBaseBorrowRateProps, calcRelativeBaseBorrowRate } from "./c
|
|
|
5
6
|
import { CalcMaxLendingDebtProps, calcMaxDebtIncrease, calcMaxLendingDebt } from "./debt.js";
|
|
6
7
|
import { TimeToLiquidationProps, getTimeToLiquidation } from "./get-time-to-liquidation.js";
|
|
7
8
|
import { liquidationPrice } from "./liquidation-price.js";
|
|
8
|
-
import { CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota } from "./quota-utils.js";
|
|
9
9
|
import { amountAbcComparator, assetComparator, sortAssets, sortBalances, tokensAbcComparator } from "./sort.js";
|
|
10
10
|
export { CalcDefaultQuotaProps, CalcHealthFactorProps, CalcMaxLendingDebtProps, CalcOverallAPYProps, CalcQuotaBorrowRateProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, CalcRelativeBaseBorrowRateProps, TimeToLiquidationProps, amountAbcComparator, assetComparator, calcDefaultQuota, calcHealthFactor, calcMaxDebtIncrease, calcMaxLendingDebt, calcOverallAPY, calcQuotaBorrowRate, calcQuotaUpdate, calcRecommendedQuota, calcRelativeBaseBorrowRate, getTimeToLiquidation, liquidationPrice, roundUpQuota, sortAssets, sortBalances, tokensAbcComparator };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Asset } from "../../../sdk/base/types.js";
|
|
2
|
-
import "../../../sdk/index.js";
|
|
3
2
|
import { TokenDataSlice } from "./types.js";
|
|
3
|
+
import "../../../sdk/index.js";
|
|
4
4
|
import { Address } from "viem";
|
|
5
5
|
//#region src/common-utils/utils/creditAccount/liquidation-price.d.ts
|
|
6
6
|
interface LiquidationPriceProps {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { BigIntMath } from "../../sdk/utils/bigint-math.js";
|
|
2
|
-
import { AssetUtils, AssetWithAmountInTarget, AssetWithView, WrapResult } from "./assets-math.js";
|
|
3
|
-
import { BONUS_APY_FROM_POINTS } from "./apy/bonus-apy-from-points.js";
|
|
4
2
|
import { AppChains } from "./strategies/types/chains.js";
|
|
5
3
|
import { StrategyCreditManagerView, StrategyDataSource, StrategyPoolView, StrategyTokenView } from "./strategies/types/strategy-data-source.js";
|
|
6
4
|
import { CreditManagerDataSlice } from "./strategies/types/credit-manager-data-legacy.js";
|
|
@@ -19,6 +17,9 @@ import { BestEarningsState, EarningsList, StrategyCMEarningsInfo, StrategyEarnin
|
|
|
19
17
|
import { IsTargetableProps } from "./strategies/types/targetable.js";
|
|
20
18
|
import { GetStrategyPointsProps, StrategyLike, StrategyPointsResult, getStrategyPoints } from "./strategies/points/get-strategy-points.js";
|
|
21
19
|
import { APYListSlice, CreditManagerSlice, GetStrategyInfoArgs, LinearModel, PoolSlice, PricesByChainSlice, QuotaSlice, StrategyInfoResult, StrategySlice, TokenSlice } from "./strategies/strategy-info/types.js";
|
|
20
|
+
import { CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota } from "./creditAccount/quota-utils.js";
|
|
21
|
+
import { AssetUtils, AssetWithAmountInTarget, AssetWithView, WrapResult } from "./assets-math.js";
|
|
22
|
+
import { BONUS_APY_FROM_POINTS } from "./apy/bonus-apy-from-points.js";
|
|
22
23
|
import { calculateBorrowRateFromUtilization } from "./apy/calculate-borrow-rate-from-utilization.js";
|
|
23
24
|
import { calculateEffectiveBorrowRate } from "./apy/calculate-effective-borrow-rate.js";
|
|
24
25
|
import { CalculateBorrowRateSafelyProps, calculateSafeBorrowRate } from "./apy/calculate-safe-borrow-rate.js";
|
|
@@ -36,7 +37,6 @@ import { CalcRelativeBaseBorrowRateProps, calcRelativeBaseBorrowRate } from "./c
|
|
|
36
37
|
import { CalcMaxLendingDebtProps, calcMaxDebtIncrease, calcMaxLendingDebt } from "./creditAccount/debt.js";
|
|
37
38
|
import { TimeToLiquidationProps, getTimeToLiquidation } from "./creditAccount/get-time-to-liquidation.js";
|
|
38
39
|
import { liquidationPrice } from "./creditAccount/liquidation-price.js";
|
|
39
|
-
import { CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota } from "./creditAccount/quota-utils.js";
|
|
40
40
|
import { amountAbcComparator, assetComparator, sortAssets, sortBalances, tokensAbcComparator } from "./creditAccount/sort.js";
|
|
41
41
|
import "./creditAccount/index.js";
|
|
42
42
|
import { PriceUtils } from "./price-math.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Asset } from "../../../../sdk/base/types.js";
|
|
2
|
-
import "../../../../sdk/index.js";
|
|
3
2
|
import { TokenSlice } from "../strategy-info/types.js";
|
|
3
|
+
import "../../../../sdk/index.js";
|
|
4
4
|
import { Address } from "viem";
|
|
5
5
|
//#region src/common-utils/utils/strategies/credit-managers/get-wallet-balances-allowed-on-cm.d.ts
|
|
6
6
|
interface GetWalletBalancesAllowedOnCMProps {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Asset } from "../../../../sdk/base/types.js";
|
|
2
|
-
import "../../../../sdk/index.js";
|
|
3
2
|
import { QuotaSlice, TokenSlice } from "./types.js";
|
|
3
|
+
import "../../../../sdk/index.js";
|
|
4
4
|
import { Address } from "viem";
|
|
5
5
|
//#region src/common-utils/utils/strategies/strategy-info/calculate-total-apy.d.ts
|
|
6
6
|
interface TotalAPY {
|