@gearbox-protocol/sdk 18.4.1-aave.1 → 18.4.1-aave.2

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 (60) hide show
  1. package/dist/cjs/onchain/accounts/bots/AccountBotsService.js +29 -0
  2. package/dist/cjs/onchain/accounts/bots/PeripheryCompressorV310Contract.js +2 -1
  3. package/dist/cjs/onchain/accounts/intents/operations.js +2 -2
  4. package/dist/cjs/onchain/index.js +4 -0
  5. package/dist/cjs/onchain/market/ZapperRegister.js +1 -1
  6. package/dist/cjs/onchain/market/adapters/abi/aave/iAaveOracle.js +20 -0
  7. package/dist/cjs/onchain/market/adapters/abi/aave/iAaveV3Pool.js +166 -0
  8. package/dist/cjs/onchain/market/adapters/abi/aave/iPoolAddressesProvider.js +11 -0
  9. package/dist/cjs/onchain/market/adapters/abi/aave/index.js +4 -0
  10. package/dist/cjs/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.js +27 -0
  11. package/dist/cjs/onchain/market/adapters/abi/index.js +4 -0
  12. package/dist/cjs/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.js +53 -12
  13. package/dist/cjs/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.js +5 -11
  14. package/dist/cjs/onchain/market/adapters/index.js +4 -0
  15. package/dist/cjs/onchain/market/index.js +4 -0
  16. package/dist/cjs/onchain/positions/projectAavePosition.js +161 -26
  17. package/dist/cjs/sdk/prepare/PrepareApi.js +19 -2
  18. package/dist/cjs/sdk/preview/PreviewNamespace.js +11 -2
  19. package/dist/esm/onchain/accounts/bots/AccountBotsService.js +29 -0
  20. package/dist/esm/onchain/accounts/bots/PeripheryCompressorV310Contract.js +1 -1
  21. package/dist/esm/onchain/accounts/intents/operations.js +2 -2
  22. package/dist/esm/onchain/index.js +3 -1
  23. package/dist/esm/onchain/market/ZapperRegister.js +1 -1
  24. package/dist/esm/onchain/market/adapters/abi/aave/iAaveOracle.js +19 -0
  25. package/dist/esm/onchain/market/adapters/abi/aave/iAaveV3Pool.js +166 -0
  26. package/dist/esm/onchain/market/adapters/abi/aave/iPoolAddressesProvider.js +10 -0
  27. package/dist/esm/onchain/market/adapters/abi/aave/index.js +3 -1
  28. package/dist/esm/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.js +27 -0
  29. package/dist/esm/onchain/market/adapters/abi/index.js +3 -1
  30. package/dist/esm/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.js +54 -13
  31. package/dist/esm/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.js +6 -12
  32. package/dist/esm/onchain/market/adapters/index.js +3 -1
  33. package/dist/esm/onchain/market/index.js +3 -1
  34. package/dist/esm/onchain/positions/projectAavePosition.js +162 -27
  35. package/dist/esm/sdk/prepare/PrepareApi.js +20 -3
  36. package/dist/esm/sdk/preview/PreviewNamespace.js +11 -2
  37. package/dist/types/model/aave.d.ts +5 -3
  38. package/dist/types/onchain/accounts/bots/AccountBotsService.d.ts +11 -1
  39. package/dist/types/onchain/accounts/bots/index.d.ts +2 -2
  40. package/dist/types/onchain/accounts/bots/types.d.ts +7 -1
  41. package/dist/types/onchain/accounts/index.d.ts +2 -2
  42. package/dist/types/onchain/accounts/intents/operations.d.ts +9 -3
  43. package/dist/types/onchain/index.d.ts +4 -2
  44. package/dist/types/onchain/market/adapters/abi/aave/iAaveOracle.d.ts +22 -0
  45. package/dist/types/onchain/market/adapters/abi/aave/iAaveV3Pool.d.ts +139 -0
  46. package/dist/types/onchain/market/adapters/abi/aave/iPoolAddressesProvider.d.ts +11 -0
  47. package/dist/types/onchain/market/adapters/abi/aave/index.d.ts +3 -1
  48. package/dist/types/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.d.ts +21 -0
  49. package/dist/types/onchain/market/adapters/abi/index.d.ts +3 -1
  50. package/dist/types/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.d.ts +39 -10
  51. package/dist/types/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.d.ts +142 -4
  52. package/dist/types/onchain/market/adapters/index.d.ts +3 -1
  53. package/dist/types/onchain/market/index.d.ts +3 -1
  54. package/dist/types/onchain/positions/projectAavePosition.d.ts +33 -4
  55. package/dist/types/sdk/index.d.ts +2 -2
  56. package/dist/types/sdk/prepare/PrepareApi.d.ts +2 -2
  57. package/dist/types/sdk/prepare/index.d.ts +2 -2
  58. package/dist/types/sdk/prepare/types.d.ts +32 -5
  59. package/dist/types/sdk/preview/types.d.ts +4 -2
  60. package/package.json +1 -1
