@gearbox-protocol/sdk 18.4.1-aave.2 → 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.
Files changed (70) hide show
  1. package/dist/cjs/model/errors/index.js +1 -0
  2. package/dist/cjs/model/errors/operation-errors.js +9 -0
  3. package/dist/cjs/model/index.js +1 -0
  4. package/dist/cjs/onchain/accounts/intents/plan.js +6 -1
  5. package/dist/cjs/onchain/accounts/intents/tail.js +1 -1
  6. package/dist/cjs/onchain/index.js +6 -0
  7. package/dist/cjs/onchain/market/adapters/abi/aave/iVariableDebtToken.js +17 -0
  8. package/dist/cjs/onchain/market/adapters/abi/aave/index.js +2 -0
  9. package/dist/cjs/onchain/market/adapters/abi/index.js +2 -0
  10. package/dist/cjs/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.js +18 -0
  11. package/dist/cjs/onchain/market/adapters/index.js +2 -0
  12. package/dist/cjs/onchain/market/index.js +2 -0
  13. package/dist/cjs/onchain/positions/projectAavePosition.js +4 -2
  14. package/dist/cjs/onchain/preview/index.js +2 -0
  15. package/dist/cjs/onchain/preview/preview/aaveBridgeBorrows.js +24 -0
  16. package/dist/cjs/onchain/preview/preview/index.js +2 -0
  17. package/dist/cjs/onchain/preview/preview/previewAdjustStrategyPosition.js +3 -0
  18. package/dist/cjs/onchain/preview/preview/previewExitOrRepayStrategyPosition.js +3 -0
  19. package/dist/cjs/onchain/validation/bundles/checkAaveDelegation.js +54 -0
  20. package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +34 -11
  21. package/dist/cjs/onchain/validation/bundles/index.js +2 -0
  22. package/dist/cjs/onchain/validation/checkOperation.js +16 -4
  23. package/dist/cjs/onchain/validation/index.js +2 -0
  24. package/dist/cjs/sdk/prepare/PrepareApi.js +2 -1
  25. package/dist/esm/model/errors/index.js +2 -2
  26. package/dist/esm/model/errors/operation-errors.js +9 -1
  27. package/dist/esm/model/index.js +2 -2
  28. package/dist/esm/onchain/accounts/intents/plan.js +6 -1
  29. package/dist/esm/onchain/accounts/intents/tail.js +1 -1
  30. package/dist/esm/onchain/index.js +4 -1
  31. package/dist/esm/onchain/market/adapters/abi/aave/iVariableDebtToken.js +16 -0
  32. package/dist/esm/onchain/market/adapters/abi/aave/index.js +2 -1
  33. package/dist/esm/onchain/market/adapters/abi/index.js +2 -1
  34. package/dist/esm/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.js +18 -0
  35. package/dist/esm/onchain/market/adapters/index.js +2 -1
  36. package/dist/esm/onchain/market/index.js +2 -1
  37. package/dist/esm/onchain/positions/projectAavePosition.js +4 -2
  38. package/dist/esm/onchain/preview/index.js +2 -1
  39. package/dist/esm/onchain/preview/preview/aaveBridgeBorrows.js +23 -0
  40. package/dist/esm/onchain/preview/preview/index.js +2 -1
  41. package/dist/esm/onchain/preview/preview/previewAdjustStrategyPosition.js +3 -0
  42. package/dist/esm/onchain/preview/preview/previewExitOrRepayStrategyPosition.js +3 -0
  43. package/dist/esm/onchain/validation/bundles/checkAaveDelegation.js +53 -0
  44. package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +34 -11
  45. package/dist/esm/onchain/validation/bundles/index.js +2 -1
  46. package/dist/esm/onchain/validation/checkOperation.js +16 -4
  47. package/dist/esm/onchain/validation/index.js +2 -1
  48. package/dist/esm/sdk/prepare/PrepareApi.js +2 -1
  49. package/dist/types/model/aave.d.ts +15 -0
  50. package/dist/types/model/errors/index.d.ts +2 -2
  51. package/dist/types/model/errors/operation-errors.d.ts +19 -0
  52. package/dist/types/model/index.d.ts +3 -3
  53. package/dist/types/model/previews.d.ts +11 -1
  54. package/dist/types/onchain/accounts/intents/types.d.ts +5 -0
  55. package/dist/types/onchain/index.d.ts +4 -1
  56. package/dist/types/onchain/market/adapters/abi/aave/iVariableDebtToken.d.ts +17 -0
  57. package/dist/types/onchain/market/adapters/abi/aave/index.d.ts +2 -1
  58. package/dist/types/onchain/market/adapters/abi/index.d.ts +2 -1
  59. package/dist/types/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.d.ts +8 -0
  60. package/dist/types/onchain/market/adapters/index.d.ts +2 -1
  61. package/dist/types/onchain/market/index.d.ts +2 -1
  62. package/dist/types/onchain/preview/index.d.ts +2 -1
  63. package/dist/types/onchain/preview/preview/aaveBridgeBorrows.d.ts +15 -0
  64. package/dist/types/onchain/preview/preview/index.d.ts +2 -1
  65. package/dist/types/onchain/validation/bundles/checkAaveDelegation.d.ts +21 -0
  66. package/dist/types/onchain/validation/bundles/checkCreditOperation.d.ts +2 -2
  67. package/dist/types/onchain/validation/bundles/index.d.ts +2 -1
  68. package/dist/types/onchain/validation/index.d.ts +2 -1
  69. package/dist/types/sdk/prepare/types.d.ts +17 -6
  70. package/package.json +1 -1
