@gearbox-protocol/sdk 18.4.1-aave.4 → 18.4.1-aave.5

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 (38) hide show
  1. package/dist/cjs/abi/rwa/iSecuritizeRWAFactory.js +15 -0
  2. package/dist/cjs/onchain/accounts/intents/plan.js +1 -0
  3. package/dist/cjs/onchain/accounts/intents/realize.js +6 -3
  4. package/dist/cjs/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.js +10 -3
  5. package/dist/cjs/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +9 -0
  6. package/dist/esm/abi/rwa/iSecuritizeRWAFactory.js +15 -0
  7. package/dist/esm/dev/AccountOpener.js +1 -1
  8. package/dist/esm/dev/withdrawalUtils.js +1 -1
  9. package/dist/esm/history/trace/extractTransfers.js +1 -1
  10. package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
  11. package/dist/esm/onchain/accounts/intents/plan.js +1 -0
  12. package/dist/esm/onchain/accounts/intents/realize.js +6 -3
  13. package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  14. package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  15. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  16. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  17. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  18. package/dist/esm/onchain/base/TokensMeta.js +3 -3
  19. package/dist/esm/onchain/core/createAddressProvider.js +1 -1
  20. package/dist/esm/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.js +10 -3
  21. package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
  22. package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
  23. package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
  24. package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
  25. package/dist/esm/onchain/market/rwa/createDegenNFT.js +1 -1
  26. package/dist/esm/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +9 -0
  27. package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
  28. package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
  29. package/dist/esm/onchain/preview/preview/previewPoolPositionOperation.js +2 -2
  30. package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
  31. package/dist/types/abi/rwa/iSecuritizeRWAFactory.d.ts +14 -0
  32. package/dist/types/onchain/accounts/intents/plan.d.ts +2 -1
  33. package/dist/types/onchain/accounts/intents/types.d.ts +2 -1
  34. package/dist/types/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.d.ts +5 -1
  35. package/dist/types/onchain/market/rwa/securitize/SecuritizeRWAFactory.d.ts +20 -0
  36. package/dist/types/onchain/market/rwa/types.d.ts +6 -0
  37. package/dist/types/sdk/prepare/types.d.ts +6 -2
  38. package/package.json +1 -1
@@ -79,6 +79,21 @@ const iSecuritizeRWAFactoryAbi = [
79
79
  }],
80
80
  stateMutability: "view"
81
81
  },
82
+ {
83
+ type: "function",
84
+ name: "isAllowedBot",
85
+ inputs: [{
86
+ name: "bot",
87
+ type: "address",
88
+ internalType: "address"
89
+ }],
90
+ outputs: [{
91
+ name: "",
92
+ type: "bool",
93
+ internalType: "bool"
94
+ }],
95
+ stateMutability: "view"
96
+ },
82
97
  {
83
98
  type: "function",
84
99
  name: "isCreditAccount",
@@ -137,6 +137,7 @@ function planMoveToAave(intent, view) {
137
137
  token: intent.token,
138
138
  borrow: withMargin(view.debt)
139
139
  },
140
+ ...view.rwaAsset ? [convert(view.rwaAsset, view.underlying, RAISED)] : [],
140
141
  clearQuotas(),
141
142
  repay(view.debt)
142
143
  ];
@@ -371,16 +371,19 @@ async function realize(steps, props) {
371
371
  const aToken = await aavePoolAdapter(sdk, suite, step.token).aToken(step.token);
372
372
  const aTokenAmount = ledger.balanceOf(aToken);
373
373
  assertHolds(aToken, aTokenAmount, "aaveOpenPosition");
374
+ const debtToken = rwaAsset ?? underlying;
375
+ const borrowAmount = require_onchain_accounts_intents_utils_common.toTargetDecimals(step.borrow, underlying, debtToken, sdk);
374
376
  push(require_onchain_accounts_intents_operations.buildAaveOpenPositionOperation({
375
377
  adapter: aaveBridgeAdapter(sdk, suite, step.token, {
376
378
  aToken,
377
- debtToken: underlying
379
+ debtToken
378
380
  }),
379
381
  aToken,
380
382
  aTokenAmount,
381
- debtToken: underlying,
382
- borrowAmount: step.borrow
383
+ debtToken,
384
+ borrowAmount
383
385
  }));
386
+ raised = borrowAmount;
384
387
  break;
385
388
  }
