@gearbox-protocol/sdk 18.4.1-aave.1 → 18.4.1-aave.3
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/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/intents/operations.js +2 -2
- package/dist/cjs/onchain/accounts/intents/plan.js +6 -1
- package/dist/cjs/onchain/accounts/intents/tail.js +1 -1
- package/dist/cjs/onchain/index.js +10 -0
- 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 +6 -0
- package/dist/cjs/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.js +71 -12
- package/dist/cjs/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.js +5 -11
- package/dist/cjs/onchain/market/adapters/index.js +6 -0
- package/dist/cjs/onchain/market/index.js +6 -0
- package/dist/cjs/onchain/positions/projectAavePosition.js +163 -26
- 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/index.js +2 -0
- package/dist/cjs/onchain/preview/preview/previewAdjustStrategyPosition.js +3 -0
- package/dist/cjs/onchain/preview/preview/previewExitOrRepayStrategyPosition.js +3 -0
- package/dist/cjs/onchain/validation/bundles/checkAaveDelegation.js +54 -0
- package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +34 -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/prepare/PrepareApi.js +21 -3
- package/dist/cjs/sdk/preview/PreviewNamespace.js +11 -2
- 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/intents/operations.js +2 -2
- package/dist/esm/onchain/accounts/intents/plan.js +6 -1
- package/dist/esm/onchain/accounts/intents/tail.js +1 -1
- package/dist/esm/onchain/index.js +6 -1
- 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 +4 -1
- package/dist/esm/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.js +72 -13
- package/dist/esm/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.js +6 -12
- package/dist/esm/onchain/market/adapters/index.js +4 -1
- package/dist/esm/onchain/market/index.js +4 -1
- package/dist/esm/onchain/positions/projectAavePosition.js +164 -27
- 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/index.js +2 -1
- package/dist/esm/onchain/preview/preview/previewAdjustStrategyPosition.js +3 -0
- package/dist/esm/onchain/preview/preview/previewExitOrRepayStrategyPosition.js +3 -0
- package/dist/esm/onchain/validation/bundles/checkAaveDelegation.js +53 -0
- package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +34 -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/prepare/PrepareApi.js +22 -4
- package/dist/esm/sdk/preview/PreviewNamespace.js +11 -2
- package/dist/types/model/aave.d.ts +20 -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 +3 -3
- package/dist/types/model/previews.d.ts +11 -1
- 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 +2 -2
- package/dist/types/onchain/accounts/intents/operations.d.ts +9 -3
- package/dist/types/onchain/accounts/intents/types.d.ts +5 -0
- package/dist/types/onchain/index.d.ts +7 -2
- 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 +4 -1
- package/dist/types/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.d.ts +47 -10
- package/dist/types/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.d.ts +142 -4
- package/dist/types/onchain/market/adapters/index.d.ts +4 -1
- package/dist/types/onchain/market/index.d.ts +4 -1
- package/dist/types/onchain/positions/projectAavePosition.d.ts +33 -4
- 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/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/index.d.ts +2 -2
- package/dist/types/sdk/prepare/PrepareApi.d.ts +2 -2
- package/dist/types/sdk/prepare/index.d.ts +2 -2
- package/dist/types/sdk/prepare/types.d.ts +49 -11
- package/dist/types/sdk/preview/types.d.ts +4 -2
- package/package.json +1 -1
|
@@ -4,6 +4,6 @@ import { ExecutionCost, OperationState, PathLossRate, RouteErrors, WithPartialSt
|
|
|
4
4
|
import { BorrowState } from "../../onchain/accounts/intents/borrow.js";
|
|
5
5
|
import { LeverageBand } from "../../onchain/accounts/intents/leverage-band.js";
|
|
6
6
|
import { PoolOperationError } from "../../onchain/validation/bundles/checkPoolOperation.js";
|
|
7
|
-
import { AccountFlowError, AddCollateralParams, AdjustLeverageParams, BorrowAndWithdrawParams, BorrowParams, BorrowResult, DelayedStrategyResult, DepositStrategyParams, EmptyCreditAccountResult, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, LpParams, LpRedeemParams, LpResult, LpState, MaxBorrowAndWithdrawOptions, MaxBorrowParams, MaxWithdrawCollateralOptions, MoveToAaveParams, OpenAavePositionResult, OpenAavePositionState, OpenFlowError, OpenStrategyError, OpenStrategyParams, OpenStrategyResult, PoolInput, PositionInput, PrepareOptions, QuotaBufferState, RepayStrategyParams, StrategyInput, StrategyResult, StrategyRoutesResult, UpdateQuotaParams, WithRouteErrors, WithdrawCollateralParams, WithdrawStrategyParams } from "./types.js";
|
|
7
|
+
import { AccountFlowError, AddCollateralParams, AdjustLeverageParams, BorrowAndWithdrawParams, BorrowParams, BorrowResult, DelayedStrategyResult, DepositStrategyParams, EmptyCreditAccountResult, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, LpParams, LpRedeemParams, LpResult, LpState, MaxBorrowAndWithdrawOptions, MaxBorrowParams, MaxWithdrawCollateralOptions, MoveToAaveParams, OpenAavePositionParams, OpenAavePositionResult, OpenAavePositionState, OpenFlowError, OpenStrategyError, OpenStrategyParams, OpenStrategyResult, PoolInput, PositionInput, PrepareOptions, QuotaBufferState, RepayStrategyParams, StrategyInput, StrategyResult, StrategyRoutesResult, UpdateQuotaParams, WithRouteErrors, WithdrawCollateralParams, WithdrawStrategyParams } from "./types.js";
|
|
8
8
|
import { ChainOf, PrepareApi } from "./PrepareApi.js";
|
|
9
|
-
export { AccountFlowError, AddCollateralParams, AdjustLeverageParams, BorrowAndWithdrawParams, BorrowParams, BorrowResult, type BorrowState, ChainOf, type CreditAccountNotEmptyError, type CreditAccountNotFoundError, DelayedStrategyResult, DepositStrategyParams, EmptyCreditAccountResult, type ExecutionCost, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, type LeverageBand, LpParams, LpRedeemParams, LpResult, LpState, MaxBorrowAndWithdrawOptions, MaxBorrowParams, MaxWithdrawCollateralOptions, MoveToAaveParams, type MultipleDelayedWithdrawalsError, type NoDelayedRouteError, type NoRecordedIntentError, type NoStrategyTargetCollateralError, OpenAavePositionResult, OpenAavePositionState, OpenFlowError, OpenStrategyError, OpenStrategyParams, OpenStrategyResult, type OperationState, type PathLossRate, PoolInput, type PoolOperationError, PositionInput, PrepareApi, PrepareOptions, QuotaBufferState, RepayStrategyParams, type RouteErrors, StrategyInput, StrategyResult, StrategyRoutesResult, type UnexpectedFailureError, type UnsupportedCollateralTokenError, type UnsupportedTokenPairError, UpdateQuotaParams, type WithPartialState, WithRouteErrors, type WithdrawCeilings, WithdrawCollateralParams, WithdrawStrategyParams, type WithdrawalInProgressError, creditAccountNotEmpty, creditAccountNotFound, noStrategyTargetCollateral, unexpectedFailure };
|
|
9
|
+
export { AccountFlowError, AddCollateralParams, AdjustLeverageParams, BorrowAndWithdrawParams, BorrowParams, BorrowResult, type BorrowState, ChainOf, type CreditAccountNotEmptyError, type CreditAccountNotFoundError, DelayedStrategyResult, DepositStrategyParams, EmptyCreditAccountResult, type ExecutionCost, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, type LeverageBand, LpParams, LpRedeemParams, LpResult, LpState, MaxBorrowAndWithdrawOptions, MaxBorrowParams, MaxWithdrawCollateralOptions, MoveToAaveParams, type MultipleDelayedWithdrawalsError, type NoDelayedRouteError, type NoRecordedIntentError, type NoStrategyTargetCollateralError, OpenAavePositionParams, OpenAavePositionResult, OpenAavePositionState, OpenFlowError, OpenStrategyError, OpenStrategyParams, OpenStrategyResult, type OperationState, type PathLossRate, PoolInput, type PoolOperationError, PositionInput, PrepareApi, PrepareOptions, QuotaBufferState, RepayStrategyParams, type RouteErrors, StrategyInput, StrategyResult, StrategyRoutesResult, type UnexpectedFailureError, type UnsupportedCollateralTokenError, type UnsupportedTokenPairError, UpdateQuotaParams, type WithPartialState, WithRouteErrors, type WithdrawCeilings, WithdrawCollateralParams, WithdrawStrategyParams, type WithdrawalInProgressError, creditAccountNotEmpty, creditAccountNotFound, noStrategyTargetCollateral, unexpectedFailure };
|
|
@@ -397,6 +397,13 @@ export interface RepayStrategyParams extends PrepareOptions {
|
|
|
397
397
|
export interface MoveToAaveParams {
|
|
398
398
|
/** RWA collateral on the account; its whole balance moves to Aave. */
|
|
399
399
|
token: Address;
|
|
400
|
+
/**
|
|
401
|
+
* The matured mint of `token`, from `sdk.positions.getCurrentWithdrawals()`:
|
|
402
|
+
* claimed in the same transaction ahead of the supply, so what it brings
|
|
403
|
+
* moves too. Needed while the account still holds the mint's withdrawal
|
|
404
|
+
* phantom token rather than `token`.
|
|
405
|
+
**/
|
|
406
|
+
claimable?: PositionClaimableWithdrawal;
|
|
400
407
|
}
|
|
401
408
|
export interface AdjustLeverageParams extends PrepareOptions {
|
|
402
409
|
/**
|
|
@@ -463,6 +470,14 @@ export interface OpenStrategyParams extends PrepareOptions {
|
|
|
463
470
|
**/
|
|
464
471
|
creditAccount?: Address;
|
|
465
472
|
}
|
|
473
|
+
export interface OpenAavePositionParams extends OpenStrategyParams {
|
|
474
|
+
/**
|
|
475
|
+
* Wallet the account is opened for. The Aave position is this wallet's own,
|
|
476
|
+
* so what it already holds and owes on the Horizon pool counts towards the
|
|
477
|
+
* health factor and the debt Aave lends.
|
|
478
|
+
**/
|
|
479
|
+
wallet: Address;
|
|
480
|
+
}
|
|
466
481
|
export interface BorrowParams extends PrepareOptions {
|
|
467
482
|
/**
|
|
468
483
|
* Token the wallet puts up as collateral. Must be a collateral token of the
|
|
@@ -657,12 +672,27 @@ export interface IOpportunitiesPrepare {
|
|
|
657
672
|
/**
|
|
658
673
|
* Opening a leveraged position on Aave Horizon from wallet collateral.
|
|
659
674
|
*
|
|
660
|
-
* The RWA collateral
|
|
661
|
-
* one {@link openNewStrategy} prepares: a Gearbox credit account borrows
|
|
662
|
-
* subscribes to the mint. Once the mint settles
|
|
663
|
-
*
|
|
675
|
+
* The RWA collateral may be minted asynchronously, so the opening itself is
|
|
676
|
+
* the one {@link openNewStrategy} prepares: a Gearbox credit account borrows
|
|
677
|
+
* and subscribes to the mint. Once the mint settles — at once where the
|
|
678
|
+
* withdrawal compressor lists no delayed operation for the RWA — the
|
|
679
|
+
* position moves to Aave, and `state.aave` describes it there.
|
|
680
|
+
*
|
|
681
|
+
* The move is the finalizer bot's: the facade refuses to change an
|
|
682
|
+
* account's debt twice in a block, so it cannot ride on the opening even
|
|
683
|
+
* when the mint is instant. The opening grants the bot its permissions on
|
|
684
|
+
* every credit manager with a Horizon bridge adapter, whichever of the two
|
|
685
|
+
* methods prepared it; the bot is the one the market configurator lists
|
|
686
|
+
* among its periphery contracts for that bridge, and with none listed the
|
|
687
|
+
* opening grants nothing and the move is left to {@link moveToAave}.
|
|
688
|
+
*
|
|
689
|
+
* The bot borrows the whole Gearbox debt on Aave or reverts, so an opening
|
|
690
|
+
* whose debt is above what Aave lends against the collateral at its LTV is
|
|
691
|
+
* refused with `debtOutOfRange`, `maxDebt` being that amount. A market whose
|
|
692
|
+
* target collateral cannot be moved to Aave is refused with
|
|
693
|
+
* `unsupportedCollateralToken`.
|
|
664
694
|
**/
|
|
665
|
-
openAavePosition(strategy: StrategyInput, params:
|
|
695
|
+
openAavePosition(strategy: StrategyInput, params: OpenAavePositionParams): Promise<SDKReturn<OpenAavePositionResult, (OpenStrategyError | UnsupportedCollateralTokenError) & WithPartialState<OpenAavePositionState>>>;
|
|
666
696
|
/**
|
|
667
697
|
* Handing a wallet an account that holds nothing: no collateral, no debt, no
|
|
668
698
|
* quotas and no route quoted. It exists so a wallet can hold an account
|
|
@@ -787,7 +817,12 @@ export interface IOpportunitiesPrepare {
|
|
|
787
817
|
* The second half of an {@link openAavePosition}: once the RWA collateral
|
|
788
818
|
* has been minted, the position leaves the credit account for Aave Horizon.
|
|
789
819
|
*
|
|
790
|
-
*
|
|
820
|
+
* The finalizer bot does this by itself; this is the manual path, for an
|
|
821
|
+
* account the bot has not reached. It makes the bot's adapter calls, but the
|
|
822
|
+
* debt is read here rather than in the transaction, hence the margin.
|
|
823
|
+
*
|
|
824
|
+
* One transaction: a matured mint passed as `claimable` is claimed first,
|
|
825
|
+
* the whole balance of `token` is supplied to the Aave
|
|
791
826
|
* pool, the aTokens go to the account owner through the Horizon bridge,
|
|
792
827
|
* which borrows the underlying on the owner's behalf into the account, and
|
|
793
828
|
* the Gearbox loan is repaid in full with its quotas. Aave lends the debt
|
|
@@ -796,11 +831,14 @@ export interface IOpportunitiesPrepare {
|
|
|
796
831
|
* account's: owing nothing, holding that remainder.
|
|
797
832
|
*
|
|
798
833
|
* The bridge borrows as the owner, so the transaction reverts unless the
|
|
799
|
-
* owner has delegated credit on Aave's variable debt token to the bridge
|
|
800
|
-
*
|
|
801
|
-
*
|
|
802
|
-
*
|
|
803
|
-
* `
|
|
834
|
+
* owner has delegated credit on Aave's variable debt token to the bridge;
|
|
835
|
+
* `checkOperation` reports a missing delegation as
|
|
836
|
+
* `insufficientBorrowAllowance`.
|
|
837
|
+
*
|
|
838
|
+
* Refused with `unsupportedCollateralToken` when `token` is neither on the
|
|
839
|
+
* account nor brought by `claimable`, or the credit manager has no Aave
|
|
840
|
+
* adapters that take it, and with `debtOutOfRange` when the account owes
|
|
841
|
+
* nothing.
|
|
804
842
|
**/
|
|
805
843
|
moveToAave(position: PositionInput, params: MoveToAaveParams): Promise<SDKReturn<StrategyResult, (AccountFlowError | DebtOutOfRangeError | UnsupportedCollateralTokenError) & WithPartialState<OperationState>>>;
|
|
806
844
|
/**
|
|
@@ -31,8 +31,10 @@ export interface IPreview {
|
|
|
31
31
|
* credit account the position is built in while the mint settles, and the
|
|
32
32
|
* position it becomes on Aave after that.
|
|
33
33
|
*
|
|
34
|
-
* Calldata that is not an account opening
|
|
35
|
-
* `unsupportedOperation`.
|
|
34
|
+
* Calldata that is not an account opening, or opens on a credit manager
|
|
35
|
+
* that cannot move it to Aave, is refused with `unsupportedOperation`. The
|
|
36
|
+
* Aave position is the one of the opening's `onBehalfOf`, or of the sender
|
|
37
|
+
* where the calldata names no owner.
|
|
36
38
|
**/
|
|
37
39
|
openAavePosition(input: PreviewOperationInput, options?: PreviewOperationOptions): Promise<SDKReturn<OpenAavePositionPreview, PreviewOperationError>>;
|
|
38
40
|
/**
|