@@ -1,3 +1,4 @@
1
+ import { CheckAaveDelegationInput, checkAaveDelegation } from "./checkAaveDelegation.js";
1
2
  import { checkAccountQuotas } from "./checkAccountQuotas.js";
2
3
  import { CheckWalletInput, WalletFundingError, checkWallet } from "./checkWallet.js";
3
4
  import { CheckCollateralFundingInput, CollateralFundingPreview, checkCollateralFunding } from "./checkCollateralFunding.js";
@@ -17,4 +18,4 @@ import { CheckRWAOpeningInput, RWAOpeningError, checkRWAOpening } from "./checkR
17
18
  import { CheckRWAOpenRequirementsInput, checkRWAOpenRequirements } from "./checkRWAOpenRequirements.js";
18
19
  import { CheckWalletAllowanceInput, checkWalletAllowance } from "./checkWalletAllowance.js";
19
20
  import { CheckWalletBalanceInput, checkWalletBalance } from "./checkWalletBalance.js";
20
- export { CheckCollateralFundingInput, CheckLiquidationEligibilityInput, CheckLiquidationFundingInput, CheckMidasAccountGreenlistInput, CheckPoolFundingInput, CheckRWAOpenRequirementsInput, CheckRWAOpeningInput, CheckWalletAllowanceInput, CheckWalletBalanceInput, CheckWalletInput, CollateralFundingPreview, CreditOperationArgs, CreditOperationError, CreditOperationPreview, HealthFactorThresholds, LiquidationEligibilityError, MarketStateError, PoolOperationArgs, PoolOperationError, QuotaUpdateError, RWAOpeningError, WalletFundingError, WeighedFactors, checkAccountQuotas, checkCollateralFunding, checkCreditOperation, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLiquidationEligibility, checkLiquidationFunding, checkMarket, checkMidasAccountGreenlist, checkObtained, checkPoolFunding, checkPoolOperation, checkQuotaUpdates, checkRWAOpenRequirements, checkRWAOpening, checkWallet, checkWalletAllowance, checkWalletBalance };
21
+ export { CheckAaveDelegationInput, CheckCollateralFundingInput, CheckLiquidationEligibilityInput, CheckLiquidationFundingInput, CheckMidasAccountGreenlistInput, CheckPoolFundingInput, CheckRWAOpenRequirementsInput, CheckRWAOpeningInput, CheckWalletAllowanceInput, CheckWalletBalanceInput, CheckWalletInput, CollateralFundingPreview, CreditOperationArgs, CreditOperationError, CreditOperationPreview, HealthFactorThresholds, LiquidationEligibilityError, MarketStateError, PoolOperationArgs, PoolOperationError, QuotaUpdateError, RWAOpeningError, WalletFundingError, WeighedFactors, checkAaveDelegation, checkAccountQuotas, checkCollateralFunding, checkCreditOperation, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLiquidationEligibility, checkLiquidationFunding, checkMarket, checkMidasAccountGreenlist, checkObtained, checkPoolFunding, checkPoolOperation, checkQuotaUpdates, checkRWAOpenRequirements, checkRWAOpening, checkWallet, checkWalletAllowance, checkWalletBalance };
@@ -1,4 +1,5 @@
1
1
  import { IntentValidationError, raise } from "./raise.js";
2
+ import { CheckAaveDelegationInput, checkAaveDelegation } from "./bundles/checkAaveDelegation.js";
2
3
  import { checkAccountQuotas } from "./bundles/checkAccountQuotas.js";
3
4
  import { CheckWalletInput, WalletFundingError, checkWallet } from "./bundles/checkWallet.js";
4
5
  import { CheckCollateralFundingInput, CollateralFundingPreview, checkCollateralFunding } from "./bundles/checkCollateralFunding.js";
@@ -47,4 +48,4 @@ import { amountOf } from "./helpers/amount.js";
47
48
  import { MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM } from "./helpers/health-factor-limits.js";
48
49
  import { toToken, toTokenAmount } from "./helpers/token.js";
49
50
  import "./helpers/index.js";