386
389
  }
@@ -13,6 +13,7 @@ let viem = require("viem");
13
13
  const abi = require_onchain_market_adapters_abi_adapters_iAaveHorizonBridgeAdapter.iAaveHorizonBridgeAdapterAbi;
14
14
  const protocolAbi = require_onchain_market_adapters_abi_aave_iAaveHorizonBridge.iAaveHorizonBridgeAbi;
15
15
  const FINALIZER_BOT_TYPE = (0, viem.stringToHex)("BOT::AAVE_HORIZON_FINALIZER", { size: 32 });
16
+ const SECURITIZE_FINALIZER_BOT_TYPE = (0, viem.stringToHex)("BOT::AAVE_HORIZON_SECURITIZE", { size: 32 });
16
17
  /**
17
18
  * The bridge a finalizer bot serves, from its `serialize()`:
18
19
  * `abi.encode(pool, bridge)`. `undefined` where the bot did not serialize.
@@ -123,17 +124,23 @@ var AaveHorizonBridgeAdapterContract = class extends require_onchain_market_adap
123
124
  }
124
125
  }
125
126
  /**
126
- * Every account on this credit manager is finished by the Horizon finalizer
127
+ * Every account on this credit manager is finished by a Horizon finalizer
127
128
  * bot a block after its own transaction, so opening one grants the bot its
128
129
  * permissions. The bot is the one the market configurator lists among its
129
130
  * periphery contracts for this adapter's bridge, the latest version where
130
131
  * there are several; nothing where it lists none.
132
+ *
133
+ * An account opened through an RWA factory belongs to the factory's wallet,
134
+ * which needs the Securitize finalizer and grants only the bots the factory
135
+ * allows; nothing where it does not allow that bot.
131
136
  */
132
137
  async openingCalls() {
133
138
  const { configurator } = this.sdk.marketRegister.findByCreditManager(this.creditManager);
134
- const [bot] = (await this.sdk.accounts.bots.getMarketBots(configurator.address)).filter(({ baseParams }) => require_onchain_utils_hex.hexEq(baseParams.contractType, FINALIZER_BOT_TYPE) && require_onchain_utils_hex.hexEq(finalizerBridge(baseParams.serializedParams), this.bridge)).sort((a, b) => Number(b.baseParams.version - a.baseParams.version));
139
+ const { creditFacade, rwaFactory } = this.sdk.marketRegister.findCreditManager(this.creditManager);
140
+ const botType = rwaFactory ? SECURITIZE_FINALIZER_BOT_TYPE : FINALIZER_BOT_TYPE;
141
+ const [bot] = (await this.sdk.accounts.bots.getMarketBots(configurator.address)).filter(({ baseParams }) => require_onchain_utils_hex.hexEq(baseParams.contractType, botType) && require_onchain_utils_hex.hexEq(finalizerBridge(baseParams.serializedParams), this.bridge)).sort((a, b) => Number(b.baseParams.version - a.baseParams.version));
135
142
  if (!bot) return [];
136
- const { creditFacade } = this.sdk.marketRegister.findCreditManager(this.creditManager);
143
+ if (rwaFactory && !await rwaFactory.isAllowedBot(bot.baseParams.addr)) return [];
137
144
  return [creditFacade.prepareSetBotPermissions(bot.baseParams.addr, bot.requiredPermissions)];
138
145
  }
139
146
  stateHuman(raw) {
@@ -167,6 +167,15 @@ var SecuritizeRWAFactory = class extends require_onchain_base_BaseContract.BaseC
167
167
  return this.contract.read.getWallet([creditAccount]);
168
168
  }