@@ -1,40 +1,175 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_onchain_constants_math = require("../constants/math.js");
3
+ const require_onchain_market_adapters_abi_aave_iAaveOracle = require("../market/adapters/abi/aave/iAaveOracle.js");
4
+ const require_onchain_market_adapters_abi_aave_iAaveV3Pool = require("../market/adapters/abi/aave/iAaveV3Pool.js");
5
+ const require_onchain_market_adapters_abi_aave_iPoolAddressesProvider = require("../market/adapters/abi/aave/iPoolAddressesProvider.js");
6
+ require("../market/adapters/abi/aave/index.js");
7
+ const require_onchain_market_adapters_contracts_AaveHorizonBridgeAdapterContract = require("../market/adapters/contracts/AaveHorizonBridgeAdapterContract.js");
8
+ const require_onchain_market_adapters_contracts_AaveV3PoolAdapterContract = require("../market/adapters/contracts/AaveV3PoolAdapterContract.js");
9
+ const require_onchain_market_math = require("../market/math.js");
10
+ let viem = require("viem");
3
11
  //#region src/onchain/positions/projectAavePosition.ts
4
12
  /**
5
- * Mint settlement period, until each RWA token reports its own.
6
- **/
7
- const MINT_DURATION = 432e3;
8
- /**
9
13
  * Where an opening lands once it has moved to Aave Horizon, from the snapshot
10
14
  * of the credit account it is built in.
11
15
  *
12
- * Placeholder until the Aave Horizon contracts ship: the mint is assumed to
13
- * take {@link MINT_DURATION} and to mint the account's balances one for one,
14
- * and the Aave side is weighed by the credit manager's own projection.
16
+ * The finalizer bot supplies the account's RWA to the pool and borrows the
17
+ * Gearbox debt against it on the owner's behalf, so the Aave side is read off
18
+ * the pool for `owner`: the reserve's LTV and liquidation threshold (its eMode
19
+ * category's, where the owner is in one that lists it), the Aave oracle's
20
+ * prices, the variable borrow rate of the underlying, and whatever the owner
21
+ * already holds and owes there. `healthFactor` and `liquidationPrice` are of
22
+ * that whole position; the values describe this opening alone.
23
+ *
24
+ * The RWA is either on the account already, and the position is on Aave at
25
+ * once (the bot's move is the next block), or still being minted: 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.
15
34
  **/