50
- export { BorrowLimitArgs, CheckCollateralFundingInput, CheckLiquidationEligibilityInput, CheckLiquidationFundingInput, CheckLiquidationInput, CheckLiquidationOptions, CheckMidasAccountGreenlistInput, CheckOperationInput, CheckOperationOptions, CheckPoolFundingInput, CheckRWAOpenRequirementsInput, CheckRWAOpeningInput, CheckSimulationInput, CheckWalletAllowanceInput, CheckWalletBalanceInput, CheckWalletInput, CollateralFundingPreview, CollateralisedArgs, CreditAccountFrozenArgs, CreditManagerPausedArgs, CreditOperationArgs, CreditOperationError, CreditOperationPreview, CreditSimulationInput, DebtLimitsArgs, EmergencyLiquidatorArgs, ForbiddenTokenArgs, HealthFactorThresholds, type IntentValidationError, LeverageArgs, LiquidationEligibilityError, LiquidationValidationError, LiquidatorEligibleArgs, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM, MarketExpiredArgs, MarketStateError, MaxQuotaArgs, OperationValidationError, PartiallyLiquidatableArgs, PoolLiquidityArgs, PoolOperationArgs, PoolOperationError, PoolPausedArgs, PoolSunsetArgs, QuotaActiveArgs, QuotaChangeArgs, QuotaCountArgs, QuotaLimitArgs, QuotaUpdateError, RWAOpeningError, ReservePriceLimitedArgs, SimulationValidationError, WalletFundingError, WeighedFactors, amountOf, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkMaxQuota, checkMidasAccountGreenlist, checkObtained, checkOperation, checkPartiallyLiquidatable, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaActive, checkQuotaChange, checkQuotaCount, checkQuotaLimit, checkQuotaUpdates, checkRWAOpenRequirements, checkRWAOpening, checkReservePriceLimited, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, raise, toToken, toTokenAmount };
51
+ export { BorrowLimitArgs, CheckAaveDelegationInput, CheckCollateralFundingInput, CheckLiquidationEligibilityInput, CheckLiquidationFundingInput, CheckLiquidationInput, CheckLiquidationOptions, CheckMidasAccountGreenlistInput, CheckOperationInput, CheckOperationOptions, CheckPoolFundingInput, CheckRWAOpenRequirementsInput, CheckRWAOpeningInput, CheckSimulationInput, CheckWalletAllowanceInput, CheckWalletBalanceInput, CheckWalletInput, CollateralFundingPreview, CollateralisedArgs, CreditAccountFrozenArgs, CreditManagerPausedArgs, CreditOperationArgs, CreditOperationError, CreditOperationPreview, CreditSimulationInput, DebtLimitsArgs, EmergencyLiquidatorArgs, ForbiddenTokenArgs, HealthFactorThresholds, type IntentValidationError, LeverageArgs, LiquidationEligibilityError, LiquidationValidationError, LiquidatorEligibleArgs, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM, MarketExpiredArgs, MarketStateError, MaxQuotaArgs, OperationValidationError, PartiallyLiquidatableArgs, PoolLiquidityArgs, PoolOperationArgs, PoolOperationError, PoolPausedArgs, PoolSunsetArgs, QuotaActiveArgs, QuotaChangeArgs, QuotaCountArgs, QuotaLimitArgs, QuotaUpdateError, RWAOpeningError, ReservePriceLimitedArgs, SimulationValidationError, WalletFundingError, WeighedFactors, amountOf, checkAaveDelegation, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkMaxQuota, checkMidasAccountGreenlist, checkObtained, checkOperation, checkPartiallyLiquidatable, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaActive, checkQuotaChange, checkQuotaCount, checkQuotaLimit, checkQuotaUpdates, checkRWAOpenRequirements, checkRWAOpening, checkReservePriceLimited, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, raise, toToken, toTokenAmount };
@@ -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
  /**
@@ -814,7 +821,8 @@ export interface IOpportunitiesPrepare {
814
821
  * account the bot has not reached. It makes the bot's adapter calls, but the
815
822
  * debt is read here rather than in the transaction, hence the margin.
816
823
  *
817
- * One transaction: the whole balance of `token` is supplied to the Aave
824
+ * One transaction: a matured mint passed as `claimable` is claimed first,
825
+ * the whole balance of `token` is supplied to the Aave
818
826
  * pool, the aTokens go to the account owner through the Horizon bridge,
819
827
  * which borrows the underlying on the owner's behalf into the account, and
820
828
  * the Gearbox loan is repaid in full with its quotas. Aave lends the debt
@@ -823,11 +831,14 @@ export interface IOpportunitiesPrepare {
823
831
  * account's: owing nothing, holding that remainder.
824
832
  *
825
833
  * The bridge borrows as the owner, so the transaction reverts unless the
826
- * owner has delegated credit on Aave's variable debt token to the bridge.
827
- *
828
- * Refused with `unsupportedCollateralToken` when `token` is not on the
829
- * account or the credit manager has no Aave adapters that take it, and with
830
- * `debtOutOfRange` when the account owes nothing.
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.
831
842
  **/
832
843
  moveToAave(position: PositionInput, params: MoveToAaveParams): Promise<SDKReturn<StrategyResult, (AccountFlowError | DebtOutOfRangeError | UnsupportedCollateralTokenError) & WithPartialState<OperationState>>>;
833
844
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "18.4.1-aave.2",
3
+ "version": "18.4.1-aave.3",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {