@gearbox-protocol/sdk 18.4.1-aave.1 → 18.4.1-aave.11
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/abi/rwa/iSecuritizeRWAFactory.js +15 -0
- package/dist/cjs/model/errors/index.js +1 -0
- package/dist/cjs/model/errors/operation-errors.js +9 -0
- package/dist/cjs/model/index.js +1 -0
- package/dist/cjs/onchain/accounts/bots/AccountBotsService.js +29 -0
- package/dist/cjs/onchain/accounts/bots/PeripheryCompressorV310Contract.js +2 -1
- package/dist/cjs/onchain/accounts/index.js +1 -1
- package/dist/cjs/onchain/accounts/intents/index.js +33 -1
- package/dist/cjs/onchain/accounts/intents/operations.js +13 -13
- package/dist/cjs/onchain/accounts/intents/plan.js +45 -23
- package/dist/cjs/onchain/accounts/intents/readAaveHoldings.js +56 -0
- package/dist/cjs/onchain/accounts/intents/realize.js +61 -23
- package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +1 -1
- package/dist/cjs/onchain/accounts/intents/utils/ledger.js +6 -6
- package/dist/cjs/onchain/chain/chains.js +1 -0
- package/dist/cjs/onchain/index.js +13 -1
- package/dist/cjs/onchain/market/ZapperRegister.js +1 -1
- package/dist/cjs/onchain/market/adapters/abi/aave/iAaveOracle.js +20 -0
- package/dist/cjs/onchain/market/adapters/abi/aave/iAaveV3Pool.js +166 -0
- package/dist/cjs/onchain/market/adapters/abi/aave/iPoolAddressesProvider.js +11 -0
- package/dist/cjs/onchain/market/adapters/abi/aave/iVariableDebtToken.js +17 -0
- package/dist/cjs/onchain/market/adapters/abi/aave/index.js +6 -0
- package/dist/cjs/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.js +27 -0
- package/dist/cjs/onchain/market/adapters/abi/index.js +8 -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 +100 -12
- package/dist/cjs/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.js +19 -11
- package/dist/cjs/onchain/market/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js +42 -5
- package/dist/cjs/onchain/market/adapters/index.js +8 -0
- package/dist/cjs/onchain/market/index.js +8 -0
- package/dist/cjs/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +9 -0
- package/dist/cjs/onchain/positions/MultichainPositionsService.js +15 -0
- package/dist/cjs/onchain/positions/PositionsService.js +31 -0
- package/dist/cjs/onchain/positions/aaveMoveCalls.js +45 -0
- package/dist/cjs/onchain/positions/projectAavePosition.js +164 -26
- package/dist/cjs/onchain/positions/readAavePosition.js +152 -0
- package/dist/cjs/onchain/preview/index.js +2 -0
- package/dist/cjs/onchain/preview/preview/aaveBridgeBorrows.js +24 -0
- package/dist/cjs/onchain/preview/preview/aaveMoveStart.js +27 -0
- package/dist/cjs/onchain/preview/preview/index.js +2 -0
- package/dist/cjs/onchain/preview/preview/previewAdjustStrategyPosition.js +3 -0
- package/dist/cjs/onchain/preview/preview/previewExitOrRepayStrategyPosition.js +5 -2
- package/dist/cjs/onchain/preview/preview/previewOpenStrategyPosition.js +4 -1
- package/dist/cjs/onchain/preview/preview/previewOperation.js +31 -8
- package/dist/cjs/onchain/validation/bundles/checkAaveDelegation.js +54 -0
- package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +36 -11
- package/dist/cjs/onchain/validation/bundles/index.js +2 -0
- package/dist/cjs/onchain/validation/checkOperation.js +16 -4
- package/dist/cjs/onchain/validation/index.js +2 -0
- package/dist/cjs/sdk/execute/ExecuteApi.js +1 -0
- package/dist/cjs/sdk/positions/PositionsNamespace.js +6 -0
- package/dist/cjs/sdk/prepare/PrepareApi.js +68 -9
- package/dist/cjs/sdk/preview/PreviewNamespace.js +11 -2
- package/dist/esm/abi/rwa/iSecuritizeRWAFactory.js +15 -0
- package/dist/esm/model/errors/index.js +2 -2
- package/dist/esm/model/errors/operation-errors.js +9 -1
- package/dist/esm/model/index.js +2 -2
- package/dist/esm/onchain/accounts/bots/AccountBotsService.js +29 -0
- package/dist/esm/onchain/accounts/bots/PeripheryCompressorV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/index.js +1 -1
- package/dist/esm/onchain/accounts/intents/index.js +34 -2
- package/dist/esm/onchain/accounts/intents/operations.js +12 -12
- package/dist/esm/onchain/accounts/intents/plan.js +46 -24
- package/dist/esm/onchain/accounts/intents/readAaveHoldings.js +55 -0
- package/dist/esm/onchain/accounts/intents/realize.js +62 -24
- package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +1 -1
- package/dist/esm/onchain/accounts/intents/utils/ledger.js +6 -6
- package/dist/esm/onchain/chain/chains.js +1 -0
- package/dist/esm/onchain/index.js +8 -2
- package/dist/esm/onchain/market/ZapperRegister.js +1 -1
- package/dist/esm/onchain/market/adapters/abi/aave/iAaveOracle.js +19 -0
- package/dist/esm/onchain/market/adapters/abi/aave/iAaveV3Pool.js +166 -0
- package/dist/esm/onchain/market/adapters/abi/aave/iPoolAddressesProvider.js +10 -0
- package/dist/esm/onchain/market/adapters/abi/aave/iVariableDebtToken.js +16 -0
- package/dist/esm/onchain/market/adapters/abi/aave/index.js +4 -1
- package/dist/esm/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.js +27 -0
- package/dist/esm/onchain/market/adapters/abi/index.js +5 -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 +101 -13
- package/dist/esm/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.js +20 -12
- package/dist/esm/onchain/market/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js +43 -6
- package/dist/esm/onchain/market/adapters/index.js +5 -1
- package/dist/esm/onchain/market/index.js +5 -1
- package/dist/esm/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +9 -0
- package/dist/esm/onchain/positions/MultichainPositionsService.js +15 -0
- package/dist/esm/onchain/positions/PositionsService.js +31 -0
- package/dist/esm/onchain/positions/aaveMoveCalls.js +44 -0
- package/dist/esm/onchain/positions/projectAavePosition.js +165 -27
- package/dist/esm/onchain/positions/readAavePosition.js +151 -0
- package/dist/esm/onchain/preview/index.js +2 -1
- package/dist/esm/onchain/preview/preview/aaveBridgeBorrows.js +23 -0
- package/dist/esm/onchain/preview/preview/aaveMoveStart.js +26 -0
- package/dist/esm/onchain/preview/preview/index.js +2 -1
- package/dist/esm/onchain/preview/preview/previewAdjustStrategyPosition.js +3 -0
- package/dist/esm/onchain/preview/preview/previewExitOrRepayStrategyPosition.js +5 -2
- package/dist/esm/onchain/preview/preview/previewOpenStrategyPosition.js +4 -1
- package/dist/esm/onchain/preview/preview/previewOperation.js +31 -8
- package/dist/esm/onchain/validation/bundles/checkAaveDelegation.js +53 -0
- package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +36 -11
- package/dist/esm/onchain/validation/bundles/index.js +2 -1
- package/dist/esm/onchain/validation/checkOperation.js +16 -4
- package/dist/esm/onchain/validation/index.js +2 -1
- package/dist/esm/sdk/execute/ExecuteApi.js +1 -0
- package/dist/esm/sdk/positions/PositionsNamespace.js +6 -0
- package/dist/esm/sdk/prepare/PrepareApi.js +69 -10
- package/dist/esm/sdk/preview/PreviewNamespace.js +11 -2
- package/dist/types/abi/rwa/iSecuritizeRWAFactory.d.ts +14 -0
- package/dist/types/model/aave.d.ts +60 -3
- package/dist/types/model/errors/index.d.ts +2 -2
- package/dist/types/model/errors/operation-errors.d.ts +19 -0
- package/dist/types/model/index.d.ts +5 -5
- package/dist/types/model/opportunities.d.ts +1 -1
- package/dist/types/model/previews.d.ts +18 -2
- package/dist/types/onchain/accounts/bots/AccountBotsService.d.ts +11 -1
- package/dist/types/onchain/accounts/bots/index.d.ts +2 -2
- package/dist/types/onchain/accounts/bots/types.d.ts +7 -1
- package/dist/types/onchain/accounts/index.d.ts +3 -3
- package/dist/types/onchain/accounts/intents/index.d.ts +21 -3
- package/dist/types/onchain/accounts/intents/operations.d.ts +27 -23
- package/dist/types/onchain/accounts/intents/plan.d.ts +23 -19
- package/dist/types/onchain/accounts/intents/readAaveHoldings.d.ts +16 -0
- package/dist/types/onchain/accounts/intents/types.d.ts +37 -14
- package/dist/types/onchain/index.d.ts +10 -4
- package/dist/types/onchain/market/adapters/abi/aave/iAaveOracle.d.ts +22 -0
- package/dist/types/onchain/market/adapters/abi/aave/iAaveV3Pool.d.ts +139 -0
- package/dist/types/onchain/market/adapters/abi/aave/iPoolAddressesProvider.d.ts +11 -0
- package/dist/types/onchain/market/adapters/abi/aave/iVariableDebtToken.d.ts +17 -0
- package/dist/types/onchain/market/adapters/abi/aave/index.d.ts +4 -1
- package/dist/types/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.d.ts +21 -0
- package/dist/types/onchain/market/adapters/abi/index.d.ts +5 -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 +59 -10
- package/dist/types/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.d.ts +147 -4
- package/dist/types/onchain/market/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.d.ts +19 -4
- package/dist/types/onchain/market/adapters/index.d.ts +5 -1
- package/dist/types/onchain/market/index.d.ts +5 -1
- package/dist/types/onchain/market/rwa/securitize/SecuritizeRWAFactory.d.ts +20 -0
- package/dist/types/onchain/market/rwa/types.d.ts +6 -0
- 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/aaveMoveCalls.d.ts +30 -0
- package/dist/types/onchain/positions/index.d.ts +2 -2
- package/dist/types/onchain/positions/projectAavePosition.d.ts +34 -4
- package/dist/types/onchain/positions/readAavePosition.d.ts +22 -0
- package/dist/types/onchain/positions/types.d.ts +25 -0
- package/dist/types/onchain/preview/index.d.ts +2 -1
- package/dist/types/onchain/preview/preview/aaveBridgeBorrows.d.ts +15 -0
- package/dist/types/onchain/preview/preview/aaveMoveStart.d.ts +18 -0
- package/dist/types/onchain/preview/preview/index.d.ts +2 -1
- package/dist/types/onchain/validation/bundles/checkAaveDelegation.d.ts +21 -0
- package/dist/types/onchain/validation/bundles/checkCreditOperation.d.ts +2 -2
- package/dist/types/onchain/validation/bundles/index.d.ts +2 -1
- package/dist/types/onchain/validation/index.d.ts +2 -1
- package/dist/types/sdk/execute/types.d.ts +7 -5
- 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 +4 -4
- package/dist/types/sdk/prepare/index.d.ts +2 -2
- package/dist/types/sdk/prepare/types.d.ts +88 -28
- package/dist/types/sdk/preview/types.d.ts +4 -2
- package/package.json +1 -1
package/dist/esm/onchain/market/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { MissingSerializedParamsError } from "../../../base/errors.js";
|
|
2
2
|
import "../../../base/index.js";
|
|
3
3
|
import { iSecuritizeRedemptionGatewayAdapterV311Abi } from "../abi/adapters/iSecuritizeRedemptionGatewayAdapterV311.js";
|
|
4
|
+
import { iSecuritizeNAVProviderAbi } from "../abi/securitize/iSecuritizeNAVProvider.js";
|
|
4
5
|
import { iSecuritizeRedemptionGatewayV311Abi } from "../abi/securitize/iSecuritizeRedemptionGatewayV311.js";
|
|
5
6
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
6
|
-
import { decodeAbiParameters, decodeFunctionData } from "viem";
|
|
7
|
+
import { decodeAbiParameters, decodeFunctionData, encodeFunctionData } from "viem";
|
|
7
8
|
//#region src/onchain/market/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.ts
|
|
8
9
|
const abi = iSecuritizeRedemptionGatewayAdapterV311Abi;
|
|
9
10
|
const protocolAbi = iSecuritizeRedemptionGatewayV311Abi;
|
|
@@ -66,17 +67,52 @@ var SecuritizeRedemptionGatewayAdapterContract = class extends AbstractAdapterCo
|
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
70
|
+
* Facade call redeeming every DS token the credit account holds above
|
|
71
|
+
* `leftoverAmount` when it executes, with the intent `extraData` logged
|
|
72
|
+
* alongside. Names no amount, so it can redeem what an earlier call of the
|
|
73
|
+
* same multicall brings in.
|
|
74
|
+
*/
|
|
75
|
+
redeemDiffCall(leftoverAmount, extraData) {
|
|
76
|
+
return {
|
|
77
|
+
target: this.address,
|
|
78
|
+
callData: encodeFunctionData({
|
|
79
|
+
abi,
|
|
80
|
+
functionName: "redeemDiff",
|
|
81
|
+
args: [leftoverAmount, extraData]
|
|
82
|
+
})
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Stable coin a redemption of `dsTokenAmount` started now is worth, at the
|
|
87
|
+
* NAV rate it would start at — what the redemption phantom token reports
|
|
88
|
+
* for it, and the amount the withdrawal compressor quotes.
|
|
89
|
+
*/
|
|
90
|
+
async redemptionValue(dsTokenAmount) {
|
|
91
|
+
const navProvider = await this.client.readContract({
|
|
92
|
+
address: this.targetContract,
|
|
93
|
+
abi: this.protocolAbi,
|
|
94
|
+
functionName: "navProvider"
|
|
95
|
+
});
|
|
96
|
+
const rate = await this.client.readContract({
|
|
97
|
+
address: navProvider,
|
|
98
|
+
abi: iSecuritizeNAVProviderAbi,
|
|
99
|
+
functionName: "rate"
|
|
100
|
+
});
|
|
101
|
+
const dsUnit = 10n ** BigInt(this.sdk.tokensMeta.decimals(this.dsToken));
|
|
102
|
+
return dsTokenAmount * 10n ** BigInt(this.sdk.tokensMeta.decimals(this.stableCoinToken)) * rate / (dsUnit * dsUnit);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* `redeem` — the request call the withdrawal compressor emits — and
|
|
106
|
+
* `redeemDiff` spend the DS token and mint the redemption phantom token; the
|
|
107
|
+
* stable coin is received when the redemption is claimed. The 2-arg
|
|
108
|
+
* overloads carry the intent `extraData`.
|
|
73
109
|
*/
|
|
74
110
|
parseDelayedWithdrawalRequest(calldata) {
|
|
75
111
|
const decoded = decodeFunctionData({
|
|
76
112
|
abi: this.abi,
|
|
77
113
|
data: calldata
|
|
78
114
|
});
|
|
79
|
-
if (decoded.functionName !== "redeem") return;
|
|
115
|
+
if (decoded.functionName !== "redeem" && decoded.functionName !== "redeemDiff") return;
|
|
80
116
|
const [, extraData] = decoded.args;
|
|
81
117
|
return {
|
|
82
118
|
phantomToken: this.redemptionPhantomToken,
|
|
@@ -101,6 +137,7 @@ var SecuritizeRedemptionGatewayAdapterContract = class extends AbstractAdapterCo
|
|
|
101
137
|
}
|
|
102
138
|
applyBalanceChanges(balances, decoded) {
|
|
103
139
|
switch (decoded.functionName) {
|
|
140
|
+
case "redeemDiff":
|
|
104
141
|
case "redeem": break;
|
|
105
142
|
case "claim": break;
|
|
106
143
|
default: super.applyBalanceChanges(balances, decoded);
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { iAaveHorizonBridgeAbi } from "./abi/aave/iAaveHorizonBridge.js";
|
|
2
|
+
import { iAaveOracleAbi } from "./abi/aave/iAaveOracle.js";
|
|
2
3
|
import { iAaveV3PoolAbi } from "./abi/aave/iAaveV3Pool.js";
|
|
4
|
+
import { iPoolAddressesProviderAbi } from "./abi/aave/iPoolAddressesProvider.js";
|
|
5
|
+
import { iVariableDebtTokenAbi } from "./abi/aave/iVariableDebtToken.js";
|
|
3
6
|
import { AdapterType } from "./types.js";
|
|
4
7
|
import { adapterActionAbi, adapterActionSelectors, adapterActionSignatures } from "./abi/actionAbi.js";
|
|
5
8
|
import { erc4626ReferralAdapterAbi } from "./abi/adapters/erc4626ReferralAdapter.js";
|
|
@@ -45,6 +48,7 @@ import { mellowDvvAdapterAbi } from "./abi/adapters/mellowDvvAdapter.js";
|
|
|
45
48
|
import { adapterConstructorAbi } from "./abi/conctructorAbi.js";
|
|
46
49
|
import { iMidasGatewayV311Abi } from "./abi/midas/iMidasGatewayV311.js";
|
|
47
50
|
import { iBaseOnRampAbi } from "./abi/securitize/iBaseOnRamp.js";
|
|
51
|
+
import { iSecuritizeNAVProviderAbi } from "./abi/securitize/iSecuritizeNAVProvider.js";
|
|
48
52
|
import { iSecuritizeOnRampAbi } from "./abi/securitize/iSecuritizeOnRamp.js";
|
|
49
53
|
import { iSecuritizeRedemptionGatewayV311Abi } from "./abi/securitize/iSecuritizeRedemptionGatewayV311.js";
|
|
50
54
|
import { iBalancerV3RouterAbi, iBalancerV3WrapperAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3RouterAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iDaiUsdsAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iInfinifiGatewayAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iMellowClaimerAbi, iMellowWrapperAbi, iMidasIssuanceVaultV310Abi, iPendleRouterAbi, iStakingRewardsAbi, iTraderJoeRouterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iVelodromeV2RouterAbi, iwstETHAbi, lidoV1_WETHGatewayAbi } from "./abi/targetContractAbi.js";
|
|
@@ -102,4 +106,4 @@ import "./contracts/index.js";
|
|
|
102
106
|
import { createAdapter } from "./createAdapter.js";
|
|
103
107
|
import "./legacyAdapterOperations.js";
|
|
104
108
|
import "./transfers.js";
|
|
105
|
-
export { AaveHorizonBridgeAdapterContract, AaveV3PoolAdapterContract, AbstractAdapterContract, AccountMigratorAdapterContract, AdapterType, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, CamelotV3AdapterContract, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, FluidDexAdapterContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LidoV1AdapterContract, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowWrapperAdapterContract, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasRedemptionVaultAdapterContract, PendlePairStatus, PendleRouterAdapterContract, PendleTokenType, SecuritizeOnRampAdapterContract, SecuritizeRedemptionGatewayAdapterContract, StakingRewardsAdapterContract, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TreehouseFastlaneAdapterContract, TreehouseRedemptionGatewayAdapterContract, TreehouseRouterAdapterContract, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpshiftVaultAdapterContract, VelodromeV2RouterAdapterContract, WstETHV1AdapterContract, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, classifyCurveOperation, createAdapter, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, erc4626ReferralAdapterAbi, fnSigToName, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, hasAdapterDeployParamsAbi, iAaveHorizonBridgeAbi, iAaveHorizonBridgeAdapterAbi, iAaveV3PoolAbi, iAaveV3PoolAdapterAbi, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iTreehouseFastlaneAbi, iTreehouseFastlaneAdapterAbi, iTreehouseRedemptionGatewayAbi, iTreehouseRedemptionGatewayAdapterAbi, iTreehouseRouterAbi, iTreehouseRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, iwstETHAbi, iwstEthv1AdapterAbi, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, parseAdapterAction, parseAdapterDeployParams, parsePosNegAmount, rewardsFromTransfers, swapFromTransfers, toNetTransfers };
|
|
109
|
+
export { AaveHorizonBridgeAdapterContract, AaveV3PoolAdapterContract, AbstractAdapterContract, AccountMigratorAdapterContract, AdapterType, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, CamelotV3AdapterContract, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, FluidDexAdapterContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LidoV1AdapterContract, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowWrapperAdapterContract, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasRedemptionVaultAdapterContract, PendlePairStatus, PendleRouterAdapterContract, PendleTokenType, SecuritizeOnRampAdapterContract, SecuritizeRedemptionGatewayAdapterContract, StakingRewardsAdapterContract, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TreehouseFastlaneAdapterContract, TreehouseRedemptionGatewayAdapterContract, TreehouseRouterAdapterContract, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpshiftVaultAdapterContract, VelodromeV2RouterAdapterContract, WstETHV1AdapterContract, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, classifyCurveOperation, createAdapter, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, erc4626ReferralAdapterAbi, fnSigToName, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, hasAdapterDeployParamsAbi, iAaveHorizonBridgeAbi, iAaveHorizonBridgeAdapterAbi, iAaveOracleAbi, iAaveV3PoolAbi, iAaveV3PoolAdapterAbi, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iPoolAddressesProviderAbi, iSecuritizeNAVProviderAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iTreehouseFastlaneAbi, iTreehouseFastlaneAdapterAbi, iTreehouseRedemptionGatewayAbi, iTreehouseRedemptionGatewayAdapterAbi, iTreehouseRouterAbi, iTreehouseRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVariableDebtTokenAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, iwstETHAbi, iwstEthv1AdapterAbi, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, parseAdapterAction, parseAdapterDeployParams, parsePosNegAmount, rewardsFromTransfers, swapFromTransfers, toNetTransfers };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { iAaveHorizonBridgeAbi } from "./adapters/abi/aave/iAaveHorizonBridge.js";
|
|
2
|
+
import { iAaveOracleAbi } from "./adapters/abi/aave/iAaveOracle.js";
|
|
2
3
|
import { iAaveV3PoolAbi } from "./adapters/abi/aave/iAaveV3Pool.js";
|
|
4
|
+
import { iPoolAddressesProviderAbi } from "./adapters/abi/aave/iPoolAddressesProvider.js";
|
|
5
|
+
import { iVariableDebtTokenAbi } from "./adapters/abi/aave/iVariableDebtToken.js";
|
|
3
6
|
import { AdapterType } from "./adapters/types.js";
|
|
4
7
|
import { adapterActionAbi, adapterActionSelectors, adapterActionSignatures } from "./adapters/abi/actionAbi.js";
|
|
5
8
|
import { erc4626ReferralAdapterAbi } from "./adapters/abi/adapters/erc4626ReferralAdapter.js";
|
|
@@ -45,6 +48,7 @@ import { mellowDvvAdapterAbi } from "./adapters/abi/adapters/mellowDvvAdapter.js
|
|
|
45
48
|
import { adapterConstructorAbi } from "./adapters/abi/conctructorAbi.js";
|
|
46
49
|
import { iMidasGatewayV311Abi } from "./adapters/abi/midas/iMidasGatewayV311.js";
|
|
47
50
|
import { iBaseOnRampAbi } from "./adapters/abi/securitize/iBaseOnRamp.js";
|
|
51
|
+
import { iSecuritizeNAVProviderAbi } from "./adapters/abi/securitize/iSecuritizeNAVProvider.js";
|
|
48
52
|
import { iSecuritizeOnRampAbi } from "./adapters/abi/securitize/iSecuritizeOnRamp.js";
|
|
49
53
|
import { iSecuritizeRedemptionGatewayV311Abi } from "./adapters/abi/securitize/iSecuritizeRedemptionGatewayV311.js";
|
|
50
54
|
import { iBalancerV3RouterAbi, iBalancerV3WrapperAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3RouterAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iDaiUsdsAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iInfinifiGatewayAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iMellowClaimerAbi, iMellowWrapperAbi, iMidasIssuanceVaultV310Abi, iPendleRouterAbi, iStakingRewardsAbi, iTraderJoeRouterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iVelodromeV2RouterAbi, iwstETHAbi, lidoV1_WETHGatewayAbi } from "./adapters/abi/targetContractAbi.js";
|
|
@@ -164,4 +168,4 @@ import { RWARegistry, RWA_COMPRESSOR_ADDRESS } from "./rwa/RWARegistry.js";
|
|
|
164
168
|
import { isRWAFactory } from "./rwa/types.js";
|
|
165
169
|
import "./rwa/index.js";
|
|
166
170
|
import "./types.js";
|
|
167
|
-
export { AaveHorizonBridgeAdapterContract, AaveV3PoolAdapterContract, AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AccountMigratorAdapterContract, AdapterType, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CamelotV3AdapterContract, CompositePriceFeedContract, ConstantPriceFeedContract, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CreditSuiteStrategy, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LidoV1AdapterContract, LinearInterestRateModelContract, MAX_LEVERAGE_BUFFER_BPS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, PARTIAL_LIQUIDATION_BUFFER_BPS, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PoolSuite, PoolV310Contract, PriceFeedRef, PriceFeedRegistry, PriceOracleV310Contract, PriceUpdatesCache, PythPriceFeed, RWARegistry, RWA_COMPRESSOR_ADDRESS, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RedstonePriceFeedContract, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, StakingRewardsAdapterContract, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TreehouseFastlaneAdapterContract, TreehouseRedemptionGatewayAdapterContract, TreehouseRouterAdapterContract, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatablePriceFeedRegistry, UpshiftVaultAdapterContract, VelodromeV2RouterAdapterContract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, bpsToRay, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, calcUtilizationRaw, classifyCurveOperation, collateralPriceInUnderlying, createAdapter, createPriceOracle, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, dominantCollateral, erc4626ReferralAdapterAbi, expectedBalanceDeltas, fnSigToName, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getRawPriceUpdates, hasAdapterDeployParamsAbi, healthFactorBps, iAaveHorizonBridgeAbi, iAaveHorizonBridgeAdapterAbi, iAaveV3PoolAbi, iAaveV3PoolAdapterAbi, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iTreehouseFastlaneAbi, iTreehouseFastlaneAdapterAbi, iTreehouseRedemptionGatewayAbi, iTreehouseRedemptionGatewayAdapterAbi, iTreehouseRouterAbi, iTreehouseRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isLPPriceFeed, isRWAFactory, isStrategyCollateral, isUpdatablePriceFeed, iwstETHAbi, iwstEthv1AdapterAbi, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, minSeizedAmount, optimalHFForPartialLiquidation, optimalPartialLiquidationAmounts, parseAdapterAction, parseAdapterDeployParams, parsePosNegAmount, pickStrategyTargetCollateral, rayToBps, rewardsFromTransfers, strategyName, swapFromTransfers, toNetTransfers, updatableDependencies, usdToNumber };
|
|
171
|
+
export { AaveHorizonBridgeAdapterContract, AaveV3PoolAdapterContract, AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AccountMigratorAdapterContract, AdapterType, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CamelotV3AdapterContract, CompositePriceFeedContract, ConstantPriceFeedContract, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CreditSuiteStrategy, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LidoV1AdapterContract, LinearInterestRateModelContract, MAX_LEVERAGE_BUFFER_BPS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, PARTIAL_LIQUIDATION_BUFFER_BPS, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PoolSuite, PoolV310Contract, PriceFeedRef, PriceFeedRegistry, PriceOracleV310Contract, PriceUpdatesCache, PythPriceFeed, RWARegistry, RWA_COMPRESSOR_ADDRESS, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RedstonePriceFeedContract, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, StakingRewardsAdapterContract, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TreehouseFastlaneAdapterContract, TreehouseRedemptionGatewayAdapterContract, TreehouseRouterAdapterContract, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatablePriceFeedRegistry, UpshiftVaultAdapterContract, VelodromeV2RouterAdapterContract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, bpsToRay, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, calcUtilizationRaw, classifyCurveOperation, collateralPriceInUnderlying, createAdapter, createPriceOracle, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, dominantCollateral, erc4626ReferralAdapterAbi, expectedBalanceDeltas, fnSigToName, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getRawPriceUpdates, hasAdapterDeployParamsAbi, healthFactorBps, iAaveHorizonBridgeAbi, iAaveHorizonBridgeAdapterAbi, iAaveOracleAbi, iAaveV3PoolAbi, iAaveV3PoolAdapterAbi, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iPoolAddressesProviderAbi, iSecuritizeNAVProviderAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iTreehouseFastlaneAbi, iTreehouseFastlaneAdapterAbi, iTreehouseRedemptionGatewayAbi, iTreehouseRedemptionGatewayAdapterAbi, iTreehouseRouterAbi, iTreehouseRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVariableDebtTokenAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isLPPriceFeed, isRWAFactory, isStrategyCollateral, isUpdatablePriceFeed, iwstETHAbi, iwstEthv1AdapterAbi, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, minSeizedAmount, optimalHFForPartialLiquidation, optimalPartialLiquidationAmounts, parseAdapterAction, parseAdapterDeployParams, parsePosNegAmount, pickStrategyTargetCollateral, rayToBps, rewardsFromTransfers, strategyName, swapFromTransfers, toNetTransfers, updatableDependencies, usdToNumber };
|
|
@@ -166,6 +166,15 @@ var SecuritizeRWAFactory = class extends BaseContract {
|
|
|
166
166
|
return this.contract.read.getWallet([creditAccount]);
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
169
|
+
* {@inheritDoc IRWAFactory.isAllowedBot}
|
|
170
|
+
*
|
|
171
|
+
* Factories below 3.12 keep no allowlist, and their wallets reject every bot.
|
|
172
|
+
*/
|
|
173
|
+
async isAllowedBot(bot) {
|
|
174
|
+
if (this.version < 312) return false;
|
|
175
|
+
return this.contract.read.isAllowedBot([bot]);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
169
178
|
* {@inheritDoc IRWAFactory.multicall}
|
|
170
179
|
*/
|
|
171
180
|
multicall(creditAccount, calls, args) {
|
|
@@ -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,44 @@
|
|
|
1
|
+
import { PERCENTAGE_FACTOR } from "../constants/math.js";
|
|
2
|
+
import { AaveHorizonBridgeAdapterContract } from "../market/adapters/contracts/AaveHorizonBridgeAdapterContract.js";
|
|
3
|
+
import { AaveV3PoolAdapterContract } from "../market/adapters/contracts/AaveV3PoolAdapterContract.js";
|
|
4
|
+
import { toTargetDecimals } from "../accounts/intents/utils/common.js";
|
|
5
|
+
//#region src/onchain/positions/aaveMoveCalls.ts
|
|
6
|
+
/**
|
|
7
|
+
* The calls that move an opening to Aave Horizon at the end of its own
|
|
8
|
+
* multicall, the ones the finalizer bot makes a block later otherwise.
|
|
9
|
+
*
|
|
10
|
+
* The whole balance of `token` is supplied to the Aave pool, the Horizon
|
|
11
|
+
* bridge hands the aTokens to the account owner and borrows against them into
|
|
12
|
+
* the account exactly what the account owes — the debt plus the quota increase
|
|
13
|
+
* fees, no interest accruing within the transaction — on an RWA market the
|
|
14
|
+
* loan is wrapped back into the underlying, the quotas are dropped and the
|
|
15
|
+
* debt is repaid in full.
|
|
16
|
+
*
|
|
17
|
+
* `undefined` when the credit manager has no Aave adapters for `token`.
|
|
18
|
+
**/
|
|
19
|
+
async function aaveMoveCalls(sdk, props) {
|
|
20
|
+
const suite = sdk.marketRegister.findCreditManager(props.creditManager);
|
|
21
|
+
const market = sdk.marketRegister.findByCreditManager(props.creditManager);
|
|
22
|
+
const debtToken = market.unwrappedUnderlying;
|
|
23
|
+
const adapters = suite.creditManager.adapters.values();
|
|
24
|
+
const poolAdapter = adapters.find((a) => a instanceof AaveV3PoolAdapterContract && a.isAssetAllowed(props.token));
|
|
25
|
+
if (!poolAdapter) return;
|
|
26
|
+
const aToken = await poolAdapter.aToken(props.token);
|
|
27
|
+
const bridgeAdapter = adapters.find((b) => b instanceof AaveHorizonBridgeAdapterContract && b.isATokenAllowed(aToken) && b.isDebtTokenAllowed(debtToken));
|
|
28
|
+
if (!bridgeAdapter) return;
|
|
29
|
+
const quotaFees = props.quotas.reduce((sum, q) => sum + q.balance * BigInt(market.pool.pqk.quotas.get(q.token)?.quotaIncreaseFee ?? 0) / PERCENTAGE_FACTOR, 0n);
|
|
30
|
+
const borrow = toTargetDecimals(props.debt + quotaFees, market.underlying, debtToken, sdk);
|
|
31
|
+
const wrap = await sdk.accounts.assembleDepositDiffCalls(0n, props.creditManager) ?? [];
|
|
32
|
+
return [
|
|
33
|
+
poolAdapter.supplyDiffCall(props.token, 0n),
|
|
34
|
+
bridgeAdapter.openPositionDiffCall(aToken, debtToken, 0n, borrow),
|
|
35
|
+
...wrap,
|
|
36
|
+
...suite.creditFacade.prepareDisableQuotas(props.quotas.map((q) => ({
|
|
37
|
+
token: q.token,
|
|
38
|
+
quota: q.balance
|
|
39
|
+
}))),
|
|
40
|
+
suite.creditFacade.prepareDecreaseDebtFull()
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { aaveMoveCalls };
|
|
@@ -1,39 +1,177 @@
|
|
|
1
|
-
import { PERCENTAGE_FACTOR, SECONDS_PER_YEAR } from "../constants/math.js";
|
|
1
|
+
import { MAX_UINT16, PERCENTAGE_FACTOR, PRICE_DECIMALS, RAY, SECONDS_PER_YEAR } 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 } from "../market/math.js";
|
|
9
|
+
import { isAddressEqual } from "viem";
|
|
2
10
|
//#region src/onchain/positions/projectAavePosition.ts
|
|
3
11
|
/**
|
|
4
|
-
* Mint settlement period, until each RWA token reports its own.
|
|
5
|
-
**/
|
|
6
|
-
const MINT_DURATION = 432e3;
|
|
7
|
-
/**
|
|
8
12
|
* Where an opening lands once it has moved to Aave Horizon, from the snapshot
|
|
9
13
|
* of the credit account it is built in.
|
|
10
14
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
15
|
+
* The move supplies the account's RWA to the pool and borrows the Gearbox
|
|
16
|
+
* debt against it on the owner's behalf, so the Aave side is read off
|
|
17
|
+
* the pool for `owner`: the reserve's LTV and liquidation threshold (its eMode
|
|
18
|
+
* category's, where the owner is in one that lists it), the Aave oracle's
|
|
19
|
+
* prices, the variable borrow rate of the underlying, and whatever the owner
|
|
20
|
+
* already holds and owes there. `healthFactor` and `liquidationPrice` are of
|
|
21
|
+
* that whole position; the values describe this opening alone.
|
|
22
|
+
*
|
|
23
|
+
* The RWA is either on the account already, and the position is on Aave at
|
|
24
|
+
* once (the opening moves it in its own transaction), or still being minted
|
|
25
|
+
* and moved by the finalizer bot once it settles: then the
|
|
26
|
+
* account holds the withdrawal phantom token of a delayed operation the
|
|
27
|
+
* withdrawal compressor lists for the credit manager, the mint takes that
|
|
28
|
+
* operation's `withdrawalLength` and is assumed to come out one for one, and
|
|
29
|
+
* the Gearbox debt accrues interest at the credit manager's rate meanwhile.
|
|
30
|
+
*
|
|
31
|
+
* `undefined` when the credit manager cannot move the account to Aave: no
|
|
32
|
+
* pool adapter lists an asset of the account or the RWA it is being minted
|
|
33
|
+
* into, or no bridge adapter takes its aToken against the underlying.
|
|
14
34
|
**/
|
|
15
|
-
function projectAavePosition(sdk, snapshot) {
|
|
35
|
+
async function projectAavePosition(sdk, snapshot, owner) {
|
|
36
|
+
const suite = sdk.marketRegister.findCreditManager(snapshot.creditManager);
|
|
16
37
|
const market = sdk.marketRegister.findByCreditManager(snapshot.creditManager);
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
38
|
+
const underlying = market.unwrappedUnderlying;
|
|
39
|
+
const adapters = suite.creditManager.adapters.values();
|
|
40
|
+
const poolAdapters = adapters.filter((p) => p instanceof AaveV3PoolAdapterContract);
|
|
41
|
+
const compressor = sdk.withdrawalCompressor;
|
|
42
|
+
const delayed = compressor?.state ? compressor.getWithdrawableAssets(snapshot.creditManager) : [];
|
|
43
|
+
let collateral;
|
|
44
|
+
let mintDuration = 0;
|
|
45
|
+
let poolAdapter;
|
|
46
|
+
for (const a of snapshot.assets) {
|
|
47
|
+
if (a.balance <= 10n || isAddressEqual(a.token, underlying)) continue;
|
|
48
|
+
const mint = delayed.find((d) => isAddressEqual(d.withdrawalPhantomToken, a.token));
|
|
49
|
+
const token = mint ? mint.underlying : a.token;
|
|
50
|
+
poolAdapter = poolAdapters.find((p) => p.isAssetAllowed(token));
|
|
51
|
+
if (poolAdapter) {
|
|
52
|
+
collateral = {
|
|
53
|
+
token,
|
|
54
|
+
balance: a.balance
|
|
55
|
+
};
|
|
56
|
+
mintDuration = mint ? Number(mint.withdrawalLength) : 0;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (!collateral || !poolAdapter) return;
|
|
61
|
+
const pool = poolAdapter.targetContract;
|
|
62
|
+
const [rwaReserve, debtReserve, account, eMode, provider] = await sdk.client.multicall({
|
|
63
|
+
contracts: [
|
|
64
|
+
{
|
|
65
|
+
address: pool,
|
|
66
|
+
abi: iAaveV3PoolAbi,
|
|
67
|
+
functionName: "getReserveData",
|
|
68
|
+
args: [collateral.token]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
address: pool,
|
|
72
|
+
abi: iAaveV3PoolAbi,
|
|
73
|
+
functionName: "getReserveData",
|
|
74
|
+
args: [underlying]
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
address: pool,
|
|
78
|
+
abi: iAaveV3PoolAbi,
|
|
79
|
+
functionName: "getUserAccountData",
|
|
80
|
+
args: [owner]
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
address: pool,
|
|
84
|
+
abi: iAaveV3PoolAbi,
|
|
85
|
+
functionName: "getUserEMode",
|
|
86
|
+
args: [owner]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
address: pool,
|
|
90
|
+
abi: iAaveV3PoolAbi,
|
|
91
|
+
functionName: "ADDRESSES_PROVIDER"
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
allowFailure: false,
|
|
95
|
+
batchSize: 0
|
|
96
|
+
});
|
|
97
|
+
const bridgeAdapter = adapters.find((b) => b instanceof AaveHorizonBridgeAdapterContract && b.isATokenAllowed(rwaReserve.aTokenAddress) && b.isDebtTokenAllowed(underlying));
|
|
98
|
+
if (!bridgeAdapter) return;
|
|
99
|
+
const oracle = await sdk.client.readContract({
|
|
100
|
+
address: provider,
|
|
101
|
+
abi: iPoolAddressesProviderAbi,
|
|
102
|
+
functionName: "getPriceOracle"
|
|
103
|
+
});
|
|
104
|
+
const [[rwaPrice, underlyingPrice], categoryParams] = await Promise.all([sdk.client.readContract({
|
|
105
|
+
address: oracle,
|
|
106
|
+
abi: iAaveOracleAbi,
|
|
107
|
+
functionName: "getAssetsPrices",
|
|
108
|
+
args: [[collateral.token, underlying]]
|
|
109
|
+
}), eMode > 0n ? sdk.client.multicall({
|
|
110
|
+
contracts: [{
|
|
111
|
+
address: pool,
|
|
112
|
+
abi: iAaveV3PoolAbi,
|
|
113
|
+
functionName: "getEModeCategoryCollateralConfig",
|
|
114
|
+
args: [Number(eMode)]
|
|
115
|
+
}, {
|
|
116
|
+
address: pool,
|
|
117
|
+
abi: iAaveV3PoolAbi,
|
|
118
|
+
functionName: "getEModeCategoryCollateralBitmap",
|
|
119
|
+
args: [Number(eMode)]
|
|
120
|
+
}],
|
|
121
|
+
allowFailure: false,
|
|
122
|
+
batchSize: 0
|
|
123
|
+
}) : void 0]);
|
|
124
|
+
const rwaConfig = rwaReserve.configuration.data;
|
|
125
|
+
let ltv = rwaConfig & 65535n;
|
|
126
|
+
let liquidationThreshold = rwaConfig >> 16n & 65535n;
|
|
127
|
+
const [category, bitmap] = categoryParams ?? [];
|
|
128
|
+
if (category && bitmap && bitmap >> BigInt(rwaReserve.id) & 1n) {
|
|
129
|
+
ltv = BigInt(category.ltv);
|
|
130
|
+
liquidationThreshold = BigInt(category.liquidationThreshold);
|
|
131
|
+
}
|
|
132
|
+
const rwaScale = 10n ** (rwaConfig >> 48n & 255n);
|
|
133
|
+
const underlyingScale = 10n ** (debtReserve.configuration.data >> 48n & 255n);
|
|
134
|
+
const collateralBase = account[0];
|
|
135
|
+
const debtBase = account[1];
|
|
136
|
+
const currentLiquidationThreshold = account[3];
|
|
137
|
+
const currentLtv = account[4];
|
|
138
|
+
const gearboxPool = { availableLiquidityChange: -snapshot.totalDebt };
|
|
139
|
+
const gearboxRate = sdk.positions.metrics(snapshot, gearboxPool).borrowRate.totalOnDebt;
|
|
140
|
+
const interest = snapshot.totalDebt * BigInt(gearboxRate) * BigInt(mintDuration) / (PERCENTAGE_FACTOR * BigInt(SECONDS_PER_YEAR));
|
|
141
|
+
const totalDebt = snapshot.totalDebt + interest;
|
|
142
|
+
const suppliedBase = collateral.balance * rwaPrice / rwaScale;
|
|
143
|
+
const owedBase = debtBase + ceilDiv(totalDebt * underlyingPrice, underlyingScale);
|
|
144
|
+
const weightedLiquidation = collateralBase * currentLiquidationThreshold + suppliedBase * liquidationThreshold;
|
|
145
|
+
const borrowableBase = (collateralBase * currentLtv + suppliedBase * ltv) / PERCENTAGE_FACTOR;
|
|
146
|
+
const totalValue = collateral.balance * rwaPrice * underlyingScale / (rwaScale * underlyingPrice);
|
|
147
|
+
const rate = Number(debtReserve.currentVariableBorrowRate * PERCENTAGE_FACTOR / RAY);
|
|
148
|
+
const uncovered = owedBase * PERCENTAGE_FACTOR - collateralBase * currentLiquidationThreshold;
|
|
149
|
+
const liquidationPrice = liquidationThreshold === 0n ? null : uncovered <= 0n ? 0n : uncovered * rwaScale * PRICE_DECIMALS / (collateral.balance * liquidationThreshold * underlyingPrice);
|
|
24
150
|
return {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
151
|
+
aave: {
|
|
152
|
+
totalValue: market.toUnderlyingAmount(totalValue),
|
|
153
|
+
totalDebt: market.toUnderlyingAmount(totalDebt),
|
|
154
|
+
netValue: market.toUnderlyingAmount(totalValue - totalDebt),
|
|
155
|
+
assets: [market.priceOracle.toTokenAmount(collateral.token, collateral.balance)],
|
|
156
|
+
healthFactor: Number(owedBase > 0n ? weightedLiquidation / owedBase : MAX_UINT16),
|
|
157
|
+
liquidationPrice,
|
|
158
|
+
borrowRate: {
|
|
159
|
+
total: totalValue > 0n ? Number(BigInt(rate) * totalDebt / totalValue) : 0,
|
|
160
|
+
totalOnDebt: rate,
|
|
161
|
+
base: rate,
|
|
162
|
+
quotas: []
|
|
163
|
+
},
|
|
164
|
+
leverage: calcPositionLeverage(totalValue, totalDebt),
|
|
165
|
+
mintPeriodInterest: market.toUnderlyingAmount(interest),
|
|
166
|
+
mintDuration,
|
|
167
|
+
estLiveAt: Number(sdk.timestamp) + mintDuration,
|
|
168
|
+
bridge: bridgeAdapter.bridge
|
|
169
|
+
},
|
|
170
|
+
maxDebt: borrowableBase > debtBase ? (borrowableBase - debtBase) * underlyingScale / underlyingPrice : 0n
|
|
36
171
|
};
|
|
37
172
|
}
|
|
173
|
+
function ceilDiv(a, b) {
|
|
174
|
+
return (a + b - 1n) / b;
|
|
175
|
+
}
|
|
38
176
|
//#endregion
|
|
39
177
|
export { projectAavePosition };
|
|
@@ -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 };
|