169
169
  /**
170
+ * {@inheritDoc IRWAFactory.isAllowedBot}
171
+ *
172
+ * Factories below 3.12 keep no allowlist, and their wallets reject every bot.
173
+ */
174
+ async isAllowedBot(bot) {
175
+ if (this.version < 312) return false;
176
+ return this.contract.read.isAllowedBot([bot]);
177
+ }
178
+ /**
170
179
  * {@inheritDoc IRWAFactory.multicall}
171
180
  */
172
181
  multicall(creditAccount, calls, args) {
@@ -78,6 +78,21 @@ const iSecuritizeRWAFactoryAbi = [
78
78
  }],
79
79
  stateMutability: "view"
80
80
  },
81
+ {
82
+ type: "function",
83
+ name: "isAllowedBot",
84
+ inputs: [{
85
+ name: "bot",
86
+ type: "address",
87
+ internalType: "address"
88
+ }],
89
+ outputs: [{
90
+ name: "",
91
+ type: "bool",
92
+ internalType: "bool"
93
+ }],
94
+ stateMutability: "view"
95
+ },
81
96
  {
82
97
  type: "function",
83
98
  name: "isCreditAccount",
@@ -1,5 +1,5 @@
1
- import { iCreditFacadeV310Abi } from "../abi/310/generated.js";
2
1
  import { ierc20Abi } from "../abi/iERC20.js";
2
+ import { iCreditFacadeV310Abi } from "../abi/310/generated.js";
3
3
  import { AddressMap } from "../onchain/utils/AddressMap.js";
4
4
  import { AddressSet } from "../onchain/utils/AddressSet.js";
5
5
  import { AssetsMap } from "../onchain/utils/AssetsMap.js";
@@ -1,6 +1,6 @@
1
+ import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
1
2
  import { getNetworkType } from "../onchain/chain/chains.js";
2
3
  import { getWithdrawalCompressorAddress } from "../onchain/accounts/withdrawal-compressor/addresses.js";
3
- import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
4
4
  import "../onchain/index.js";
5
5
  import { iMidasDataFeedAbi, iMidasRedemptionVaultAbi, midasGatewayAbi, midasRedeemerAbi, midasRedemptionVaultPhantomTokenAbi, securitizeRedeemerAbi, securitizeRedemptionGatewayAbi, securitizeRedemptionPhantomTokenAbi } from "./withdrawalAbi.js";
6
6
  import { erc20Abi, hexToString, parseAbi, parseEther } from "viem";
@@ -1,5 +1,5 @@
1
- import { iCreditFacadeV310Abi } from "../../abi/310/generated.js";
2
1
  import { ierc20Abi } from "../../abi/iERC20.js";
2
+ import { iCreditFacadeV310Abi } from "../../abi/310/generated.js";
3
3
  import { AddressMap } from "../../onchain/utils/AddressMap.js";
4
4
  import "../../onchain/index.js";
5
5
  import { UnexpectedFacadeEventOrderError } from "./errors.js";
@@ -1,3 +1,5 @@
1
+ import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
2
+ import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
1
3
  import { AP_REWARDS_COMPRESSOR } from "../constants/address-provider.js";
2
4
  import { ADDRESS_0X0 } from "../constants/addresses.js";
3
5
  import { MAX_UINT256 } from "../constants/math.js";
@@ -8,8 +10,6 @@ import "../base/index.js";
8
10
  import { AccountBotsService } from "./bots/AccountBotsService.js";
9
11
  import "./bots/index.js";
10
12
  import { rewardsCompressorAbi } from "../../abi/compressors/rewardsCompressor.js";
11
- import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
12
- import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
13
13
  import { expectedBalanceDeltas } from "../market/credit/expectedBalanceDeltas.js";
14
14
  import "../market/index.js";
15
15
  import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
@@ -136,6 +136,7 @@ function planMoveToAave(intent, view) {
136
136
  token: intent.token,
137
137
  borrow: withMargin(view.debt)
138
138
  },
139
+ ...view.rwaAsset ? [convert(view.rwaAsset, view.underlying, RAISED)] : [],
139
140
  clearQuotas(),
140
141
  repay(view.debt)
141
142
  ];
