@gearbox-protocol/sdk 16.3.0-next.4 → 16.3.0-next.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/cjs/onchain/index.js +4 -4
  2. package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +7 -6
  3. package/dist/cjs/onchain/validation/bundles/{checkDraw.js → checkIncreaseDebt.js} +10 -10
  4. package/dist/cjs/onchain/validation/bundles/{checkQuotasAsked.js → checkIncreaseQuota.js} +3 -3
  5. package/dist/cjs/onchain/validation/bundles/index.js +4 -4
  6. package/dist/cjs/onchain/validation/checks/checkBorrowLimit.js +1 -1
  7. package/dist/cjs/onchain/validation/checks/checkPoolLiquidity.js +1 -1
  8. package/dist/cjs/onchain/validation/index.js +4 -4
  9. package/dist/esm/dev/AccountOpener.js +1 -1
  10. package/dist/esm/dev/withdrawalUtils.js +1 -1
  11. package/dist/esm/history/trace/extractTransfers.js +1 -1
  12. package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
  13. package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  14. package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  15. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  16. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  17. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  18. package/dist/esm/onchain/base/TokensMeta.js +3 -3
  19. package/dist/esm/onchain/core/createAddressProvider.js +1 -1
  20. package/dist/esm/onchain/index.js +3 -3
  21. package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
  22. package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
  23. package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
  24. package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
  25. package/dist/esm/onchain/market/rwa/createDegenNFT.js +1 -1
  26. package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
  27. package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
  28. package/dist/esm/onchain/preview/preview/previewPoolPositionOperation.js +2 -2
  29. package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
  30. package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +7 -6
  31. package/dist/esm/onchain/validation/bundles/checkIncreaseDebt.js +27 -0
  32. package/dist/esm/onchain/validation/bundles/{checkQuotasAsked.js → checkIncreaseQuota.js} +3 -3
  33. package/dist/esm/onchain/validation/bundles/index.js +3 -3
  34. package/dist/esm/onchain/validation/checks/checkBorrowLimit.js +1 -1
  35. package/dist/esm/onchain/validation/checks/checkPoolLiquidity.js +1 -1
  36. package/dist/esm/onchain/validation/index.js +3 -3
  37. package/dist/types/model/errors/operation-errors.d.ts +2 -2
  38. package/dist/types/model/opportunities.d.ts +2 -2
  39. package/dist/types/onchain/index.d.ts +3 -3
  40. package/dist/types/onchain/market/pool/types.d.ts +1 -1
  41. package/dist/types/onchain/validation/bundles/checkCreditOperation.d.ts +3 -2
  42. package/dist/types/onchain/validation/bundles/{checkDraw.d.ts → checkIncreaseDebt.d.ts} +7 -7
  43. package/dist/types/onchain/validation/bundles/{checkQuotasAsked.d.ts → checkIncreaseQuota.d.ts} +3 -3
  44. package/dist/types/onchain/validation/bundles/index.d.ts +3 -3
  45. package/dist/types/onchain/validation/checks/checkBorrowLimit.d.ts +1 -1
  46. package/dist/types/onchain/validation/checks/checkPoolLiquidity.d.ts +1 -1
  47. package/dist/types/onchain/validation/index.d.ts +3 -3
  48. package/package.json +1 -1
  49. package/dist/cjs/plugins/bots/BotsPlugin.js +0 -107
  50. package/dist/cjs/plugins/bots/PartialLiquidationBotV310Contract.js +0 -47
  51. package/dist/cjs/plugins/bots/abi/iPartialLiquidationBotV310.js +0 -225
  52. package/dist/cjs/plugins/bots/abi/index.js +0 -3
  53. package/dist/cjs/plugins/bots/config.js +0 -39
  54. package/dist/cjs/plugins/bots/deserializePartialLiquidationBotParams.js +0 -39
  55. package/dist/cjs/plugins/bots/index.js +0 -17
  56. package/dist/cjs/plugins/bots/package.json +0 -1
  57. package/dist/cjs/plugins/bots/types.js +0 -28
  58. package/dist/cjs/plugins/degen-distributors/DegenDistributorsPlugin.js +0 -61
  59. package/dist/cjs/plugins/degen-distributors/index.js +0 -4
  60. package/dist/cjs/plugins/degen-distributors/package.json +0 -1
  61. package/dist/cjs/plugins/degen-distributors/types.js +0 -1
  62. package/dist/cjs/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +0 -114
  63. package/dist/cjs/plugins/delayed-withdrawal/index.js +0 -4
  64. package/dist/cjs/plugins/delayed-withdrawal/package.json +0 -1
  65. package/dist/cjs/plugins/delayed-withdrawal/types.js +0 -1
  66. package/dist/esm/onchain/validation/bundles/checkDraw.js +0 -27
  67. package/dist/esm/plugins/bots/BotsPlugin.js +0 -106
  68. package/dist/esm/plugins/bots/PartialLiquidationBotV310Contract.js +0 -46
  69. package/dist/esm/plugins/bots/abi/iPartialLiquidationBotV310.js +0 -224
  70. package/dist/esm/plugins/bots/abi/index.js +0 -2
  71. package/dist/esm/plugins/bots/config.js +0 -34
  72. package/dist/esm/plugins/bots/deserializePartialLiquidationBotParams.js +0 -35
  73. package/dist/esm/plugins/bots/index.js +0 -7
  74. package/dist/esm/plugins/bots/package.json +0 -1
  75. package/dist/esm/plugins/bots/types.js +0 -26
  76. package/dist/esm/plugins/degen-distributors/DegenDistributorsPlugin.js +0 -60
  77. package/dist/esm/plugins/degen-distributors/index.js +0 -3
  78. package/dist/esm/plugins/degen-distributors/package.json +0 -1
  79. package/dist/esm/plugins/degen-distributors/types.js +0 -1
  80. package/dist/esm/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +0 -113
  81. package/dist/esm/plugins/delayed-withdrawal/index.js +0 -3
  82. package/dist/esm/plugins/delayed-withdrawal/package.json +0 -1
  83. package/dist/esm/plugins/delayed-withdrawal/types.js +0 -1
  84. package/dist/types/plugins/bots/BotsPlugin.d.ts +0 -18
  85. package/dist/types/plugins/bots/PartialLiquidationBotV310Contract.d.ts +0 -216
  86. package/dist/types/plugins/bots/abi/iPartialLiquidationBotV310.d.ts +0 -193
  87. package/dist/types/plugins/bots/abi/index.d.ts +0 -2
  88. package/dist/types/plugins/bots/config.d.ts +0 -12
  89. package/dist/types/plugins/bots/deserializePartialLiquidationBotParams.d.ts +0 -7
  90. package/dist/types/plugins/bots/index.d.ts +0 -7
  91. package/dist/types/plugins/bots/types.d.ts +0 -53
  92. package/dist/types/plugins/degen-distributors/DegenDistributorsPlugin.d.ts +0 -25
  93. package/dist/types/plugins/degen-distributors/index.d.ts +0 -3
  94. package/dist/types/plugins/degen-distributors/types.d.ts +0 -8
  95. package/dist/types/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.d.ts +0 -25
  96. package/dist/types/plugins/delayed-withdrawal/index.d.ts +0 -3
  97. package/dist/types/plugins/delayed-withdrawal/types.d.ts +0 -10