16
- function projectAavePosition(sdk, snapshot) {
35
+ async function projectAavePosition(sdk, snapshot, owner) {
36
+ const suite = sdk.marketRegister.findCreditManager(snapshot.creditManager);
17
37
  const market = sdk.marketRegister.findByCreditManager(snapshot.creditManager);
18
- const pool = { availableLiquidityChange: -snapshot.totalDebt };
19
- const rate = sdk.positions.metrics(snapshot, pool).borrowRate.totalOnDebt;
20
- const interest = snapshot.totalDebt * BigInt(rate) * BigInt(MINT_DURATION) / (require_onchain_constants_math.PERCENTAGE_FACTOR * BigInt(require_onchain_constants_math.SECONDS_PER_YEAR));
21
- const { totalValue, totalDebt, netValue, assets, healthFactor, liquidationPrice, borrowRate, leverage } = sdk.positions.projection({
22
- ...snapshot,
23
- totalDebt: snapshot.totalDebt + interest
24
- }, pool);
38
+ const { underlying } = market;
39
+ const adapters = suite.creditManager.adapters.values();
40
+ const poolAdapters = adapters.filter((p) => p instanceof require_onchain_market_adapters_contracts_AaveV3PoolAdapterContract.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 || (0, viem.isAddressEqual)(a.token, underlying)) continue;
48
+ const mint = delayed.find((d) => (0, viem.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: require_onchain_market_adapters_abi_aave_iAaveV3Pool.iAaveV3PoolAbi,
67
+ functionName: "getReserveData",
68
+ args: [collateral.token]
69
+ },
70
+ {
71
+ address: pool,
72
+ abi: require_onchain_market_adapters_abi_aave_iAaveV3Pool.iAaveV3PoolAbi,
73
+ functionName: "getReserveData",
74
+ args: [underlying]
75
+ },
76
+ {
77
+ address: pool,
78
+ abi: require_onchain_market_adapters_abi_aave_iAaveV3Pool.iAaveV3PoolAbi,
79
+ functionName: "getUserAccountData",
80
+ args: [owner]
81
+ },
82
+ {
83
+ address: pool,
84
+ abi: require_onchain_market_adapters_abi_aave_iAaveV3Pool.iAaveV3PoolAbi,
85
+ functionName: "getUserEMode",
86
+ args: [owner]
87
+ },
88
+ {
89
+ address: pool,
90
+ abi: require_onchain_market_adapters_abi_aave_iAaveV3Pool.iAaveV3PoolAbi,
91
+ functionName: "ADDRESSES_PROVIDER"
92
+ }
93
+ ],
94
+ allowFailure: false,
95
+ batchSize: 0
96
+ });
97
+ if (!adapters.some((b) => b instanceof require_onchain_market_adapters_contracts_AaveHorizonBridgeAdapterContract.AaveHorizonBridgeAdapterContract && b.isATokenAllowed(rwaReserve.aTokenAddress) && b.isDebtTokenAllowed(underlying))) return;
98
+ const oracle = await sdk.client.readContract({
99
+ address: provider,
100
+ abi: require_onchain_market_adapters_abi_aave_iPoolAddressesProvider.iPoolAddressesProviderAbi,
101
+ functionName: "getPriceOracle"
102
+ });
103
+ const [[rwaPrice, underlyingPrice], categoryParams] = await Promise.all([sdk.client.readContract({
104
+ address: oracle,
105
+ abi: require_onchain_market_adapters_abi_aave_iAaveOracle.iAaveOracleAbi,
106
+ functionName: "getAssetsPrices",
107
+ args: [[collateral.token, underlying]]
108
+ }), eMode > 0n ? sdk.client.multicall({
109
+ contracts: [{
110
+ address: pool,
111
+ abi: require_onchain_market_adapters_abi_aave_iAaveV3Pool.iAaveV3PoolAbi,
112
+ functionName: "getEModeCategoryCollateralConfig",
113
+ args: [Number(eMode)]
114
+ }, {
115
+ address: pool,
116
+ abi: require_onchain_market_adapters_abi_aave_iAaveV3Pool.iAaveV3PoolAbi,
117
+ functionName: "getEModeCategoryCollateralBitmap",
118
+ args: [Number(eMode)]
119
+ }],
120
+ allowFailure: false,
121
+ batchSize: 0
122
+ }) : void 0]);
123
+ const rwaConfig = rwaReserve.configuration.data;
124
+ let ltv = rwaConfig & 65535n;
125
+ let liquidationThreshold = rwaConfig >> 16n & 65535n;
126
+ const [category, bitmap] = categoryParams ?? [];
127
+ if (category && bitmap && bitmap >> BigInt(rwaReserve.id) & 1n) {
128
+ ltv = BigInt(category.ltv);
129
+ liquidationThreshold = BigInt(category.liquidationThreshold);
130
+ }
131
+ const rwaScale = 10n ** (rwaConfig >> 48n & 255n);
132
+ const underlyingScale = 10n ** (debtReserve.configuration.data >> 48n & 255n);
133
+ const collateralBase = account[0];
134
+ const debtBase = account[1];
135
+ const currentLiquidationThreshold = account[3];
136
+ const currentLtv = account[4];
137
+ const gearboxPool = { availableLiquidityChange: -snapshot.totalDebt };
138
+ const gearboxRate = sdk.positions.metrics(snapshot, gearboxPool).borrowRate.totalOnDebt;
139
+ const interest = snapshot.totalDebt * BigInt(gearboxRate) * BigInt(mintDuration) / (require_onchain_constants_math.PERCENTAGE_FACTOR * BigInt(require_onchain_constants_math.SECONDS_PER_YEAR));
140
+ const totalDebt = snapshot.totalDebt + interest;
141
+ const suppliedBase = collateral.balance * rwaPrice / rwaScale;
142
+ const owedBase = debtBase + ceilDiv(totalDebt * underlyingPrice, underlyingScale);
143
+ const weightedLiquidation = collateralBase * currentLiquidationThreshold + suppliedBase * liquidationThreshold;
144
+ const borrowableBase = (collateralBase * currentLtv + suppliedBase * ltv) / require_onchain_constants_math.PERCENTAGE_FACTOR;
145
+ const totalValue = collateral.balance * rwaPrice * underlyingScale / (rwaScale * underlyingPrice);
146
+ const rate = Number(debtReserve.currentVariableBorrowRate * require_onchain_constants_math.PERCENTAGE_FACTOR / require_onchain_constants_math.RAY);
147
+ const uncovered = owedBase * require_onchain_constants_math.PERCENTAGE_FACTOR - collateralBase * currentLiquidationThreshold;
148
+ const liquidationPrice = liquidationThreshold === 0n ? null : uncovered <= 0n ? 0n : uncovered * rwaScale * require_onchain_constants_math.PRICE_DECIMALS / (collateral.balance * liquidationThreshold * underlyingPrice);
25
149
  return {
26
- totalValue,
27
- totalDebt,
28
- netValue,
29
- assets,
30
- healthFactor,
31
- liquidationPrice,
32
- borrowRate,
33
- leverage,
34
- mintPeriodInterest: market.toUnderlyingAmount(interest),
35
- mintDuration: MINT_DURATION,
36
- estLiveAt: Number(sdk.timestamp) + MINT_DURATION
150
+ aave: {
151
+ totalValue: market.toUnderlyingAmount(totalValue),
152
+ totalDebt: market.toUnderlyingAmount(totalDebt),
153
+ netValue: market.toUnderlyingAmount(totalValue - totalDebt),
154
+ assets: [market.priceOracle.toTokenAmount(collateral.token, collateral.balance)],
155
+ healthFactor: Number(owedBase > 0n ? weightedLiquidation / owedBase : require_onchain_constants_math.MAX_UINT16),
156
+ liquidationPrice,
157
+ borrowRate: {
158
+ total: totalValue > 0n ? Number(BigInt(rate) * totalDebt / totalValue) : 0,
159
+ totalOnDebt: rate,
160
+ base: rate,
161
+ quotas: []
162
+ },
163
+ leverage: require_onchain_market_math.calcPositionLeverage(totalValue, totalDebt),
164
+ mintPeriodInterest: market.toUnderlyingAmount(interest),
165
+ mintDuration,
166
+ estLiveAt: Number(sdk.timestamp) + mintDuration
167
+ },
168
+ maxDebt: borrowableBase > debtBase ? (borrowableBase - debtBase) * underlyingScale / underlyingPrice : 0n
37
169
  };