@@ -370,16 +370,19 @@ async function realize(steps, props) {
370
370
  const aToken = await aavePoolAdapter(sdk, suite, step.token).aToken(step.token);
371
371
  const aTokenAmount = ledger.balanceOf(aToken);
372
372
  assertHolds(aToken, aTokenAmount, "aaveOpenPosition");
373
+ const debtToken = rwaAsset ?? underlying;
374
+ const borrowAmount = toTargetDecimals(step.borrow, underlying, debtToken, sdk);
373
375
  push(buildAaveOpenPositionOperation({
374
376
  adapter: aaveBridgeAdapter(sdk, suite, step.token, {
375
377
  aToken,
376
- debtToken: underlying
378
+ debtToken
377
379
  }),
378
380
  aToken,
379
381
  aTokenAmount,
380
- debtToken: underlying,
381
- borrowAmount: step.borrow
382
+ debtToken,
383
+ borrowAmount
382
384
  }));
385
+ raised = borrowAmount;
383
386
  break;
384
387
  }
385
388
  }
@@ -1,3 +1,4 @@
1
+ import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
1
2
  import { AddressSet } from "../../utils/AddressSet.js";
2
3
  import { bytes32ToString } from "../../utils/bytes32ToString.js";
3
4
  import { ADDRESS_0X0 } from "../../constants/addresses.js";
@@ -19,7 +20,6 @@ import { SecuritizeLiquidatorContract } from "../../market/rwa/securitize/Securi
19
20
  import "../../market/rwa/securitize/index.js";
20
21
  import "../../market/index.js";
