@gearbox-protocol/sdk 16.3.1-next.1 → 16.3.2-next.1
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/errors/index.js +1 -0
- package/dist/cjs/model/errors/operation-errors.js +9 -0
- package/dist/cjs/model/index.js +1 -0
- package/dist/cjs/onchain/accounts/intents/collateral-money.js +41 -0
- package/dist/cjs/onchain/accounts/intents/guards.js +15 -3
- package/dist/cjs/onchain/accounts/intents/index.js +21 -18
- package/dist/cjs/onchain/accounts/intents/maxWithdrawCollateral.js +12 -38
- package/dist/cjs/onchain/accounts/intents/realize.js +10 -2
- package/dist/cjs/onchain/accounts/intents/tail.js +1 -1
- package/dist/cjs/onchain/accounts/intents/withdraw-limits.js +97 -0
- package/dist/cjs/onchain/index.js +2 -0
- package/dist/cjs/onchain/market/adapters/abi/conctructorAbi.js +1 -1
- package/dist/cjs/onchain/validation/checks/checkReservePriceLimited.js +30 -0
- package/dist/cjs/onchain/validation/checks/index.js +2 -0
- package/dist/cjs/onchain/validation/index.js +2 -0
- package/dist/cjs/plugins/bots/BotsPlugin.js +107 -0
- package/dist/cjs/plugins/bots/PartialLiquidationBotV310Contract.js +47 -0
- package/dist/cjs/plugins/bots/abi/iPartialLiquidationBotV310.js +225 -0
- package/dist/cjs/plugins/bots/abi/index.js +3 -0
- package/dist/cjs/plugins/bots/config.js +39 -0
- package/dist/cjs/plugins/bots/deserializePartialLiquidationBotParams.js +39 -0
- package/dist/cjs/plugins/bots/index.js +17 -0
- package/dist/cjs/plugins/bots/package.json +1 -0
- package/dist/cjs/plugins/bots/types.js +28 -0
- package/dist/cjs/sdk/prepare/PrepareApi.js +3 -2
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/history/trace/extractTransfers.js +1 -1
- package/dist/esm/model/errors/index.js +2 -2
- package/dist/esm/model/errors/operation-errors.js +9 -1
- package/dist/esm/model/index.js +2 -2
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/onchain/accounts/intents/collateral-money.js +40 -0
- package/dist/esm/onchain/accounts/intents/guards.js +15 -3
- package/dist/esm/onchain/accounts/intents/index.js +21 -18
- package/dist/esm/onchain/accounts/intents/maxWithdrawCollateral.js +12 -38
- package/dist/esm/onchain/accounts/intents/realize.js +10 -2
- package/dist/esm/onchain/accounts/intents/tail.js +1 -1
- package/dist/esm/onchain/accounts/intents/withdraw-limits.js +95 -0
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/onchain/base/TokensMeta.js +3 -3
- package/dist/esm/onchain/core/createAddressProvider.js +1 -1
- package/dist/esm/onchain/index.js +2 -1
- package/dist/esm/onchain/market/adapters/abi/conctructorAbi.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/onchain/market/rwa/createDegenNFT.js +1 -1
- package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/onchain/preview/preview/previewPoolPositionOperation.js +2 -2
- package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/esm/onchain/validation/checks/checkReservePriceLimited.js +29 -0
- package/dist/esm/onchain/validation/checks/index.js +2 -1
- package/dist/esm/onchain/validation/index.js +2 -1
- package/dist/esm/plugins/bots/BotsPlugin.js +106 -0
- package/dist/esm/plugins/bots/PartialLiquidationBotV310Contract.js +46 -0
- package/dist/esm/plugins/bots/abi/iPartialLiquidationBotV310.js +224 -0
- package/dist/esm/plugins/bots/abi/index.js +2 -0
- package/dist/esm/plugins/bots/config.js +34 -0
- package/dist/esm/plugins/bots/deserializePartialLiquidationBotParams.js +35 -0
- package/dist/esm/plugins/bots/index.js +7 -0
- package/dist/esm/plugins/bots/package.json +1 -0
- package/dist/esm/plugins/bots/types.js +26 -0
- package/dist/esm/sdk/prepare/PrepareApi.js +3 -2
- package/dist/types/model/errors/index.d.ts +2 -2
- package/dist/types/model/errors/operation-errors.d.ts +41 -1
- package/dist/types/model/index.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/collateral-money.d.ts +42 -0
- package/dist/types/onchain/accounts/intents/guards.d.ts +18 -2
- package/dist/types/onchain/accounts/intents/index.d.ts +23 -14
- package/dist/types/onchain/accounts/intents/maxWithdrawCollateral.d.ts +3 -8
- package/dist/types/onchain/accounts/intents/types.d.ts +26 -4
- package/dist/types/onchain/accounts/intents/withdraw-limits.d.ts +80 -0
- package/dist/types/onchain/index.d.ts +2 -1
- package/dist/types/onchain/validation/checks/checkReservePriceLimited.d.ts +31 -0
- package/dist/types/onchain/validation/checks/index.d.ts +2 -1
- package/dist/types/onchain/validation/index.d.ts +2 -1
- package/dist/types/onchain/validation/raise.d.ts +2 -2
- package/dist/types/plugins/bots/BotsPlugin.d.ts +18 -0
- package/dist/types/plugins/bots/PartialLiquidationBotV310Contract.d.ts +216 -0
- package/dist/types/plugins/bots/abi/iPartialLiquidationBotV310.d.ts +193 -0
- package/dist/types/plugins/bots/abi/index.d.ts +2 -0
- package/dist/types/plugins/bots/config.d.ts +12 -0
- package/dist/types/plugins/bots/deserializePartialLiquidationBotParams.d.ts +7 -0
- package/dist/types/plugins/bots/index.d.ts +7 -0
- package/dist/types/plugins/bots/types.d.ts +53 -0
- package/dist/types/sdk/prepare/PrepareApi.d.ts +1 -1
- package/dist/types/sdk/prepare/types.d.ts +23 -16
- package/package.json +1 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_onchain_utils_formatter = require("../../onchain/utils/formatter.js");
|
|
3
|
+
const require_onchain_base_BaseContract = require("../../onchain/base/BaseContract.js");
|
|
4
|
+
require("../../onchain/index.js");
|
|
5
|
+
const require_plugins_bots_abi_iPartialLiquidationBotV310 = require("./abi/iPartialLiquidationBotV310.js");
|
|
6
|
+
require("./abi/index.js");
|
|
7
|
+
const require_plugins_bots_types = require("./types.js");
|
|
8
|
+
let viem = require("viem");
|
|
9
|
+
//#region src/plugins/bots/PartialLiquidationBotV310Contract.ts
|
|
10
|
+
const abi = require_plugins_bots_abi_iPartialLiquidationBotV310.iPartialLiquidationBotV310Abi;
|
|
11
|
+
var PartialLiquidationBotV310Contract = class extends require_onchain_base_BaseContract.BaseContract {
|
|
12
|
+
treasury;
|
|
13
|
+
minHealthFactor;
|
|
14
|
+
maxHealthFactor;
|
|
15
|
+
premiumScaleFactor;
|
|
16
|
+
feeScaleFactor;
|
|
17
|
+
#serializedParams;
|
|
18
|
+
constructor(sdk, args) {
|
|
19
|
+
super(sdk, {
|
|
20
|
+
...args,
|
|
21
|
+
abi,
|
|
22
|
+
name: "PartialLiquidationBotV310"
|
|
23
|
+
});
|
|
24
|
+
[this.treasury, this.minHealthFactor, this.maxHealthFactor, this.premiumScaleFactor, this.feeScaleFactor] = (0, viem.decodeAbiParameters)(require_plugins_bots_types.BOT_PARAMS_ABI, args.serializedParams);
|
|
25
|
+
this.#serializedParams = args.serializedParams;
|
|
26
|
+
}
|
|
27
|
+
stateHuman(raw) {
|
|
28
|
+
return {
|
|
29
|
+
...super.stateHuman(raw),
|
|
30
|
+
treasury: this.treasury,
|
|
31
|
+
minHealthFactor: require_onchain_utils_formatter.percentFmt(this.minHealthFactor, raw),
|
|
32
|
+
maxHealthFactor: require_onchain_utils_formatter.percentFmt(this.maxHealthFactor, raw),
|
|
33
|
+
premiumScaleFactor: require_onchain_utils_formatter.percentFmt(this.premiumScaleFactor, raw),
|
|
34
|
+
feeScaleFactor: require_onchain_utils_formatter.percentFmt(this.feeScaleFactor, raw)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
get state() {
|
|
38
|
+
return {
|
|
39
|
+
addr: this.address,
|
|
40
|
+
version: BigInt(this.version),
|
|
41
|
+
contractType: (0, viem.stringToHex)(this.contractType, { size: 32 }),
|
|
42
|
+
serializedParams: this.#serializedParams
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
exports.PartialLiquidationBotV310Contract = PartialLiquidationBotV310Contract;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/plugins/bots/abi/iPartialLiquidationBotV310.ts
|
|
3
|
+
const iPartialLiquidationBotV310Abi = [
|
|
4
|
+
{
|
|
5
|
+
type: "function",
|
|
6
|
+
name: "contractType",
|
|
7
|
+
inputs: [],
|
|
8
|
+
outputs: [{
|
|
9
|
+
name: "",
|
|
10
|
+
type: "bytes32",
|
|
11
|
+
internalType: "bytes32"
|
|
12
|
+
}],
|
|
13
|
+
stateMutability: "view"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
type: "function",
|
|
17
|
+
name: "feeScaleFactor",
|
|
18
|
+
inputs: [],
|
|
19
|
+
outputs: [{
|
|
20
|
+
name: "",
|
|
21
|
+
type: "uint16",
|
|
22
|
+
internalType: "uint16"
|
|
23
|
+
}],
|
|
24
|
+
stateMutability: "view"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: "function",
|
|
28
|
+
name: "maxHealthFactor",
|
|
29
|
+
inputs: [],
|
|
30
|
+
outputs: [{
|
|
31
|
+
name: "",
|
|
32
|
+
type: "uint16",
|
|
33
|
+
internalType: "uint16"
|
|
34
|
+
}],
|
|
35
|
+
stateMutability: "view"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: "function",
|
|
39
|
+
name: "minHealthFactor",
|
|
40
|
+
inputs: [],
|
|
41
|
+
outputs: [{
|
|
42
|
+
name: "",
|
|
43
|
+
type: "uint16",
|
|
44
|
+
internalType: "uint16"
|
|
45
|
+
}],
|
|
46
|
+
stateMutability: "view"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: "function",
|
|
50
|
+
name: "partiallyLiquidate",
|
|
51
|
+
inputs: [
|
|
52
|
+
{
|
|
53
|
+
name: "creditAccount",
|
|
54
|
+
type: "address",
|
|
55
|
+
internalType: "address"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "token",
|
|
59
|
+
type: "address",
|
|
60
|
+
internalType: "address"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "repaidAmount",
|
|
64
|
+
type: "uint256",
|
|
65
|
+
internalType: "uint256"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "minSeizedAmount",
|
|
69
|
+
type: "uint256",
|
|
70
|
+
internalType: "uint256"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "to",
|
|
74
|
+
type: "address",
|
|
75
|
+
internalType: "address"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "priceUpdates",
|
|
79
|
+
type: "tuple[]",
|
|
80
|
+
internalType: "struct PriceUpdate[]",
|
|
81
|
+
components: [{
|
|
82
|
+
name: "priceFeed",
|
|
83
|
+
type: "address",
|
|
84
|
+
internalType: "address"
|
|
85
|
+
}, {
|
|
86
|
+
name: "data",
|
|
87
|
+
type: "bytes",
|
|
88
|
+
internalType: "bytes"
|
|
89
|
+
}]
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
outputs: [{
|
|
93
|
+
name: "seizedAmount",
|
|
94
|
+
type: "uint256",
|
|
95
|
+
internalType: "uint256"
|
|
96
|
+
}],
|
|
97
|
+
stateMutability: "nonpayable"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
type: "function",
|
|
101
|
+
name: "premiumScaleFactor",
|
|
102
|
+
inputs: [],
|
|
103
|
+
outputs: [{
|
|
104
|
+
name: "",
|
|
105
|
+
type: "uint16",
|
|
106
|
+
internalType: "uint16"
|
|
107
|
+
}],
|
|
108
|
+
stateMutability: "view"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
type: "function",
|
|
112
|
+
name: "requiredPermissions",
|
|
113
|
+
inputs: [],
|
|
114
|
+
outputs: [{
|
|
115
|
+
name: "",
|
|
116
|
+
type: "uint192",
|
|
117
|
+
internalType: "uint192"
|
|
118
|
+
}],
|
|
119
|
+
stateMutability: "view"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
type: "function",
|
|
123
|
+
name: "serialize",
|
|
124
|
+
inputs: [],
|
|
125
|
+
outputs: [{
|
|
126
|
+
name: "serializedData",
|
|
127
|
+
type: "bytes",
|
|
128
|
+
internalType: "bytes"
|
|
129
|
+
}],
|
|
130
|
+
stateMutability: "view"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
type: "function",
|
|
134
|
+
name: "treasury",
|
|
135
|
+
inputs: [],
|
|
136
|
+
outputs: [{
|
|
137
|
+
name: "",
|
|
138
|
+
type: "address",
|
|
139
|
+
internalType: "address"
|
|
140
|
+
}],
|
|
141
|
+
stateMutability: "view"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
type: "function",
|
|
145
|
+
name: "version",
|
|
146
|
+
inputs: [],
|
|
147
|
+
outputs: [{
|
|
148
|
+
name: "",
|
|
149
|
+
type: "uint256",
|
|
150
|
+
internalType: "uint256"
|
|
151
|
+
}],
|
|
152
|
+
stateMutability: "view"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
type: "event",
|
|
156
|
+
name: "PartiallyLiquidate",
|
|
157
|
+
inputs: [
|
|
158
|
+
{
|
|
159
|
+
name: "creditManager",
|
|
160
|
+
type: "address",
|
|
161
|
+
indexed: true,
|
|
162
|
+
internalType: "address"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: "creditAccount",
|
|
166
|
+
type: "address",
|
|
167
|
+
indexed: true,
|
|
168
|
+
internalType: "address"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: "token",
|
|
172
|
+
type: "address",
|
|
173
|
+
indexed: true,
|
|
174
|
+
internalType: "address"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: "liquidator",
|
|
178
|
+
type: "address",
|
|
179
|
+
indexed: false,
|
|
180
|
+
internalType: "address"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: "repaidDebt",
|
|
184
|
+
type: "uint256",
|
|
185
|
+
indexed: false,
|
|
186
|
+
internalType: "uint256"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: "seizedCollateral",
|
|
190
|
+
type: "uint256",
|
|
191
|
+
indexed: false,
|
|
192
|
+
internalType: "uint256"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: "fee",
|
|
196
|
+
type: "uint256",
|
|
197
|
+
indexed: false,
|
|
198
|
+
internalType: "uint256"
|
|
199
|
+
}
|
|
200
|
+
],
|
|
201
|
+
anonymous: false
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
type: "error",
|
|
205
|
+
name: "LiquidatedLessThanNeededException",
|
|
206
|
+
inputs: []
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
type: "error",
|
|
210
|
+
name: "LiquidatedMoreThanNeededException",
|
|
211
|
+
inputs: []
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
type: "error",
|
|
215
|
+
name: "SeizedLessThanRequiredException",
|
|
216
|
+
inputs: []
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
type: "error",
|
|
220
|
+
name: "UnderlyingNotLiquidatableException",
|
|
221
|
+
inputs: []
|
|
222
|
+
}
|
|
223
|
+
];
|
|
224
|
+
//#endregion
|
|
225
|
+
exports.iPartialLiquidationBotV310Abi = iPartialLiquidationBotV310Abi;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_plugins_bots_abi_iPartialLiquidationBotV310 = require("./iPartialLiquidationBotV310.js");
|
|
3
|
+
exports.iPartialLiquidationBotV310Abi = require_plugins_bots_abi_iPartialLiquidationBotV310.iPartialLiquidationBotV310Abi;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../../onchain/constants/bot-permissions.js");
|
|
3
|
+
require("../../onchain/index.js");
|
|
4
|
+
//#region src/plugins/bots/config.ts
|
|
5
|
+
const PARTIAL_LIQUIDATION_BOT_CONFIGS = {
|
|
6
|
+
Mainnet: [{
|
|
7
|
+
minHealthFactor: 10300,
|
|
8
|
+
maxHealthFactor: 10700,
|
|
9
|
+
premiumScaleFactor: 1e4,
|
|
10
|
+
feeScaleFactor: 1e4
|
|
11
|
+
}],
|
|
12
|
+
Monad: [{
|
|
13
|
+
minHealthFactor: 10300,
|
|
14
|
+
maxHealthFactor: 10700,
|
|
15
|
+
premiumScaleFactor: 1e4,
|
|
16
|
+
feeScaleFactor: 1e4
|
|
17
|
+
}],
|
|
18
|
+
Plasma: [{
|
|
19
|
+
minHealthFactor: 10300,
|
|
20
|
+
maxHealthFactor: 10700,
|
|
21
|
+
premiumScaleFactor: 1e4,
|
|
22
|
+
feeScaleFactor: 1e4
|
|
23
|
+
}]
|
|
24
|
+
};
|
|
25
|
+
const PARTIAL_LIQUIDATION_BOT_SALT = "GEARBOX";
|
|
26
|
+
const PARTIAL_LIQUIDATION_BOT_DEPLOYER = "0xc93155E0a835Cf4E17a19463Fa67ed43c164d06a";
|
|
27
|
+
const LEGACY_MIGRATION_BOT = {
|
|
28
|
+
address: "0x286Fe53994f5668D56538Aa10eaa3Ac36f878e9C".toLowerCase(),
|
|
29
|
+
previewer: "0x6523B8c9daB92eea7944a79b4Dbb598c7934DCca".toLowerCase(),
|
|
30
|
+
version: 310,
|
|
31
|
+
baseType: "LEGACY_MIGRATION"
|
|
32
|
+
};
|
|
33
|
+
const PERMISSION_BY_TYPE = { LEGACY_MIGRATION: BigInt(65604) };
|
|
34
|
+
//#endregion
|
|
35
|
+
exports.LEGACY_MIGRATION_BOT = LEGACY_MIGRATION_BOT;
|
|
36
|
+
exports.PARTIAL_LIQUIDATION_BOT_CONFIGS = PARTIAL_LIQUIDATION_BOT_CONFIGS;
|
|
37
|
+
exports.PARTIAL_LIQUIDATION_BOT_DEPLOYER = PARTIAL_LIQUIDATION_BOT_DEPLOYER;
|
|
38
|
+
exports.PARTIAL_LIQUIDATION_BOT_SALT = PARTIAL_LIQUIDATION_BOT_SALT;
|
|
39
|
+
exports.PERMISSION_BY_TYPE = PERMISSION_BY_TYPE;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
let viem = require("viem");
|
|
6
|
+
//#region src/plugins/bots/deserializePartialLiquidationBotParams.ts
|
|
7
|
+
function deserializePartialLiquidationBotParams(params) {
|
|
8
|
+
const [treasury, minHealthFactor, maxHealthFactor, premiumScaleFactor, feeScaleFactor] = (0, viem.decodeAbiParameters)([
|
|
9
|
+
{
|
|
10
|
+
name: "treasury",
|
|
11
|
+
type: "address"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: "minHealthFactor",
|
|
15
|
+
type: "uint16"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "maxHealthFactor",
|
|
19
|
+
type: "uint16"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "premiumScaleFactor",
|
|
23
|
+
type: "uint16"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "feeScaleFactor",
|
|
27
|
+
type: "uint16"
|
|
28
|
+
}
|
|
29
|
+
], params.serializedParams);
|
|
30
|
+
return {
|
|
31
|
+
treasury,
|
|
32
|
+
minHealthFactor,
|
|
33
|
+
maxHealthFactor,
|
|
34
|
+
premiumScaleFactor,
|
|
35
|
+
feeScaleFactor
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.default = deserializePartialLiquidationBotParams;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_plugins_bots_abi_iPartialLiquidationBotV310 = require("./abi/iPartialLiquidationBotV310.js");
|
|
3
|
+
const require_plugins_bots_config = require("./config.js");
|
|
4
|
+
require("./abi/index.js");
|
|
5
|
+
const require_plugins_bots_types = require("./types.js");
|
|
6
|
+
const require_plugins_bots_PartialLiquidationBotV310Contract = require("./PartialLiquidationBotV310Contract.js");
|
|
7
|
+
const require_plugins_bots_BotsPlugin = require("./BotsPlugin.js");
|
|
8
|
+
exports.BOT_PARAMS_ABI = require_plugins_bots_types.BOT_PARAMS_ABI;
|
|
9
|
+
exports.BOT_PARTIAL_LIQUIDATION = require_plugins_bots_types.BOT_PARTIAL_LIQUIDATION;
|
|
10
|
+
exports.BotsPlugin = require_plugins_bots_BotsPlugin.BotsPlugin;
|
|
11
|
+
exports.LEGACY_MIGRATION_BOT = require_plugins_bots_config.LEGACY_MIGRATION_BOT;
|
|
12
|
+
exports.PARTIAL_LIQUIDATION_BOT_CONFIGS = require_plugins_bots_config.PARTIAL_LIQUIDATION_BOT_CONFIGS;
|
|
13
|
+
exports.PARTIAL_LIQUIDATION_BOT_DEPLOYER = require_plugins_bots_config.PARTIAL_LIQUIDATION_BOT_DEPLOYER;
|
|
14
|
+
exports.PARTIAL_LIQUIDATION_BOT_SALT = require_plugins_bots_config.PARTIAL_LIQUIDATION_BOT_SALT;
|
|
15
|
+
exports.PERMISSION_BY_TYPE = require_plugins_bots_config.PERMISSION_BY_TYPE;
|
|
16
|
+
exports.PartialLiquidationBotV310Contract = require_plugins_bots_PartialLiquidationBotV310Contract.PartialLiquidationBotV310Contract;
|
|
17
|
+
exports.iPartialLiquidationBotV310Abi = require_plugins_bots_abi_iPartialLiquidationBotV310.iPartialLiquidationBotV310Abi;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "commonjs"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/plugins/bots/types.ts
|
|
3
|
+
const BOT_PARTIAL_LIQUIDATION = "BOT::PARTIAL_LIQUIDATION";
|
|
4
|
+
const BOT_PARAMS_ABI = [
|
|
5
|
+
{
|
|
6
|
+
type: "address",
|
|
7
|
+
name: "treasury"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
type: "uint16",
|
|
11
|
+
name: "minHealthFactor"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
type: "uint16",
|
|
15
|
+
name: "maxHealthFactor"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
type: "uint16",
|
|
19
|
+
name: "premiumScaleFactor"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: "uint16",
|
|
23
|
+
name: "feeScaleFactor"
|
|
24
|
+
}
|
|
25
|
+
];
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.BOT_PARAMS_ABI = BOT_PARAMS_ABI;
|
|
28
|
+
exports.BOT_PARTIAL_LIQUIDATION = BOT_PARTIAL_LIQUIDATION;
|
|
@@ -259,12 +259,13 @@ var PrepareApi = class extends require_onchain_base_MultichainConstruct.Multicha
|
|
|
259
259
|
/**
|
|
260
260
|
* {@inheritDoc IOpportunitiesPrepare.maxWithdraw}
|
|
261
261
|
**/
|
|
262
|
-
async maxWithdraw(position) {
|
|
262
|
+
async maxWithdraw(position, sourceToken) {
|
|
263
263
|
const sdk = await this.#chain(position.chainId);
|
|
264
264
|
const creditAccount = await this.#account(sdk, position);
|
|
265
265
|
return service(sdk).maxWithdraw({
|
|
266
266
|
creditAccount,
|
|
267
|
-
sdk
|
|
267
|
+
sdk,
|
|
268
|
+
sourceToken
|
|
268
269
|
});
|
|
269
270
|
}
|
|
270
271
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ierc20Abi } from "../abi/iERC20.js";
|
|
2
1
|
import { iCreditFacadeV310Abi } from "../abi/310/generated.js";
|
|
2
|
+
import { ierc20Abi } from "../abi/iERC20.js";
|
|
3
3
|
import { AddressMap } from "../onchain/utils/AddressMap.js";
|
|
4
4
|
import { AddressSet } from "../onchain/utils/AddressSet.js";
|
|
5
5
|
import { AssetsMap } from "../onchain/utils/AssetsMap.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
|
|
2
1
|
import { getNetworkType } from "../onchain/chain/chains.js";
|
|
3
2
|
import { getWithdrawalCompressorAddress } from "../onchain/accounts/withdrawal-compressor/addresses.js";
|
|
3
|
+
import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
|
|
4
4
|
import "../onchain/index.js";
|
|
5
5
|
import { iMidasDataFeedAbi, iMidasRedemptionVaultAbi, midasGatewayAbi, midasRedeemerAbi, midasRedemptionVaultPhantomTokenAbi, securitizeRedeemerAbi, securitizeRedemptionGatewayAbi, securitizeRedemptionPhantomTokenAbi } from "./withdrawalAbi.js";
|
|
6
6
|
import { erc20Abi, hexToString, parseAbi, parseEther } from "viem";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
2
1
|
import { iCreditFacadeV310Abi } from "../../abi/310/generated.js";
|
|
2
|
+
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
3
3
|
import { AddressMap } from "../../onchain/utils/AddressMap.js";
|
|
4
4
|
import "../../onchain/index.js";
|
|
5
5
|
import { UnexpectedFacadeEventOrderError } from "./errors.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./base.js";
|
|
2
2
|
import { creditAccountFrozen, liquidatorNotEligible, notEmergencyLiquidator } from "./liquidation-errors.js";
|
|
3
|
-
import { creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, rwaOpenRequirementsNotMet } from "./operation-errors.js";
|
|
3
|
+
import { creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, reservePriceLimited, rwaOpenRequirementsNotMet } from "./operation-errors.js";
|
|
4
4
|
import { unpriceableTokenError } from "./oracle-errors.js";
|
|
5
5
|
import { creditAccountNotEmpty, creditAccountNotFound, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, unexpectedFailure, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress } from "./prepare-errors.js";
|
|
6
6
|
import { malformedTransaction } from "./preview-errors.js";
|
|
7
|
-
export { creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, liquidatorNotEligible, malformedTransaction, marketExpired, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, rwaOpenRequirementsNotMet, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress };
|
|
7
|
+
export { creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, liquidatorNotEligible, malformedTransaction, marketExpired, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, reservePriceLimited, rwaOpenRequirementsNotMet, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress };
|
|
@@ -66,6 +66,14 @@ function insufficientCollateral(args) {
|
|
|
66
66
|
...args
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
+
/** {@inheritDoc ReservePriceLimitedError} */
|
|
70
|
+
function reservePriceLimited(args) {
|
|
71
|
+
return {
|
|
72
|
+
code: "reservePriceLimited",
|
|
73
|
+
message: `The reserve price feed values this collateral below what the operation pays out: the account covers its debt at ${args.atMainPrices} on the main feed and only ${args.healthFactor} at the reserve one, below ${args.healthFactorThreshold}.`,
|
|
74
|
+
...args
|
|
75
|
+
};
|
|
76
|
+
}
|
|
69
77
|
/** {@inheritDoc ForbiddenTokenError} */
|
|
70
78
|
function forbiddenToken(token) {
|
|
71
79
|
return {
|
|
@@ -118,4 +126,4 @@ function rwaOpenRequirementsNotMet(args) {
|
|
|
118
126
|
};
|
|
119
127
|
}
|
|
120
128
|
//#endregion
|
|
121
|
-
export { creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, rwaOpenRequirementsNotMet };
|
|
129
|
+
export { creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, reservePriceLimited, rwaOpenRequirementsNotMet };
|
package/dist/esm/model/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, analy
|
|
|
15
15
|
import "./curators.js";
|
|
16
16
|
import "./delayed-intents.js";
|
|
17
17
|
import { creditAccountFrozen, liquidatorNotEligible, notEmergencyLiquidator } from "./errors/liquidation-errors.js";
|
|
18
|
-
import { creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, rwaOpenRequirementsNotMet } from "./errors/operation-errors.js";
|
|
18
|
+
import { creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, reservePriceLimited, rwaOpenRequirementsNotMet } from "./errors/operation-errors.js";
|
|
19
19
|
import { unpriceableTokenError } from "./errors/oracle-errors.js";
|
|
20
20
|
import { creditAccountNotEmpty, creditAccountNotFound, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, unexpectedFailure, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress } from "./errors/prepare-errors.js";
|
|
21
21
|
import { malformedTransaction } from "./errors/preview-errors.js";
|
|
@@ -32,4 +32,4 @@ import { chainFailedSchema, chainMetadataSchema, chainSucceededSchema, dataSourc
|
|
|
32
32
|
import { safeValue, sdkErr, sdkOk } from "./result.js";
|
|
33
33
|
import "./withdrawals.js";
|
|
34
34
|
import { positionClaimableWithdrawalSchema, positionPendingWithdrawalSchema, positionWithdrawalsSchema, withdrawalOutputAmountSchema } from "./withdrawals.schema.js";
|
|
35
|
-
export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, FILTER_ALL, KYC_REGISTRATION_LINKS, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_PROTOCOLS, SECURITIZE_REGISTER_VAULT_TYPES, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, amountSchema, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, curatorNameSchema, curatorSchema, dataSourceSchema, debtOutOfRange, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, forbiddenToken, instantReceivedAssetSchema, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, isFilterSet, kycRequirementSchema, leverageOutOfRange, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, liquidatorNotEligible, malformedTransaction, marketExpired, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPaused, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, poolSunset, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, protocolChartMetricSchema, quotaAssetSchema, quotaCountExceeded, quotaLimitReached, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, rwaOpenRequirementsNotMet, rwaProtocolSchema, safeValue, sdkErr, sdkOk, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress, withdrawalOutputAmountSchema };
|
|
35
|
+
export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, FILTER_ALL, KYC_REGISTRATION_LINKS, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_PROTOCOLS, SECURITIZE_REGISTER_VAULT_TYPES, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, amountSchema, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, curatorNameSchema, curatorSchema, dataSourceSchema, debtOutOfRange, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, forbiddenToken, instantReceivedAssetSchema, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, isFilterSet, kycRequirementSchema, leverageOutOfRange, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, liquidatorNotEligible, malformedTransaction, marketExpired, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPaused, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, poolSunset, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, protocolChartMetricSchema, quotaAssetSchema, quotaCountExceeded, quotaLimitReached, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, reservePriceLimited, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, rwaOpenRequirementsNotMet, rwaProtocolSchema, safeValue, sdkErr, sdkOk, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress, withdrawalOutputAmountSchema };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
2
|
-
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
3
1
|
import { AP_REWARDS_COMPRESSOR } from "../constants/address-provider.js";
|
|
4
2
|
import { ADDRESS_0X0 } from "../constants/addresses.js";
|
|
5
3
|
import { MAX_UINT256 } from "../constants/math.js";
|
|
@@ -10,6 +8,8 @@ import "../base/index.js";
|
|
|
10
8
|
import { AccountBotsService } from "./bots/AccountBotsService.js";
|
|
11
9
|
import "./bots/index.js";
|
|
12
10
|
import { rewardsCompressorAbi } from "../../abi/compressors/rewardsCompressor.js";
|
|
11
|
+
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
12
|
+
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
13
13
|
import { expectedBalanceDeltas } from "../market/credit/expectedBalanceDeltas.js";
|
|
14
14
|
import "../market/index.js";
|
|
15
15
|
import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { BigIntMath } from "../../utils/bigint-math.js";
|
|
2
|
+
import { PERCENTAGE_FACTOR } from "../../constants/math.js";
|
|
3
|
+
import "../../utils/index.js";
|
|
4
|
+
import { eq } from "./utils/common.js";
|
|
5
|
+
//#region src/onchain/accounts/intents/collateral-money.ts
|
|
6
|
+
/** {@inheritDoc CollateralMoney} */
|
|
7
|
+
function collateralMoney(creditAccount, sdk) {
|
|
8
|
+
const { market, creditManager } = sdk.marketRegister.findCreditManager(creditAccount.creditManager);
|
|
9
|
+
const { priceOracle } = market;
|
|
10
|
+
const { pqk } = market.pool;
|
|
11
|
+
const underlying = market.pool.underlying;
|
|
12
|
+
const masked = creditAccount.enabledTokensMask !== 0n;
|
|
13
|
+
const mainUsd = (token, amount) => {
|
|
14
|
+
try {
|
|
15
|
+
return priceOracle.convertToUSD(token, amount);
|
|
16
|
+
} catch {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const lt = (token) => BigInt(creditManager.liquidationThresholds.get(token) ?? 0);
|
|
21
|
+
const checkedUsd = (holding) => eq(holding.token, underlying) ? mainUsd(holding.token, holding.balance) ?? 0n : priceOracle.safeConvertMinUSD(holding.token, holding.balance).value;
|
|
22
|
+
/** A quota is underlying-denominated, and a closed market backs nothing. */
|
|
23
|
+
const quotaMoney = (holding) => pqk.hasActiveQuota(holding.token) ? (mainUsd(underlying, holding.quota) ?? 0n) * PERCENTAGE_FACTOR : 0n;
|
|
24
|
+
const weigh = (holding) => {
|
|
25
|
+
const weighted = checkedUsd(holding) * lt(holding.token);
|
|
26
|
+
if (holding.quota === 0n) return weighted;
|
|
27
|
+
return BigIntMath.min(quotaMoney(holding), weighted);
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
underlying,
|
|
31
|
+
counts: (holding) => holding.balance > 10n && (!masked || (holding.mask & creditAccount.enabledTokensMask) !== 0n),
|
|
32
|
+
weigh,
|
|
33
|
+
quotaMoney,
|
|
34
|
+
mainUsd,
|
|
35
|
+
checkedUsd,
|
|
36
|
+
lt
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { collateralMoney };
|
|
@@ -6,6 +6,7 @@ import { checkCreditManagerPaused } from "../../validation/checks/checkCreditMan
|
|
|
6
6
|
import { checkForbiddenToken } from "../../validation/checks/checkForbiddenToken.js";
|
|
7
7
|
import { checkMarketExpired } from "../../validation/checks/checkMarketExpired.js";
|
|
8
8
|
import { checkQuotaLimit } from "../../validation/checks/checkQuotaLimit.js";
|
|
9
|
+
import { checkReservePriceLimited } from "../../validation/checks/checkReservePriceLimited.js";
|
|
9
10
|
import { raise } from "../../validation/raise.js";
|
|
10
11
|
import "../../validation/index.js";
|
|
11
12
|
import { eq } from "./utils/common.js";
|
|
@@ -111,13 +112,24 @@ function assertGrowthAllowed(args) {
|
|
|
111
112
|
* whose reserve feed the SDK cannot read keeps its main price, so a plan can
|
|
112
113
|
* still be refused on-chain after passing here.
|
|
113
114
|
*/
|
|
114
|
-
function assertCollateralised(healthFactorBps, safePrices) {
|
|
115
|
+
function assertCollateralised(healthFactorBps, safePrices, atSafePrices) {
|
|
115
116
|
const healthFactorThreshold = MIN_HEALTH_FACTOR_FACADE;
|
|
116
|
-
|
|
117
|
+
const errors = checkCollateralised({
|
|
117
118
|
healthFactor: healthFactorBps,
|
|
118
119
|
healthFactorThreshold,
|
|
119
120
|
safePrices
|
|
120
|
-
})
|
|
121
|
+
});
|
|
122
|
+
if (errors.length === 0) return;
|
|
123
|
+
if (safePrices && atSafePrices) {
|
|
124
|
+
const { atMainPrices, withdrawable } = atSafePrices();
|
|
125
|
+
raise(checkReservePriceLimited({
|
|
126
|
+
healthFactor: healthFactorBps,
|
|
127
|
+
atMainPrices,
|
|
128
|
+
healthFactorThreshold,
|
|
129
|
+
withdrawable
|
|
130
|
+
}), `the account covers its debt at ${atMainPrices} on the main feed and only ${healthFactorBps} at the reserve one, below ${healthFactorThreshold}`);
|
|
131
|
+
}
|
|
132
|
+
raise(errors, `the account would end at a health factor of ${healthFactorBps}, below ${healthFactorThreshold}`);
|
|
121
133
|
}
|
|
122
134
|
/**
|
|
123
135
|
* A quota can only be raised as far as the market still has room for: past the
|