@@ -1,106 +0,0 @@
1
- import { AddressMap } from "../../onchain/utils/AddressMap.js";
2
- import { chains } from "../../onchain/chain/chains.js";
3
- import { AP_BYTECODE_REPOSITORY, AP_TREASURY } from "../../onchain/constants/address-provider.js";
4
- import { hexEq } from "../../onchain/utils/hex.js";
5
- import { BasePlugin } from "../../onchain/plugins/BasePlugin.js";
6
- import "../../onchain/index.js";
7
- import { iBytecodeRepositoryAbi } from "../../abi/310/iBytecodeRepository.js";
8
- import { iPartialLiquidationBotV310Abi } from "./abi/iPartialLiquidationBotV310.js";
9
- import { LEGACY_MIGRATION_BOT, PARTIAL_LIQUIDATION_BOT_CONFIGS, PARTIAL_LIQUIDATION_BOT_DEPLOYER, PARTIAL_LIQUIDATION_BOT_SALT } from "./config.js";
10
- import { BOT_PARAMS_ABI, BOT_PARTIAL_LIQUIDATION } from "./types.js";
11
- import { PartialLiquidationBotV310Contract } from "./PartialLiquidationBotV310Contract.js";
12
- import { encodeAbiParameters, stringToHex } from "viem";
13
- //#region src/plugins/bots/BotsPlugin.ts
14
- var BotsPlugin = class extends BasePlugin {
15
- #bots;
16
- get loaded() {
17
- return !!this.#bots;
18
- }
19
- get bots() {
20
- return this.#bots?.values() ?? [];
21
- }
22
- async load(force) {
23
- if (!force && this.loaded) return this.state;
24
- const treasury = this.sdk.addressProvider.getAddress(AP_TREASURY);
25
- const bcr = this.sdk.addressProvider.getAddress(AP_BYTECODE_REPOSITORY);
26
- const configs = PARTIAL_LIQUIDATION_BOT_CONFIGS[this.sdk.networkType] ?? [];
27
- this.#bots = new AddressMap();
28
- if (!configs.length) return this.state;
29
- const deployedBots = await this.client.multicall({
30
- contracts: configs.map((config) => ({
31
- address: bcr,
32
- abi: iBytecodeRepositoryAbi,
33
- functionName: "computeAddress",
34
- args: [
35
- stringToHex(BOT_PARTIAL_LIQUIDATION, { size: 32 }),
36
- 310,
37
- encodeAbiParameters(BOT_PARAMS_ABI, [
38
- treasury,
39
- config.minHealthFactor,
40
- config.maxHealthFactor,
41
- config.premiumScaleFactor,
42
- config.feeScaleFactor
43
- ]),
44
- stringToHex(PARTIAL_LIQUIDATION_BOT_SALT, { size: 32 }),
45
- PARTIAL_LIQUIDATION_BOT_DEPLOYER
46
- ]
47
- })),
48
- allowFailure: true,
49
- blockNumber: this.sdk.currentBlock,
50
- batchSize: 0
51
- });
52
- const expectedBots = new AddressMap();
53
- for (let i = 0; i < configs.length; i++) {
54
- const b = deployedBots[i];
55
- const { minHealthFactor, maxHealthFactor } = configs[i];
56
- if (b.status === "success") {
57
- expectedBots.upsert(b.result, {
58
- ...configs[i],
59
- treasury
60
- });
61
- this.logger?.debug(`expected bot [${minHealthFactor}, ${maxHealthFactor}] at ${b.result}`);
62
- } else this.logger?.error(`failed compute address for bot [${minHealthFactor}, ${maxHealthFactor}]`, b.error);
63
- }
64
- const botAddrs = expectedBots.keys();
65
- const serializedBots = await this.client.multicall({
66
- contracts: botAddrs.map((address) => ({
67
- address,
68
- abi: iPartialLiquidationBotV310Abi,
69
- functionName: "serialize"
70
- })),
71
- allowFailure: true,
72
- blockNumber: this.sdk.currentBlock,
73
- batchSize: 0
74
- });
75
- for (let i = 0; i < botAddrs.length; i++) {
76
- const serialized = serializedBots[i];
77
- const expected = expectedBots.mustGet(botAddrs[i]);
78
- if (serialized.status === "success") {
79
- const bot = new PartialLiquidationBotV310Contract(this.sdk, {
80
- addr: botAddrs[i],
81
- version: BigInt(310),
82
- contractType: BOT_PARTIAL_LIQUIDATION,
83
- serializedParams: serialized.result
84
- });
85
- if (!hexEq(treasury, expected.treasury) || bot.minHealthFactor !== expected.minHealthFactor || bot.maxHealthFactor !== expected.maxHealthFactor || bot.premiumScaleFactor !== expected.premiumScaleFactor || bot.feeScaleFactor !== expected.feeScaleFactor) this.logger?.error(`serialized bot ${botAddrs[i]} does not match expected bot`, serialized.error);
86
- else this.#bots.upsert(botAddrs[i], bot);
87
- }
88
- }
89
- return this.state;
90
- }
91
- stateHuman(raw) {
92
- return { bots: this.#bots?.values().map((bot) => bot.stateHuman(raw)) ?? [] };
93
- }
94
- get state() {
95
- return { bots: this.#bots?.values().map((bot) => bot.state) ?? [] };
96
- }
97
- hydrate(state) {
98
- this.#bots = new AddressMap();
99
- for (const botState of state.bots) this.#bots.upsert(botState.addr, new PartialLiquidationBotV310Contract(this.sdk, botState));
100
- }
101
- static getMigrationBotData(chainId) {
102
- return chainId === chains.Mainnet.id ? LEGACY_MIGRATION_BOT : void 0;
103
- }
104
- };
105
- //#endregion
106
- export { BotsPlugin };
@@ -1,46 +0,0 @@
1
- import { percentFmt } from "../../onchain/utils/formatter.js";
2
- import { BaseContract } from "../../onchain/base/BaseContract.js";
3
- import "../../onchain/index.js";
4
- import { iPartialLiquidationBotV310Abi } from "./abi/iPartialLiquidationBotV310.js";
5
- import "./abi/index.js";
6
- import { BOT_PARAMS_ABI } from "./types.js";
7
- import { decodeAbiParameters, stringToHex } from "viem";
8
- //#region src/plugins/bots/PartialLiquidationBotV310Contract.ts
9
- const abi = iPartialLiquidationBotV310Abi;
10
- var PartialLiquidationBotV310Contract = class extends BaseContract {
11
- treasury;
12
- minHealthFactor;
13
- maxHealthFactor;
14
- premiumScaleFactor;
15
- feeScaleFactor;
16
- #serializedParams;
17
- constructor(sdk, args) {
18
- super(sdk, {
19
- ...args,
20
- abi,
21
- name: "PartialLiquidationBotV310"
22
- });
23
- [this.treasury, this.minHealthFactor, this.maxHealthFactor, this.premiumScaleFactor, this.feeScaleFactor] = decodeAbiParameters(BOT_PARAMS_ABI, args.serializedParams);
24
- this.#serializedParams = args.serializedParams;
25
- }
26
- stateHuman(raw) {
27
- return {
28
- ...super.stateHuman(raw),
29
- treasury: this.treasury,
30
- minHealthFactor: percentFmt(this.minHealthFactor, raw),
31
- maxHealthFactor: percentFmt(this.maxHealthFactor, raw),
32
- premiumScaleFactor: percentFmt(this.premiumScaleFactor, raw),
33
- feeScaleFactor: percentFmt(this.feeScaleFactor, raw)
34
- };
35
- }
36
- get state() {
37
- return {
38
- addr: this.address,
39
- version: BigInt(this.version),
40
- contractType: stringToHex(this.contractType, { size: 32 }),
41
- serializedParams: this.#serializedParams
42
- };
43
- }
44
- };
45
- //#endregion
46
- export { PartialLiquidationBotV310Contract };
@@ -1,224 +0,0 @@
1
- //#region src/plugins/bots/abi/iPartialLiquidationBotV310.ts
2
- const iPartialLiquidationBotV310Abi = [
3
- {
4
- type: "function",
5
- name: "contractType",
6
- inputs: [],
7
- outputs: [{
8
- name: "",
9
- type: "bytes32",
10
- internalType: "bytes32"
11
- }],
12
- stateMutability: "view"
13
- },
14
- {
15
- type: "function",
16
- name: "feeScaleFactor",
17
- inputs: [],
18
- outputs: [{
19
- name: "",
20
- type: "uint16",
21
- internalType: "uint16"
22
- }],
23
- stateMutability: "view"
24
- },
25
- {
26
- type: "function",
27
- name: "maxHealthFactor",
28
- inputs: [],
29
- outputs: [{
30
- name: "",
31
- type: "uint16",
32
- internalType: "uint16"
33
- }],
34
- stateMutability: "view"
35
- },
36
- {
37
- type: "function",
38
- name: "minHealthFactor",
39
- inputs: [],
40
- outputs: [{
41
- name: "",
42
- type: "uint16",
43
- internalType: "uint16"
44
- }],
45
- stateMutability: "view"
46
- },
47
- {
48
- type: "function",
49
- name: "partiallyLiquidate",
50
- inputs: [
51
- {
52
- name: "creditAccount",
53
- type: "address",
54
- internalType: "address"
55
- },
56
- {
57
- name: "token",
58
- type: "address",
59
- internalType: "address"
60
- },
61
- {
62
- name: "repaidAmount",
63
- type: "uint256",
64
- internalType: "uint256"
65
- },
66
- {
67
- name: "minSeizedAmount",
68
- type: "uint256",
69
- internalType: "uint256"
70
- },
71
- {
72
- name: "to",
73
- type: "address",
74
- internalType: "address"
75
- },
76
- {
77
- name: "priceUpdates",
78
- type: "tuple[]",
79
- internalType: "struct PriceUpdate[]",
80
- components: [{
81
- name: "priceFeed",
82
- type: "address",
83
- internalType: "address"
84
- }, {
85
- name: "data",
86
- type: "bytes",
87
- internalType: "bytes"
88
- }]
89
- }
90
- ],
91
- outputs: [{
92
- name: "seizedAmount",
93
- type: "uint256",
94
- internalType: "uint256"
95
- }],
96
- stateMutability: "nonpayable"
97
- },
98
- {
99
- type: "function",
100
- name: "premiumScaleFactor",
101
- inputs: [],
102
- outputs: [{
103
- name: "",
104
- type: "uint16",
105
- internalType: "uint16"
106
- }],
107
- stateMutability: "view"
108
- },
109
- {
110
- type: "function",
111
- name: "requiredPermissions",
112
- inputs: [],
113
- outputs: [{
114
- name: "",
115
- type: "uint192",
116
- internalType: "uint192"
117
- }],
118
- stateMutability: "view"
119
- },
120
- {
121
- type: "function",
122
- name: "serialize",
123
- inputs: [],
124
- outputs: [{
125
- name: "serializedData",
126
- type: "bytes",
127
- internalType: "bytes"
128
- }],
129
- stateMutability: "view"
130
- },
131
- {
132
- type: "function",
133
- name: "treasury",
134
- inputs: [],
135
- outputs: [{
136
- name: "",
137
- type: "address",
138
- internalType: "address"
139
- }],
140
- stateMutability: "view"
141
- },
142
- {
143
- type: "function",
144
- name: "version",
145
- inputs: [],
146
- outputs: [{
147
- name: "",
148
- type: "uint256",
149
- internalType: "uint256"
150
- }],
151
- stateMutability: "view"
152
- },
153
- {
154
- type: "event",
155
- name: "PartiallyLiquidate",
156
- inputs: [
157
- {
158
- name: "creditManager",
159
- type: "address",
160
- indexed: true,
161
- internalType: "address"
162
- },
163
- {
164
- name: "creditAccount",
165
- type: "address",
166
- indexed: true,
167
- internalType: "address"
168
- },
169
- {
170
- name: "token",
171
- type: "address",
172
- indexed: true,
173
- internalType: "address"
174
- },
175
- {
176
- name: "liquidator",
177
- type: "address",
178
- indexed: false,
179
- internalType: "address"
180
- },
181
- {
182
- name: "repaidDebt",
183
- type: "uint256",
184
- indexed: false,
185
- internalType: "uint256"
186
- },
187
- {
188
- name: "seizedCollateral",
189
- type: "uint256",
190
- indexed: false,
191
- internalType: "uint256"
192
- },
193
- {
194
- name: "fee",
195
- type: "uint256",
196
- indexed: false,
197
- internalType: "uint256"
198
- }
199
- ],
200
- anonymous: false
201
- },
202
- {
203
- type: "error",
204
- name: "LiquidatedLessThanNeededException",
205
- inputs: []
206
- },
207
- {
208
- type: "error",
209
- name: "LiquidatedMoreThanNeededException",
210
- inputs: []
211
- },
212
- {
213
- type: "error",
214
- name: "SeizedLessThanRequiredException",
215
- inputs: []
216
- },
217
- {
218
- type: "error",
219
- name: "UnderlyingNotLiquidatableException",
220
- inputs: []
221
- }
222
- ];
223
- //#endregion
224
- export { iPartialLiquidationBotV310Abi };
@@ -1,2 +0,0 @@
1
- import { iPartialLiquidationBotV310Abi } from "./iPartialLiquidationBotV310.js";
2
- export { iPartialLiquidationBotV310Abi };
@@ -1,34 +0,0 @@
1
- import "../../onchain/constants/bot-permissions.js";
2
- import "../../onchain/index.js";
3
- //#region src/plugins/bots/config.ts
4
- const PARTIAL_LIQUIDATION_BOT_CONFIGS = {
5
- Mainnet: [{
6
- minHealthFactor: 10300,
7
- maxHealthFactor: 10700,
8
- premiumScaleFactor: 1e4,
9
- feeScaleFactor: 1e4
10
- }],
11
- Monad: [{
12
- minHealthFactor: 10300,
13
- maxHealthFactor: 10700,
14
- premiumScaleFactor: 1e4,
15
- feeScaleFactor: 1e4
16
- }],
17
- Plasma: [{
18
- minHealthFactor: 10300,
19
- maxHealthFactor: 10700,
20
- premiumScaleFactor: 1e4,
21
- feeScaleFactor: 1e4
22
- }]
23
- };
24
- const PARTIAL_LIQUIDATION_BOT_SALT = "GEARBOX";
25
- const PARTIAL_LIQUIDATION_BOT_DEPLOYER = "0xc93155E0a835Cf4E17a19463Fa67ed43c164d06a";
26
- const LEGACY_MIGRATION_BOT = {
27
- address: "0x286Fe53994f5668D56538Aa10eaa3Ac36f878e9C".toLowerCase(),
28
- previewer: "0x6523B8c9daB92eea7944a79b4Dbb598c7934DCca".toLowerCase(),
29
- version: 310,
30
- baseType: "LEGACY_MIGRATION"
31
- };
32
- const PERMISSION_BY_TYPE = { LEGACY_MIGRATION: BigInt(65604) };
33
- //#endregion
34
- export { LEGACY_MIGRATION_BOT, PARTIAL_LIQUIDATION_BOT_CONFIGS, PARTIAL_LIQUIDATION_BOT_DEPLOYER, PARTIAL_LIQUIDATION_BOT_SALT, PERMISSION_BY_TYPE };
@@ -1,35 +0,0 @@
1
- import { decodeAbiParameters } from "viem";
2
- //#region src/plugins/bots/deserializePartialLiquidationBotParams.ts
3
- function deserializePartialLiquidationBotParams(params) {
4
- const [treasury, minHealthFactor, maxHealthFactor, premiumScaleFactor, feeScaleFactor] = decodeAbiParameters([
5
- {
6
- name: "treasury",
7
- type: "address"
8
- },
9
- {
10
- name: "minHealthFactor",
11
- type: "uint16"
12
- },
13
- {
14
- name: "maxHealthFactor",
15
- type: "uint16"
16
- },
17
- {
18
- name: "premiumScaleFactor",
19
- type: "uint16"
20
- },
21
- {
22
- name: "feeScaleFactor",
23
- type: "uint16"
24
- }
25
- ], params.serializedParams);
26
- return {
27
- treasury,
28
- minHealthFactor,
29
- maxHealthFactor,
30
- premiumScaleFactor,
31
- feeScaleFactor
32
- };
33
- }
34
- //#endregion
35
- export { deserializePartialLiquidationBotParams as default };
@@ -1,7 +0,0 @@
1
- import { iPartialLiquidationBotV310Abi } from "./abi/iPartialLiquidationBotV310.js";
2
- import { LEGACY_MIGRATION_BOT, PARTIAL_LIQUIDATION_BOT_CONFIGS, PARTIAL_LIQUIDATION_BOT_DEPLOYER, PARTIAL_LIQUIDATION_BOT_SALT, PERMISSION_BY_TYPE } from "./config.js";
3
- import "./abi/index.js";
4
- import { BOT_PARAMS_ABI, BOT_PARTIAL_LIQUIDATION } from "./types.js";
5
- import { PartialLiquidationBotV310Contract } from "./PartialLiquidationBotV310Contract.js";
6
- import { BotsPlugin } from "./BotsPlugin.js";
7
- export { BOT_PARAMS_ABI, BOT_PARTIAL_LIQUIDATION, BotsPlugin, LEGACY_MIGRATION_BOT, PARTIAL_LIQUIDATION_BOT_CONFIGS, PARTIAL_LIQUIDATION_BOT_DEPLOYER, PARTIAL_LIQUIDATION_BOT_SALT, PERMISSION_BY_TYPE, PartialLiquidationBotV310Contract, iPartialLiquidationBotV310Abi };
@@ -1 +0,0 @@
1
- {"type": "module","sideEffects":false}
@@ -1,26 +0,0 @@
1
- //#region src/plugins/bots/types.ts
2
- const BOT_PARTIAL_LIQUIDATION = "BOT::PARTIAL_LIQUIDATION";
3
- const BOT_PARAMS_ABI = [
4
- {
5
- type: "address",
6
- name: "treasury"
7
- },
8
- {
9
- type: "uint16",
10
- name: "minHealthFactor"
11
- },
12
- {
13
- type: "uint16",
14
- name: "maxHealthFactor"
15
- },
16
- {
17
- type: "uint16",
18
- name: "premiumScaleFactor"
19
- },
20
- {
21
- type: "uint16",
22
- name: "feeScaleFactor"
23
- }
24
- ];
25
- //#endregion
26
- export { BOT_PARAMS_ABI, BOT_PARTIAL_LIQUIDATION };
@@ -1,60 +0,0 @@
1
- import { AddressMap } from "../../onchain/utils/AddressMap.js";
2
- import { MarketConfiguratorContract } from "../../onchain/market/MarketConfiguratorContract.js";
3
- import { BasePlugin } from "../../onchain/plugins/BasePlugin.js";
4
- import "../../onchain/index.js";
5
- //#region src/plugins/degen-distributors/DegenDistributorsPlugin.ts
6
- const MAP_LABEL = "degenDistributors";
7
- var DegenDistributorsPlugin = class extends BasePlugin {
8
- #distributors;
9
- async load(force) {
10
- if (!force && this.loaded) return this.state;
11
- const configurators = Object.values(this.sdk.marketRegister.markets.reduce((acc, market) => {
12
- const cfgLC = market.configurator.address.toLowerCase();
13
- acc[cfgLC] = market.configurator;
14
- return acc;
15
- }, {}));
16
- this.sdk.logger?.debug(`loading degen distributors for ${this.sdk.networkType}`);
17
- const distributors = await MarketConfiguratorContract.getPeripheryContractBatch(Object.values(configurators), this.sdk.client, "DEGEN_DISTRIBUTOR", this.sdk.currentBlock);
18
- const distributorByConfigurator = configurators.reduce((acc, cfg, index) => {
19
- const cfgLC = cfg.address.toLowerCase();
20
- acc[cfgLC] = distributors[index];
21
- return acc;
22
- }, {});
23
- this.#distributors = new AddressMap(void 0, MAP_LABEL);
24
- this.sdk.marketRegister.markets.forEach((m) => {
25
- const pool = m.pool.pool.address;
26
- const cfg = m.configurator.address;
27
- const cfgLC = cfg.toLowerCase();
28
- const r = distributorByConfigurator?.[cfgLC];
29
- if (r.status === "success" && r.result.length > 0) this.#distributors?.upsert(pool, r.result[0]);
30
- else this.sdk.logger?.warn(`failed to load degen distributor for market configurator ${this.labelAddress(cfg)} and pool ${this.labelAddress(pool)}: ${r.error}`);
31
- });
32
- return this.state;
33
- }
34
- get loaded() {
35
- return !!this.#distributors;
36
- }
37
- /**
38
- * Returns a map of pool addresses to degen distributor addresses
39
- * @throws if degen distributor plugin is not attached
40
- */
41
- get distributors() {
42
- if (!this.#distributors) throw new Error("degen distributor plugin not attached");
43
- return this.#distributors;
44
- }
45
- stateHuman(_) {
46
- return this.distributors.entries().flatMap(([pool, distributor]) => ({
47
- address: distributor,
48
- version: this.version,
49
- pool
50
- }));
51
- }
52
- get state() {
53
- return { distributors: this.distributors.asRecord() };
54
- }
55
- hydrate(state) {
56
- this.#distributors = new AddressMap(Object.entries(state.distributors), MAP_LABEL);
57
- }
58
- };
59
- //#endregion
60
- export { DegenDistributorsPlugin };
@@ -1,3 +0,0 @@
1
- import { DegenDistributorsPlugin } from "./DegenDistributorsPlugin.js";
2
- import "./types.js";
3
- export { DegenDistributorsPlugin };
@@ -1 +0,0 @@
1
- {"type": "module","sideEffects":false}
@@ -1 +0,0 @@
1
- export {};
@@ -1,113 +0,0 @@
1
- import { AddressMap } from "../../onchain/utils/AddressMap.js";
2
- import { BasePlugin } from "../../onchain/plugins/BasePlugin.js";
3
- import "../../onchain/index.js";
4
- //#region src/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.ts
5
- const MAP_LABEL = "delayedWithdrawal";
6
- var DelayedWithdrawalPlugin = class extends BasePlugin {
7
- async load(force) {
8
- if (!force && this.loaded) return this.state;
9
- await this.sdk.withdrawalCompressor?.loadWithdrawableAssets(force);
10
- return this.state;
11
- }
12
- get loaded() {
13
- return !!this.sdk.withdrawalCompressor?.state;
14
- }
15
- /**
16
- * Returns a map of cmAddress -> array of delayed assets
17
- * @throws if withdrawable assets have not been loaded
18
- */
19
- get withdrawableAssets() {
20
- const compressor = this.sdk.withdrawalCompressor;
21
- if (!compressor?.state) throw new Error("withdrawable assets are not loaded");
22
- const result = new AddressMap(void 0, MAP_LABEL);
23
- for (const cfg of compressor.getWithdrawableAssets()) {
24
- const assets = result.get(cfg.creditManager) ?? [];
25
- assets.push({
26
- ...cfg,
27
- disabled: isConfigToOmit({
28
- creditManager: cfg.creditManager,
29
- token: cfg.token,
30
- withdrawalPhantomToken: cfg.withdrawalPhantomToken,
31
- underlying: cfg.underlying
32
- })
33
- });
34
- result.upsert(cfg.creditManager, assets);
35
- }
36
- return result;
37
- }
38
- stateHuman(_) {
39
- return this.withdrawableAssets.values().flatMap((cm) => {
40
- return cm.map((a) => {
41
- return {
42
- address: a.creditManager,
43
- version: this.version,
44
- ...a
45
- };
46
- });
47
- });
48
- }
49
- get state() {
50
- return {};
51
- }
52
- };
53
- function getConfigKey(config) {
54
- return `${config.creditManager}-${config.token}-${config.withdrawalPhantomToken}-${config.underlying}`.toLowerCase();
55
- }
56
- function isConfigToOmit(config) {
57
- return !!CONFIGS_TO_OMIT_RECORD[getConfigKey(config)];
58
- }
59
- const CONFIGS_TO_OMIT_RECORD = [
60
- {
61
- creditManager: "0xf5edc34204e67e592bdcb84114571c9e4bd0bdf7",
62
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
63
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
64
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
65
- },
66
- {
67
- creditManager: "0xb79d6544839d169869476589d2e54014a074317b",
68
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
69
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
70
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
71
- },
72
- {
73
- creditManager: "0x79c6c1ce5b12abcc3e407ce8c160ee1160250921",
74
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
75
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
76
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
77
- },
78
- {
79
- creditManager: "0xc307a074bd5aec2d6ad1d9b74465c24a59b490fd",
80
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
81
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
82
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
83
- },
84
- {
85
- creditManager: "0x9a0fdf7cdab4604fc27ebeab4b3d57bd825e8ebe",
86
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
87
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
88
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
89
- },
90
- {
91
- creditManager: "0x06c0df5ac1f24bc2097b59ed8ee1db86bf0b09df",
92
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
93
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
94
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
95
- },
96
- {
97
- creditManager: "0x1128860755c6d452d9326e35d1672ca7c920b7c1",
98
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
99
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
100
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
101
- },
102
- {
103
- creditManager: "0x35e154be3c856c37d539aae90178fe5ac6d37644",
104
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
105
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
106
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
107
- }
108
- ].reduce((acc, config) => {
109
- acc[getConfigKey(config)] = config;
110
- return acc;
111
- }, {});
112
- //#endregion
113
- export { DelayedWithdrawalPlugin };
@@ -1,3 +0,0 @@
1
- import { DelayedWithdrawalPlugin } from "./DelayedWithdrawalPlugin.js";
2
- import "./types.js";
3
- export { DelayedWithdrawalPlugin };
@@ -1 +0,0 @@
1
- {"type": "module","sideEffects":false}
@@ -1 +0,0 @@
1
- export {};