38
170
  }
171
+ function ceilDiv(a, b) {
172
+ return (a + b - 1n) / b;
173
+ }
39
174
  //#endregion
40
175
  exports.projectAavePosition = projectAavePosition;
@@ -3,6 +3,7 @@ const require_onchain_constants_math = require("../../onchain/constants/math.js"
3
3
  const require_onchain_utils_hex = require("../../onchain/utils/hex.js");
4
4
  const require_onchain_base_MultichainConstruct = require("../../onchain/base/MultichainConstruct.js");
5
5
  require("../../onchain/market/math.js");
6
+ const require_model_errors_operation_errors = require("../../model/errors/operation-errors.js");
6
7
  const require_model_errors_prepare_errors = require("../../model/errors/prepare-errors.js");
7
8
  const require_model_result = require("../../model/result.js");
8
9
  require("../../model/index.js");
@@ -266,7 +267,8 @@ var PrepareApi = class extends require_onchain_base_MultichainConstruct.Multicha
266
267
  if (!opened.ok) return opened;
267
268
  const { state } = opened.data;
268
269
  try {
269
- const aave = require_onchain_positions_projectAavePosition.projectAavePosition(this.sdk.chain(strategy.chainId), {
270
+ const sdk = this.sdk.chain(strategy.chainId);
271
+ const projected = await require_onchain_positions_projectAavePosition.projectAavePosition(sdk, {
270
272
  creditManager: state.creditManager,
271
273
  assets: state.averageAssets.map((a) => ({
272
274
  token: a.token.address,
@@ -275,7 +277,22 @@ var PrepareApi = class extends require_onchain_base_MultichainConstruct.Multicha
275
277
  quotas: state.averageQuota,
276
278
  totalDebt: state.totalDebt.value,
277
279
  totalValue: state.totalValue.value
278
- });
280
+ }, params.wallet);
281
+ const suite = sdk.marketRegister.findCreditManager(strategy.creditManager);
282
+ if (!projected) {
283
+ const target = params.targetToken ?? suite.strategy?.targetCollateral;
284
+ return refused(target ? require_model_errors_prepare_errors.unsupportedCollateralToken(require_onchain_validation_helpers_token.toToken(sdk, target)) : require_model_errors_prepare_errors.noStrategyTargetCollateral(strategy.creditManager), state);
285
+ }
286
+ const { aave, maxDebt } = projected;
287
+ if (aave.totalDebt.value > maxDebt) {
288
+ const market = sdk.marketRegister.findByCreditManager(strategy.creditManager);
289
+ const { creditFacade } = suite;
290
+ return refused(require_model_errors_operation_errors.debtOutOfRange({
291
+ requested: aave.totalDebt,
292
+ minDebt: market.toUnderlyingAmount(creditFacade.minDebt),
293
+ maxDebt: market.toUnderlyingAmount(maxDebt)
294
+ }), state);
295
+ }
279
296
  return require_model_result.sdkOk({
280
297
  ...opened.data,
281
298
  state: {
@@ -3,6 +3,7 @@ const require_model_result = require("../../model/result.js");
3
3
  require("../../model/index.js");
4
4
  const require_onchain_validation_checkOperation = require("../../onchain/validation/checkOperation.js");
5
5
  const require_onchain_validation_checkSimulation = require("../../onchain/validation/checkSimulation.js");
6
+ const require_onchain_preview_parse_parseOperationCalldata = require("../../onchain/preview/parse/parseOperationCalldata.js");
6
7
  const require_onchain_preview_preview_previewOperation = require("../../onchain/preview/preview/previewOperation.js");
7
8
  require("../../onchain/index.js");
8
9
  const require_onchain_positions_projectAavePosition = require("../../onchain/positions/projectAavePosition.js");
@@ -37,7 +38,10 @@ var PreviewNamespace = class {
37
38
  message: `operation "${preview.operation}" is not an Aave position opening`,
38
39
  operation: preview.operation
39
40
  });
40
- const aave = require_onchain_positions_projectAavePosition.projectAavePosition(this.#onchain.chain(input.chainId), {
41
+ const sdk = this.#onchain.chain(input.chainId);
42
+ const parsed = require_onchain_preview_parse_parseOperationCalldata.parseOperationCalldata(sdk, input);
43
+ const owner = parsed.ok && parsed.data.operation === "OpenCreditAccount" ? parsed.data.onBehalfOf : input.sender;
44
+ const projected = await require_onchain_positions_projectAavePosition.projectAavePosition(sdk, {
41
45
  creditManager: preview.creditManager,
42
46
  assets: preview.estAssets.map((a) => ({
43
47
  token: a.token.address,
@@ -49,10 +53,15 @@ var PreviewNamespace = class {
49
53
  })),
50
54
  totalDebt: preview.totalDebt.value,
51
55
  totalValue: preview.estTotalValue.value
56
+ }, owner);
57
+ if (!projected) return require_model_result.sdkErr({
58
+ code: "unsupportedOperation",
59
+ message: `credit manager ${preview.creditManager} cannot move this opening to Aave`,
60
+ operation: preview.operation
52
61
  });
53
62
  return require_model_result.sdkOk({
54
63
  ...preview,
55
- aave
64
+ aave: projected.aave
56
65
  });
57
66
  }
58
67
  /**
@@ -1,7 +1,10 @@
1
1
  import { iBotListV310Abi } from "../../../abi/310/generated.js";
2
+ import { peripheryCompressorAbi } from "../../../abi/compressors/peripheryCompressor.js";
3
+ import { AddressMap } from "../../utils/AddressMap.js";
2
4
  import { AP_PERIPHERY_COMPRESSOR } from "../../constants/address-provider.js";
3
5
  import { VERSION_RANGE_310 } from "../../constants/versions.js";
4
6
  import "../../constants/index.js";
7
+ import "../../utils/index.js";
5
8
  import { SDKConstruct } from "../../base/SDKConstruct.js";
6
9
  import "../../base/index.js";
7
10
  import { iBotAbi } from "./abi.js";
@@ -14,6 +17,32 @@ import { PeripheryCompressorV310Contract } from "./PeripheryCompressorV310Contra
14
17
  * and builds the transactions that connect or disconnect one.
15
18
  **/
16
19
  var AccountBotsService = class extends SDKConstruct {
20
+ #marketBots = new AddressMap(void 0, "marketBots");
21
+ /**
22
+ * The bots a market configurator lists among its periphery contracts.
23
+ *
24
+ * Read once per configurator and kept for the service's lifetime: the list
25
+ * changes only when the curator adds or removes a bot. A failed read is not
26
+ * kept, so the next call tries again.
27
+ *
28
+ * @param marketConfigurator - Configurator to list the bots of.
29
+ **/
30
+ getMarketBots(marketConfigurator) {
31
+ let bots = this.#marketBots.get(marketConfigurator);
32
+ if (!bots) {
33
+ bots = this.client.readContract({
34
+ address: this.#compressor.address,
35
+ abi: peripheryCompressorAbi,
36
+ functionName: "getBots",
37
+ args: [marketConfigurator]
38
+ }).catch((e) => {
39
+ this.#marketBots.delete(marketConfigurator);
40
+ throw e;
41
+ });
42
+ this.#marketBots.upsert(marketConfigurator, bots);
43
+ }
44
+ return bots;
45
+ }
17
46
  /**
18
47
  * Reads the bots connected to each of the given credit accounts.
19
48
  *
@@ -1,6 +1,6 @@
1
+ import { peripheryCompressorAbi } from "../../../abi/compressors/peripheryCompressor.js";
1
2
  import { BaseContract } from "../../base/BaseContract.js";
2
3
  import "../../base/index.js";
3
- import { peripheryCompressorAbi } from "../../../abi/compressors/peripheryCompressor.js";
4
4
  //#region src/onchain/accounts/bots/PeripheryCompressorV310Contract.ts
5
5
  const abi = peripheryCompressorAbi;
6
6
  var PeripheryCompressorV310Contract = class extends BaseContract {
@@ -140,7 +140,7 @@ function buildAaveSupplyOperation(input) {
140
140
  token: input.token,
141
141
  aToken: input.aToken,
142
142
  amount: input.amount,
143
- calls: [input.adapter.supplyCall(input.token, input.amount)]
143
+ calls: [input.adapter.supplyDiffCall(input.token, 0n)]
144
144
  };
145
145
  }
146
146
  function buildAaveOpenPositionOperation(input) {
@@ -150,7 +150,7 @@ function buildAaveOpenPositionOperation(input) {
150
150
  aTokenAmount: input.aTokenAmount,
151
151
  debtToken: input.debtToken,
152
152
  borrowAmount: input.borrowAmount,
153
- calls: [input.adapter.openPositionCall(input.aToken, input.debtToken, input.aTokenAmount, input.borrowAmount)]
153
+ calls: [input.adapter.openPositionDiffCall(input.aToken, input.debtToken, 0n, input.borrowAmount)]
154
154
  };
155
155
  }
156
156
  /**
@@ -46,7 +46,9 @@ import "./base/index.js";
46
46
  import { PeripheryCompressorV310Contract } from "./accounts/bots/PeripheryCompressorV310Contract.js";
47
47
  import { AccountBotsService } from "./accounts/bots/AccountBotsService.js";
48
48
  import { iAaveHorizonBridgeAbi } from "./market/adapters/abi/aave/iAaveHorizonBridge.js";
49
+ import { iAaveOracleAbi } from "./market/adapters/abi/aave/iAaveOracle.js";
49
50
  import { iAaveV3PoolAbi } from "./market/adapters/abi/aave/iAaveV3Pool.js";
51
+ import { iPoolAddressesProviderAbi } from "./market/adapters/abi/aave/iPoolAddressesProvider.js";
50
52
  import { AdapterType } from "./market/adapters/types.js";
51
53
  import { adapterActionAbi, adapterActionSelectors, adapterActionSignatures } from "./market/adapters/abi/actionAbi.js";
52
54
  import { erc4626ReferralAdapterAbi } from "./market/adapters/abi/adapters/erc4626ReferralAdapter.js";
@@ -326,4 +328,4 @@ import { replayMulticall } from "./preview/preview/replayMulticall.js";
326
328
  import { previewOperation } from "./preview/preview/previewOperation.js";
327
329
  import "./preview/index.js";
328
330
  import "./types/index.js";
329
- export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AaveHorizonBridgeAdapterContract, AaveV3PoolAdapterContract, AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AccountMigratorAdapterContract, AdapterType, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, ConstantPriceFeedContract, Construct, ContractParseError, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountState, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CreditSuiteStrategy, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DIRECT_TRANSFERS_QUOTA, DUST_THRESHOLD, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EXECUTE_BYTES_SELECTOR, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LidoV1AdapterContract, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_QUOTA_MULTIPLIER, MAX_UINT16, MAX_UINT256, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_INT96, MIN_SAFE_HEALTH_FACTOR_FORM, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegistry, PriceOracleV310Contract, PriceUpdatesCache, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_COMPRESSOR_ADDRESS, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, SimulateWithPriceUpdatesError, SimulationError, StakingRewardsAdapterContract, TokensMeta, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TreehouseFastlaneAdapterContract, TreehouseRedemptionGatewayAdapterContract, TreehouseRouterAdapterContract, TypedObjectUtils, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatablePriceFeedRegistry, UpshiftVaultAdapterContract, VERSION_RANGE_310, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, amountOf, assetsMap, attachOptionsSchema, botPermissionsToString, bpsToRay, buildDelayedStrategyPositionOperationPreview, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, 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, childLogger, classifyCloseOrRepay, classifyCurveOperation, classifyInnerOperations, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectDelayedClaim, detectDelayedOperation, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateClaimableAt, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, filterDust, filterDustUSD, findCallTo, findCallWithInput, findCuratorMarketConfigurator, findExecuteBytes, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getDirectTransferToken, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, hasAdapterDeployParamsAbi, healthFactorBps, hexEq, hydrateAddressProvider, iAaveHorizonBridgeAbi, iAaveHorizonBridgeAdapterAbi, iAaveV3PoolAbi, iAaveV3PoolAdapterAbi, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCreditAccountAbi, 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, isCloseOrRepay, isDust, isLPPriceFeed, isPhantomToken, isPoolOperation, isPublicNetwork, isRWAFactory, isRWAOperation, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, makeReplayState, maxAmountForQuota, mellowDvvAdapterAbi, midasGreenlistsAccount, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalPartialLiquidation, optimalPartialLiquidationAmounts, parseAdapterAction, parseAdapterDeployParams, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parsePosNegAmount, parseRWAFactoryOperationCalldata, partialLiquidationParams, percentFmt, pickStrategyTargetCollateral, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, raise, rayToBps, rayToNumber, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, resolveProtocolCall, retry, rewardsFromTransfers, roundUpQuota, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, soleNonUnderlyingCollateral, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toToken, toTokenAmount, toWithdrawalStatus, updatableDependencies, usdToNumber, watchBlocksAsync };
331
+ export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AaveHorizonBridgeAdapterContract, AaveV3PoolAdapterContract, AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AccountMigratorAdapterContract, AdapterType, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, ConstantPriceFeedContract, Construct, ContractParseError, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountState, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CreditSuiteStrategy, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DIRECT_TRANSFERS_QUOTA, DUST_THRESHOLD, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EXECUTE_BYTES_SELECTOR, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LidoV1AdapterContract, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_QUOTA_MULTIPLIER, MAX_UINT16, MAX_UINT256, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_INT96, MIN_SAFE_HEALTH_FACTOR_FORM, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegistry, PriceOracleV310Contract, PriceUpdatesCache, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_COMPRESSOR_ADDRESS, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, SimulateWithPriceUpdatesError, SimulationError, StakingRewardsAdapterContract, TokensMeta, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TreehouseFastlaneAdapterContract, TreehouseRedemptionGatewayAdapterContract, TreehouseRouterAdapterContract, TypedObjectUtils, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatablePriceFeedRegistry, UpshiftVaultAdapterContract, VERSION_RANGE_310, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, amountOf, assetsMap, attachOptionsSchema, botPermissionsToString, bpsToRay, buildDelayedStrategyPositionOperationPreview, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, 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, childLogger, classifyCloseOrRepay, classifyCurveOperation, classifyInnerOperations, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectDelayedClaim, detectDelayedOperation, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateClaimableAt, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, filterDust, filterDustUSD, findCallTo, findCallWithInput, findCuratorMarketConfigurator, findExecuteBytes, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getDirectTransferToken, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, hasAdapterDeployParamsAbi, healthFactorBps, hexEq, hydrateAddressProvider, iAaveHorizonBridgeAbi, iAaveHorizonBridgeAdapterAbi, iAaveOracleAbi, iAaveV3PoolAbi, iAaveV3PoolAdapterAbi, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCreditAccountAbi, 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, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iTreehouseFastlaneAbi, iTreehouseFastlaneAdapterAbi, iTreehouseRedemptionGatewayAbi, iTreehouseRedemptionGatewayAdapterAbi, iTreehouseRouterAbi, iTreehouseRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isCloseOrRepay, isDust, isLPPriceFeed, isPhantomToken, isPoolOperation, isPublicNetwork, isRWAFactory, isRWAOperation, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, makeReplayState, maxAmountForQuota, mellowDvvAdapterAbi, midasGreenlistsAccount, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalPartialLiquidation, optimalPartialLiquidationAmounts, parseAdapterAction, parseAdapterDeployParams, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parsePosNegAmount, parseRWAFactoryOperationCalldata, partialLiquidationParams, percentFmt, pickStrategyTargetCollateral, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, raise, rayToBps, rayToNumber, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, resolveProtocolCall, retry, rewardsFromTransfers, roundUpQuota, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, soleNonUnderlyingCollateral, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toToken, toTokenAmount, toWithdrawalStatus, updatableDependencies, usdToNumber, watchBlocksAsync };
@@ -1,3 +1,4 @@
1
+ import { peripheryCompressorAbi } from "../../abi/compressors/peripheryCompressor.js";
1
2
  import { AddressMap } from "../utils/AddressMap.js";
2
3
  import { AP_PERIPHERY_COMPRESSOR } from "../constants/address-provider.js";
3
4
  import { VERSION_RANGE_310 } from "../constants/versions.js";
@@ -7,7 +8,6 @@ import "../utils/index.js";
7
8
  import { executeMulticallBatches } from "../utils/viem/executeMulticallBatches.js";
8
9
  import { SDKConstruct } from "../base/SDKConstruct.js";
9
10
  import "../base/index.js";
10
- import { peripheryCompressorAbi } from "../../abi/compressors/peripheryCompressor.js";
11
11
  import "../utils/viem/index.js";
12
12
  import { createZapper } from "./zapper/createZapper.js";
13
13
  import "./zapper/index.js";
@@ -0,0 +1,19 @@
1
+ //#region src/onchain/market/adapters/abi/aave/iAaveOracle.ts
2
+ const iAaveOracleAbi = [{
3
+ name: "BASE_CURRENCY_UNIT",
4
+ type: "function",
5
+ stateMutability: "view",
6
+ inputs: [],
7
+ outputs: [{ type: "uint256" }]
8
+ }, {
9
+ name: "getAssetsPrices",
10
+ type: "function",
11
+ stateMutability: "view",
12
+ inputs: [{
13
+ type: "address[]",
14
+ name: "assets"
15
+ }],
16
+ outputs: [{ type: "uint256[]" }]
17
+ }];
18
+ //#endregion
19
+ export { iAaveOracleAbi };
@@ -105,6 +105,172 @@ const iAaveV3PoolAbi = [
105
105
  name: "asset"
106
106
  }],
107
107
  outputs: [{ type: "address" }]
108
+ },
109
+ {
110
+ name: "ADDRESSES_PROVIDER",
111
+ type: "function",
112
+ stateMutability: "view",
113
+ inputs: [],
114
+ outputs: [{ type: "address" }]
115
+ },
116
+ {
117
+ name: "getReserveData",
118
+ type: "function",
119
+ stateMutability: "view",
120
+ inputs: [{
121
+ type: "address",
122
+ name: "asset"
123
+ }],
124
+ outputs: [{
125
+ type: "tuple",
126
+ components: [
127
+ {
128
+ type: "tuple",
129
+ name: "configuration",
130
+ components: [{
131
+ type: "uint256",
132
+ name: "data"
133
+ }]
134
+ },
135
+ {
136
+ type: "uint128",
137
+ name: "liquidityIndex"
138
+ },
139
+ {
140
+ type: "uint128",
141
+ name: "currentLiquidityRate"
142
+ },
143
+ {
144
+ type: "uint128",
145
+ name: "variableBorrowIndex"
146
+ },
147
+ {
148
+ type: "uint128",
149
+ name: "currentVariableBorrowRate"
150
+ },
151
+ {
152
+ type: "uint128",
153
+ name: "currentStableBorrowRate"
154
+ },
155
+ {
156
+ type: "uint40",
157
+ name: "lastUpdateTimestamp"
158
+ },
159
+ {
160
+ type: "uint16",
161
+ name: "id"
162
+ },
163
+ {
164
+ type: "address",
165
+ name: "aTokenAddress"
166
+ },
167
+ {
168
+ type: "address",
169
+ name: "stableDebtTokenAddress"
170
+ },
171
+ {
172
+ type: "address",
173
+ name: "variableDebtTokenAddress"
174
+ },
175
+ {
176
+ type: "address",
177
+ name: "interestRateStrategyAddress"
178
+ },
179
+ {
180
+ type: "uint128",
181
+ name: "accruedToTreasury"
182
+ },
183
+ {
184
+ type: "uint128",
185
+ name: "unbacked"
186
+ },
187
+ {
188
+ type: "uint128",
189
+ name: "isolationModeTotalDebt"
190
+ }
191
+ ]
192
+ }]
193
+ },
194
+ {
195
+ name: "getUserAccountData",
196
+ type: "function",
197
+ stateMutability: "view",
198
+ inputs: [{
199
+ type: "address",
200
+ name: "user"
201
+ }],
202
+ outputs: [
203
+ {
204
+ type: "uint256",
205
+ name: "totalCollateralBase"
206
+ },
207
+ {
208
+ type: "uint256",
209
+ name: "totalDebtBase"
210
+ },
211
+ {
212
+ type: "uint256",
213
+ name: "availableBorrowsBase"
214
+ },
215
+ {
216
+ type: "uint256",
217
+ name: "currentLiquidationThreshold"
218
+ },
219
+ {
220
+ type: "uint256",
221
+ name: "ltv"
222
+ },
223
+ {
224
+ type: "uint256",
225
+ name: "healthFactor"
226
+ }
227
+ ]
228
+ },
229
+ {
230
+ name: "getUserEMode",
231
+ type: "function",
232
+ stateMutability: "view",
233
+ inputs: [{
234
+ type: "address",
235
+ name: "user"
236
+ }],
237
+ outputs: [{ type: "uint256" }]
238
+ },
239
+ {
240
+ name: "getEModeCategoryCollateralConfig",
241
+ type: "function",
242
+ stateMutability: "view",
243
+ inputs: [{
244
+ type: "uint8",
245
+ name: "id"
246
+ }],
247
+ outputs: [{
248
+ type: "tuple",
249
+ components: [
250
+ {
251
+ type: "uint16",
252
+ name: "ltv"
253
+ },
254
+ {
255
+ type: "uint16",
256
+ name: "liquidationThreshold"
257
+ },
258
+ {
259
+ type: "uint16",
260
+ name: "liquidationBonus"
261
+ }
262
+ ]
263
+ }]
264
+ },
265
+ {
266
+ name: "getEModeCategoryCollateralBitmap",
267
+ type: "function",
268
+ stateMutability: "view",
269
+ inputs: [{
270
+ type: "uint8",
271
+ name: "id"
272
+ }],
273
+ outputs: [{ type: "uint128" }]
108
274
  }
109
275
  ];
110
276
  //#endregion
@@ -0,0 +1,10 @@
1
+ //#region src/onchain/market/adapters/abi/aave/iPoolAddressesProvider.ts
2
+ const iPoolAddressesProviderAbi = [{
3
+ name: "getPriceOracle",
4
+ type: "function",
5
+ stateMutability: "view",
6
+ inputs: [],
7
+ outputs: [{ type: "address" }]
8
+ }];
9
+ //#endregion
10
+ export { iPoolAddressesProviderAbi };
@@ -1,3 +1,5 @@
1
1
  import { iAaveHorizonBridgeAbi } from "./iAaveHorizonBridge.js";
2
+ import { iAaveOracleAbi } from "./iAaveOracle.js";
2
3
  import { iAaveV3PoolAbi } from "./iAaveV3Pool.js";
3
- export { iAaveHorizonBridgeAbi, iAaveV3PoolAbi };
4
+ import { iPoolAddressesProviderAbi } from "./iPoolAddressesProvider.js";
5
+ export { iAaveHorizonBridgeAbi, iAaveOracleAbi, iAaveV3PoolAbi, iPoolAddressesProviderAbi };