@gearbox-protocol/sdk 18.4.1-aave.7 → 18.4.1-aave.9
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/onchain/accounts/index.js +1 -1
- package/dist/cjs/onchain/accounts/intents/index.js +33 -0
- package/dist/cjs/onchain/accounts/intents/operations.js +21 -0
- package/dist/cjs/onchain/accounts/intents/plan.js +55 -0
- package/dist/cjs/onchain/accounts/intents/readAaveHoldings.js +56 -0
- package/dist/cjs/onchain/accounts/intents/realize.js +64 -1
- package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +1 -1
- package/dist/cjs/onchain/accounts/intents/utils/ledger.js +8 -0
- package/dist/cjs/onchain/index.js +3 -1
- package/dist/cjs/onchain/market/adapters/abi/index.js +2 -0
- package/dist/cjs/onchain/market/adapters/abi/securitize/iSecuritizeNAVProvider.js +15 -0
- package/dist/cjs/onchain/market/adapters/abi/securitize/index.js +2 -0
- package/dist/cjs/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.js +21 -0
- package/dist/cjs/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.js +14 -0
- package/dist/cjs/onchain/market/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js +42 -5
- package/dist/cjs/onchain/market/adapters/index.js +2 -0
- package/dist/cjs/onchain/market/index.js +2 -0
- package/dist/cjs/onchain/positions/MultichainPositionsService.js +15 -0
- package/dist/cjs/onchain/positions/PositionsService.js +31 -0
- package/dist/cjs/onchain/positions/readAavePosition.js +152 -0
- package/dist/cjs/onchain/preview/preview/previewExitOrRepayStrategyPosition.js +3 -3
- package/dist/cjs/onchain/preview/preview/previewOperation.js +8 -5
- package/dist/cjs/sdk/positions/PositionsNamespace.js +6 -0
- package/dist/cjs/sdk/prepare/PrepareApi.js +43 -0
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/history/trace/extractTransfers.js +1 -1
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/onchain/accounts/index.js +1 -1
- package/dist/esm/onchain/accounts/intents/index.js +34 -1
- package/dist/esm/onchain/accounts/intents/operations.js +20 -1
- package/dist/esm/onchain/accounts/intents/plan.js +56 -2
- package/dist/esm/onchain/accounts/intents/readAaveHoldings.js +55 -0
- package/dist/esm/onchain/accounts/intents/realize.js +65 -2
- package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +1 -1
- package/dist/esm/onchain/accounts/intents/utils/ledger.js +8 -0
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/onchain/base/TokensMeta.js +3 -3
- package/dist/esm/onchain/core/createAddressProvider.js +1 -1
- package/dist/esm/onchain/index.js +3 -2
- package/dist/esm/onchain/market/adapters/abi/index.js +2 -1
- package/dist/esm/onchain/market/adapters/abi/securitize/iSecuritizeNAVProvider.js +14 -0
- package/dist/esm/onchain/market/adapters/abi/securitize/index.js +2 -1
- package/dist/esm/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.js +21 -0
- package/dist/esm/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.js +14 -0
- package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js +43 -6
- package/dist/esm/onchain/market/adapters/index.js +2 -1
- package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/onchain/market/index.js +2 -1
- package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/onchain/market/rwa/createDegenNFT.js +1 -1
- package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/onchain/positions/MultichainPositionsService.js +15 -0
- package/dist/esm/onchain/positions/PositionsService.js +31 -0
- package/dist/esm/onchain/positions/readAavePosition.js +151 -0
- package/dist/esm/onchain/preview/preview/previewExitOrRepayStrategyPosition.js +3 -3
- package/dist/esm/onchain/preview/preview/previewOperation.js +8 -5
- package/dist/esm/onchain/preview/preview/previewPoolPositionOperation.js +2 -2
- package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/esm/sdk/positions/PositionsNamespace.js +6 -0
- package/dist/esm/sdk/prepare/PrepareApi.js +43 -0
- package/dist/types/model/aave.d.ts +39 -0
- package/dist/types/model/index.d.ts +4 -4
- package/dist/types/model/opportunities.d.ts +1 -1
- package/dist/types/onchain/accounts/index.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/index.d.ts +21 -3
- package/dist/types/onchain/accounts/intents/operations.d.ts +38 -1
- package/dist/types/onchain/accounts/intents/plan.d.ts +27 -1
- package/dist/types/onchain/accounts/intents/readAaveHoldings.d.ts +16 -0
- package/dist/types/onchain/accounts/intents/types.d.ts +42 -0
- package/dist/types/onchain/index.d.ts +4 -3
- package/dist/types/onchain/market/adapters/abi/index.d.ts +2 -1
- package/dist/types/onchain/market/adapters/abi/securitize/iSecuritizeNAVProvider.d.ts +13 -0
- package/dist/types/onchain/market/adapters/abi/securitize/index.d.ts +2 -1
- package/dist/types/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.d.ts +7 -0
- package/dist/types/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.d.ts +5 -0
- package/dist/types/onchain/market/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.d.ts +19 -4
- package/dist/types/onchain/market/adapters/index.d.ts +2 -1
- package/dist/types/onchain/market/index.d.ts +2 -1
- package/dist/types/onchain/positions/MultichainPositionsService.d.ts +7 -1
- package/dist/types/onchain/positions/PositionsService.d.ts +16 -2
- package/dist/types/onchain/positions/index.d.ts +2 -2
- package/dist/types/onchain/positions/readAavePosition.d.ts +22 -0
- package/dist/types/onchain/positions/types.d.ts +25 -0
- package/dist/types/sdk/index.d.ts +2 -2
- package/dist/types/sdk/positions/PositionsNamespace.d.ts +6 -1
- package/dist/types/sdk/positions/types.d.ts +9 -1
- package/dist/types/sdk/prepare/PrepareApi.d.ts +5 -1
- package/dist/types/sdk/prepare/index.d.ts +2 -2
- package/dist/types/sdk/prepare/types.d.ts +42 -0
- package/package.json +1 -1
|
@@ -37,6 +37,21 @@ var MultichainPositionsService = class extends MultichainConstruct {
|
|
|
37
37
|
})
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Aave Horizon positions of a wallet on all queried chains, see
|
|
42
|
+
* {@link PositionsService.listAavePositions}.
|
|
43
|
+
**/
|
|
44
|
+
async listAavePositions(props) {
|
|
45
|
+
return this.queryChains({
|
|
46
|
+
chainIds: props.chainIds,
|
|
47
|
+
label: "list aave positions",
|
|
48
|
+
block: "latest",
|
|
49
|
+
run: (sdk, block) => sdk.positions.listAavePositions({
|
|
50
|
+
wallet: props.wallet,
|
|
51
|
+
blockNumber: block.blockNumber
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
}
|
|
40
55
|
};
|
|
41
56
|
//#endregion
|
|
42
57
|
export { MultichainPositionsService };
|
|
@@ -14,6 +14,7 @@ import { calcBorrowRate } from "./calcBorrowRate.js";
|
|
|
14
14
|
import { calcHealthFactor } from "./calcHealthFactor.js";
|
|
15
15
|
import { calcLiquidationPrice, soleNonUnderlyingCollateral } from "./calcLiquidationPrice.js";
|
|
16
16
|
import { calcTimeToLiquidationMs } from "./calcTimeToLiquidationMs.js";
|
|
17
|
+
import { readAavePosition } from "./readAavePosition.js";
|
|
17
18
|
import { accountSnapshotFromCreditAccountData } from "./types.js";
|
|
18
19
|
//#region src/onchain/positions/PositionsService.ts
|
|
19
20
|
/**
|
|
@@ -67,6 +68,36 @@ var PositionsService = class extends SDKConstruct {
|
|
|
67
68
|
return accounts.map((ca, i) => this.#toStrategyPosition(ca, withdrawals[i] ?? new AddressMap()));
|
|
68
69
|
}
|
|
69
70
|
/**
|
|
71
|
+
* Describes the Aave Horizon positions of a wallet, see
|
|
72
|
+
* {@link readAavePosition}. Accounts are found as
|
|
73
|
+
* {@link listStrategyPositions} finds them, zero-debt ones included: an
|
|
74
|
+
* account whose position moved to Aave carries no debt.
|
|
75
|
+
*
|
|
76
|
+
* One Aave pool holds one position per owner, however many of the owner's
|
|
77
|
+
* accounts moved into it, so each is reported once. Its `creditAccount` is
|
|
78
|
+
* one the exit can run through — with no debt and no quota, as
|
|
79
|
+
* `prepare.closeAavePosition` requires — where the owner has one, and any
|
|
80
|
+
* of the accounts otherwise.
|
|
81
|
+
**/
|
|
82
|
+
async listAavePositions(props) {
|
|
83
|
+
const { wallet, blockNumber } = props;
|
|
84
|
+
const accounts = await this.sdk.accounts.getBorrowerCreditAccounts(wallet, { includeZeroDebt: true }, blockNumber);
|
|
85
|
+
const positions = await Promise.all(accounts.map((ca) => readAavePosition(this.sdk, ca, blockNumber)));
|
|
86
|
+
const byOwner = /* @__PURE__ */ new Map();
|
|
87
|
+
positions.forEach((position, i) => {
|
|
88
|
+
const ca = accounts[i];
|
|
89
|
+
if (!position || !ca) return;
|
|
90
|
+
const key = `${position.pool}:${ca.investor ?? ca.owner}`.toLowerCase();
|
|
91
|
+
const exitable = ca.debt + ca.accruedInterest + ca.accruedFees === 0n && ca.tokens.every((t) => t.quota === 0n);
|
|
92
|
+
const known = byOwner.get(key);
|
|
93
|
+
if (!known || exitable && !known.exitable) byOwner.set(key, {
|
|
94
|
+
position,
|
|
95
|
+
exitable
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
return [...byOwner.values()].map((p) => p.position);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
70
101
|
* Returns delayed withdrawals of a strategy position
|
|
71
102
|
**/
|
|
72
103
|
async getCurrentWithdrawals(props) {
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { PERCENTAGE_FACTOR, PRICE_DECIMALS, RAY } from "../constants/math.js";
|
|
2
|
+
import { iAaveOracleAbi } from "../market/adapters/abi/aave/iAaveOracle.js";
|
|
3
|
+
import { iAaveV3PoolAbi } from "../market/adapters/abi/aave/iAaveV3Pool.js";
|
|
4
|
+
import { iPoolAddressesProviderAbi } from "../market/adapters/abi/aave/iPoolAddressesProvider.js";
|
|
5
|
+
import "../market/adapters/abi/aave/index.js";
|
|
6
|
+
import { AaveHorizonBridgeAdapterContract } from "../market/adapters/contracts/AaveHorizonBridgeAdapterContract.js";
|
|
7
|
+
import { AaveV3PoolAdapterContract } from "../market/adapters/contracts/AaveV3PoolAdapterContract.js";
|
|
8
|
+
import { calcPositionLeverage, healthFactorBps } from "../market/math.js";
|
|
9
|
+
import { strategyName } from "../market/strategyName.js";
|
|
10
|
+
import { calcTimeToLiquidationMs } from "./calcTimeToLiquidationMs.js";
|
|
11
|
+
import { erc20Abi } from "viem";
|
|
12
|
+
//#region src/onchain/positions/readAavePosition.ts
|
|
13
|
+
/**
|
|
14
|
+
* The Aave Horizon position of a credit account's owner — the investor of an
|
|
15
|
+
* RWA account — on the pool the account's credit manager moves positions to,
|
|
16
|
+
* reported beside that account.
|
|
17
|
+
*
|
|
18
|
+
* The pool and its RWAs come from the credit manager's Aave pool adapter, kept
|
|
19
|
+
* to those whose aToken a Horizon bridge adapter of the same credit manager
|
|
20
|
+
* takes against the underlying (the asset an RWA underlying wraps). Values are
|
|
21
|
+
* at the Aave oracle's prices, the ones Aave liquidates at.
|
|
22
|
+
*
|
|
23
|
+
* `undefined` when the credit manager has no such adapters, or the owner
|
|
24
|
+
* neither supplies any of those RWAs nor owes anything on the pool.
|
|
25
|
+
**/
|
|
26
|
+
async function readAavePosition(sdk, ca, blockNumber) {
|
|
27
|
+
const suite = sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
28
|
+
const market = sdk.marketRegister.findByCreditManager(ca.creditManager);
|
|
29
|
+
const underlying = market.unwrappedUnderlying;
|
|
30
|
+
const adapters = suite.creditManager.adapters.values();
|
|
31
|
+
const poolAdapter = adapters.find((p) => p instanceof AaveV3PoolAdapterContract);
|
|
32
|
+
const bridgeAdapter = adapters.find((b) => b instanceof AaveHorizonBridgeAdapterContract && b.isDebtTokenAllowed(underlying));
|
|
33
|
+
if (!poolAdapter || !bridgeAdapter) return;
|
|
34
|
+
const pool = poolAdapter.targetContract;
|
|
35
|
+
const owner = ca.investor ?? ca.owner;
|
|
36
|
+
const assets = poolAdapter.allowedAssets.filter((a) => !market.isUnderlyingLike(a));
|
|
37
|
+
const [[account, provider], [debtReserve, ...reserves]] = await Promise.all([sdk.client.multicall({
|
|
38
|
+
contracts: [{
|
|
39
|
+
address: pool,
|
|
40
|
+
abi: iAaveV3PoolAbi,
|
|
41
|
+
functionName: "getUserAccountData",
|
|
42
|
+
args: [owner]
|
|
43
|
+
}, {
|
|
44
|
+
address: pool,
|
|
45
|
+
abi: iAaveV3PoolAbi,
|
|
46
|
+
functionName: "ADDRESSES_PROVIDER"
|
|
47
|
+
}],
|
|
48
|
+
allowFailure: false,
|
|
49
|
+
batchSize: 0,
|
|
50
|
+
blockNumber
|
|
51
|
+
}), sdk.client.multicall({
|
|
52
|
+
contracts: [underlying, ...assets].map((asset) => ({
|
|
53
|
+
address: pool,
|
|
54
|
+
abi: iAaveV3PoolAbi,
|
|
55
|
+
functionName: "getReserveData",
|
|
56
|
+
args: [asset]
|
|
57
|
+
})),
|
|
58
|
+
allowFailure: false,
|
|
59
|
+
batchSize: 0,
|
|
60
|
+
blockNumber
|
|
61
|
+
})]);
|
|
62
|
+
if (!debtReserve) return;
|
|
63
|
+
const listed = assets.flatMap((token, i) => {
|
|
64
|
+
const reserve = reserves[i];
|
|
65
|
+
return reserve && bridgeAdapter.isATokenAllowed(reserve.aTokenAddress) ? [{
|
|
66
|
+
token,
|
|
67
|
+
reserve
|
|
68
|
+
}] : [];
|
|
69
|
+
});
|
|
70
|
+
if (!listed.length) return;
|
|
71
|
+
const [oracle, [owed = 0n, ...supplied]] = await Promise.all([sdk.client.readContract({
|
|
72
|
+
address: provider,
|
|
73
|
+
abi: iPoolAddressesProviderAbi,
|
|
74
|
+
functionName: "getPriceOracle",
|
|
75
|
+
blockNumber
|
|
76
|
+
}), sdk.client.multicall({
|
|
77
|
+
contracts: [debtReserve.variableDebtTokenAddress, ...listed.map((l) => l.reserve.aTokenAddress)].map((token) => ({
|
|
78
|
+
address: token,
|
|
79
|
+
abi: erc20Abi,
|
|
80
|
+
functionName: "balanceOf",
|
|
81
|
+
args: [owner]
|
|
82
|
+
})),
|
|
83
|
+
allowFailure: false,
|
|
84
|
+
batchSize: 0,
|
|
85
|
+
blockNumber
|
|
86
|
+
})]);
|
|
87
|
+
const held = listed.flatMap(({ token, reserve }, i) => {
|
|
88
|
+
const balance = supplied[i] ?? 0n;
|
|
89
|
+
return balance > 10n ? [{
|
|
90
|
+
token,
|
|
91
|
+
reserve,
|
|
92
|
+
balance
|
|
93
|
+
}] : [];
|
|
94
|
+
});
|
|
95
|
+
if (!held.length && owed === 0n) return;
|
|
96
|
+
const [underlyingPrice, ...prices] = await sdk.client.readContract({
|
|
97
|
+
address: oracle,
|
|
98
|
+
abi: iAaveOracleAbi,
|
|
99
|
+
functionName: "getAssetsPrices",
|
|
100
|
+
args: [[underlying, ...held.map((h) => h.token)]],
|
|
101
|
+
blockNumber
|
|
102
|
+
});
|
|
103
|
+
const scale = (configuration) => 10n ** (configuration >> 48n & 255n);
|
|
104
|
+
const underlyingScale = scale(debtReserve.configuration.data);
|
|
105
|
+
let totalValue = 0n;
|
|
106
|
+
held.forEach(({ reserve, balance }, i) => {
|
|
107
|
+
totalValue += balance * (prices[i] ?? 0n) * underlyingScale / (scale(reserve.configuration.data) * underlyingPrice);
|
|
108
|
+
});
|
|
109
|
+
const debtBase = account[1];
|
|
110
|
+
const currentLiquidationThreshold = account[3];
|
|
111
|
+
const healthFactor = healthFactorBps(account[5]);
|
|
112
|
+
const rate = Number(debtReserve.currentVariableBorrowRate * PERCENTAGE_FACTOR / RAY);
|
|
113
|
+
const sole = held.length === 1 ? held[0] : void 0;
|
|
114
|
+
let liquidationPrice = null;
|
|
115
|
+
if (sole && currentLiquidationThreshold > 0n) liquidationPrice = debtBase * PERCENTAGE_FACTOR * scale(sole.reserve.configuration.data) * PRICE_DECIMALS / (sole.balance * currentLiquidationThreshold * underlyingPrice);
|
|
116
|
+
const { priceOracle } = market;
|
|
117
|
+
const collaterals = held.map(({ token, balance }) => ({
|
|
118
|
+
collateral: priceOracle.toTokenAmount(token, balance),
|
|
119
|
+
quota: priceOracle.toTokenAmount(market.underlying, 0n),
|
|
120
|
+
withdrawals: []
|
|
121
|
+
}));
|
|
122
|
+
const targetCollateral = sole ? sdk.tokensMeta.mustGetToken(sole.token) : suite.accountTargetCollateral(ca.creditAccount);
|
|
123
|
+
return {
|
|
124
|
+
kind: "aave",
|
|
125
|
+
chainId: sdk.chainId,
|
|
126
|
+
creditManager: ca.creditManager,
|
|
127
|
+
creditAccount: ca.creditAccount,
|
|
128
|
+
underlyingToken: suite.underlyingToken,
|
|
129
|
+
name: targetCollateral ? strategyName(targetCollateral, suite.underlyingToken) : suite.underlyingToken.symbol,
|
|
130
|
+
curator: market.curator,
|
|
131
|
+
targetCollateral,
|
|
132
|
+
leverage: calcPositionLeverage(totalValue, owed),
|
|
133
|
+
borrowApy: rate,
|
|
134
|
+
totalDebt: market.toUnderlyingAmount(owed),
|
|
135
|
+
totalValue: market.toUnderlyingAmount(totalValue),
|
|
136
|
+
healthFactor,
|
|
137
|
+
borrowRate: {
|
|
138
|
+
total: totalValue > 0n ? Number(BigInt(rate) * owed / totalValue) : 0,
|
|
139
|
+
totalOnDebt: rate,
|
|
140
|
+
base: rate,
|
|
141
|
+
quotas: []
|
|
142
|
+
},
|
|
143
|
+
timeToLiquidation: calcTimeToLiquidationMs(healthFactor, BigInt(rate)),
|
|
144
|
+
liquidationPrice,
|
|
145
|
+
collaterals,
|
|
146
|
+
pool,
|
|
147
|
+
bridge: bridgeAdapter.bridge
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
export { readAavePosition };
|
|
@@ -12,7 +12,8 @@ function previewExitOrRepayStrategyPosition(sdk, input, operation, permanent, re
|
|
|
12
12
|
const exitTokens = [market.underlying];
|
|
13
13
|
const meta = sdk.tokensMeta.get(market.underlying);
|
|
14
14
|
if (meta && sdk.tokensMeta.isRWAUnderlying(meta)) exitTokens.push(meta.asset);
|
|
15
|
-
|
|
15
|
+
const aaveBorrows = aaveBridgeBorrows(sdk, operation.creditManager, operation.multicall);
|
|
16
|
+
return (aaveBorrows.length > 0 ? "repay" : classifyCloseOrRepay(operation.multicall, exitTokens)) === "close" ? sdkOk(previewCloseCreditAccount(sdk, operation, permanent, replay)) : previewRepayCreditAccount(sdk, input, operation, permanent, replay, aaveBorrows);
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* Previews a credit account closure: all collateral is swapped into
|
|
@@ -46,7 +47,7 @@ function previewCloseCreditAccount(sdk, operation, permanent, replay) {
|
|
|
46
47
|
* from the wallet when needed) and collateral is returned to the user
|
|
47
48
|
* in-kind.
|
|
48
49
|
*/
|
|
49
|
-
function previewRepayCreditAccount(sdk, input, operation, permanent, replay) {
|
|
50
|
+
function previewRepayCreditAccount(sdk, input, operation, permanent, replay, aaveBorrows) {
|
|
50
51
|
const { value = 0n } = input;
|
|
51
52
|
const market = sdk.marketRegister.findByCreditManager(operation.creditManager);
|
|
52
53
|
const { before, after } = replay;
|
|
@@ -56,7 +57,6 @@ function previewRepayCreditAccount(sdk, input, operation, permanent, replay) {
|
|
|
56
57
|
const collateralAdded = unwrapped.data;
|
|
57
58
|
const priced = market.priceOracle.safeConvertAssets(account.balances.toAssets(), market.underlying);
|
|
58
59
|
const suite = sdk.marketRegister.findCreditManager(operation.creditManager);
|
|
59
|
-
const aaveBorrows = aaveBridgeBorrows(sdk, operation.creditManager, operation.multicall);
|
|
60
60
|
return sdkOk({
|
|
61
61
|
operation: "RepayCreditAccount",
|
|
62
62
|
permanent,
|
|
@@ -84,10 +84,16 @@ async function resolveCreditAccount(sdk, address, options, data) {
|
|
|
84
84
|
* best-effort preview of the state after the withdrawal is claimed.
|
|
85
85
|
*
|
|
86
86
|
* A reopening is reported as `OpenCreditAccount` and never as a delayed
|
|
87
|
-
* withdrawal: an opening requests no redemption.
|
|
87
|
+
* withdrawal: an opening requests no redemption. A multicall that borrows on
|
|
88
|
+
* an empty account and does request one — the exit from Aave Horizon, which
|
|
89
|
+
* borrows to bring the position back and redeems it at once — is a delayed
|
|
90
|
+
* operation instead.
|
|
88
91
|
*/
|
|
89
92
|
async function previewMulticallOperation(sdk, input, operation, replay, blockNumber) {
|
|
90
|
-
|
|
93
|
+
const detected = detectDelayedOperation(sdk, operation.multicall);
|
|
94
|
+
if (!detected.ok) return detected;
|
|
95
|
+
const delayed = detected.data;
|
|
96
|
+
if (!delayed && replay.before.totalDebt === 0n && replay.before.quotas.toAssets(0n).length === 0 && replay.after.account.totalDebt > 0n) return previewOpenStrategyPosition(sdk, input, operation, replay);
|
|
91
97
|
let instantPreview;
|
|
92
98
|
if (isCloseOrRepay(operation.multicall)) {
|
|
93
99
|
const instant = previewExitOrRepayStrategyPosition(sdk, input, operation, false, replay);
|
|
@@ -98,9 +104,6 @@ async function previewMulticallOperation(sdk, input, operation, replay, blockNum
|
|
|
98
104
|
if (!instant.ok) return instant;
|
|
99
105
|
instantPreview = instant.data;
|
|
100
106
|
}
|
|
101
|
-
const detected = detectDelayedOperation(sdk, operation.multicall);
|
|
102
|
-
if (!detected.ok) return detected;
|
|
103
|
-
const delayed = detected.data;
|
|
104
107
|
if (!delayed) {
|
|
105
108
|
const intent = await resolveDelayedClaimIntent(sdk, operation.multicall, blockNumber);
|
|
106
109
|
if (!intent.ok) return intent;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ierc20Abi } from "../../../abi/iERC20.js";
|
|
2
|
-
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
3
1
|
import { iPoolV310Abi } from "../../../abi/310/generated.js";
|
|
2
|
+
import { ierc20Abi } from "../../../abi/iERC20.js";
|
|
4
3
|
import { sdkErr, sdkOk } from "../../../model/result.js";
|
|
5
4
|
import "../../../model/index.js";
|
|
5
|
+
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
6
6
|
//#region src/onchain/preview/preview/previewPoolPositionOperation.ts
|
|
7
7
|
function previewRead(operation) {
|
|
8
8
|
switch (operation.operation) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { errorAbis } from "../../../abi/errors.js";
|
|
2
|
-
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
3
2
|
import { generateCastTraceCall } from "./cast.js";
|
|
3
|
+
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
4
4
|
import { simulateMulticall } from "./simulateMulticall.js";
|
|
5
5
|
import { BaseError, CallExecutionError, ContractFunctionRevertedError, decodeFunctionData, decodeFunctionResult, encodeFunctionData, parseAbi } from "viem";
|
|
6
6
|
import { getAction, parseAccount } from "viem/utils";
|
|
@@ -61,6 +61,12 @@ var PositionsNamespace = class extends AbstractNamespace {
|
|
|
61
61
|
async getCurrentWithdrawals(props) {
|
|
62
62
|
return this.onchain.getCurrentWithdrawals(props);
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* {@inheritDoc IPositionsOnchainOnly.listAavePositions}
|
|
66
|
+
**/
|
|
67
|
+
async listAavePositions(props) {
|
|
68
|
+
return this.onchain.listAavePositions(props);
|
|
69
|
+
}
|
|
64
70
|
};
|
|
65
71
|
//#endregion
|
|
66
72
|
export { PositionsNamespace };
|
|
@@ -402,6 +402,32 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
404
|
/**
|
|
405
|
+
* {@inheritDoc IOpportunitiesPrepare.closeAavePosition}
|
|
406
|
+
**/
|
|
407
|
+
async closeAavePosition(position, params) {
|
|
408
|
+
const state = {};
|
|
409
|
+
try {
|
|
410
|
+
const sdk = await this.#chain(position.chainId);
|
|
411
|
+
const at = stateBlock(sdk);
|
|
412
|
+
const data = await sdk.accounts.getCreditAccountData(position.creditAccount);
|
|
413
|
+
if (!data) return refused(creditAccountNotFound(position.creditAccount), state);
|
|
414
|
+
const creditAccount = toCreditAccountSlice(data);
|
|
415
|
+
if (creditAccount.totalDebt > 0n || creditAccount.tokens.some((t) => t.quota > 0n)) return refused(creditAccountNotEmpty(position.creditAccount), state);
|
|
416
|
+
return delayedStarted(await service(sdk).closeAavePositionIntent({
|
|
417
|
+
creditAccount,
|
|
418
|
+
sdk,
|
|
419
|
+
token: params.token,
|
|
420
|
+
to: params.to,
|
|
421
|
+
owner: data.investor ?? data.owner,
|
|
422
|
+
slippage: params.slippage,
|
|
423
|
+
quotaReserve: params.quotaReserve,
|
|
424
|
+
draft: state
|
|
425
|
+
}), at);
|
|
426
|
+
} catch (e) {
|
|
427
|
+
return refused(unexpectedFailure(e), state);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
405
431
|
* {@inheritDoc IOpportunitiesPrepare.adjustLeverage}
|
|
406
432
|
**/
|
|
407
433
|
async adjustLeverage(position, params) {
|
|
@@ -789,6 +815,23 @@ function finalized(result, at) {
|
|
|
789
815
|
}
|
|
790
816
|
/**
|
|
791
817
|
* {@inheritDoc planned}
|
|
818
|
+
*
|
|
819
|
+
* A request carries one thing an instant operation does not: what it recorded
|
|
820
|
+
* for the tail, and when that tail can run.
|
|
821
|
+
**/
|
|
822
|
+
function delayedStarted(result, at) {
|
|
823
|
+
if (!result.ok) return methodError(result);
|
|
824
|
+
const { operations, state, calls, delayed } = result;
|
|
825
|
+
return sdkOk({
|
|
826
|
+
operations,
|
|
827
|
+
state,
|
|
828
|
+
calls,
|
|
829
|
+
delayed,
|
|
830
|
+
...at
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* {@inheritDoc planned}
|
|
792
835
|
**/
|
|
793
836
|
function opened(result, at) {
|
|
794
837
|
return result.ok ? sdkOk({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Timestamp, TokenAmount } from "./primitives.js";
|
|
2
2
|
import { AccountProjection } from "./previews.js";
|
|
3
|
+
import { StrategyPosition } from "./positions.js";
|
|
3
4
|
import { Address } from "viem";
|
|
4
5
|
//#region src/model/aave.d.ts
|
|
5
6
|
/**
|
|
@@ -46,4 +47,42 @@ export interface AavePositionProjection extends Pick<AccountProjection, "totalVa
|
|
|
46
47
|
**/
|
|
47
48
|
bridge: Address;
|
|
48
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* A position that lives on Aave Horizon: the RWA the account owner supplied to
|
|
52
|
+
* the Aave pool and the loan the Horizon bridge took against it in the owner's
|
|
53
|
+
* name. The credit account it was built in stays open with no debt, and the
|
|
54
|
+
* exit runs through such an account again. One pool holds one position per
|
|
55
|
+
* owner, however many accounts moved into it.
|
|
56
|
+
*
|
|
57
|
+
* Shaped like {@link StrategyPosition} so the two are shown alike. The shared
|
|
58
|
+
* fields mean what they mean there, read on Aave for the owner (the investor
|
|
59
|
+
* of an RWA account):
|
|
60
|
+
*
|
|
61
|
+
* - `creditManager` and `creditAccount` are an account of the owner the exit
|
|
62
|
+
* can run through, not necessarily the one the position was built in;
|
|
63
|
+
* - `collaterals` lists the RWA supplied to Aave in the RWA itself, not in its
|
|
64
|
+
* aToken, which Aave mints one for one; `quota` is always zero, since Aave
|
|
65
|
+
* charges none, and `withdrawals` is empty;
|
|
66
|
+
* - `totalDebt` is the variable debt owed on Aave, and `totalValue` the
|
|
67
|
+
* collateral at the Aave oracle's prices, both in the underlying;
|
|
68
|
+
* - `healthFactor` is Aave's, of everything the owner holds on the pool;
|
|
69
|
+
* - `borrowApy` and `borrowRate` are the pool's variable borrow rate, with no
|
|
70
|
+
* quota part.
|
|
71
|
+
**/
|
|
72
|
+
export interface AavePosition extends Omit<StrategyPosition, "kind" | "borrowApyAvg7D" | "netApy" | "netApyAvg7D" | "borrowRateAvg7D" | "pnl" | "error"> {
|
|
73
|
+
/**
|
|
74
|
+
* Tells this position from a credit account; not one of the
|
|
75
|
+
* {@link PositionKind}s `positions.list` returns.
|
|
76
|
+
**/
|
|
77
|
+
kind: "aave";
|
|
78
|
+
/**
|
|
79
|
+
* Aave pool the collateral is supplied to and the debt is owed on.
|
|
80
|
+
**/
|
|
81
|
+
pool: Address;
|
|
82
|
+
/**
|
|
83
|
+
* Horizon bridge that holds the owner's borrow delegation, see
|
|
84
|
+
* {@link AaveBridgeBorrow}.
|
|
85
|
+
**/
|
|
86
|
+
bridge: Address;
|
|
87
|
+
}
|
|
49
88
|
//#endregion
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Amount, Asset, AssetType, Bps, ChainId, Leverage, Timestamp, Token, TokenAmount, TxCall, UnderlyingToken } from "./primitives.js";
|
|
2
2
|
import { Curator, CuratorName } from "./curators.js";
|
|
3
|
+
import { ChainScopedFilter, FILTER_ALL, FilterAll, Filterable, isFilterSet } from "./filters.js";
|
|
3
4
|
import { DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedWithdrawCollateralIntent } from "./delayed-intents.js";
|
|
4
5
|
import { IGearboxError } from "./errors/base.js";
|
|
5
6
|
import { CreditAccountFrozenError, LiquidatorNotEligibleError, NotEmergencyLiquidatorError, PartialLiquidationImpossibleError, creditAccountFrozen, liquidatorNotEligible, notEmergencyLiquidator, partialLiquidationImpossible } from "./errors/liquidation-errors.js";
|
|
@@ -9,12 +10,11 @@ import { UnpriceableTokenError, unpriceableTokenError } from "./errors/oracle-er
|
|
|
9
10
|
import { CreditAccountNotEmptyError, CreditAccountNotFoundError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError, creditAccountNotEmpty, creditAccountNotFound, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, unexpectedFailure, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress } from "./errors/prepare-errors.js";
|
|
10
11
|
import { InvalidDelayedIntentError, MalformedTransactionError, PoolOperationPreviewError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedZapperFunctionError, malformedTransaction } from "./errors/preview-errors.js";
|
|
11
12
|
import "./errors/index.js";
|
|
12
|
-
import {
|
|
13
|
+
import { AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdjustStrategyPositionPreview, CreditOperationMarket, DelayedStrategyPositionOperationPreview, Estimated, EstimatedProjection, ExitStrategyPositionPreview, InstantStrategyPositionOperationPreview, OpenAavePositionPreview, OpenStrategyPositionPreview, OperationPreview, PoolOperationType, PoolPositionOperationPreview, PreviewOperationInput, PreviewOperationOptions, RepayStrategyPositionPreview, RoutedField, asEstimated } from "./previews.js";
|
|
13
14
|
import { DelayedReceivedAsset, InstantReceivedAsset, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, ReceivedAsset, matchesLiquidatableAccountFilter } from "./liquidations.js";
|
|
14
15
|
import { ApyBreakdown, Opportunity, OpportunityBase, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, PointRewards, PointsProgram, PoolOpportunity, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, Rewards, StrategyOpportunity, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, TokenRewards, matchesOpportunityFilter, opportunityId, poolOpportunityId, strategyOpportunityId } from "./opportunities.js";
|
|
15
16
|
import { BorrowRateBreakdown, PnlBreakdown, PointsProgramPnL, PointsRewardsPnL, PoolPosition, PoolPositionKey, PoolPositionRef, Position, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionTransaction, PositionTransactionKind, PositionsTotals, RewardsPnL, STRATEGY_POSITION_COLLATERAL_ERROR, StrategyPosition, StrategyPositionKey, StrategyPositionRef, TokenQuotaRate, TokenRewardsPnL, liquidationPositionId, matchesPositionFilter, poolPositionId, positionId, strategyPositionId } from "./positions.js";
|
|
16
|
-
import {
|
|
17
|
-
import { AaveBridgeBorrow, AavePositionProjection } from "./aave.js";
|
|
17
|
+
import { AaveBridgeBorrow, AavePosition, AavePositionProjection } from "./aave.js";
|
|
18
18
|
import { CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, GridSampling, OpportunityChartMetric, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, PoolOpportunityChartMetric, PoolPositionChartMetric, PositionChartMetric, ProtocolChartMetric, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, StrategyOpportunityChartMetric, StrategyPositionChartMetric } from "./charts.js";
|
|
19
19
|
import { AnalyticsChartQuery, AnalyticsContractOption, AnalyticsContractRef, AnalyticsCuratorOption, AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionFilterOptions, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition } from "./analytics.js";
|
|
20
20
|
import { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsContractOptionSchema, analyticsContractRefSchema, analyticsCuratorOptionSchema, analyticsPositionFilterOptionsQuerySchema, analyticsPositionFilterOptionsSchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema } from "./analytics.schema.js";
|
|
@@ -33,4 +33,4 @@ import { MerklReward, PointsReward, Reward } from "./rewards.js";
|
|
|
33
33
|
import { kycRequirementSchema, rwaProtocolSchema } from "./rwa.schema.js";
|
|
34
34
|
import { PositionClaimableWithdrawal, PositionPendingWithdrawal, PositionWithdrawals, WithdrawalOutputAmount } from "./withdrawals.js";
|
|
35
35
|
import { positionClaimableWithdrawalSchema, positionPendingWithdrawalSchema, positionWithdrawalsSchema, withdrawalOutputAmountSchema } from "./withdrawals.schema.js";
|
|
36
|
-
export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, AaveBridgeBorrow, AavePositionProjection, AccountHoldings, AccountMetrics, AccountNotMidasGreenlistedError, AccountProjection, AccountStateChange, AdjustStrategyPositionPreview, Amount, AnalyticsChartQuery, AnalyticsContractOption, AnalyticsContractRef, AnalyticsCuratorOption, AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionFilterOptions, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition, ApyBreakdown, Asset, AssetType, BorrowLimitCause, BorrowRateBreakdown, Bps, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChainFailed, ChainId, ChainMetadata, ChainScoped, ChainScopedFilter, ChainSucceeded, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, CollateralLimits, CompareTag, CompareTolerance, CreditAccountFrozenError, CreditAccountNotEmptyError, CreditAccountNotFoundError, CreditManagerPausedError, CreditOperationMarket, Curator, CuratorName, DataResponse, DataSource, DebtOutOfRangeError, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedReceivedAsset, DelayedStrategyPositionOperationPreview, DelayedWithdrawCollateralIntent, Estimated, EstimatedProjection, ExitStrategyPositionPreview, FILTER_ALL, FilterAll, Filterable, ForbiddenTokenError, GridSampling, IGearboxError, InstantReceivedAsset, InstantStrategyPositionOperationPreview, InsufficientAllowanceError, InsufficientBalanceError, InsufficientBorrowAllowanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, InvalidDelayedIntentError, KYC_REGISTRATION_LINKS, KycProtocol, KycRequirement, Leverage, LeverageLimits, LeverageOutOfRangeError, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, LiquidatorNotEligibleError, MalformedTransactionError, MarketExpiredError, MerklReward, MidasOpenAccountRequirements, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, NotEmergencyLiquidatorError, OpenAavePositionPreview, OpenStrategyPositionPreview, OperationLimitOptions, OperationPreview, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, PartialLiquidationImpossibleError, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsReward, PointsRewardsPnL, PoolOperationPreviewError, PoolOperationType, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPausedError, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionOperationPreview, PoolPositionRef, PoolSunsetError, Position, PositionChartMetric, PositionClaimableWithdrawal, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionPendingWithdrawal, PositionTransaction, PositionTransactionKind, PositionWithdrawals, PositionsTotals, PreviewOperationInput, PreviewOperationOptions, PriceFeedData, PriceFeedSummary, ProtocolChartMetric, QuotaAboveMaxError, QuotaAsset, QuotaCountExceededError, QuotaInactiveError, QuotaInputLimits, QuotaLimitReachedError, QuotaUnchangedError, RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOpenRequirementsError, RWAOperationArgs, RWAProtocol, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_PROTOCOLS, RateCurve, RateCurvePoint, ReceivedAsset, RepayStrategyPositionPreview, ReservePriceLimitedError, ResponseMetadata, Reward, Rewards, RewardsPnL, RoutedField, SDKError, SDKResult, SDKReturn, SECURITIZE_REGISTER_VAULT_TYPES, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, SafeValue, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature, StrategyOpportunity, StrategyOpportunityChartMetric, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionChartMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenQuotaRate, TokenRewards, TokenRewardsPnL, ToleranceCompareTag, TxCall, UnderlyingToken, UnexpectedFailureError, UnpriceableTokenError, UnsupportedCollateralTokenError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedTokenPairError, UnsupportedZapperFunctionError, WithdrawalInProgressError, WithdrawalOutputAmount, accountNotMidasGreenlisted, amountSchema, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsContractOptionSchema, analyticsContractRefSchema, analyticsCuratorOptionSchema, analyticsPositionFilterOptionsQuerySchema, analyticsPositionFilterOptionsSchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, curatorNameSchema, curatorSchema, dataSourceSchema, debtOutOfRange, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, forbiddenToken, instantReceivedAssetSchema, insufficientAllowance, insufficientBalance, insufficientBorrowAllowance, insufficientCollateral, insufficientPoolLiquidity, isFilterSet, kycRequirementSchema, leverageOutOfRange, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, liquidatorNotEligible, malformedTransaction, marketExpired, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, partialLiquidationImpossible, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPaused, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, poolSunset, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, protocolChartMetricSchema, quotaAboveMax, quotaAssetSchema, quotaCountExceeded, quotaInactive, quotaLimitReached, quotaUnchanged, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, reservePriceLimited, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, rwaOpenRequirementsNotMet, rwaProtocolSchema, safeValue, sdkErr, sdkOk, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress, withdrawalOutputAmountSchema };
|
|
36
|
+
export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, AaveBridgeBorrow, AavePosition, AavePositionProjection, AccountHoldings, AccountMetrics, AccountNotMidasGreenlistedError, AccountProjection, AccountStateChange, AdjustStrategyPositionPreview, Amount, AnalyticsChartQuery, AnalyticsContractOption, AnalyticsContractRef, AnalyticsCuratorOption, AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionFilterOptions, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition, ApyBreakdown, Asset, AssetType, BorrowLimitCause, BorrowRateBreakdown, Bps, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChainFailed, ChainId, ChainMetadata, ChainScoped, ChainScopedFilter, ChainSucceeded, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, CollateralLimits, CompareTag, CompareTolerance, CreditAccountFrozenError, CreditAccountNotEmptyError, CreditAccountNotFoundError, CreditManagerPausedError, CreditOperationMarket, Curator, CuratorName, DataResponse, DataSource, DebtOutOfRangeError, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedReceivedAsset, DelayedStrategyPositionOperationPreview, DelayedWithdrawCollateralIntent, Estimated, EstimatedProjection, ExitStrategyPositionPreview, FILTER_ALL, FilterAll, Filterable, ForbiddenTokenError, GridSampling, IGearboxError, InstantReceivedAsset, InstantStrategyPositionOperationPreview, InsufficientAllowanceError, InsufficientBalanceError, InsufficientBorrowAllowanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, InvalidDelayedIntentError, KYC_REGISTRATION_LINKS, KycProtocol, KycRequirement, Leverage, LeverageLimits, LeverageOutOfRangeError, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, LiquidatorNotEligibleError, MalformedTransactionError, MarketExpiredError, MerklReward, MidasOpenAccountRequirements, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, NotEmergencyLiquidatorError, OpenAavePositionPreview, OpenStrategyPositionPreview, OperationLimitOptions, OperationPreview, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, PartialLiquidationImpossibleError, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsReward, PointsRewardsPnL, PoolOperationPreviewError, PoolOperationType, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPausedError, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionOperationPreview, PoolPositionRef, PoolSunsetError, Position, PositionChartMetric, PositionClaimableWithdrawal, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionPendingWithdrawal, PositionTransaction, PositionTransactionKind, PositionWithdrawals, PositionsTotals, PreviewOperationInput, PreviewOperationOptions, PriceFeedData, PriceFeedSummary, ProtocolChartMetric, QuotaAboveMaxError, QuotaAsset, QuotaCountExceededError, QuotaInactiveError, QuotaInputLimits, QuotaLimitReachedError, QuotaUnchangedError, RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOpenRequirementsError, RWAOperationArgs, RWAProtocol, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_PROTOCOLS, RateCurve, RateCurvePoint, ReceivedAsset, RepayStrategyPositionPreview, ReservePriceLimitedError, ResponseMetadata, Reward, Rewards, RewardsPnL, RoutedField, SDKError, SDKResult, SDKReturn, SECURITIZE_REGISTER_VAULT_TYPES, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, SafeValue, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature, StrategyOpportunity, StrategyOpportunityChartMetric, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionChartMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenQuotaRate, TokenRewards, TokenRewardsPnL, ToleranceCompareTag, TxCall, UnderlyingToken, UnexpectedFailureError, UnpriceableTokenError, UnsupportedCollateralTokenError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedTokenPairError, UnsupportedZapperFunctionError, WithdrawalInProgressError, WithdrawalOutputAmount, accountNotMidasGreenlisted, amountSchema, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsContractOptionSchema, analyticsContractRefSchema, analyticsCuratorOptionSchema, analyticsPositionFilterOptionsQuerySchema, analyticsPositionFilterOptionsSchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, curatorNameSchema, curatorSchema, dataSourceSchema, debtOutOfRange, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, forbiddenToken, instantReceivedAssetSchema, insufficientAllowance, insufficientBalance, insufficientBorrowAllowance, insufficientCollateral, insufficientPoolLiquidity, isFilterSet, kycRequirementSchema, leverageOutOfRange, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, liquidatorNotEligible, malformedTransaction, marketExpired, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, partialLiquidationImpossible, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPaused, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, poolSunset, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, protocolChartMetricSchema, quotaAboveMax, quotaAssetSchema, quotaCountExceeded, quotaInactive, quotaLimitReached, quotaUnchanged, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, reservePriceLimited, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, rwaOpenRequirementsNotMet, rwaProtocolSchema, safeValue, sdkErr, sdkOk, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress, withdrawalOutputAmountSchema };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Amount, AssetType, Bps, ChainId, Leverage, Timestamp, Token, UnderlyingToken } from "./primitives.js";
|
|
2
2
|
import { Curator } from "./curators.js";
|
|
3
|
-
import { KycRequirement } from "./rwa.js";
|
|
4
3
|
import { ChainScopedFilter, Filterable } from "./filters.js";
|
|
4
|
+
import { KycRequirement } from "./rwa.js";
|
|
5
5
|
import { Address } from "viem";
|
|
6
6
|
//#region src/model/opportunities.d.ts
|
|
7
7
|
/**
|
|
@@ -21,7 +21,7 @@ import "./bots/index.js";
|
|
|
21
21
|
import { CreditAccountsServiceV310 } from "./CreditAccountsServiceV310.js";
|
|
22
22
|
import { CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, DIRECT_TRANSFERS_QUOTA, MaxAmountForQuotaProps, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, maxAmountForQuota, roundUpQuota } from "./quota-utils.js";
|
|
23
23
|
import { AccountCalculatorOperation } from "./intents/operations.js";
|
|
24
|
-
import { AddCollateralIntent, AdjustLeverageIntent, ClaimRemainder, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, ExecutionCost, FinishIntentProps, FinishIntentResult, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RefusedIntent, RepayStrategyIntent, ResumableIntent, RouteErrors, StartIntent, UpdateQuotaIntent, WithPartialState, WithdrawAssetIntent, WithdrawCeilings, WithdrawStrategyIntent } from "./intents/types.js";
|
|
24
|
+
import { AaveHoldings, AddCollateralIntent, AdjustLeverageIntent, ClaimRemainder, CloseAavePositionIntent, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, ExecutionCost, FinishIntentProps, FinishIntentResult, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RedeemingIntent, RefusedIntent, RepayStrategyIntent, ResumableIntent, RouteErrors, StartIntent, UpdateQuotaIntent, WithPartialState, WithdrawAssetIntent, WithdrawCeilings, WithdrawStrategyIntent } from "./intents/types.js";
|
|
25
25
|
import { BorrowProps, BorrowState } from "./intents/borrow.js";
|
|
26
26
|
import { LeverageBand } from "./intents/leverage-band.js";
|
|
27
27
|
import { OpenStrategyProps, OpenStrategyState } from "./intents/open-strategy.js";
|
|
@@ -34,4 +34,4 @@ import { OptimalPartialLiquidation, OptimalPartialLiquidationProps, PartialLiqui
|
|
|
34
34
|
import { LiquidationsService } from "./liquidations/LiquidationsService.js";
|
|
35
35
|
import { MultichainLiquidationsService } from "./liquidations/MultichainLiquidationsService.js";
|
|
36
36
|
import "./liquidations/index.js";
|
|
37
|
-
export { AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountToCheck, type AddCollateralIntent, type AdjustLeverageIntent, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BorrowPreviewResult, type BorrowProps, type BorrowState, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, BuildPartialLiquidationTxProps, BuildPartialLiquidationTxPropsBase, CMSlice, CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, ClaimFarmRewardsProps, type ClaimRemainder, ClaimableWithdrawal, ConnectedBotsCall, ConnectedBotsPerAccount, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountDataCall, CreditAccountFilter, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditManagerFilter, CreditManagerOperationResult, CurrentWithdrawals, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DIRECT_TRANSFERS_QUOTA, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, EmptyAccountPreviewResult, EncodableCreditAccountOperation, type ExecutionCost, type FinishIntentProps, type FinishIntentResult, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetPartialLiquidationDetailsProps, GetPartialLiquidationDetailsPropsBase, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, type LeverageBand, LiquidationsService, LoadRWALiquidatorsProps, MarketBot, MaxAmountForQuotaProps, MulticallWithFailure, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps, OpenStrategyPreviewResult, type OpenStrategyProps, type OpenStrategyState, type OperationState, OptimalPartialLiquidation, OptimalPartialLiquidationProps, PartialLiquidationParams, PartialLiquidationParamsProps, type PathLossRate, PendingWithdrawal, PeripheryCompressorV310Contract, PreviewDelayedWithdrawalProps, RWALiquidatorInfo, RedemptionLog, RedemptionLoggerV310Contract, type RefusedIntent, type RepayStrategyIntent, RequestableWithdrawal, type ResumableIntent, Rewards, type RouteErrors, SetBotProps, SetBotResult, type StartIntent, type UpdateQuotaIntent, type WithPartialState, type WithdrawAssetIntent, type WithdrawCeilings, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, fetchCreditAccountSlice, getWithdrawalCompressorAddress, iCreditAccountAbi, isPhantomToken, maxAmountForQuota, optimalPartialLiquidation, partialLiquidationParams, roundUpQuota, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
|
|
37
|
+
export { type AaveHoldings, AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountToCheck, type AddCollateralIntent, type AdjustLeverageIntent, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BorrowPreviewResult, type BorrowProps, type BorrowState, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, BuildPartialLiquidationTxProps, BuildPartialLiquidationTxPropsBase, CMSlice, CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, ClaimFarmRewardsProps, type ClaimRemainder, ClaimableWithdrawal, type CloseAavePositionIntent, ConnectedBotsCall, ConnectedBotsPerAccount, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountDataCall, CreditAccountFilter, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditManagerFilter, CreditManagerOperationResult, CurrentWithdrawals, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DIRECT_TRANSFERS_QUOTA, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, EmptyAccountPreviewResult, EncodableCreditAccountOperation, type ExecutionCost, type FinishIntentProps, type FinishIntentResult, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetPartialLiquidationDetailsProps, GetPartialLiquidationDetailsPropsBase, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, type LeverageBand, LiquidationsService, LoadRWALiquidatorsProps, MarketBot, MaxAmountForQuotaProps, MulticallWithFailure, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps, OpenStrategyPreviewResult, type OpenStrategyProps, type OpenStrategyState, type OperationState, OptimalPartialLiquidation, OptimalPartialLiquidationProps, PartialLiquidationParams, PartialLiquidationParamsProps, type PathLossRate, PendingWithdrawal, PeripheryCompressorV310Contract, PreviewDelayedWithdrawalProps, RWALiquidatorInfo, type RedeemingIntent, RedemptionLog, RedemptionLoggerV310Contract, type RefusedIntent, type RepayStrategyIntent, RequestableWithdrawal, type ResumableIntent, Rewards, type RouteErrors, SetBotProps, SetBotResult, type StartIntent, type UpdateQuotaIntent, type WithPartialState, type WithdrawAssetIntent, type WithdrawCeilings, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, fetchCreditAccountSlice, getWithdrawalCompressorAddress, iCreditAccountAbi, isPhantomToken, maxAmountForQuota, optimalPartialLiquidation, partialLiquidationParams, roundUpQuota, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
|
|
@@ -3,7 +3,7 @@ import "../../../model/index.js";
|
|
|
3
3
|
import { SDKConstruct } from "../../base/SDKConstruct.js";
|
|
4
4
|
import { IntentValidationError } from "../../validation/raise.js";
|
|
5
5
|
import { AccountCalculatorOperation } from "./operations.js";
|
|
6
|
-
import { AddCollateralIntent, AdjustLeverageIntent, ClaimRemainder, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, ExecutionCost, FinishIntentProps, FinishIntentResult, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RefusedIntent, RepayStrategyIntent, ResumableIntent, RouteErrors, StartIntent, StartIntentProps, UpdateQuotaIntent, WithPartialState, WithdrawAssetIntent, WithdrawCeilings, WithdrawStrategyIntent } from "./types.js";
|
|
6
|
+
import { AaveHoldings, AddCollateralIntent, AdjustLeverageIntent, ClaimRemainder, CloseAavePositionIntent, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, ExecutionCost, FinishIntentProps, FinishIntentResult, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RedeemingIntent, RefusedIntent, RepayStrategyIntent, ResumableIntent, RouteErrors, StartIntent, StartIntentProps, UpdateQuotaIntent, WithPartialState, WithdrawAssetIntent, WithdrawCeilings, WithdrawStrategyIntent } from "./types.js";
|
|
7
7
|
import { BorrowProps, BorrowState } from "./borrow.js";
|
|
8
8
|
import { LeverageBand, LeverageBandProps } from "./leverage-band.js";
|
|
9
9
|
import { MaxBorrowProps } from "./maxBorrow.js";
|
|
@@ -190,7 +190,25 @@ export declare class CreditAccountOperationsService extends SDKConstruct {
|
|
|
190
190
|
* does not exist for the account at all
|
|
191
191
|
*/
|
|
192
192
|
startDelayedIntent(props: StartIntentProps & {
|
|
193
|
-
intent:
|
|
193
|
+
intent: RedeemingIntent;
|
|
194
|
+
}): Promise<DelayedStartResult>;
|
|
195
|
+
/**
|
|
196
|
+
* Previews leaving `owner`'s Aave Horizon position in `token` in one
|
|
197
|
+
* transaction, see {@link CloseAavePositionIntent}.
|
|
198
|
+
*
|
|
199
|
+
* What the owner holds and owes on Aave is read here, at the block the SDK
|
|
200
|
+
* stands at; the rest is {@link startDelayedIntent}, tail included.
|
|
201
|
+
*
|
|
202
|
+
* @param props - Account slice, quota reserve and slippage, the RWA, the
|
|
203
|
+
* wallet the exit pays, and the owner the bridge resolves for the account:
|
|
204
|
+
* the investor of an RWA factory account, the borrower otherwise
|
|
205
|
+
* @returns The request transaction, the state the exit ends in and what it
|
|
206
|
+
* recorded for the tail, or `{ ok: false, error }`
|
|
207
|
+
*/
|
|
208
|
+
closeAavePositionIntent(props: StartIntentProps & {
|
|
209
|
+
token: Address;
|
|
210
|
+
to: Address;
|
|
211
|
+
owner: Address;
|
|
194
212
|
}): Promise<DelayedStartResult>;
|
|
195
213
|
/**
|
|
196
214
|
* Previews a delayable intent both ways at once: settled by the router now,
|
|
@@ -286,4 +304,4 @@ export declare class CreditAccountOperationsService extends SDKConstruct {
|
|
|
286
304
|
borrowIntent(props: BorrowProps): Promise<BorrowPreviewResult>;
|
|
287
305
|
}
|
|
288
306
|
//#endregion
|
|
289
|
-
export { type AccountCalculatorOperation, type AddCollateralIntent, type AdjustLeverageIntent, type BorrowProps, type BorrowState, type ClaimRemainder, type CreditAccountSlice, type DelayableIntent, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, type ExecutionCost, type FinishIntentProps, type FinishIntentResult, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, type LeverageBand, type OpenStrategyProps, type OpenStrategyState, type OperationState, type PathLossRate, type RefusedIntent, type RepayStrategyIntent, type ResumableIntent, type RouteErrors, type StartIntent, type UpdateQuotaIntent, type WithPartialState, type WithdrawAssetIntent, type WithdrawCeilings, type WithdrawStrategyIntent, fetchCreditAccountSlice, isPhantomToken, toCreditAccountSlice };
|
|
307
|
+
export { type AaveHoldings, type AccountCalculatorOperation, type AddCollateralIntent, type AdjustLeverageIntent, type BorrowProps, type BorrowState, type ClaimRemainder, type CloseAavePositionIntent, type CreditAccountSlice, type DelayableIntent, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, type ExecutionCost, type FinishIntentProps, type FinishIntentResult, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, type LeverageBand, type OpenStrategyProps, type OpenStrategyState, type OperationState, type PathLossRate, type RedeemingIntent, type RefusedIntent, type RepayStrategyIntent, type ResumableIntent, type RouteErrors, type StartIntent, type UpdateQuotaIntent, type WithPartialState, type WithdrawAssetIntent, type WithdrawCeilings, type WithdrawStrategyIntent, fetchCreditAccountSlice, isPhantomToken, toCreditAccountSlice };
|
|
@@ -19,7 +19,7 @@ import { Address } from "viem";
|
|
|
19
19
|
* plus the quoted amounts the preview and the tests read, plus the RWA legs
|
|
20
20
|
* that come from their own assemblers rather than from `assembleCaOperations`.
|
|
21
21
|
*/
|
|
22
|
-
export type AccountCalculatorOperation = AddCollateralOperation | IncreaseDebtOperation | DecreaseDebtOperation | SwapOperation | WithdrawCollateralOperation | QuotaUpdateOperation | WrapRwaCollateralOperation | UnwrapRwaCollateralOperation | StartDelayedWithdrawalOperation | ClaimDelayedWithdrawalOperation | AaveSupplyOperation | AaveOpenPositionOperation;
|
|
22
|
+
export type AccountCalculatorOperation = AddCollateralOperation | IncreaseDebtOperation | DecreaseDebtOperation | SwapOperation | WithdrawCollateralOperation | QuotaUpdateOperation | WrapRwaCollateralOperation | UnwrapRwaCollateralOperation | StartDelayedWithdrawalOperation | ClaimDelayedWithdrawalOperation | AaveSupplyOperation | AaveOpenPositionOperation | AaveClosePositionOperation | AaveWithdrawOperation;
|
|
23
23
|
/**
|
|
24
24
|
* Compile-time proof that the engine's operations really are the SDK's own
|
|
25
25
|
* encodable ones with the quoted amounts attached, so the two cannot drift into
|
|
@@ -253,6 +253,43 @@ export declare function buildAaveOpenPositionOperation(input: {
|
|
|
253
253
|
debtToken: Address;
|
|
254
254
|
borrowAmount: bigint;
|
|
255
255
|
}): AaveOpenPositionOperation;
|
|
256
|
+
/**
|
|
257
|
+
* Repays `repayAmount` of the owner's Aave debt out of the account and brings
|
|
258
|
+
* `aTokenAmount` of the owner's aTokens into it, through the Horizon bridge.
|
|
259
|
+
*/
|
|
260
|
+
export interface AaveClosePositionOperation {
|
|
261
|
+
type: "aaveClosePosition";
|
|
262
|
+
aToken: Address;
|
|
263
|
+
aTokenAmount: bigint;
|
|
264
|
+
debtToken: Address;
|
|
265
|
+
repayAmount: bigint;
|
|
266
|
+
calls: MultiCall[];
|
|
267
|
+
}
|
|
268
|
+
export declare function buildAaveClosePositionOperation(input: {
|
|
269
|
+
adapter: AaveHorizonBridgeAdapterContract;
|
|
270
|
+
aToken: Address;
|
|
271
|
+
aTokenAmount: bigint;
|
|
272
|
+
debtToken: Address;
|
|
273
|
+
repayAmount: bigint;
|
|
274
|
+
}): AaveClosePositionOperation;
|
|
275
|
+
/**
|
|
276
|
+
* Withdraws an asset from the Aave pool for every aToken of it on the account,
|
|
277
|
+
* one for one. The call names no amount, as the supply does, and `amount` is
|
|
278
|
+
* the balance the projection was built on.
|
|
279
|
+
*/
|
|
280
|
+
export interface AaveWithdrawOperation {
|
|
281
|
+
type: "aaveWithdraw";
|
|
282
|
+
token: Address;
|
|
283
|
+
aToken: Address;
|
|
284
|
+
amount: bigint;
|
|
285
|
+
calls: MultiCall[];
|
|
286
|
+
}
|
|
287
|
+
export declare function buildAaveWithdrawOperation(input: {
|
|
288
|
+
adapter: AaveV3PoolAdapterContract;
|
|
289
|
+
token: Address;
|
|
290
|
+
aToken: Address;
|
|
291
|
+
amount: bigint;
|
|
292
|
+
}): AaveWithdrawOperation;
|
|
256
293
|
/**
|
|
257
294
|
* What a request or a claim puts on the account right away, as opposed to what
|
|
258
295
|
* only the phantom token represents.
|