@gearbox-protocol/sdk 18.4.0 → 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/model/index.js +1 -4
- package/dist/cjs/offchain/GearboxAPI.js +0 -7
- package/dist/cjs/offchain/index.js +0 -3
- 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/index.js +1 -0
- package/dist/cjs/onchain/accounts/intents/operations.js +21 -0
- package/dist/cjs/onchain/accounts/intents/plan.js +33 -0
- package/dist/cjs/onchain/accounts/intents/realize.js +44 -0
- package/dist/cjs/onchain/accounts/intents/testing/market.js +1 -0
- package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +2 -1
- package/dist/cjs/onchain/accounts/intents/utils/ledger.js +8 -0
- package/dist/cjs/onchain/chain/chains.js +4 -0
- package/dist/cjs/onchain/index.js +16 -0
- package/dist/cjs/onchain/market/ZapperRegister.js +1 -1
- package/dist/cjs/onchain/market/adapters/abi/aave/iAaveHorizonBridge.js +94 -0
- package/dist/cjs/onchain/market/adapters/abi/aave/iAaveOracle.js +20 -0
- package/dist/cjs/onchain/market/adapters/abi/aave/iAaveV3Pool.js +278 -0
- package/dist/cjs/onchain/market/adapters/abi/aave/iPoolAddressesProvider.js +11 -0
- package/dist/cjs/onchain/market/adapters/abi/aave/index.js +9 -0
- package/dist/cjs/onchain/market/adapters/abi/actionAbi.js +1 -0
- package/dist/cjs/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.js +224 -0
- package/dist/cjs/onchain/market/adapters/abi/adapters/iAaveV3PoolAdapter.js +177 -0
- package/dist/cjs/onchain/market/adapters/abi/adapters/index.js +4 -0
- package/dist/cjs/onchain/market/adapters/abi/conctructorAbi.js +2 -0
- package/dist/cjs/onchain/market/adapters/abi/index.js +13 -0
- package/dist/cjs/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.js +171 -0
- package/dist/cjs/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.js +199 -0
- package/dist/cjs/onchain/market/adapters/contracts/AbstractAdapter.js +8 -0
- package/dist/cjs/onchain/market/adapters/contracts/index.js +4 -0
- package/dist/cjs/onchain/market/adapters/createAdapter.js +4 -0
- package/dist/cjs/onchain/market/adapters/index.js +16 -0
- package/dist/cjs/onchain/market/adapters/types.js +2 -0
- package/dist/cjs/onchain/market/index.js +16 -0
- package/dist/cjs/onchain/positions/projectAavePosition.js +175 -0
- package/dist/cjs/onchain/preview/preview/loadAdapterReplayState.js +17 -0
- package/dist/cjs/onchain/preview/preview/previewOperation.js +2 -0
- package/dist/cjs/sdk/GearboxSDK.js +0 -9
- package/dist/cjs/sdk/prepare/PrepareApi.js +56 -0
- package/dist/cjs/sdk/preview/PreviewNamespace.js +42 -0
- package/dist/esm/model/index.js +2 -3
- package/dist/esm/offchain/GearboxAPI.js +0 -7
- package/dist/esm/offchain/index.js +1 -3
- 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/index.js +2 -1
- package/dist/esm/onchain/accounts/intents/operations.js +20 -1
- package/dist/esm/onchain/accounts/intents/plan.js +33 -1
- package/dist/esm/onchain/accounts/intents/realize.js +46 -2
- package/dist/esm/onchain/accounts/intents/testing/market.js +1 -0
- package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +2 -1
- package/dist/esm/onchain/accounts/intents/utils/ledger.js +8 -0
- package/dist/esm/onchain/chain/chains.js +4 -0
- package/dist/esm/onchain/index.js +9 -1
- package/dist/esm/onchain/market/ZapperRegister.js +1 -1
- package/dist/esm/onchain/market/adapters/abi/aave/iAaveHorizonBridge.js +93 -0
- package/dist/esm/onchain/market/adapters/abi/aave/iAaveOracle.js +19 -0
- package/dist/esm/onchain/market/adapters/abi/aave/iAaveV3Pool.js +277 -0
- package/dist/esm/onchain/market/adapters/abi/aave/iPoolAddressesProvider.js +10 -0
- package/dist/esm/onchain/market/adapters/abi/aave/index.js +5 -0
- package/dist/esm/onchain/market/adapters/abi/actionAbi.js +1 -0
- package/dist/esm/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.js +223 -0
- package/dist/esm/onchain/market/adapters/abi/adapters/iAaveV3PoolAdapter.js +176 -0
- package/dist/esm/onchain/market/adapters/abi/adapters/index.js +3 -1
- package/dist/esm/onchain/market/adapters/abi/conctructorAbi.js +2 -0
- package/dist/esm/onchain/market/adapters/abi/index.js +8 -1
- package/dist/esm/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.js +170 -0
- package/dist/esm/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.js +198 -0
- package/dist/esm/onchain/market/adapters/contracts/AbstractAdapter.js +8 -0
- package/dist/esm/onchain/market/adapters/contracts/index.js +3 -1
- package/dist/esm/onchain/market/adapters/createAdapter.js +4 -0
- package/dist/esm/onchain/market/adapters/index.js +9 -1
- package/dist/esm/onchain/market/adapters/types.js +2 -0
- package/dist/esm/onchain/market/index.js +9 -1
- package/dist/esm/onchain/positions/projectAavePosition.js +174 -0
- package/dist/esm/onchain/preview/preview/loadAdapterReplayState.js +16 -0
- package/dist/esm/onchain/preview/preview/previewOperation.js +2 -0
- package/dist/esm/sdk/GearboxSDK.js +0 -9
- package/dist/esm/sdk/prepare/PrepareApi.js +57 -1
- package/dist/esm/sdk/preview/PreviewNamespace.js +42 -0
- package/dist/types/model/aave.d.ts +34 -0
- package/dist/types/model/analytics.d.ts +2 -2
- package/dist/types/model/index.d.ts +6 -7
- package/dist/types/model/opportunities.d.ts +1 -1
- package/dist/types/model/positions.d.ts +1 -1
- package/dist/types/model/previews.d.ts +15 -0
- package/dist/types/offchain/AbstractOffchainNamespace.d.ts +1 -1
- package/dist/types/offchain/GearboxAPI.d.ts +0 -6
- package/dist/types/offchain/analytics/OffchainAnalytics.d.ts +1 -1
- package/dist/types/offchain/analytics/types.d.ts +1 -1
- package/dist/types/offchain/index.d.ts +1 -3
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +1 -1
- package/dist/types/offchain/opportunities/types.d.ts +1 -1
- package/dist/types/offchain/positions/OffchainPositions.d.ts +1 -1
- package/dist/types/offchain/positions/types.d.ts +1 -1
- package/dist/types/onchain/accounts/bots/AccountBotsService.d.ts +11 -1
- package/dist/types/onchain/accounts/bots/index.d.ts +2 -2
- package/dist/types/onchain/accounts/bots/types.d.ts +7 -1
- package/dist/types/onchain/accounts/index.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/operations.d.ts +43 -1
- package/dist/types/onchain/accounts/intents/plan.d.ts +26 -1
- package/dist/types/onchain/accounts/intents/testing/market.d.ts +4 -0
- package/dist/types/onchain/accounts/intents/testing/sdk-mock.d.ts +4 -0
- package/dist/types/onchain/accounts/intents/types.d.ts +20 -1
- package/dist/types/onchain/index.d.ts +10 -2
- package/dist/types/onchain/market/adapters/abi/aave/iAaveHorizonBridge.d.ts +83 -0
- package/dist/types/onchain/market/adapters/abi/aave/iAaveOracle.d.ts +22 -0
- package/dist/types/onchain/market/adapters/abi/aave/iAaveV3Pool.d.ts +229 -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 +5 -0
- package/dist/types/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.d.ts +207 -0
- package/dist/types/onchain/market/adapters/abi/adapters/iAaveV3PoolAdapter.d.ts +172 -0
- package/dist/types/onchain/market/adapters/abi/adapters/index.d.ts +3 -1
- package/dist/types/onchain/market/adapters/abi/index.d.ts +8 -1
- package/dist/types/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.d.ts +341 -0
- package/dist/types/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.d.ts +450 -0
- package/dist/types/onchain/market/adapters/contracts/AbstractAdapter.d.ts +8 -0
- package/dist/types/onchain/market/adapters/contracts/index.d.ts +3 -1
- package/dist/types/onchain/market/adapters/index.d.ts +9 -1
- package/dist/types/onchain/market/adapters/types.d.ts +3 -1
- package/dist/types/onchain/market/index.d.ts +9 -1
- package/dist/types/onchain/positions/projectAavePosition.d.ts +45 -0
- package/dist/types/onchain/preview/preview/loadAdapterReplayState.d.ts +13 -0
- package/dist/types/sdk/GearboxSDK.d.ts +1 -8
- package/dist/types/sdk/analytics/AnalyticsNamespace.d.ts +1 -1
- package/dist/types/sdk/analytics/types.d.ts +1 -1
- package/dist/types/sdk/index.d.ts +3 -3
- package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +1 -1
- package/dist/types/sdk/opportunities/types.d.ts +1 -1
- package/dist/types/sdk/positions/PositionsNamespace.d.ts +1 -1
- package/dist/types/sdk/positions/types.d.ts +1 -1
- package/dist/types/sdk/prepare/PrepareApi.d.ts +11 -3
- package/dist/types/sdk/prepare/index.d.ts +2 -2
- package/dist/types/sdk/prepare/types.d.ts +83 -1
- package/dist/types/sdk/preview/PreviewNamespace.d.ts +5 -1
- package/dist/types/sdk/preview/types.d.ts +12 -1
- package/dist/types/sdk/types.d.ts +0 -20
- package/package.json +1 -1
- package/dist/cjs/model/notices.schema.js +0 -25
- package/dist/cjs/offchain/notices/OffchainNotices.js +0 -27
- package/dist/cjs/offchain/notices/index.js +0 -3
- package/dist/esm/model/notices.schema.js +0 -23
- package/dist/esm/offchain/notices/OffchainNotices.js +0 -26
- package/dist/esm/offchain/notices/index.js +0 -1
- package/dist/types/model/notices.d.ts +0 -28
- package/dist/types/model/notices.schema.d.ts +0 -22
- package/dist/types/offchain/notices/OffchainNotices.d.ts +0 -18
- package/dist/types/offchain/notices/index.d.ts +0 -2
- /package/dist/cjs/model/{notices.js → aave.js} +0 -0
- /package/dist/esm/model/{notices.js → aave.js} +0 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
//#region src/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.ts
|
|
2
|
+
const iAaveHorizonBridgeAdapterAbi = [
|
|
3
|
+
{
|
|
4
|
+
name: "contractType",
|
|
5
|
+
type: "function",
|
|
6
|
+
stateMutability: "view",
|
|
7
|
+
inputs: [],
|
|
8
|
+
outputs: [{ type: "bytes32" }]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
name: "creditManager",
|
|
12
|
+
type: "function",
|
|
13
|
+
stateMutability: "view",
|
|
14
|
+
inputs: [],
|
|
15
|
+
outputs: [{ type: "address" }]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "targetContract",
|
|
19
|
+
type: "function",
|
|
20
|
+
stateMutability: "view",
|
|
21
|
+
inputs: [],
|
|
22
|
+
outputs: [{ type: "address" }]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "version",
|
|
26
|
+
type: "function",
|
|
27
|
+
stateMutability: "view",
|
|
28
|
+
inputs: [],
|
|
29
|
+
outputs: [{ type: "uint256" }]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "serialize",
|
|
33
|
+
type: "function",
|
|
34
|
+
stateMutability: "view",
|
|
35
|
+
inputs: [],
|
|
36
|
+
outputs: [{
|
|
37
|
+
type: "bytes",
|
|
38
|
+
name: "serializedData"
|
|
39
|
+
}]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "bridge",
|
|
43
|
+
type: "function",
|
|
44
|
+
stateMutability: "view",
|
|
45
|
+
inputs: [],
|
|
46
|
+
outputs: [{ type: "address" }]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "isATokenAllowed",
|
|
50
|
+
type: "function",
|
|
51
|
+
stateMutability: "view",
|
|
52
|
+
inputs: [{
|
|
53
|
+
type: "address",
|
|
54
|
+
name: "token"
|
|
55
|
+
}],
|
|
56
|
+
outputs: [{ type: "bool" }]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "isDebtTokenAllowed",
|
|
60
|
+
type: "function",
|
|
61
|
+
stateMutability: "view",
|
|
62
|
+
inputs: [{
|
|
63
|
+
type: "address",
|
|
64
|
+
name: "token"
|
|
65
|
+
}],
|
|
66
|
+
outputs: [{ type: "bool" }]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "allowedATokens",
|
|
70
|
+
type: "function",
|
|
71
|
+
stateMutability: "view",
|
|
72
|
+
inputs: [],
|
|
73
|
+
outputs: [{ type: "address[]" }]
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "allowedDebtTokens",
|
|
77
|
+
type: "function",
|
|
78
|
+
stateMutability: "view",
|
|
79
|
+
inputs: [],
|
|
80
|
+
outputs: [{ type: "address[]" }]
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "openPosition",
|
|
84
|
+
type: "function",
|
|
85
|
+
stateMutability: "nonpayable",
|
|
86
|
+
inputs: [
|
|
87
|
+
{
|
|
88
|
+
type: "address",
|
|
89
|
+
name: "aToken"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: "address",
|
|
93
|
+
name: "debtToken"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: "uint256",
|
|
97
|
+
name: "aTokenAmount"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
type: "uint256",
|
|
101
|
+
name: "borrowAmount"
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
outputs: [{
|
|
105
|
+
type: "bool",
|
|
106
|
+
name: "useSafePrices"
|
|
107
|
+
}]
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "openPositionDiff",
|
|
111
|
+
type: "function",
|
|
112
|
+
stateMutability: "nonpayable",
|
|
113
|
+
inputs: [
|
|
114
|
+
{
|
|
115
|
+
type: "address",
|
|
116
|
+
name: "aToken"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
type: "address",
|
|
120
|
+
name: "debtToken"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: "uint256",
|
|
124
|
+
name: "leftoverAmount"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
type: "uint256",
|
|
128
|
+
name: "borrowAmount"
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
outputs: [{
|
|
132
|
+
type: "bool",
|
|
133
|
+
name: "useSafePrices"
|
|
134
|
+
}]
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "closePosition",
|
|
138
|
+
type: "function",
|
|
139
|
+
stateMutability: "nonpayable",
|
|
140
|
+
inputs: [
|
|
141
|
+
{
|
|
142
|
+
type: "address",
|
|
143
|
+
name: "aToken"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
type: "address",
|
|
147
|
+
name: "debtToken"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
type: "uint256",
|
|
151
|
+
name: "repayAmount"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
type: "uint256",
|
|
155
|
+
name: "aTokenAmount"
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
outputs: [{
|
|
159
|
+
type: "bool",
|
|
160
|
+
name: "useSafePrices"
|
|
161
|
+
}]
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: "setATokenStatusBatch",
|
|
165
|
+
type: "function",
|
|
166
|
+
stateMutability: "nonpayable",
|
|
167
|
+
inputs: [{
|
|
168
|
+
type: "tuple[]",
|
|
169
|
+
name: "tokens",
|
|
170
|
+
components: [{
|
|
171
|
+
type: "address",
|
|
172
|
+
name: "token"
|
|
173
|
+
}, {
|
|
174
|
+
type: "bool",
|
|
175
|
+
name: "allowed"
|
|
176
|
+
}]
|
|
177
|
+
}],
|
|
178
|
+
outputs: []
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "setDebtTokenStatusBatch",
|
|
182
|
+
type: "function",
|
|
183
|
+
stateMutability: "nonpayable",
|
|
184
|
+
inputs: [{
|
|
185
|
+
type: "tuple[]",
|
|
186
|
+
name: "tokens",
|
|
187
|
+
components: [{
|
|
188
|
+
type: "address",
|
|
189
|
+
name: "token"
|
|
190
|
+
}, {
|
|
191
|
+
type: "bool",
|
|
192
|
+
name: "allowed"
|
|
193
|
+
}]
|
|
194
|
+
}],
|
|
195
|
+
outputs: []
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: "SetATokenStatus",
|
|
199
|
+
type: "event",
|
|
200
|
+
inputs: [{
|
|
201
|
+
type: "address",
|
|
202
|
+
name: "token",
|
|
203
|
+
indexed: true
|
|
204
|
+
}, {
|
|
205
|
+
type: "bool",
|
|
206
|
+
name: "allowed"
|
|
207
|
+
}]
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: "SetDebtTokenStatus",
|
|
211
|
+
type: "event",
|
|
212
|
+
inputs: [{
|
|
213
|
+
type: "address",
|
|
214
|
+
name: "token",
|
|
215
|
+
indexed: true
|
|
216
|
+
}, {
|
|
217
|
+
type: "bool",
|
|
218
|
+
name: "allowed"
|
|
219
|
+
}]
|
|
220
|
+
}
|
|
221
|
+
];
|
|
222
|
+
//#endregion
|
|
223
|
+
export { iAaveHorizonBridgeAdapterAbi };
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
//#region src/onchain/market/adapters/abi/adapters/iAaveV3PoolAdapter.ts
|
|
2
|
+
const iAaveV3PoolAdapterAbi = [
|
|
3
|
+
{
|
|
4
|
+
name: "contractType",
|
|
5
|
+
type: "function",
|
|
6
|
+
stateMutability: "view",
|
|
7
|
+
inputs: [],
|
|
8
|
+
outputs: [{ type: "bytes32" }]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
name: "creditManager",
|
|
12
|
+
type: "function",
|
|
13
|
+
stateMutability: "view",
|
|
14
|
+
inputs: [],
|
|
15
|
+
outputs: [{ type: "address" }]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "targetContract",
|
|
19
|
+
type: "function",
|
|
20
|
+
stateMutability: "view",
|
|
21
|
+
inputs: [],
|
|
22
|
+
outputs: [{ type: "address" }]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "version",
|
|
26
|
+
type: "function",
|
|
27
|
+
stateMutability: "view",
|
|
28
|
+
inputs: [],
|
|
29
|
+
outputs: [{ type: "uint256" }]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "serialize",
|
|
33
|
+
type: "function",
|
|
34
|
+
stateMutability: "view",
|
|
35
|
+
inputs: [],
|
|
36
|
+
outputs: [{
|
|
37
|
+
type: "bytes",
|
|
38
|
+
name: "serializedData"
|
|
39
|
+
}]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "pool",
|
|
43
|
+
type: "function",
|
|
44
|
+
stateMutability: "view",
|
|
45
|
+
inputs: [],
|
|
46
|
+
outputs: [{ type: "address" }]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "referralCode",
|
|
50
|
+
type: "function",
|
|
51
|
+
stateMutability: "view",
|
|
52
|
+
inputs: [],
|
|
53
|
+
outputs: [{ type: "uint16" }]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "isAssetAllowed",
|
|
57
|
+
type: "function",
|
|
58
|
+
stateMutability: "view",
|
|
59
|
+
inputs: [{
|
|
60
|
+
type: "address",
|
|
61
|
+
name: "asset"
|
|
62
|
+
}],
|
|
63
|
+
outputs: [{ type: "bool" }]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "allowedAssets",
|
|
67
|
+
type: "function",
|
|
68
|
+
stateMutability: "view",
|
|
69
|
+
inputs: [],
|
|
70
|
+
outputs: [{ type: "address[]" }]
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "supply",
|
|
74
|
+
type: "function",
|
|
75
|
+
stateMutability: "nonpayable",
|
|
76
|
+
inputs: [
|
|
77
|
+
{
|
|
78
|
+
type: "address",
|
|
79
|
+
name: "asset"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: "uint256",
|
|
83
|
+
name: "amount"
|
|
84
|
+
},
|
|
85
|
+
{ type: "address" },
|
|
86
|
+
{ type: "uint16" }
|
|
87
|
+
],
|
|
88
|
+
outputs: [{
|
|
89
|
+
type: "bool",
|
|
90
|
+
name: "useSafePrices"
|
|
91
|
+
}]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "supplyDiff",
|
|
95
|
+
type: "function",
|
|
96
|
+
stateMutability: "nonpayable",
|
|
97
|
+
inputs: [{
|
|
98
|
+
type: "address",
|
|
99
|
+
name: "asset"
|
|
100
|
+
}, {
|
|
101
|
+
type: "uint256",
|
|
102
|
+
name: "leftoverAmount"
|
|
103
|
+
}],
|
|
104
|
+
outputs: [{
|
|
105
|
+
type: "bool",
|
|
106
|
+
name: "useSafePrices"
|
|
107
|
+
}]
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "withdraw",
|
|
111
|
+
type: "function",
|
|
112
|
+
stateMutability: "nonpayable",
|
|
113
|
+
inputs: [
|
|
114
|
+
{
|
|
115
|
+
type: "address",
|
|
116
|
+
name: "asset"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
type: "uint256",
|
|
120
|
+
name: "amount"
|
|
121
|
+
},
|
|
122
|
+
{ type: "address" }
|
|
123
|
+
],
|
|
124
|
+
outputs: [{
|
|
125
|
+
type: "bool",
|
|
126
|
+
name: "useSafePrices"
|
|
127
|
+
}]
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: "withdrawDiff",
|
|
131
|
+
type: "function",
|
|
132
|
+
stateMutability: "nonpayable",
|
|
133
|
+
inputs: [{
|
|
134
|
+
type: "address",
|
|
135
|
+
name: "asset"
|
|
136
|
+
}, {
|
|
137
|
+
type: "uint256",
|
|
138
|
+
name: "leftoverAmount"
|
|
139
|
+
}],
|
|
140
|
+
outputs: [{
|
|
141
|
+
type: "bool",
|
|
142
|
+
name: "useSafePrices"
|
|
143
|
+
}]
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "setAssetStatusBatch",
|
|
147
|
+
type: "function",
|
|
148
|
+
stateMutability: "nonpayable",
|
|
149
|
+
inputs: [{
|
|
150
|
+
type: "tuple[]",
|
|
151
|
+
name: "assets",
|
|
152
|
+
components: [{
|
|
153
|
+
type: "address",
|
|
154
|
+
name: "asset"
|
|
155
|
+
}, {
|
|
156
|
+
type: "bool",
|
|
157
|
+
name: "allowed"
|
|
158
|
+
}]
|
|
159
|
+
}],
|
|
160
|
+
outputs: []
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: "SetAssetStatus",
|
|
164
|
+
type: "event",
|
|
165
|
+
inputs: [{
|
|
166
|
+
type: "address",
|
|
167
|
+
name: "asset",
|
|
168
|
+
indexed: true
|
|
169
|
+
}, {
|
|
170
|
+
type: "bool",
|
|
171
|
+
name: "allowed"
|
|
172
|
+
}]
|
|
173
|
+
}
|
|
174
|
+
];
|
|
175
|
+
//#endregion
|
|
176
|
+
export { iAaveV3PoolAdapterAbi };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { erc4626ReferralAdapterAbi } from "./erc4626ReferralAdapter.js";
|
|
2
|
+
import { iAaveHorizonBridgeAdapterAbi } from "./iAaveHorizonBridgeAdapter.js";
|
|
3
|
+
import { iAaveV3PoolAdapterAbi } from "./iAaveV3PoolAdapter.js";
|
|
2
4
|
import { iBalancerV3RouterAdapterAbi } from "./iBalancerV3RouterAdapter.js";
|
|
3
5
|
import { iBalancerV3WrapperAdapterAbi } from "./iBalancerV3WrapperAdapter.js";
|
|
4
6
|
import { iCamelotV3AdapterAbi } from "./iCamelotV3Adapter.js";
|
|
@@ -36,4 +38,4 @@ import { iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi } from "./iUpshiftVaul
|
|
|
36
38
|
import { iVelodromeV2RouterAdapterAbi } from "./iVelodromeV2RouterAdapter.js";
|
|
37
39
|
import { iwstEthv1AdapterAbi } from "./iwstEthv1Adapter.js";
|
|
38
40
|
import { mellowDvvAdapterAbi } from "./mellowDvvAdapter.js";
|
|
39
|
-
export { erc4626ReferralAdapterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAdapterAbi, iCamelotV3AdapterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAdapterAbi, iFluidDexAdapterAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAdapterAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAdapterAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iStakingRewardsAdapterAbi, iTraderJoeRouterAdapterAbi, iTreehouseFastlaneAdapterAbi, iTreehouseRedemptionGatewayAdapterAbi, iTreehouseRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAdapterAbi, iwstEthv1AdapterAbi, mellowDvvAdapterAbi };
|
|
41
|
+
export { erc4626ReferralAdapterAbi, iAaveHorizonBridgeAdapterAbi, iAaveV3PoolAdapterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAdapterAbi, iCamelotV3AdapterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAdapterAbi, iFluidDexAdapterAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAdapterAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAdapterAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iStakingRewardsAdapterAbi, iTraderJoeRouterAdapterAbi, iTreehouseFastlaneAdapterAbi, iTreehouseRedemptionGatewayAdapterAbi, iTreehouseRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAdapterAbi, iwstEthv1AdapterAbi, mellowDvvAdapterAbi };
|
|
@@ -7,6 +7,8 @@ import { ADDRESS_REFERRAL_ADAPTER_ABI, BASIC_ADAPTER_ABI, CURVE_V1_ADAPTER_310_A
|
|
|
7
7
|
* Based on the actual encodeAbiParameters calls in the adapter implementations
|
|
8
8
|
*/
|
|
9
9
|
const adapterConstructorAbi = {
|
|
10
|
+
["AAVE_HORIZON_BRIDGE"]: { 311: BASIC_ADAPTER_ABI },
|
|
11
|
+
["AAVE_V3_POOL"]: { 311: UINT_REFERRAL_ADAPTER_ABI },
|
|
10
12
|
["ACCOUNT_MIGRATOR"]: { 310: BASIC_ADAPTER_ABI },
|
|
11
13
|
["BALANCER_V3_ROUTER"]: {
|
|
12
14
|
310: BASIC_ADAPTER_ABI,
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import { iAaveHorizonBridgeAbi } from "./aave/iAaveHorizonBridge.js";
|
|
2
|
+
import { iAaveOracleAbi } from "./aave/iAaveOracle.js";
|
|
3
|
+
import { iAaveV3PoolAbi } from "./aave/iAaveV3Pool.js";
|
|
4
|
+
import { iPoolAddressesProviderAbi } from "./aave/iPoolAddressesProvider.js";
|
|
5
|
+
import "./aave/index.js";
|
|
1
6
|
import { adapterActionAbi, adapterActionSelectors, adapterActionSignatures } from "./actionAbi.js";
|
|
2
7
|
import { erc4626ReferralAdapterAbi } from "./adapters/erc4626ReferralAdapter.js";
|
|
8
|
+
import { iAaveHorizonBridgeAdapterAbi } from "./adapters/iAaveHorizonBridgeAdapter.js";
|
|
9
|
+
import { iAaveV3PoolAdapterAbi } from "./adapters/iAaveV3PoolAdapter.js";
|
|
3
10
|
import { iBalancerV3RouterAdapterAbi } from "./adapters/iBalancerV3RouterAdapter.js";
|
|
4
11
|
import { iBalancerV3WrapperAdapterAbi } from "./adapters/iBalancerV3WrapperAdapter.js";
|
|
5
12
|
import { iCamelotV3AdapterAbi } from "./adapters/iCamelotV3Adapter.js";
|
|
@@ -51,4 +58,4 @@ import { iTreehouseRedemptionGatewayAbi } from "./treehouse/iTreehouseRedemption
|
|
|
51
58
|
import { iTreehouseRouterAbi } from "./treehouse/iTreehouseRouter.js";
|
|
52
59
|
import "./treehouse/index.js";
|
|
53
60
|
import { getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, hasAdapterDeployParamsAbi, parseAdapterAction, parseAdapterDeployParams } from "./utils.js";
|
|
54
|
-
export { adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, erc4626ReferralAdapterAbi, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, hasAdapterDeployParamsAbi, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, 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, iwstETHAbi, iwstEthv1AdapterAbi, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, parseAdapterAction, parseAdapterDeployParams };
|
|
61
|
+
export { adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, erc4626ReferralAdapterAbi, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, hasAdapterDeployParamsAbi, iAaveHorizonBridgeAbi, iAaveHorizonBridgeAdapterAbi, iAaveOracleAbi, iAaveV3PoolAbi, iAaveV3PoolAdapterAbi, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, 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, iwstETHAbi, iwstEthv1AdapterAbi, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, parseAdapterAction, parseAdapterDeployParams };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { hexEq } from "../../../utils/hex.js";
|
|
2
|
+
import "../../../utils/index.js";
|
|
3
|
+
import { MissingSerializedParamsError } from "../../../base/errors.js";
|
|
4
|
+
import "../../../base/index.js";
|
|
5
|
+
import { iAaveHorizonBridgeAbi } from "../abi/aave/iAaveHorizonBridge.js";
|
|
6
|
+
import "../abi/aave/index.js";
|
|
7
|
+
import { iAaveHorizonBridgeAdapterAbi } from "../abi/adapters/iAaveHorizonBridgeAdapter.js";
|
|
8
|
+
import "../abi/adapters/index.js";
|
|
9
|
+
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
10
|
+
import { decodeAbiParameters, decodeFunctionData, encodeFunctionData, stringToHex } from "viem";
|
|
11
|
+
//#region src/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.ts
|
|
12
|
+
const abi = iAaveHorizonBridgeAdapterAbi;
|
|
13
|
+
const protocolAbi = iAaveHorizonBridgeAbi;
|
|
14
|
+
const FINALIZER_BOT_TYPE = stringToHex("BOT::AAVE_HORIZON_FINALIZER", { size: 32 });
|
|
15
|
+
/**
|
|
16
|
+
* The bridge a finalizer bot serves, from its `serialize()`:
|
|
17
|
+
* `abi.encode(pool, bridge)`. `undefined` where the bot did not serialize.
|
|
18
|
+
*/
|
|
19
|
+
function finalizerBridge(serializedParams) {
|
|
20
|
+
if (serializedParams === "0x") return;
|
|
21
|
+
const [, bridge] = decodeAbiParameters([{
|
|
22
|
+
type: "address",
|
|
23
|
+
name: "pool"
|
|
24
|
+
}, {
|
|
25
|
+
type: "address",
|
|
26
|
+
name: "bridge"
|
|
27
|
+
}], serializedParams);
|
|
28
|
+
return bridge;
|
|
29
|
+
}
|
|
30
|
+
var AaveHorizonBridgeAdapterContract = class extends AbstractAdapterContract {
|
|
31
|
+
#bridge;
|
|
32
|
+
#allowedATokens;
|
|
33
|
+
#allowedDebtTokens;
|
|
34
|
+
constructor(sdk, args) {
|
|
35
|
+
super(sdk, {
|
|
36
|
+
...args,
|
|
37
|
+
abi,
|
|
38
|
+
protocolAbi
|
|
39
|
+
});
|
|
40
|
+
if (args.baseParams.serializedParams) {
|
|
41
|
+
const decoded = decodeAbiParameters([
|
|
42
|
+
{
|
|
43
|
+
type: "address",
|
|
44
|
+
name: "creditManager"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: "address",
|
|
48
|
+
name: "targetContract"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: "address",
|
|
52
|
+
name: "bridge"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: "address[]",
|
|
56
|
+
name: "allowedATokens"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
type: "address[]",
|
|
60
|
+
name: "allowedDebtTokens"
|
|
61
|
+
}
|
|
62
|
+
], args.baseParams.serializedParams);
|
|
63
|
+
this.#bridge = decoded[2];
|
|
64
|
+
this.#allowedATokens = [...decoded[3]];
|
|
65
|
+
this.#allowedDebtTokens = [...decoded[4]];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
get bridge() {
|
|
69
|
+
if (!this.#bridge) throw new MissingSerializedParamsError("bridge");
|
|
70
|
+
return this.#bridge;
|
|
71
|
+
}
|
|
72
|
+
get allowedATokens() {
|
|
73
|
+
if (!this.#allowedATokens) throw new MissingSerializedParamsError("allowedATokens");
|
|
74
|
+
return this.#allowedATokens;
|
|
75
|
+
}
|
|
76
|
+
get allowedDebtTokens() {
|
|
77
|
+
if (!this.#allowedDebtTokens) throw new MissingSerializedParamsError("allowedDebtTokens");
|
|
78
|
+
return this.#allowedDebtTokens;
|
|
79
|
+
}
|
|
80
|
+
isATokenAllowed(token) {
|
|
81
|
+
return includes(this.allowedATokens, token);
|
|
82
|
+
}
|
|
83
|
+
isDebtTokenAllowed(token) {
|
|
84
|
+
return includes(this.allowedDebtTokens, token);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Facade call handing every `aToken` the account holds above
|
|
88
|
+
* `leftoverAmount` to the account owner and borrowing `borrowAmount` of
|
|
89
|
+
* `debtToken` on the owner's behalf into the account.
|
|
90
|
+
*/
|
|
91
|
+
openPositionDiffCall(aToken, debtToken, leftoverAmount, borrowAmount) {
|
|
92
|
+
return {
|
|
93
|
+
target: this.address,
|
|
94
|
+
callData: encodeFunctionData({
|
|
95
|
+
abi,
|
|
96
|
+
functionName: "openPositionDiff",
|
|
97
|
+
args: [
|
|
98
|
+
aToken,
|
|
99
|
+
debtToken,
|
|
100
|
+
leftoverAmount,
|
|
101
|
+
borrowAmount
|
|
102
|
+
]
|
|
103
|
+
})
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Every account on this credit manager is finished by the Horizon finalizer
|
|
108
|
+
* bot a block after its own transaction, so opening one grants the bot its
|
|
109
|
+
* permissions. The bot is the one the market configurator lists among its
|
|
110
|
+
* periphery contracts for this adapter's bridge, the latest version where
|
|
111
|
+
* there are several; nothing where it lists none.
|
|
112
|
+
*/
|
|
113
|
+
async openingCalls() {
|
|
114
|
+
const { configurator } = this.sdk.marketRegister.findByCreditManager(this.creditManager);
|
|
115
|
+
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));
|
|
116
|
+
if (!bot) return [];
|
|
117
|
+
const { creditFacade } = this.sdk.marketRegister.findCreditManager(this.creditManager);
|
|
118
|
+
return [creditFacade.prepareSetBotPermissions(bot.baseParams.addr, bot.requiredPermissions)];
|
|
119
|
+
}
|
|
120
|
+
stateHuman(raw) {
|
|
121
|
+
return {
|
|
122
|
+
...super.stateHuman(raw),
|
|
123
|
+
bridge: this.#bridge ? this.labelAddress(this.#bridge) : void 0,
|
|
124
|
+
allowedATokens: this.#allowedATokens?.map((a) => this.labelAddress(a)),
|
|
125
|
+
allowedDebtTokens: this.#allowedDebtTokens?.map((a) => this.labelAddress(a))
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Opening and closing a position are legal outside a bracket: the bridge
|
|
130
|
+
* moves exactly the amounts the calldata names, or the balance above the
|
|
131
|
+
* named leftover, so there is nothing for an on-chain comparison to enforce.
|
|
132
|
+
*
|
|
133
|
+
* Opening hands the aTokens to the account owner and brings `borrowAmount`
|
|
134
|
+
* of the debt token in; closing sends `repayAmount` of the debt token out and
|
|
135
|
+
* brings the aTokens back.
|
|
136
|
+
*/
|
|
137
|
+
replayOutOfBracketCall(balances, calldata) {
|
|
138
|
+
const decoded = decodeFunctionData({
|
|
139
|
+
abi,
|
|
140
|
+
data: calldata
|
|
141
|
+
});
|
|
142
|
+
switch (decoded.functionName) {
|
|
143
|
+
case "openPosition": {
|
|
144
|
+
const [aToken, debtToken, aTokenAmount, borrowAmount] = decoded.args;
|
|
145
|
+
balances.dec(aToken, aTokenAmount);
|
|
146
|
+
balances.inc(debtToken, borrowAmount);
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
case "openPositionDiff": {
|
|
150
|
+
const [aToken, debtToken, leftoverAmount, borrowAmount] = decoded.args;
|
|
151
|
+
const balance = balances.getOrZero(aToken);
|
|
152
|
+
if (balance > leftoverAmount) {
|
|
153
|
+
balances.dec(aToken, balance - leftoverAmount);
|
|
154
|
+
balances.inc(debtToken, borrowAmount);
|
|
155
|
+
}
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
case "closePosition": {
|
|
159
|
+
const [aToken, debtToken, repayAmount, aTokenAmount] = decoded.args;
|
|
160
|
+
balances.dec(debtToken, repayAmount);
|
|
161
|
+
balances.inc(aToken, aTokenAmount);
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
default: return false;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const includes = (list, token) => list.some((a) => a.toLowerCase() === token.toLowerCase());
|
|
169
|
+
//#endregion
|
|
170
|
+
export { AaveHorizonBridgeAdapterContract };
|