@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.
- package/dist/cjs/onchain/accounts/bots/AccountBotsService.js +29 -0
- package/dist/cjs/onchain/accounts/bots/PeripheryCompressorV310Contract.js +2 -1
- package/dist/cjs/onchain/accounts/intents/operations.js +2 -2
- package/dist/cjs/onchain/index.js +4 -0
- package/dist/cjs/onchain/market/ZapperRegister.js +1 -1
- package/dist/cjs/onchain/market/adapters/abi/aave/iAaveOracle.js +20 -0
- package/dist/cjs/onchain/market/adapters/abi/aave/iAaveV3Pool.js +166 -0
- package/dist/cjs/onchain/market/adapters/abi/aave/iPoolAddressesProvider.js +11 -0
- package/dist/cjs/onchain/market/adapters/abi/aave/index.js +4 -0
- package/dist/cjs/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.js +27 -0
- package/dist/cjs/onchain/market/adapters/abi/index.js +4 -0
- package/dist/cjs/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.js +53 -12
- package/dist/cjs/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.js +5 -11
- package/dist/cjs/onchain/market/adapters/index.js +4 -0
- package/dist/cjs/onchain/market/index.js +4 -0
- package/dist/cjs/onchain/positions/projectAavePosition.js +161 -26
- package/dist/cjs/sdk/prepare/PrepareApi.js +19 -2
- package/dist/cjs/sdk/preview/PreviewNamespace.js +11 -2
- package/dist/esm/onchain/accounts/bots/AccountBotsService.js +29 -0
- package/dist/esm/onchain/accounts/bots/PeripheryCompressorV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/intents/operations.js +2 -2
- package/dist/esm/onchain/index.js +3 -1
- package/dist/esm/onchain/market/ZapperRegister.js +1 -1
- package/dist/esm/onchain/market/adapters/abi/aave/iAaveOracle.js +19 -0
- package/dist/esm/onchain/market/adapters/abi/aave/iAaveV3Pool.js +166 -0
- package/dist/esm/onchain/market/adapters/abi/aave/iPoolAddressesProvider.js +10 -0
- package/dist/esm/onchain/market/adapters/abi/aave/index.js +3 -1
- package/dist/esm/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.js +27 -0
- package/dist/esm/onchain/market/adapters/abi/index.js +3 -1
- package/dist/esm/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.js +54 -13
- package/dist/esm/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.js +6 -12
- package/dist/esm/onchain/market/adapters/index.js +3 -1
- package/dist/esm/onchain/market/index.js +3 -1
- package/dist/esm/onchain/positions/projectAavePosition.js +162 -27
- package/dist/esm/sdk/prepare/PrepareApi.js +20 -3
- package/dist/esm/sdk/preview/PreviewNamespace.js +11 -2
- package/dist/types/model/aave.d.ts +5 -3
- package/dist/types/onchain/accounts/bots/AccountBotsService.d.ts +11 -1
- package/dist/types/onchain/accounts/bots/index.d.ts +2 -2
- package/dist/types/onchain/accounts/bots/types.d.ts +7 -1
- package/dist/types/onchain/accounts/index.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/operations.d.ts +9 -3
- package/dist/types/onchain/index.d.ts +4 -2
- package/dist/types/onchain/market/adapters/abi/aave/iAaveOracle.d.ts +22 -0
- package/dist/types/onchain/market/adapters/abi/aave/iAaveV3Pool.d.ts +139 -0
- package/dist/types/onchain/market/adapters/abi/aave/iPoolAddressesProvider.d.ts +11 -0
- package/dist/types/onchain/market/adapters/abi/aave/index.d.ts +3 -1
- package/dist/types/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.d.ts +21 -0
- package/dist/types/onchain/market/adapters/abi/index.d.ts +3 -1
- package/dist/types/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.d.ts +39 -10
- package/dist/types/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.d.ts +142 -4
- package/dist/types/onchain/market/adapters/index.d.ts +3 -1
- package/dist/types/onchain/market/index.d.ts +3 -1
- package/dist/types/onchain/positions/projectAavePosition.d.ts +33 -4
- package/dist/types/sdk/index.d.ts +2 -2
- package/dist/types/sdk/prepare/PrepareApi.d.ts +2 -2
- package/dist/types/sdk/prepare/index.d.ts +2 -2
- package/dist/types/sdk/prepare/types.d.ts +32 -5
- package/dist/types/sdk/preview/types.d.ts +4 -2
- package/package.json +1 -1
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_abi_310_generated = require("../../../abi/310/generated.js");
|
|
3
|
+
const require_abi_compressors_peripheryCompressor = require("../../../abi/compressors/peripheryCompressor.js");
|
|
4
|
+
const require_onchain_utils_AddressMap = require("../../utils/AddressMap.js");
|
|
3
5
|
const require_onchain_constants_address_provider = require("../../constants/address-provider.js");
|
|
4
6
|
const require_onchain_constants_versions = require("../../constants/versions.js");
|
|
5
7
|
require("../../constants/index.js");
|
|
8
|
+
require("../../utils/index.js");
|
|
6
9
|
const require_onchain_base_SDKConstruct = require("../../base/SDKConstruct.js");
|
|
7
10
|
require("../../base/index.js");
|
|
8
11
|
const require_onchain_accounts_bots_abi = require("./abi.js");
|
|
@@ -15,6 +18,32 @@ const require_onchain_accounts_bots_PeripheryCompressorV310Contract = require(".
|
|
|
15
18
|
* and builds the transactions that connect or disconnect one.
|
|
16
19
|
**/
|
|
17
20
|
var AccountBotsService = class extends require_onchain_base_SDKConstruct.SDKConstruct {
|
|
21
|
+
#marketBots = new require_onchain_utils_AddressMap.AddressMap(void 0, "marketBots");
|
|
22
|
+
/**
|
|
23
|
+
* The bots a market configurator lists among its periphery contracts.
|
|
24
|
+
*
|
|
25
|
+
* Read once per configurator and kept for the service's lifetime: the list
|
|
26
|
+
* changes only when the curator adds or removes a bot. A failed read is not
|
|
27
|
+
* kept, so the next call tries again.
|
|
28
|
+
*
|
|
29
|
+
* @param marketConfigurator - Configurator to list the bots of.
|
|
30
|
+
**/
|
|
31
|
+
getMarketBots(marketConfigurator) {
|
|
32
|
+
let bots = this.#marketBots.get(marketConfigurator);
|
|
33
|
+
if (!bots) {
|
|
34
|
+
bots = this.client.readContract({
|
|
35
|
+
address: this.#compressor.address,
|
|
36
|
+
abi: require_abi_compressors_peripheryCompressor.peripheryCompressorAbi,
|
|
37
|
+
functionName: "getBots",
|
|
38
|
+
args: [marketConfigurator]
|
|
39
|
+
}).catch((e) => {
|
|
40
|
+
this.#marketBots.delete(marketConfigurator);
|
|
41
|
+
throw e;
|
|
42
|
+
});
|
|
43
|
+
this.#marketBots.upsert(marketConfigurator, bots);
|
|
44
|
+
}
|
|
45
|
+
return bots;
|
|
46
|
+
}
|
|
18
47
|
/**
|
|
19
48
|
* Reads the bots connected to each of the given credit accounts.
|
|
20
49
|
*
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_abi_compressors_peripheryCompressor = require("../../../abi/compressors/peripheryCompressor.js");
|
|
2
3
|
const require_onchain_base_BaseContract = require("../../base/BaseContract.js");
|
|
3
4
|
require("../../base/index.js");
|
|
4
5
|
//#region src/onchain/accounts/bots/PeripheryCompressorV310Contract.ts
|
|
5
|
-
const abi =
|
|
6
|
+
const abi = require_abi_compressors_peripheryCompressor.peripheryCompressorAbi;
|
|
6
7
|
var PeripheryCompressorV310Contract = class extends require_onchain_base_BaseContract.BaseContract {
|
|
7
8
|
constructor(sdk, address) {
|
|
8
9
|
super(sdk, {
|
|
@@ -141,7 +141,7 @@ function buildAaveSupplyOperation(input) {
|
|
|
141
141
|
token: input.token,
|
|
142
142
|
aToken: input.aToken,
|
|
143
143
|
amount: input.amount,
|
|
144
|
-
calls: [input.adapter.
|
|
144
|
+
calls: [input.adapter.supplyDiffCall(input.token, 0n)]
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
147
|
function buildAaveOpenPositionOperation(input) {
|
|
@@ -151,7 +151,7 @@ function buildAaveOpenPositionOperation(input) {
|
|
|
151
151
|
aTokenAmount: input.aTokenAmount,
|
|
152
152
|
debtToken: input.debtToken,
|
|
153
153
|
borrowAmount: input.borrowAmount,
|
|
154
|
-
calls: [input.adapter.
|
|
154
|
+
calls: [input.adapter.openPositionDiffCall(input.aToken, input.debtToken, 0n, input.borrowAmount)]
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
@@ -47,7 +47,9 @@ require("./base/index.js");
|
|
|
47
47
|
const require_onchain_accounts_bots_PeripheryCompressorV310Contract = require("./accounts/bots/PeripheryCompressorV310Contract.js");
|
|
48
48
|
const require_onchain_accounts_bots_AccountBotsService = require("./accounts/bots/AccountBotsService.js");
|
|
49
49
|
const require_onchain_market_adapters_abi_aave_iAaveHorizonBridge = require("./market/adapters/abi/aave/iAaveHorizonBridge.js");
|
|
50
|
+
const require_onchain_market_adapters_abi_aave_iAaveOracle = require("./market/adapters/abi/aave/iAaveOracle.js");
|
|
50
51
|
const require_onchain_market_adapters_abi_aave_iAaveV3Pool = require("./market/adapters/abi/aave/iAaveV3Pool.js");
|
|
52
|
+
const require_onchain_market_adapters_abi_aave_iPoolAddressesProvider = require("./market/adapters/abi/aave/iPoolAddressesProvider.js");
|
|
51
53
|
const require_onchain_market_adapters_types = require("./market/adapters/types.js");
|
|
52
54
|
const require_onchain_market_adapters_abi_actionAbi = require("./market/adapters/abi/actionAbi.js");
|
|
53
55
|
const require_onchain_market_adapters_abi_adapters_erc4626ReferralAdapter = require("./market/adapters/abi/adapters/erc4626ReferralAdapter.js");
|
|
@@ -708,6 +710,7 @@ exports.hexEq = require_onchain_utils_hex.hexEq;
|
|
|
708
710
|
exports.hydrateAddressProvider = require_onchain_core_createAddressProvider.hydrateAddressProvider;
|
|
709
711
|
exports.iAaveHorizonBridgeAbi = require_onchain_market_adapters_abi_aave_iAaveHorizonBridge.iAaveHorizonBridgeAbi;
|
|
710
712
|
exports.iAaveHorizonBridgeAdapterAbi = require_onchain_market_adapters_abi_adapters_iAaveHorizonBridgeAdapter.iAaveHorizonBridgeAdapterAbi;
|
|
713
|
+
exports.iAaveOracleAbi = require_onchain_market_adapters_abi_aave_iAaveOracle.iAaveOracleAbi;
|
|
711
714
|
exports.iAaveV3PoolAbi = require_onchain_market_adapters_abi_aave_iAaveV3Pool.iAaveV3PoolAbi;
|
|
712
715
|
exports.iAaveV3PoolAdapterAbi = require_onchain_market_adapters_abi_adapters_iAaveV3PoolAdapter.iAaveV3PoolAdapterAbi;
|
|
713
716
|
exports.iBalancerV3RouterAbi = require_onchain_market_adapters_abi_targetContractAbi.iBalancerV3RouterAbi;
|
|
@@ -761,6 +764,7 @@ exports.iMidasRedemptionVaultAdapterV310Abi = require_onchain_market_adapters_ab
|
|
|
761
764
|
exports.iMidasRedemptionVaultGatewayV310Abi = require_onchain_market_adapters_abi_adapters_iMidasRedemptionVaultAdapterV310.iMidasRedemptionVaultGatewayV310Abi;
|
|
762
765
|
exports.iPendleRouterAbi = require_onchain_market_adapters_abi_targetContractAbi.iPendleRouterAbi;
|
|
763
766
|
exports.iPendleRouterAdapterAbi = require_onchain_market_adapters_abi_adapters_iPendleRouterAdapter.iPendleRouterAdapterAbi;
|
|
767
|
+
exports.iPoolAddressesProviderAbi = require_onchain_market_adapters_abi_aave_iPoolAddressesProvider.iPoolAddressesProviderAbi;
|
|
764
768
|
exports.iSecuritizeOnRampAbi = require_onchain_market_adapters_abi_securitize_iSecuritizeOnRamp.iSecuritizeOnRampAbi;
|
|
765
769
|
exports.iSecuritizeOnRampAdapterV310Abi = require_onchain_market_adapters_abi_adapters_iSecuritizeOnRampAdapterV310.iSecuritizeOnRampAdapterV310Abi;
|
|
766
770
|
exports.iSecuritizeRedemptionGatewayAdapterV311Abi = require_onchain_market_adapters_abi_adapters_iSecuritizeRedemptionGatewayAdapterV311.iSecuritizeRedemptionGatewayAdapterV311Abi;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_abi_compressors_peripheryCompressor = require("../../abi/compressors/peripheryCompressor.js");
|
|
2
3
|
const require_onchain_utils_AddressMap = require("../utils/AddressMap.js");
|
|
3
4
|
const require_onchain_constants_address_provider = require("../constants/address-provider.js");
|
|
4
5
|
const require_onchain_constants_versions = require("../constants/versions.js");
|
|
@@ -8,7 +9,6 @@ require("../utils/index.js");
|
|
|
8
9
|
const require_onchain_utils_viem_executeMulticallBatches = require("../utils/viem/executeMulticallBatches.js");
|
|
9
10
|
const require_onchain_base_SDKConstruct = require("../base/SDKConstruct.js");
|
|
10
11
|
require("../base/index.js");
|
|
11
|
-
const require_abi_compressors_peripheryCompressor = require("../../abi/compressors/peripheryCompressor.js");
|
|
12
12
|
require("../utils/viem/index.js");
|
|
13
13
|
const require_onchain_market_zapper_createZapper = require("./zapper/createZapper.js");
|
|
14
14
|
require("./zapper/index.js");
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/onchain/market/adapters/abi/aave/iAaveOracle.ts
|
|
3
|
+
const iAaveOracleAbi = [{
|
|
4
|
+
name: "BASE_CURRENCY_UNIT",
|
|
5
|
+
type: "function",
|
|
6
|
+
stateMutability: "view",
|
|
7
|
+
inputs: [],
|
|
8
|
+
outputs: [{ type: "uint256" }]
|
|
9
|
+
}, {
|
|
10
|
+
name: "getAssetsPrices",
|
|
11
|
+
type: "function",
|
|
12
|
+
stateMutability: "view",
|
|
13
|
+
inputs: [{
|
|
14
|
+
type: "address[]",
|
|
15
|
+
name: "assets"
|
|
16
|
+
}],
|
|
17
|
+
outputs: [{ type: "uint256[]" }]
|
|
18
|
+
}];
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.iAaveOracleAbi = iAaveOracleAbi;
|
|
@@ -106,6 +106,172 @@ const iAaveV3PoolAbi = [
|
|
|
106
106
|
name: "asset"
|
|
107
107
|
}],
|
|
108
108
|
outputs: [{ type: "address" }]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: "ADDRESSES_PROVIDER",
|
|
112
|
+
type: "function",
|
|
113
|
+
stateMutability: "view",
|
|
114
|
+
inputs: [],
|
|
115
|
+
outputs: [{ type: "address" }]
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: "getReserveData",
|
|
119
|
+
type: "function",
|
|
120
|
+
stateMutability: "view",
|
|
121
|
+
inputs: [{
|
|
122
|
+
type: "address",
|
|
123
|
+
name: "asset"
|
|
124
|
+
}],
|
|
125
|
+
outputs: [{
|
|
126
|
+
type: "tuple",
|
|
127
|
+
components: [
|
|
128
|
+
{
|
|
129
|
+
type: "tuple",
|
|
130
|
+
name: "configuration",
|
|
131
|
+
components: [{
|
|
132
|
+
type: "uint256",
|
|
133
|
+
name: "data"
|
|
134
|
+
}]
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
type: "uint128",
|
|
138
|
+
name: "liquidityIndex"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
type: "uint128",
|
|
142
|
+
name: "currentLiquidityRate"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
type: "uint128",
|
|
146
|
+
name: "variableBorrowIndex"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
type: "uint128",
|
|
150
|
+
name: "currentVariableBorrowRate"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
type: "uint128",
|
|
154
|
+
name: "currentStableBorrowRate"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
type: "uint40",
|
|
158
|
+
name: "lastUpdateTimestamp"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
type: "uint16",
|
|
162
|
+
name: "id"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
type: "address",
|
|
166
|
+
name: "aTokenAddress"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
type: "address",
|
|
170
|
+
name: "stableDebtTokenAddress"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
type: "address",
|
|
174
|
+
name: "variableDebtTokenAddress"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
type: "address",
|
|
178
|
+
name: "interestRateStrategyAddress"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
type: "uint128",
|
|
182
|
+
name: "accruedToTreasury"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
type: "uint128",
|
|
186
|
+
name: "unbacked"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
type: "uint128",
|
|
190
|
+
name: "isolationModeTotalDebt"
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
}]
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: "getUserAccountData",
|
|
197
|
+
type: "function",
|
|
198
|
+
stateMutability: "view",
|
|
199
|
+
inputs: [{
|
|
200
|
+
type: "address",
|
|
201
|
+
name: "user"
|
|
202
|
+
}],
|
|
203
|
+
outputs: [
|
|
204
|
+
{
|
|
205
|
+
type: "uint256",
|
|
206
|
+
name: "totalCollateralBase"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
type: "uint256",
|
|
210
|
+
name: "totalDebtBase"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
type: "uint256",
|
|
214
|
+
name: "availableBorrowsBase"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
type: "uint256",
|
|
218
|
+
name: "currentLiquidationThreshold"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
type: "uint256",
|
|
222
|
+
name: "ltv"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
type: "uint256",
|
|
226
|
+
name: "healthFactor"
|
|
227
|
+
}
|
|
228
|
+
]
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: "getUserEMode",
|
|
232
|
+
type: "function",
|
|
233
|
+
stateMutability: "view",
|
|
234
|
+
inputs: [{
|
|
235
|
+
type: "address",
|
|
236
|
+
name: "user"
|
|
237
|
+
}],
|
|
238
|
+
outputs: [{ type: "uint256" }]
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: "getEModeCategoryCollateralConfig",
|
|
242
|
+
type: "function",
|
|
243
|
+
stateMutability: "view",
|
|
244
|
+
inputs: [{
|
|
245
|
+
type: "uint8",
|
|
246
|
+
name: "id"
|
|
247
|
+
}],
|
|
248
|
+
outputs: [{
|
|
249
|
+
type: "tuple",
|
|
250
|
+
components: [
|
|
251
|
+
{
|
|
252
|
+
type: "uint16",
|
|
253
|
+
name: "ltv"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
type: "uint16",
|
|
257
|
+
name: "liquidationThreshold"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
type: "uint16",
|
|
261
|
+
name: "liquidationBonus"
|
|
262
|
+
}
|
|
263
|
+
]
|
|
264
|
+
}]
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
name: "getEModeCategoryCollateralBitmap",
|
|
268
|
+
type: "function",
|
|
269
|
+
stateMutability: "view",
|
|
270
|
+
inputs: [{
|
|
271
|
+
type: "uint8",
|
|
272
|
+
name: "id"
|
|
273
|
+
}],
|
|
274
|
+
outputs: [{ type: "uint128" }]
|
|
109
275
|
}
|
|
110
276
|
];
|
|
111
277
|
//#endregion
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/onchain/market/adapters/abi/aave/iPoolAddressesProvider.ts
|
|
3
|
+
const iPoolAddressesProviderAbi = [{
|
|
4
|
+
name: "getPriceOracle",
|
|
5
|
+
type: "function",
|
|
6
|
+
stateMutability: "view",
|
|
7
|
+
inputs: [],
|
|
8
|
+
outputs: [{ type: "address" }]
|
|
9
|
+
}];
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.iPoolAddressesProviderAbi = iPoolAddressesProviderAbi;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_onchain_market_adapters_abi_aave_iAaveHorizonBridge = require("./iAaveHorizonBridge.js");
|
|
3
|
+
const require_onchain_market_adapters_abi_aave_iAaveOracle = require("./iAaveOracle.js");
|
|
3
4
|
const require_onchain_market_adapters_abi_aave_iAaveV3Pool = require("./iAaveV3Pool.js");
|
|
5
|
+
const require_onchain_market_adapters_abi_aave_iPoolAddressesProvider = require("./iPoolAddressesProvider.js");
|
|
4
6
|
exports.iAaveHorizonBridgeAbi = require_onchain_market_adapters_abi_aave_iAaveHorizonBridge.iAaveHorizonBridgeAbi;
|
|
7
|
+
exports.iAaveOracleAbi = require_onchain_market_adapters_abi_aave_iAaveOracle.iAaveOracleAbi;
|
|
5
8
|
exports.iAaveV3PoolAbi = require_onchain_market_adapters_abi_aave_iAaveV3Pool.iAaveV3PoolAbi;
|
|
9
|
+
exports.iPoolAddressesProviderAbi = require_onchain_market_adapters_abi_aave_iPoolAddressesProvider.iPoolAddressesProviderAbi;
|
|
@@ -107,6 +107,33 @@ const iAaveHorizonBridgeAdapterAbi = [
|
|
|
107
107
|
name: "useSafePrices"
|
|
108
108
|
}]
|
|
109
109
|
},
|
|
110
|
+
{
|
|
111
|
+
name: "openPositionDiff",
|
|
112
|
+
type: "function",
|
|
113
|
+
stateMutability: "nonpayable",
|
|
114
|
+
inputs: [
|
|
115
|
+
{
|
|
116
|
+
type: "address",
|
|
117
|
+
name: "aToken"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
type: "address",
|
|
121
|
+
name: "debtToken"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
type: "uint256",
|
|
125
|
+
name: "leftoverAmount"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
type: "uint256",
|
|
129
|
+
name: "borrowAmount"
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
outputs: [{
|
|
133
|
+
type: "bool",
|
|
134
|
+
name: "useSafePrices"
|
|
135
|
+
}]
|
|
136
|
+
},
|
|
110
137
|
{
|
|
111
138
|
name: "closePosition",
|
|
112
139
|
type: "function",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_onchain_market_adapters_abi_aave_iAaveHorizonBridge = require("./aave/iAaveHorizonBridge.js");
|
|
3
|
+
const require_onchain_market_adapters_abi_aave_iAaveOracle = require("./aave/iAaveOracle.js");
|
|
3
4
|
const require_onchain_market_adapters_abi_aave_iAaveV3Pool = require("./aave/iAaveV3Pool.js");
|
|
5
|
+
const require_onchain_market_adapters_abi_aave_iPoolAddressesProvider = require("./aave/iPoolAddressesProvider.js");
|
|
4
6
|
require("./aave/index.js");
|
|
5
7
|
const require_onchain_market_adapters_abi_actionAbi = require("./actionAbi.js");
|
|
6
8
|
const require_onchain_market_adapters_abi_adapters_erc4626ReferralAdapter = require("./adapters/erc4626ReferralAdapter.js");
|
|
@@ -68,6 +70,7 @@ exports.getAdapterType = require_onchain_market_adapters_abi_utils.getAdapterTyp
|
|
|
68
70
|
exports.hasAdapterDeployParamsAbi = require_onchain_market_adapters_abi_utils.hasAdapterDeployParamsAbi;
|
|
69
71
|
exports.iAaveHorizonBridgeAbi = require_onchain_market_adapters_abi_aave_iAaveHorizonBridge.iAaveHorizonBridgeAbi;
|
|
70
72
|
exports.iAaveHorizonBridgeAdapterAbi = require_onchain_market_adapters_abi_adapters_iAaveHorizonBridgeAdapter.iAaveHorizonBridgeAdapterAbi;
|
|
73
|
+
exports.iAaveOracleAbi = require_onchain_market_adapters_abi_aave_iAaveOracle.iAaveOracleAbi;
|
|
71
74
|
exports.iAaveV3PoolAbi = require_onchain_market_adapters_abi_aave_iAaveV3Pool.iAaveV3PoolAbi;
|
|
72
75
|
exports.iAaveV3PoolAdapterAbi = require_onchain_market_adapters_abi_adapters_iAaveV3PoolAdapter.iAaveV3PoolAdapterAbi;
|
|
73
76
|
exports.iBalancerV3RouterAbi = require_onchain_market_adapters_abi_targetContractAbi.iBalancerV3RouterAbi;
|
|
@@ -120,6 +123,7 @@ exports.iMidasRedemptionVaultAdapterV310Abi = require_onchain_market_adapters_ab
|
|
|
120
123
|
exports.iMidasRedemptionVaultGatewayV310Abi = require_onchain_market_adapters_abi_adapters_iMidasRedemptionVaultAdapterV310.iMidasRedemptionVaultGatewayV310Abi;
|
|
121
124
|
exports.iPendleRouterAbi = require_onchain_market_adapters_abi_targetContractAbi.iPendleRouterAbi;
|
|
122
125
|
exports.iPendleRouterAdapterAbi = require_onchain_market_adapters_abi_adapters_iPendleRouterAdapter.iPendleRouterAdapterAbi;
|
|
126
|
+
exports.iPoolAddressesProviderAbi = require_onchain_market_adapters_abi_aave_iPoolAddressesProvider.iPoolAddressesProviderAbi;
|
|
123
127
|
exports.iSecuritizeOnRampAbi = require_onchain_market_adapters_abi_securitize_iSecuritizeOnRamp.iSecuritizeOnRampAbi;
|
|
124
128
|
exports.iSecuritizeOnRampAdapterV310Abi = require_onchain_market_adapters_abi_adapters_iSecuritizeOnRampAdapterV310.iSecuritizeOnRampAdapterV310Abi;
|
|
125
129
|
exports.iSecuritizeRedemptionGatewayAdapterV311Abi = require_onchain_market_adapters_abi_adapters_iSecuritizeRedemptionGatewayAdapterV311.iSecuritizeRedemptionGatewayAdapterV311Abi;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_onchain_utils_hex = require("../../../utils/hex.js");
|
|
3
|
+
require("../../../utils/index.js");
|
|
2
4
|
const require_onchain_base_errors = require("../../../base/errors.js");
|
|
3
5
|
require("../../../base/index.js");
|
|
4
6
|
const require_onchain_market_adapters_abi_aave_iAaveHorizonBridge = require("../abi/aave/iAaveHorizonBridge.js");
|
|
@@ -10,6 +12,22 @@ let viem = require("viem");
|
|
|
10
12
|
//#region src/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.ts
|
|
11
13
|
const abi = require_onchain_market_adapters_abi_adapters_iAaveHorizonBridgeAdapter.iAaveHorizonBridgeAdapterAbi;
|
|
12
14
|
const protocolAbi = require_onchain_market_adapters_abi_aave_iAaveHorizonBridge.iAaveHorizonBridgeAbi;
|
|
15
|
+
const FINALIZER_BOT_TYPE = (0, viem.stringToHex)("BOT::AAVE_HORIZON_FINALIZER", { size: 32 });
|
|
16
|
+
/**
|
|
17
|
+
* The bridge a finalizer bot serves, from its `serialize()`:
|
|
18
|
+
* `abi.encode(pool, bridge)`. `undefined` where the bot did not serialize.
|
|
19
|
+
*/
|
|
20
|
+
function finalizerBridge(serializedParams) {
|
|
21
|
+
if (serializedParams === "0x") return;
|
|
22
|
+
const [, bridge] = (0, viem.decodeAbiParameters)([{
|
|
23
|
+
type: "address",
|
|
24
|
+
name: "pool"
|
|
25
|
+
}, {
|
|
26
|
+
type: "address",
|
|
27
|
+
name: "bridge"
|
|
28
|
+
}], serializedParams);
|
|
29
|
+
return bridge;
|
|
30
|
+
}
|
|
13
31
|
var AaveHorizonBridgeAdapterContract = class extends require_onchain_market_adapters_contracts_AbstractAdapter.AbstractAdapterContract {
|
|
14
32
|
#bridge;
|
|
15
33
|
#allowedATokens;
|
|
@@ -67,25 +85,39 @@ var AaveHorizonBridgeAdapterContract = class extends require_onchain_market_adap
|
|
|
67
85
|
return includes(this.allowedDebtTokens, token);
|
|
68
86
|
}
|
|
69
87
|
/**
|
|
70
|
-
* Facade call handing
|
|
71
|
-
*
|
|
72
|
-
* account.
|
|
88
|
+
* Facade call handing every `aToken` the account holds above
|
|
89
|
+
* `leftoverAmount` to the account owner and borrowing `borrowAmount` of
|
|
90
|
+
* `debtToken` on the owner's behalf into the account.
|
|
73
91
|
*/
|
|
74
|
-
|
|
92
|
+
openPositionDiffCall(aToken, debtToken, leftoverAmount, borrowAmount) {
|
|
75
93
|
return {
|
|
76
94
|
target: this.address,
|
|
77
95
|
callData: (0, viem.encodeFunctionData)({
|
|
78
96
|
abi,
|
|
79
|
-
functionName: "
|
|
97
|
+
functionName: "openPositionDiff",
|
|
80
98
|
args: [
|
|
81
99
|
aToken,
|
|
82
100
|
debtToken,
|
|
83
|
-
|
|
101
|
+
leftoverAmount,
|
|
84
102
|
borrowAmount
|
|
85
103
|
]
|
|
86
104
|
})
|
|
87
105
|
};
|
|
88
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Every account on this credit manager is finished by the Horizon finalizer
|
|
109
|
+
* bot a block after its own transaction, so opening one grants the bot its
|
|
110
|
+
* permissions. The bot is the one the market configurator lists among its
|
|
111
|
+
* periphery contracts for this adapter's bridge, the latest version where
|
|
112
|
+
* there are several; nothing where it lists none.
|
|
113
|
+
*/
|
|
114
|
+
async openingCalls() {
|
|
115
|
+
const { configurator } = this.sdk.marketRegister.findByCreditManager(this.creditManager);
|
|
116
|
+
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));
|
|
117
|
+
if (!bot) return [];
|
|
118
|
+
const { creditFacade } = this.sdk.marketRegister.findCreditManager(this.creditManager);
|
|
119
|
+
return [creditFacade.prepareSetBotPermissions(bot.baseParams.addr, bot.requiredPermissions)];
|
|
120
|
+
}
|
|
89
121
|
stateHuman(raw) {
|
|
90
122
|
return {
|
|
91
123
|
...super.stateHuman(raw),
|
|
@@ -95,13 +127,13 @@ var AaveHorizonBridgeAdapterContract = class extends require_onchain_market_adap
|
|
|
95
127
|
};
|
|
96
128
|
}
|
|
97
129
|
/**
|
|
98
|
-
* Opening and closing a position are legal outside a bracket:
|
|
99
|
-
*
|
|
100
|
-
* nothing for an on-chain comparison to enforce.
|
|
130
|
+
* Opening and closing a position are legal outside a bracket: the bridge
|
|
131
|
+
* moves exactly the amounts the calldata names, or the balance above the
|
|
132
|
+
* named leftover, so there is nothing for an on-chain comparison to enforce.
|
|
101
133
|
*
|
|
102
|
-
* Opening hands
|
|
103
|
-
*
|
|
104
|
-
*
|
|
134
|
+
* Opening hands the aTokens to the account owner and brings `borrowAmount`
|
|
135
|
+
* of the debt token in; closing sends `repayAmount` of the debt token out and
|
|
136
|
+
* brings the aTokens back.
|
|
105
137
|
*/
|
|
106
138
|
replayOutOfBracketCall(balances, calldata) {
|
|
107
139
|
const decoded = (0, viem.decodeFunctionData)({
|
|
@@ -115,6 +147,15 @@ var AaveHorizonBridgeAdapterContract = class extends require_onchain_market_adap
|
|
|
115
147
|
balances.inc(debtToken, borrowAmount);
|
|
116
148
|
return true;
|
|
117
149
|
}
|
|
150
|
+
case "openPositionDiff": {
|
|
151
|
+
const [aToken, debtToken, leftoverAmount, borrowAmount] = decoded.args;
|
|
152
|
+
const balance = balances.getOrZero(aToken);
|
|
153
|
+
if (balance > leftoverAmount) {
|
|
154
|
+
balances.dec(aToken, balance - leftoverAmount);
|
|
155
|
+
balances.inc(debtToken, borrowAmount);
|
|
156
|
+
}
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
118
159
|
case "closePosition": {
|
|
119
160
|
const [aToken, debtToken, repayAmount, aTokenAmount] = decoded.args;
|
|
120
161
|
balances.dec(debtToken, repayAmount);
|
|
@@ -88,22 +88,16 @@ var AaveV3PoolAdapterContract = class extends require_onchain_market_adapters_co
|
|
|
88
88
|
return read;
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
|
-
* Facade call supplying
|
|
92
|
-
*
|
|
93
|
-
* neither it nor the referral code is sent.
|
|
91
|
+
* Facade call supplying every `asset` the credit account holds above
|
|
92
|
+
* `leftoverAmount`.
|
|
94
93
|
*/
|
|
95
|
-
|
|
94
|
+
supplyDiffCall(asset, leftoverAmount) {
|
|
96
95
|
return {
|
|
97
96
|
target: this.address,
|
|
98
97
|
callData: (0, viem.encodeFunctionData)({
|
|
99
98
|
abi,
|
|
100
|
-
functionName: "
|
|
101
|
-
args: [
|
|
102
|
-
asset,
|
|
103
|
-
amount,
|
|
104
|
-
viem.zeroAddress,
|
|
105
|
-
0
|
|
106
|
-
]
|
|
99
|
+
functionName: "supplyDiff",
|
|
100
|
+
args: [asset, leftoverAmount]
|
|
107
101
|
})
|
|
108
102
|
};
|
|
109
103
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_onchain_market_adapters_abi_aave_iAaveHorizonBridge = require("./abi/aave/iAaveHorizonBridge.js");
|
|
3
|
+
const require_onchain_market_adapters_abi_aave_iAaveOracle = require("./abi/aave/iAaveOracle.js");
|
|
3
4
|
const require_onchain_market_adapters_abi_aave_iAaveV3Pool = require("./abi/aave/iAaveV3Pool.js");
|
|
5
|
+
const require_onchain_market_adapters_abi_aave_iPoolAddressesProvider = require("./abi/aave/iPoolAddressesProvider.js");
|
|
4
6
|
const require_onchain_market_adapters_types = require("./types.js");
|
|
5
7
|
const require_onchain_market_adapters_abi_actionAbi = require("./abi/actionAbi.js");
|
|
6
8
|
const require_onchain_market_adapters_abi_adapters_erc4626ReferralAdapter = require("./abi/adapters/erc4626ReferralAdapter.js");
|
|
@@ -169,6 +171,7 @@ exports.getAdapterType = require_onchain_market_adapters_abi_utils.getAdapterTyp
|
|
|
169
171
|
exports.hasAdapterDeployParamsAbi = require_onchain_market_adapters_abi_utils.hasAdapterDeployParamsAbi;
|
|
170
172
|
exports.iAaveHorizonBridgeAbi = require_onchain_market_adapters_abi_aave_iAaveHorizonBridge.iAaveHorizonBridgeAbi;
|
|
171
173
|
exports.iAaveHorizonBridgeAdapterAbi = require_onchain_market_adapters_abi_adapters_iAaveHorizonBridgeAdapter.iAaveHorizonBridgeAdapterAbi;
|
|
174
|
+
exports.iAaveOracleAbi = require_onchain_market_adapters_abi_aave_iAaveOracle.iAaveOracleAbi;
|
|
172
175
|
exports.iAaveV3PoolAbi = require_onchain_market_adapters_abi_aave_iAaveV3Pool.iAaveV3PoolAbi;
|
|
173
176
|
exports.iAaveV3PoolAdapterAbi = require_onchain_market_adapters_abi_adapters_iAaveV3PoolAdapter.iAaveV3PoolAdapterAbi;
|
|
174
177
|
exports.iBalancerV3RouterAbi = require_onchain_market_adapters_abi_targetContractAbi.iBalancerV3RouterAbi;
|
|
@@ -221,6 +224,7 @@ exports.iMidasRedemptionVaultAdapterV310Abi = require_onchain_market_adapters_ab
|
|
|
221
224
|
exports.iMidasRedemptionVaultGatewayV310Abi = require_onchain_market_adapters_abi_adapters_iMidasRedemptionVaultAdapterV310.iMidasRedemptionVaultGatewayV310Abi;
|
|
222
225
|
exports.iPendleRouterAbi = require_onchain_market_adapters_abi_targetContractAbi.iPendleRouterAbi;
|
|
223
226
|
exports.iPendleRouterAdapterAbi = require_onchain_market_adapters_abi_adapters_iPendleRouterAdapter.iPendleRouterAdapterAbi;
|
|
227
|
+
exports.iPoolAddressesProviderAbi = require_onchain_market_adapters_abi_aave_iPoolAddressesProvider.iPoolAddressesProviderAbi;
|
|
224
228
|
exports.iSecuritizeOnRampAbi = require_onchain_market_adapters_abi_securitize_iSecuritizeOnRamp.iSecuritizeOnRampAbi;
|
|
225
229
|
exports.iSecuritizeOnRampAdapterV310Abi = require_onchain_market_adapters_abi_adapters_iSecuritizeOnRampAdapterV310.iSecuritizeOnRampAdapterV310Abi;
|
|
226
230
|
exports.iSecuritizeRedemptionGatewayAdapterV311Abi = require_onchain_market_adapters_abi_adapters_iSecuritizeRedemptionGatewayAdapterV311.iSecuritizeRedemptionGatewayAdapterV311Abi;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_onchain_market_adapters_abi_aave_iAaveHorizonBridge = require("./adapters/abi/aave/iAaveHorizonBridge.js");
|
|
3
|
+
const require_onchain_market_adapters_abi_aave_iAaveOracle = require("./adapters/abi/aave/iAaveOracle.js");
|
|
3
4
|
const require_onchain_market_adapters_abi_aave_iAaveV3Pool = require("./adapters/abi/aave/iAaveV3Pool.js");
|
|
5
|
+
const require_onchain_market_adapters_abi_aave_iPoolAddressesProvider = require("./adapters/abi/aave/iPoolAddressesProvider.js");
|
|
4
6
|
const require_onchain_market_adapters_types = require("./adapters/types.js");
|
|
5
7
|
const require_onchain_market_adapters_abi_actionAbi = require("./adapters/abi/actionAbi.js");
|
|
6
8
|
const require_onchain_market_adapters_abi_adapters_erc4626ReferralAdapter = require("./adapters/abi/adapters/erc4626ReferralAdapter.js");
|
|
@@ -304,6 +306,7 @@ exports.hasAdapterDeployParamsAbi = require_onchain_market_adapters_abi_utils.ha
|
|
|
304
306
|
exports.healthFactorBps = require_onchain_market_math.healthFactorBps;
|
|
305
307
|
exports.iAaveHorizonBridgeAbi = require_onchain_market_adapters_abi_aave_iAaveHorizonBridge.iAaveHorizonBridgeAbi;
|
|
306
308
|
exports.iAaveHorizonBridgeAdapterAbi = require_onchain_market_adapters_abi_adapters_iAaveHorizonBridgeAdapter.iAaveHorizonBridgeAdapterAbi;
|
|
309
|
+
exports.iAaveOracleAbi = require_onchain_market_adapters_abi_aave_iAaveOracle.iAaveOracleAbi;
|
|
307
310
|
exports.iAaveV3PoolAbi = require_onchain_market_adapters_abi_aave_iAaveV3Pool.iAaveV3PoolAbi;
|
|
308
311
|
exports.iAaveV3PoolAdapterAbi = require_onchain_market_adapters_abi_adapters_iAaveV3PoolAdapter.iAaveV3PoolAdapterAbi;
|
|
309
312
|
exports.iBalancerV3RouterAbi = require_onchain_market_adapters_abi_targetContractAbi.iBalancerV3RouterAbi;
|
|
@@ -356,6 +359,7 @@ exports.iMidasRedemptionVaultAdapterV310Abi = require_onchain_market_adapters_ab
|
|
|
356
359
|
exports.iMidasRedemptionVaultGatewayV310Abi = require_onchain_market_adapters_abi_adapters_iMidasRedemptionVaultAdapterV310.iMidasRedemptionVaultGatewayV310Abi;
|
|
357
360
|
exports.iPendleRouterAbi = require_onchain_market_adapters_abi_targetContractAbi.iPendleRouterAbi;
|
|
358
361
|
exports.iPendleRouterAdapterAbi = require_onchain_market_adapters_abi_adapters_iPendleRouterAdapter.iPendleRouterAdapterAbi;
|
|
362
|
+
exports.iPoolAddressesProviderAbi = require_onchain_market_adapters_abi_aave_iPoolAddressesProvider.iPoolAddressesProviderAbi;
|
|
359
363
|
exports.iSecuritizeOnRampAbi = require_onchain_market_adapters_abi_securitize_iSecuritizeOnRamp.iSecuritizeOnRampAbi;
|
|
360
364
|
exports.iSecuritizeOnRampAdapterV310Abi = require_onchain_market_adapters_abi_adapters_iSecuritizeOnRampAdapterV310.iSecuritizeOnRampAdapterV310Abi;
|
|
361
365
|
exports.iSecuritizeRedemptionGatewayAdapterV311Abi = require_onchain_market_adapters_abi_adapters_iSecuritizeRedemptionGatewayAdapterV311.iSecuritizeRedemptionGatewayAdapterV311Abi;
|