21
22
  import { LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./constants.js";
22
- import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
23
23
  import { optimalPartialLiquidation, partialLiquidationParams } from "./partialLiquidation.js";
24
24
  import { skipLiquidatableAccount } from "./skipLiquidatableAccount.js";
25
25
  import { isAddressEqual } from "viem";
@@ -1,9 +1,9 @@
1
+ import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
1
2
  import { BaseContract } from "../../base/BaseContract.js";
2
3
  import "../../base/index.js";
3
4
  import { sdkErr, sdkOk } from "../../../model/result.js";
4
5
  import "../../../model/index.js";
5
6
  import { decodeDelayedIntent } from "./intent-codec.js";
6
- import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
7
7
  //#region src/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.ts
8
8
  const abi = iRedemptionLoggerV310Abi;
9
9
  /**
@@ -1,5 +1,5 @@
1
- import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
2
1
  import { iWithdrawalCompressorV310Abi } from "../../../abi/IWithdrawalCompressorV310.js";
2
+ import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
3
3
  //#region src/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.ts
4
4
  const abi = iWithdrawalCompressorV310Abi;
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
2
1
  import { iWithdrawalCompressorV311Abi } from "../../../abi/IWithdrawalCompressorV311.js";
2
+ import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
3
3
  //#region src/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.ts
4
4
  const abi = iWithdrawalCompressorV311Abi;
5
5
  /**
@@ -1,6 +1,6 @@
1
+ import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
1
2
  import { encodeDelayedIntent } from "./intent-codec.js";
2
3
  import { AbstractWithdrawalCompressorContract, iCreditAccountAbi, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal } from "./AbstractWithdrawalCompressorContract.js";
3
- import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
4
4
  import { toWithdrawalStatus } from "./types.js";
5
5
  //#region src/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.ts
6
6
  const abi = iWithdrawalCompressorV313Abi;
@@ -1,12 +1,12 @@
1
+ import { iExpirableAbi } from "../../abi/iExpirable.js";
2
+ import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
3
+ import { iVersionAbi } from "../../abi/iVersion.js";
1
4
  import { AddressMap } from "../utils/AddressMap.js";
2
5
  import { AddressSet } from "../utils/AddressSet.js";
3
6
  import { bytes32ToString } from "../utils/bytes32ToString.js";
4
7
  import { getAssetType } from "../chain/chains.js";
5
8
  import { formatBN } from "../utils/formatter.js";
6
9
  import "../utils/index.js";
7
- import { iExpirableAbi } from "../../abi/iExpirable.js";
8
- import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
9
- import { iVersionAbi } from "../../abi/iVersion.js";
10
10
  import { SdkRWADataNotLoadedError } from "../core/errors.js";
11
11
  import { executeMulticallBatches } from "../utils/viem/executeMulticallBatches.js";
12
12
  import { decodeAbiParameters } from "viem";
@@ -1,8 +1,8 @@
1
+ import { iVersionAbi } from "../../abi/iVersion.js";
1
2
  import "../constants/address-provider.js";
2
3
  import { isV310 } from "../constants/versions.js";
3
4
  import "../constants/index.js";
4
5
  import { hexEq } from "../utils/hex.js";
5
- import { iVersionAbi } from "../../abi/iVersion.js";
6
6
  import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
7
7
  //#region src/onchain/core/createAddressProvider.ts
8
8
  const OVERRIDE_ADDRESSES = {};
@@ -12,6 +12,7 @@ import { decodeAbiParameters, decodeFunctionData, encodeFunctionData, stringToHe
12
12
  const abi = iAaveHorizonBridgeAdapterAbi;
13
13
  const protocolAbi = iAaveHorizonBridgeAbi;
14
14
  const FINALIZER_BOT_TYPE = stringToHex("BOT::AAVE_HORIZON_FINALIZER", { size: 32 });
15
+ const SECURITIZE_FINALIZER_BOT_TYPE = stringToHex("BOT::AAVE_HORIZON_SECURITIZE", { size: 32 });
15
16
  /**
16
17
  * The bridge a finalizer bot serves, from its `serialize()`:
17
18
  * `abi.encode(pool, bridge)`. `undefined` where the bot did not serialize.
@@ -122,17 +123,23 @@ var AaveHorizonBridgeAdapterContract = class extends AbstractAdapterContract {
122
123
  }
123
124
  }
124
125
  /**
125
- * Every account on this credit manager is finished by the Horizon finalizer
126
+ * Every account on this credit manager is finished by a Horizon finalizer
126
127
  * bot a block after its own transaction, so opening one grants the bot its
127
128
  * permissions. The bot is the one the market configurator lists among its
128
129
  * periphery contracts for this adapter's bridge, the latest version where
129
130
  * there are several; nothing where it lists none.
131
+ *
132
+ * An account opened through an RWA factory belongs to the factory's wallet,
133
+ * which needs the Securitize finalizer and grants only the bots the factory
134
+ * allows; nothing where it does not allow that bot.
130
135
  */
131
136
  async openingCalls() {
132
137
  const { configurator } = this.sdk.marketRegister.findByCreditManager(this.creditManager);
133
- const [bot] = (await this.sdk.accounts.bots.getMarketBots(configurator.address)).filter(({ baseParams }) => hexEq(baseParams.contractType, FINALIZER_BOT_TYPE) && hexEq(finalizerBridge(baseParams.serializedParams), this.bridge)).sort((a, b) => Number(b.baseParams.version - a.baseParams.version));
138
+ const { creditFacade, rwaFactory } = this.sdk.marketRegister.findCreditManager(this.creditManager);
139
+ const botType = rwaFactory ? SECURITIZE_FINALIZER_BOT_TYPE : FINALIZER_BOT_TYPE;
140
+ const [bot] = (await this.sdk.accounts.bots.getMarketBots(configurator.address)).filter(({ baseParams }) => hexEq(baseParams.contractType, botType) && hexEq(finalizerBridge(baseParams.serializedParams), this.bridge)).sort((a, b) => Number(b.baseParams.version - a.baseParams.version));
134
141
  if (!bot) return [];
135
- const { creditFacade } = this.sdk.marketRegister.findCreditManager(this.creditManager);
142
+ if (rwaFactory && !await rwaFactory.isAllowedBot(bot.baseParams.addr)) return [];
136
143
  return [creditFacade.prepareSetBotPermissions(bot.baseParams.addr, bot.requiredPermissions)];
137
144
  }
138
145
  stateHuman(raw) {
@@ -1,5 +1,5 @@
1
- import { AbstractAdapterContract } from "./AbstractAdapter.js";
2
1
  import { accountMigratorAbi } from "../../../../abi/AccountMigrator.js";
2
+ import { AbstractAdapterContract } from "./AbstractAdapter.js";
3
3
  //#region src/onchain/market/adapters/contracts/AccountMigratorAdapterContract.ts
4
4
  const abi = accountMigratorAbi;
5
5
  const protocolAbi = accountMigratorAbi;
@@ -1,6 +1,6 @@
1
+ import { ierc4626AdapterAbi } from "../../../../abi/ierc4626Adapter.js";
1
2
  import { MissingSerializedParamsError } from "../../../base/errors.js";
2
3
  import "../../../base/index.js";
3
- import { ierc4626AdapterAbi } from "../../../../abi/ierc4626Adapter.js";
4
4
  import { iERC4626Abi } from "../abi/targetContractAbi.js";
5
5
  import { fnSigToName, swapFromTransfers } from "../transferHelpers.js";
6
6
  import { AbstractAdapterContract } from "./AbstractAdapter.js";
@@ -1,7 +1,7 @@
1
+ import { iPausableAbi } from "../../../abi/iPausable.js";
1
2
  import { iCreditFacadeMulticallV310Abi, iCreditFacadeV310Abi } from "../../../abi/310/generated.js";
2
3
  import { BaseContract } from "../../base/BaseContract.js";
3
4
  import "../../base/index.js";
4
- import { iPausableAbi } from "../../../abi/iPausable.js";
5
5
  //#region src/onchain/market/credit/CreditFacadeV310BaseContract.ts
6
6
  const abi = [
7
7
  ...iCreditFacadeV310Abi,
@@ -1,3 +1,4 @@
1
+ import { iPausableAbi } from "../../../abi/iPausable.js";
1
2
  import { iPoolV310Abi } from "../../../abi/310/generated.js";
2
3
  import { AddressMap } from "../../utils/AddressMap.js";
3
4
  import { RAY } from "../../constants/math.js";
@@ -7,7 +8,6 @@ import "../../utils/index.js";
7
8
  import { SdkRWADataNotLoadedError } from "../../core/errors.js";
8
9
  import { BaseContract } from "../../base/BaseContract.js";
9
10
  import "../../base/index.js";
10
- import { iPausableAbi } from "../../../abi/iPausable.js";
11
11
  //#region src/onchain/market/pool/PoolV310Contract.ts
12
12
  const abi = [...iPoolV310Abi, ...iPausableAbi];
13
13
  var PoolV310Contract = class extends BaseContract {
@@ -1,6 +1,6 @@
1
+ import { iVersionAbi } from "../../../abi/iVersion.js";
1
2
  import { bytes32ToString } from "../../utils/bytes32ToString.js";
2
3
  import "../../utils/index.js";
3
- import { iVersionAbi } from "../../../abi/iVersion.js";
4
4
  import { iMidasDegenNFTAbi } from "../../../abi/rwa/iMidasDegenNFT.js";
5
5
  import { DEGEN_NFT_MIDAS } from "./midas/constants.js";
6
6
  import { MidasDegenNFT } from "./midas/MidasDegenNFT.js";
@@ -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) {
@@ -1,5 +1,5 @@
1
- import { ZapperContract } from "./ZapperContract.js";
2
1
  import { iethZapperAbi } from "../../../abi/iETHZapper.js";
2
+ import { ZapperContract } from "./ZapperContract.js";
3
3
  //#region src/onchain/market/zapper/IETHZapperContract.ts
4
4
  const abi = iethZapperAbi;
5
5
  var IETHZapperContract = class extends ZapperContract {
@@ -1,8 +1,8 @@
1
+ import { iZapperAbi } from "../../../abi/iZapper.js";
1
2
  import { BaseContract } from "../../base/BaseContract.js";
2
3
  import "../../base/index.js";
3
4
  import { sdkErr, sdkOk } from "../../../model/result.js";
4
5
  import "../../../model/index.js";
5
- import { iZapperAbi } from "../../../abi/iZapper.js";
6
6
  //#region src/onchain/market/zapper/ZapperContract.ts
7
7
  /**
8
8
  * Base contract for every Gearbox zapper. Specialized zappers (e.g.
@@ -1,8 +1,8 @@
1
- import { iPoolV310Abi } from "../../../abi/310/generated.js";
2
1
  import { ierc20Abi } from "../../../abi/iERC20.js";
2
+ import { iZapperAbi } from "../../../abi/iZapper.js";
3
+ import { iPoolV310Abi } from "../../../abi/310/generated.js";
3
4
  import { sdkErr, sdkOk } from "../../../model/result.js";
4
5
  import "../../../model/index.js";
5
- import { iZapperAbi } from "../../../abi/iZapper.js";
6
6
  //#region src/onchain/preview/preview/previewPoolPositionOperation.ts
7
7
  function previewRead(operation) {
8
8
  switch (operation.operation) {
@@ -1,6 +1,6 @@
1
1
  import { errorAbis } from "../../../abi/errors.js";
2
- import { generateCastTraceCall } from "./cast.js";
3
2
  import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
3
+ import { generateCastTraceCall } from "./cast.js";
4
4
  import { simulateMulticall } from "./simulateMulticall.js";
5
5
  import { BaseError, CallExecutionError, ContractFunctionRevertedError, decodeFunctionData, decodeFunctionResult, encodeFunctionData, parseAbi } from "viem";
6
6
  import { getAction, parseAccount } from "viem/utils";
@@ -71,6 +71,20 @@ export declare const iSecuritizeRWAFactoryAbi: readonly [{
71
71
  readonly internalType: "address";
72
72
  }];
73
73
  readonly stateMutability: "view";
74
+ }, {
75
+ readonly type: "function";
76
+ readonly name: "isAllowedBot";
77
+ readonly inputs: readonly [{
78
+ readonly name: "bot";
79
+ readonly type: "address";
80
+ readonly internalType: "address";
81
+ }];
82
+ readonly outputs: readonly [{
83
+ readonly name: "";
84
+ readonly type: "bool";
85
+ readonly internalType: "bool";
86
+ }];
87
+ readonly stateMutability: "view";
74
88
  }, {
75
89
  readonly type: "function";
76
90
  readonly name: "isCreditAccount";
@@ -117,7 +117,8 @@ export type Step = {
117
117
  } |
118
118
  /**
119
119
  * Hands every aToken of `token` the account holds to its owner through the
120
- * Horizon bridge, which borrows `borrow` of the underlying into the account.
120
+ * Horizon bridge, which borrows `borrow`, in underlying units, into the
121
+ * account: of the underlying, or of the asset an RWA underlying wraps.
121
122
  */
122
123
  {
123
124
  kind: "aaveOpenPosition";
@@ -450,7 +450,8 @@ export interface RepayStrategyIntent {
450
450
  * borrows the underlying on the owner's behalf into the account, and the loan
451
451
  * is repaid in full with its quotas. The bridge borrows the debt plus a 10bps
452
452
  * margin for the interest of the blocks still to come; whatever the facade
453
- * does not take stays on the account.
453
+ * does not take stays on the account. On an RWA market Aave lends the asset
454
+ * the underlying wraps, which is wrapped before the repayment.
454
455
  *
455
456
  * The bridge borrows as the owner, so the owner must have delegated credit on
456
457
  * the Aave variable debt token to the bridge beforehand.
@@ -317,11 +317,15 @@ export declare class AaveHorizonBridgeAdapterContract extends AbstractAdapterCon
317
317
  amount: bigint;
318
318
  } | undefined;
319
319
  /**
320
- * Every account on this credit manager is finished by the Horizon finalizer
320
+ * Every account on this credit manager is finished by a Horizon finalizer
321
321
  * bot a block after its own transaction, so opening one grants the bot its
322
322
  * permissions. The bot is the one the market configurator lists among its
323
323
  * periphery contracts for this adapter's bridge, the latest version where
324
324
  * there are several; nothing where it lists none.
325
+ *
326
+ * An account opened through an RWA factory belongs to the factory's wallet,
327
+ * which needs the Securitize finalizer and grants only the bots the factory
328
+ * allows; nothing where it does not allow that bot.
325
329
  */
326
330
  openingCalls(): Promise<MultiCall[]>;
327
331
  stateHuman(raw?: boolean): {
@@ -82,6 +82,20 @@ declare const abi: readonly [{
82
82
  readonly internalType: "address";
83
83
  }];
84
84
  readonly stateMutability: "view";
85
+ }, {
86
+ readonly type: "function";
87
+ readonly name: "isAllowedBot";
88
+ readonly inputs: readonly [{
89
+ readonly name: "bot";
90
+ readonly type: "address";
91
+ readonly internalType: "address";
92
+ }];
93
+ readonly outputs: readonly [{
94
+ readonly name: "";
95
+ readonly type: "bool";
96
+ readonly internalType: "bool";
97
+ }];
98
+ readonly stateMutability: "view";
85
99
  }, {
86
100
  readonly type: "function";
87
101
  readonly name: "isCreditAccount";
@@ -493,6 +507,12 @@ export declare class SecuritizeRWAFactory extends BaseContract<abi> implements I
493
507
  * {@inheritDoc IRWAFactory.getWallet}
494
508
  */
495
509
  getWallet(creditAccount: Address): Promise<Address>;
510
+ /**
511
+ * {@inheritDoc IRWAFactory.isAllowedBot}
512
+ *
513
+ * Factories below 3.12 keep no allowlist, and their wallets reject every bot.
514
+ */
515
+ isAllowedBot(bot: Address): Promise<boolean>;
496
516
  /**
497
517
  * {@inheritDoc IRWAFactory.multicall}
498
518
  */
@@ -147,6 +147,12 @@ export interface IRWAFactory<T extends RWAFactoryType = RWAFactoryType> extends
147
147
  * @param creditAccount - credit account address
148
148
  **/
149
149
  getWallet(creditAccount: Address): Promise<Address>;
150
+ /**
151
+ * Whether the factory's wallets let a multicall grant `bot` permissions;
152
+ * they reject every other `setBotPermissions`.
153
+ * @param bot - bot address
154
+ **/
155
+ isAllowedBot(bot: Address): Promise<boolean>;
150
156
  /**
151
157
  * Creates a raw transaction to perform operations on a credit account.
152
158
  * Similar to {@link CreditFacadeV310Contract.multicall}.
@@ -684,7 +684,10 @@ export interface IOpportunitiesPrepare {
684
684
  * every credit manager with a Horizon bridge adapter, whichever of the two
685
685
  * methods prepared it; the bot is the one the market configurator lists
686
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}.
687
+ * opening grants nothing and the move is left to {@link moveToAave}. An
688
+ * account opened through an RWA factory gets the Securitize finalizer
689
+ * instead, and only where the factory allows it: its wallet rejects any
690
+ * other bot.
688
691
  *
689
692
  * The bot borrows the whole Gearbox debt on Aave or reverts, so an opening
690
693
  * whose debt is above what Aave lends against the collateral at its LTV is
@@ -827,7 +830,8 @@ export interface IOpportunitiesPrepare {
827
830
  * which borrows the underlying on the owner's behalf into the account, and
828
831
  * the Gearbox loan is repaid in full with its quotas. Aave lends the debt
829
832
  * plus a 10bps margin for the interest still to come; whatever the facade
830
- * does not take stays on the account. The state answered is the credit
833
+ * does not take stays on the account. On an RWA market Aave lends the
834
+ * asset the underlying wraps, and it is wrapped before the repayment. The state answered is the credit
831
835
  * account's: owing nothing, holding that remainder.
832
836
  *
833
837
  * The bridge borrows as the owner, so the transaction reverts unless the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "18.4.1-aave.4",
3
+ "version": "18.4.1-aave.5",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {