@gearbox-protocol/sdk 14.12.0-next.75 → 14.12.0-next.76
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/sdk/accounts/CreditAccountsServiceV310.js +13 -140
- package/dist/cjs/sdk/accounts/bots/AccountBotsService.js +132 -0
- package/dist/cjs/sdk/accounts/bots/PeripheryCompressorV310Contract.js +31 -0
- package/dist/cjs/sdk/accounts/bots/abi.js +19 -0
- package/dist/cjs/sdk/accounts/bots/index.js +6 -0
- package/dist/cjs/sdk/accounts/bots/types.js +1 -0
- package/dist/cjs/sdk/accounts/index.js +5 -0
- package/dist/cjs/sdk/index.js +4 -0
- package/dist/cjs/sdk/market/ZapperRegister.js +1 -1
- package/dist/cjs/sdk/market/credit/CreditSuite.js +31 -0
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +15 -142
- package/dist/esm/sdk/accounts/bots/AccountBotsService.js +131 -0
- package/dist/esm/sdk/accounts/bots/PeripheryCompressorV310Contract.js +31 -0
- package/dist/esm/sdk/accounts/bots/abi.js +18 -0
- package/dist/esm/sdk/accounts/bots/index.js +4 -0
- package/dist/esm/sdk/accounts/bots/types.js +1 -0
- package/dist/esm/sdk/accounts/index.js +4 -1
- package/dist/esm/sdk/index.js +3 -1
- package/dist/esm/sdk/market/ZapperRegister.js +1 -1
- package/dist/esm/sdk/market/credit/CreditSuite.js +31 -0
- package/dist/types/new-sdk/AbstractNamespace.d.ts +2 -2
- package/dist/types/new-sdk/opportunities/OpportunitiesNamespace.d.ts +1 -1
- package/dist/types/new-sdk/positions/PositionsNamespace.d.ts +1 -1
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +9 -16
- package/dist/types/sdk/accounts/bots/AccountBotsService.d.ts +38 -0
- package/dist/types/sdk/accounts/bots/PeripheryCompressorV310Contract.d.ts +236 -0
- package/dist/types/sdk/accounts/bots/abi.d.ts +18 -0
- package/dist/types/sdk/accounts/bots/index.d.ts +4 -0
- package/dist/types/sdk/accounts/bots/types.d.ts +143 -0
- package/dist/types/sdk/accounts/credit-account-compressor/CreditAccountCompressor.d.ts +1 -1
- package/dist/types/sdk/accounts/index.d.ts +6 -2
- package/dist/types/sdk/accounts/liquidations/MultichainLiquidationsService.d.ts +2 -2
- package/dist/types/sdk/accounts/liquidations/types.d.ts +1 -1
- package/dist/types/sdk/accounts/types.d.ts +10 -84
- package/dist/types/sdk/base/TokensMeta.d.ts +1 -1
- package/dist/types/sdk/index.d.ts +5 -2
- package/dist/types/sdk/market/MarketConfiguratorContract.d.ts +1 -1
- package/dist/types/sdk/market/MarketSuite.d.ts +1 -1
- package/dist/types/sdk/market/credit/CreditManagerV310Contract.d.ts +1 -1
- package/dist/types/sdk/market/credit/CreditSuite.d.ts +26 -1
- package/dist/types/sdk/market/credit/types.d.ts +1 -1
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +2 -2
- package/dist/types/sdk/market/oracle/types.d.ts +2 -2
- package/dist/types/sdk/market/pool/LinearInterestRateModelContract.d.ts +1 -1
- package/dist/types/sdk/market/pool/PoolQuotaKeeperV310Contract.d.ts +1 -1
- package/dist/types/sdk/market/pool/PoolSuite.d.ts +1 -1
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +1 -1
- package/dist/types/sdk/market/pool/types.d.ts +1 -1
- package/dist/types/sdk/market/pricefeeds/AbstractPriceFeed.d.ts +1 -1
- package/dist/types/sdk/market/pricefeeds/types.d.ts +1 -1
- package/dist/types/sdk/opportunities/MultichainOpportunitiesService.d.ts +2 -2
- package/dist/types/sdk/pools/types.d.ts +1 -1
- package/dist/types/sdk/positions/MultichainPositionsService.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_abi_iBaseRewardPool = require("../../abi/iBaseRewardPool.js");
|
|
3
3
|
const require_abi_ierc4626Adapter = require("../../abi/ierc4626Adapter.js");
|
|
4
|
-
const require_abi_310_generated = require("../../abi/310/generated.js");
|
|
5
|
-
const require_abi_compressors_peripheryCompressor = require("../../abi/compressors/peripheryCompressor.js");
|
|
6
|
-
const require_abi_compressors_rewardsCompressor = require("../../abi/compressors/rewardsCompressor.js");
|
|
7
4
|
const require_sdk_constants_address_provider = require("../constants/address-provider.js");
|
|
8
5
|
const require_sdk_constants_addresses = require("../constants/addresses.js");
|
|
9
6
|
const require_sdk_constants_math = require("../constants/math.js");
|
|
@@ -11,6 +8,9 @@ const require_sdk_constants_versions = require("../constants/versions.js");
|
|
|
11
8
|
require("../constants/index.js");
|
|
12
9
|
const require_sdk_base_SDKConstruct = require("../base/SDKConstruct.js");
|
|
13
10
|
require("../base/index.js");
|
|
11
|
+
const require_sdk_accounts_bots_AccountBotsService = require("./bots/AccountBotsService.js");
|
|
12
|
+
require("./bots/index.js");
|
|
13
|
+
const require_abi_compressors_rewardsCompressor = require("../../abi/compressors/rewardsCompressor.js");
|
|
14
14
|
const require_sdk_accounts_credit_account_compressor_CreditAccountCompressor = require("./credit-account-compressor/CreditAccountCompressor.js");
|
|
15
15
|
require("./credit-account-compressor/index.js");
|
|
16
16
|
const require_sdk_accounts_multicall_utils = require("./multicall-utils.js");
|
|
@@ -27,9 +27,14 @@ let viem = require("viem");
|
|
|
27
27
|
**/
|
|
28
28
|
var CreditAccountsServiceV310 = class extends require_sdk_base_SDKConstruct.SDKConstruct {
|
|
29
29
|
#compressor;
|
|
30
|
+
/**
|
|
31
|
+
* {@inheritDoc ICreditAccountsService.bots}
|
|
32
|
+
**/
|
|
33
|
+
bots;
|
|
30
34
|
constructor(sdk) {
|
|
31
35
|
super(sdk);
|
|
32
36
|
this.#compressor = new require_sdk_accounts_credit_account_compressor_CreditAccountCompressor.CreditAccountCompressor(sdk);
|
|
37
|
+
this.bots = new require_sdk_accounts_bots_AccountBotsService.AccountBotsService(sdk);
|
|
33
38
|
}
|
|
34
39
|
/**
|
|
35
40
|
* {@inheritDoc ICreditAccountsService.getCreditAccountData}
|
|
@@ -93,76 +98,6 @@ var CreditAccountsServiceV310 = class extends require_sdk_base_SDKConstruct.SDKC
|
|
|
93
98
|
return Object.values(r);
|
|
94
99
|
}
|
|
95
100
|
/**
|
|
96
|
-
* {@inheritDoc ICreditAccountsService.getConnectedBots}
|
|
97
|
-
**/
|
|
98
|
-
async getConnectedBots(accountsToCheck, legacyMigrationBot, additionalBots) {
|
|
99
|
-
const allResp = await this.client.multicall({
|
|
100
|
-
contracts: [
|
|
101
|
-
...accountsToCheck.map((o) => {
|
|
102
|
-
const pool = this.sdk.marketRegister.findByCreditManager(o.creditManager);
|
|
103
|
-
return {
|
|
104
|
-
abi: require_abi_compressors_peripheryCompressor.peripheryCompressorAbi,
|
|
105
|
-
address: this.peripheryCompressor,
|
|
106
|
-
functionName: "getConnectedBots",
|
|
107
|
-
args: [pool.configurator.address, o.creditAccount]
|
|
108
|
-
};
|
|
109
|
-
}),
|
|
110
|
-
...legacyMigrationBot ? accountsToCheck.map((ca) => {
|
|
111
|
-
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
112
|
-
return {
|
|
113
|
-
abi: require_abi_310_generated.iBotListV310Abi,
|
|
114
|
-
address: cm.creditFacade.botList,
|
|
115
|
-
functionName: "getBotStatus",
|
|
116
|
-
args: [legacyMigrationBot, ca.creditAccount]
|
|
117
|
-
};
|
|
118
|
-
}) : [],
|
|
119
|
-
...accountsToCheck.flatMap((ca) => {
|
|
120
|
-
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
121
|
-
return additionalBots.map((bot) => {
|
|
122
|
-
return {
|
|
123
|
-
abi: require_abi_310_generated.iBotListV310Abi,
|
|
124
|
-
address: cm.creditFacade.botList,
|
|
125
|
-
functionName: "getBotStatus",
|
|
126
|
-
args: [bot, ca.creditAccount]
|
|
127
|
-
};
|
|
128
|
-
});
|
|
129
|
-
})
|
|
130
|
-
],
|
|
131
|
-
allowFailure: true,
|
|
132
|
-
batchSize: 0
|
|
133
|
-
});
|
|
134
|
-
const legacyStart = 0;
|
|
135
|
-
const legacyEnd = accountsToCheck.length;
|
|
136
|
-
const legacy = allResp.slice(legacyStart, legacyEnd);
|
|
137
|
-
const migrationStart = legacyEnd;
|
|
138
|
-
const migrationEnd = legacyMigrationBot ? migrationStart + accountsToCheck.length : migrationStart;
|
|
139
|
-
const migrationResp = allResp.slice(migrationStart, migrationEnd);
|
|
140
|
-
const additionalStart = migrationEnd;
|
|
141
|
-
const additionalResp = allResp.slice(additionalStart);
|
|
142
|
-
return {
|
|
143
|
-
legacy,
|
|
144
|
-
additionalBots: this.#getActiveBots(accountsToCheck, additionalBots, additionalResp),
|
|
145
|
-
legacyMigration: this.#getActiveMigrationBots(accountsToCheck, legacyMigrationBot, migrationResp)
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
#getActiveBots(accountsToCheck, bots, result) {
|
|
149
|
-
if (result.length !== bots.length * accountsToCheck.length) console.error("result length mismatch", result.length, bots.length * accountsToCheck.length);
|
|
150
|
-
return accountsToCheck.reduce((acc, _, index) => {
|
|
151
|
-
const r = result.slice(index * bots.length, (index + 1) * bots.length);
|
|
152
|
-
acc.push({ result: r });
|
|
153
|
-
return acc;
|
|
154
|
-
}, []);
|
|
155
|
-
}
|
|
156
|
-
#getActiveMigrationBots(accountsToCheck, bot, result) {
|
|
157
|
-
if (bot) {
|
|
158
|
-
if (result.length !== accountsToCheck.length) console.error("result length mismatch for migration bots", result.length, accountsToCheck.length);
|
|
159
|
-
return {
|
|
160
|
-
result,
|
|
161
|
-
botAddress: bot
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
101
|
* {@inheritDoc ICreditAccountsService.fullyLiquidate}
|
|
167
102
|
**/
|
|
168
103
|
async fullyLiquidate(props) {
|
|
@@ -289,15 +224,13 @@ var CreditAccountsServiceV310 = class extends require_sdk_base_SDKConstruct.SDKC
|
|
|
289
224
|
async getApprovalAddress(options) {
|
|
290
225
|
const { creditManager } = options;
|
|
291
226
|
const suite = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
292
|
-
|
|
293
|
-
if (factory) return factory.getApprovalAddress(options);
|
|
294
|
-
return suite.creditManager.address;
|
|
227
|
+
return suite.rwaFactory ? suite.rwaFactory.getApprovalAddress(options) : suite.creditManager.address;
|
|
295
228
|
}
|
|
296
229
|
/**
|
|
297
230
|
* {@inheritDoc ICreditAccountsService.getOpenAccountRequirements}
|
|
298
231
|
*/
|
|
299
232
|
async getOpenAccountRequirements(borrower, creditManager, props) {
|
|
300
|
-
const { rwaFactory } = this.sdk.marketRegister.
|
|
233
|
+
const { rwaFactory } = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
301
234
|
if (!rwaFactory) return;
|
|
302
235
|
return rwaFactory.getOpenAccountRequirements(borrower, props);
|
|
303
236
|
}
|
|
@@ -324,9 +257,7 @@ var CreditAccountsServiceV310 = class extends require_sdk_base_SDKConstruct.SDKC
|
|
|
324
257
|
...callsAfter ?? []
|
|
325
258
|
];
|
|
326
259
|
const calls = await this.prependPriceUpdates(cm.address, operationCalls);
|
|
327
|
-
|
|
328
|
-
if (reopenCreditAccount) tx = await this.#multicallTx(cmSuite, reopenCreditAccount, calls);
|
|
329
|
-
else tx = await this.#openCreditAccountTx(cmSuite, to, calls, referralCode, rwaOptions);
|
|
260
|
+
const tx = reopenCreditAccount ? cmSuite.multicallTx(reopenCreditAccount, calls) : cmSuite.openCreditAccountTx(to, calls, referralCode, rwaOptions);
|
|
330
261
|
tx.value = ethAmount.toString(10);
|
|
331
262
|
return tx;
|
|
332
263
|
}
|
|
@@ -401,34 +332,6 @@ var CreditAccountsServiceV310 = class extends require_sdk_base_SDKConstruct.SDKC
|
|
|
401
332
|
return this.#rwaVaultCalls("depositDiff", amount, creditManager);
|
|
402
333
|
}
|
|
403
334
|
/**
|
|
404
|
-
* {@inheritDoc ICreditAccountsService.setBot}
|
|
405
|
-
*/
|
|
406
|
-
async setBot({ botAddress, permissions: defaultPermissions, targetContract }) {
|
|
407
|
-
const cm = this.sdk.marketRegister.findCreditManager(targetContract.creditManager);
|
|
408
|
-
const permissions = defaultPermissions !== null ? defaultPermissions : await (0, viem.getContract)({
|
|
409
|
-
address: botAddress,
|
|
410
|
-
client: this.sdk.client,
|
|
411
|
-
abi: [{
|
|
412
|
-
type: "function",
|
|
413
|
-
name: "requiredPermissions",
|
|
414
|
-
inputs: [],
|
|
415
|
-
outputs: [{
|
|
416
|
-
name: "",
|
|
417
|
-
type: "uint192",
|
|
418
|
-
internalType: "uint192"
|
|
419
|
-
}],
|
|
420
|
-
stateMutability: "view"
|
|
421
|
-
}]
|
|
422
|
-
}).read.requiredPermissions();
|
|
423
|
-
const addBotCall = cm.creditFacade.prepareSetBotPermissions(botAddress, permissions);
|
|
424
|
-
const calls = targetContract.type === "creditAccount" ? await this.prependPriceUpdates(targetContract.creditManager, [addBotCall], targetContract) : [addBotCall];
|
|
425
|
-
return {
|
|
426
|
-
tx: targetContract.type === "creditAccount" ? await this.#multicallTx(cm, targetContract.creditAccount, calls) : void 0,
|
|
427
|
-
calls,
|
|
428
|
-
creditFacade: cm.creditFacade
|
|
429
|
-
};
|
|
430
|
-
}
|
|
431
|
-
/**
|
|
432
335
|
* {@inheritDoc ICreditAccountsService.assembleRepayCreditAccountCalls}
|
|
433
336
|
*/
|
|
434
337
|
async assembleRepayCreditAccountCalls({ collateralAssets, assetsToWithdraw, creditAccount: ca, permits, to, tokensToClaim, calls: wrapCalls = [] }) {
|
|
@@ -468,7 +371,7 @@ var CreditAccountsServiceV310 = class extends require_sdk_base_SDKConstruct.SDKC
|
|
|
468
371
|
averageQuota
|
|
469
372
|
})];
|
|
470
373
|
const calls = await this.prependPriceUpdates(ca.creditManager, operationCalls, ca);
|
|
471
|
-
return
|
|
374
|
+
return cm.multicallTx(ca.creditAccount, calls);
|
|
472
375
|
}
|
|
473
376
|
/**
|
|
474
377
|
* Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
|
|
@@ -541,7 +444,7 @@ var CreditAccountsServiceV310 = class extends require_sdk_base_SDKConstruct.SDKC
|
|
|
541
444
|
async executeCaUpdate(creditAccount, calls, options) {
|
|
542
445
|
const cm = this.sdk.marketRegister.findCreditManager(creditAccount.creditManager);
|
|
543
446
|
const callsWithPrices = await this.prependPriceUpdates(creditAccount.creditManager, calls, creditAccount, { ignoreReservePrices: options?.ignoreReservePrices });
|
|
544
|
-
const tx =
|
|
447
|
+
const tx = cm.multicallTx(creditAccount.creditAccount, callsWithPrices);
|
|
545
448
|
if (options?.ethAmount && options.ethAmount > 0n) tx.value = options.ethAmount.toString(10);
|
|
546
449
|
return tx;
|
|
547
450
|
}
|
|
@@ -578,36 +481,6 @@ var CreditAccountsServiceV310 = class extends require_sdk_base_SDKConstruct.SDKC
|
|
|
578
481
|
get rewardCompressor() {
|
|
579
482
|
return this.sdk.addressProvider.mustGetLatest(require_sdk_constants_address_provider.AP_REWARDS_COMPRESSOR, require_sdk_constants_versions.VERSION_RANGE_310)[0];
|
|
580
483
|
}
|
|
581
|
-
get peripheryCompressor() {
|
|
582
|
-
return this.sdk.addressProvider.mustGetLatest(require_sdk_constants_address_provider.AP_PERIPHERY_COMPRESSOR, require_sdk_constants_versions.VERSION_RANGE_310)[0];
|
|
583
|
-
}
|
|
584
|
-
/**
|
|
585
|
-
* Wrapper that selects between credit facade and RWA factory
|
|
586
|
-
* @param suite
|
|
587
|
-
* @param to
|
|
588
|
-
* @param calls
|
|
589
|
-
* @param referralCode
|
|
590
|
-
* @param rwaOptions
|
|
591
|
-
* @returns
|
|
592
|
-
*/
|
|
593
|
-
async #openCreditAccountTx(suite, to, calls, referralCode, rwaOptions) {
|
|
594
|
-
const factory = this.sdk.marketRegister.findByPool(suite.pool).rwaFactory;
|
|
595
|
-
if (factory) return factory.openCreditAccount(suite.creditManager.address, calls, rwaOptions);
|
|
596
|
-
return suite.creditFacade.openCreditAccount(to, calls, referralCode ?? 0n);
|
|
597
|
-
}
|
|
598
|
-
/**
|
|
599
|
-
* Wrapper that selects between credit facade and RWA factory
|
|
600
|
-
* @param suite
|
|
601
|
-
* @param creditAccount
|
|
602
|
-
* @param calls
|
|
603
|
-
* @param rwaOptions
|
|
604
|
-
* @returns
|
|
605
|
-
*/
|
|
606
|
-
async #multicallTx(suite, creditAccount, calls, rwaOptions) {
|
|
607
|
-
const factory = this.sdk.marketRegister.findByCreditManager(suite.creditManager.address).rwaFactory;
|
|
608
|
-
if (factory) return factory.multicall(creditAccount, calls, rwaOptions);
|
|
609
|
-
return suite.creditFacade.multicall(creditAccount, calls);
|
|
610
|
-
}
|
|
611
484
|
/**
|
|
612
485
|
* Withdrawal compressor of the current chain.
|
|
613
486
|
* @throws If no withdrawal compressor is supported on the current chain.
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_abi_310_generated = require("../../../abi/310/generated.js");
|
|
3
|
+
const require_sdk_constants_address_provider = require("../../constants/address-provider.js");
|
|
4
|
+
const require_sdk_constants_versions = require("../../constants/versions.js");
|
|
5
|
+
require("../../constants/index.js");
|
|
6
|
+
const require_sdk_base_SDKConstruct = require("../../base/SDKConstruct.js");
|
|
7
|
+
require("../../base/index.js");
|
|
8
|
+
const require_sdk_accounts_bots_abi = require("./abi.js");
|
|
9
|
+
const require_sdk_accounts_bots_PeripheryCompressorV310Contract = require("./PeripheryCompressorV310Contract.js");
|
|
10
|
+
//#region src/sdk/accounts/bots/AccountBotsService.ts
|
|
11
|
+
/**
|
|
12
|
+
* Bots of credit accounts.
|
|
13
|
+
*
|
|
14
|
+
* Reads which bots are connected to an account and with which permissions,
|
|
15
|
+
* and builds the transactions that connect or disconnect one.
|
|
16
|
+
**/
|
|
17
|
+
var AccountBotsService = class extends require_sdk_base_SDKConstruct.SDKConstruct {
|
|
18
|
+
/**
|
|
19
|
+
* Reads the bots connected to each of the given credit accounts.
|
|
20
|
+
*
|
|
21
|
+
* All reads go out as a single multicall, split into three groups: the
|
|
22
|
+
* periphery compressor's view of each account, the status of the legacy
|
|
23
|
+
* migration bot on each account, and the status of every bot in
|
|
24
|
+
* `additionalBots` on every account.
|
|
25
|
+
*
|
|
26
|
+
* @param accountsToCheck - Accounts to read, with their credit managers.
|
|
27
|
+
* @param legacyMigrationBot - Legacy migration bot to check, if any.
|
|
28
|
+
* @param additionalBots - Bots to check on every account.
|
|
29
|
+
**/
|
|
30
|
+
async getConnectedBots(accountsToCheck, legacyMigrationBot, additionalBots) {
|
|
31
|
+
const compressor = this.#compressor;
|
|
32
|
+
const compressorCalls = accountsToCheck.map(({ creditManager, creditAccount }) => {
|
|
33
|
+
const { configurator } = this.sdk.marketRegister.findByCreditManager(creditManager);
|
|
34
|
+
return compressor.connectedBotsCall(configurator.address, creditAccount);
|
|
35
|
+
});
|
|
36
|
+
const migrationCalls = legacyMigrationBot ? accountsToCheck.map((account) => this.#botStatusCall(account, legacyMigrationBot)) : [];
|
|
37
|
+
const additionalCalls = accountsToCheck.flatMap((account) => additionalBots.map((bot) => this.#botStatusCall(account, bot)));
|
|
38
|
+
const responses = await this.client.multicall({
|
|
39
|
+
contracts: [
|
|
40
|
+
...compressorCalls,
|
|
41
|
+
...migrationCalls,
|
|
42
|
+
...additionalCalls
|
|
43
|
+
],
|
|
44
|
+
allowFailure: true,
|
|
45
|
+
batchSize: 0
|
|
46
|
+
});
|
|
47
|
+
const migrationStart = compressorCalls.length;
|
|
48
|
+
const additionalStart = migrationStart + migrationCalls.length;
|
|
49
|
+
return {
|
|
50
|
+
legacy: responses.slice(0, migrationStart),
|
|
51
|
+
legacyMigration: this.#migrationBotStatuses(legacyMigrationBot, accountsToCheck.length, responses.slice(migrationStart, additionalStart)),
|
|
52
|
+
additionalBots: this.#botStatusesPerAccount(accountsToCheck.length, additionalBots.length, responses.slice(additionalStart))
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Connects or disconnects a bot, and updates prices when the bot is set on a
|
|
57
|
+
* credit account.
|
|
58
|
+
*
|
|
59
|
+
* @param props - {@link SetBotProps}
|
|
60
|
+
* @returns Everything needed to execute the operation. Setting a bot on a
|
|
61
|
+
* credit manager only yields calls, since it is not a standalone transaction.
|
|
62
|
+
**/
|
|
63
|
+
async setBot({ botAddress, permissions: defaultPermissions, targetContract }) {
|
|
64
|
+
const cm = this.sdk.marketRegister.findCreditManager(targetContract.creditManager);
|
|
65
|
+
const permissions = defaultPermissions !== null ? defaultPermissions : await this.client.readContract({
|
|
66
|
+
address: botAddress,
|
|
67
|
+
abi: require_sdk_accounts_bots_abi.iBotAbi,
|
|
68
|
+
functionName: "requiredPermissions"
|
|
69
|
+
});
|
|
70
|
+
const addBotCall = cm.creditFacade.prepareSetBotPermissions(botAddress, permissions);
|
|
71
|
+
if (targetContract.type !== "creditAccount") return {
|
|
72
|
+
calls: [addBotCall],
|
|
73
|
+
creditFacade: cm.creditFacade
|
|
74
|
+
};
|
|
75
|
+
const calls = await this.sdk.accounts.prependPriceUpdates(targetContract.creditManager, [addBotCall], targetContract);
|
|
76
|
+
return {
|
|
77
|
+
tx: cm.multicallTx(targetContract.creditAccount, calls),
|
|
78
|
+
calls,
|
|
79
|
+
creditFacade: cm.creditFacade
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Descriptor of a `getBotStatus` call on the bot list of an account's
|
|
84
|
+
* credit facade.
|
|
85
|
+
**/
|
|
86
|
+
#botStatusCall({ creditManager, creditAccount }, bot) {
|
|
87
|
+
const { creditFacade } = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
88
|
+
return {
|
|
89
|
+
abi: require_abi_310_generated.iBotListV310Abi,
|
|
90
|
+
address: creditFacade.botList,
|
|
91
|
+
functionName: "getBotStatus",
|
|
92
|
+
args: [bot, creditAccount]
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Regroups the flat `additionalBots` responses into one entry per account,
|
|
97
|
+
* keeping the order the bots were requested in.
|
|
98
|
+
**/
|
|
99
|
+
#botStatusesPerAccount(accounts, botsPerAccount, responses) {
|
|
100
|
+
this.#checkLength(responses, accounts * botsPerAccount, "bots");
|
|
101
|
+
const perAccount = [];
|
|
102
|
+
for (let i = 0; i < accounts; i++) perAccount.push({ result: responses.slice(i * botsPerAccount, (i + 1) * botsPerAccount) });
|
|
103
|
+
return perAccount;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Migration bot statuses, or `undefined` when no migration bot was queried.
|
|
107
|
+
**/
|
|
108
|
+
#migrationBotStatuses(bot, accounts, responses) {
|
|
109
|
+
if (!bot) return;
|
|
110
|
+
this.#checkLength(responses, accounts, "migration bots");
|
|
111
|
+
return {
|
|
112
|
+
result: responses,
|
|
113
|
+
botAddress: bot
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
#checkLength(responses, expected, what) {
|
|
117
|
+
if (responses.length !== expected) this.logger?.error(`result length mismatch for ${what}: got ${responses.length}, expected ${expected}`);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Periphery compressor of the current chain.
|
|
121
|
+
*
|
|
122
|
+
* Resolved on every access, because the address provider is only populated
|
|
123
|
+
* once the SDK is attached or hydrated; the contracts register acts as the
|
|
124
|
+
* cache.
|
|
125
|
+
**/
|
|
126
|
+
get #compressor() {
|
|
127
|
+
const [address] = this.sdk.addressProvider.mustGetLatest(require_sdk_constants_address_provider.AP_PERIPHERY_COMPRESSOR, require_sdk_constants_versions.VERSION_RANGE_310);
|
|
128
|
+
return this.sdk.getContract(address) ?? new require_sdk_accounts_bots_PeripheryCompressorV310Contract.PeripheryCompressorV310Contract(this.sdk, address);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
//#endregion
|
|
132
|
+
exports.AccountBotsService = AccountBotsService;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_sdk_base_BaseContract = require("../../base/BaseContract.js");
|
|
3
|
+
require("../../base/index.js");
|
|
4
|
+
//#region src/sdk/accounts/bots/PeripheryCompressorV310Contract.ts
|
|
5
|
+
const abi = require("../../../abi/compressors/peripheryCompressor.js").peripheryCompressorAbi;
|
|
6
|
+
var PeripheryCompressorV310Contract = class extends require_sdk_base_BaseContract.BaseContract {
|
|
7
|
+
constructor(sdk, address) {
|
|
8
|
+
super(sdk, {
|
|
9
|
+
addr: address,
|
|
10
|
+
name: "PeripheryCompressorV310",
|
|
11
|
+
abi,
|
|
12
|
+
version: 310
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Descriptor of a `getConnectedBots` call on this compressor.
|
|
17
|
+
*
|
|
18
|
+
* @param marketConfigurator - Configurator that governs the account's market.
|
|
19
|
+
* @param creditAccount - Credit account to list the connected bots of.
|
|
20
|
+
**/
|
|
21
|
+
connectedBotsCall(marketConfigurator, creditAccount) {
|
|
22
|
+
return {
|
|
23
|
+
abi,
|
|
24
|
+
address: this.address,
|
|
25
|
+
functionName: "getConnectedBots",
|
|
26
|
+
args: [marketConfigurator, creditAccount]
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.PeripheryCompressorV310Contract = PeripheryCompressorV310Contract;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/sdk/accounts/bots/abi.ts
|
|
3
|
+
/**
|
|
4
|
+
* Minimal bot interface: the permissions a bot needs to operate on a credit
|
|
5
|
+
* account, which the SDK reads when the caller does not specify them.
|
|
6
|
+
**/
|
|
7
|
+
const iBotAbi = [{
|
|
8
|
+
type: "function",
|
|
9
|
+
name: "requiredPermissions",
|
|
10
|
+
inputs: [],
|
|
11
|
+
outputs: [{
|
|
12
|
+
name: "",
|
|
13
|
+
type: "uint192",
|
|
14
|
+
internalType: "uint192"
|
|
15
|
+
}],
|
|
16
|
+
stateMutability: "view"
|
|
17
|
+
}];
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.iBotAbi = iBotAbi;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_sdk_accounts_bots_PeripheryCompressorV310Contract = require("./PeripheryCompressorV310Contract.js");
|
|
3
|
+
const require_sdk_accounts_bots_AccountBotsService = require("./AccountBotsService.js");
|
|
4
|
+
require("./types.js");
|
|
5
|
+
exports.AccountBotsService = require_sdk_accounts_bots_AccountBotsService.AccountBotsService;
|
|
6
|
+
exports.PeripheryCompressorV310Contract = require_sdk_accounts_bots_PeripheryCompressorV310Contract.PeripheryCompressorV310Contract;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_sdk_accounts_bots_PeripheryCompressorV310Contract = require("./bots/PeripheryCompressorV310Contract.js");
|
|
3
|
+
const require_sdk_accounts_bots_AccountBotsService = require("./bots/AccountBotsService.js");
|
|
4
|
+
require("./bots/index.js");
|
|
2
5
|
const require_sdk_accounts_credit_account_compressor_CreditAccountCompressorV310Contract = require("./credit-account-compressor/CreditAccountCompressorV310Contract.js");
|
|
3
6
|
const require_sdk_accounts_credit_account_compressor_CreditAccountCompressor = require("./credit-account-compressor/CreditAccountCompressor.js");
|
|
4
7
|
require("./credit-account-compressor/index.js");
|
|
@@ -23,6 +26,7 @@ const require_sdk_accounts_withdrawal_compressor_WithdrawalCompressorV313Contrac
|
|
|
23
26
|
const require_sdk_accounts_withdrawal_compressor_createWithdrawalCompressor = require("./withdrawal-compressor/createWithdrawalCompressor.js");
|
|
24
27
|
require("./withdrawal-compressor/index.js");
|
|
25
28
|
exports.AbstractWithdrawalCompressorContract = require_sdk_accounts_withdrawal_compressor_AbstractWithdrawalCompressorContract.AbstractWithdrawalCompressorContract;
|
|
29
|
+
exports.AccountBotsService = require_sdk_accounts_bots_AccountBotsService.AccountBotsService;
|
|
26
30
|
exports.CreditAccountCompressor = require_sdk_accounts_credit_account_compressor_CreditAccountCompressor.CreditAccountCompressor;
|
|
27
31
|
exports.CreditAccountCompressorV310Contract = require_sdk_accounts_credit_account_compressor_CreditAccountCompressorV310Contract.CreditAccountCompressorV310Contract;
|
|
28
32
|
exports.CreditAccountOperationsService = require_sdk_accounts_intents_index.CreditAccountOperationsService;
|
|
@@ -34,6 +38,7 @@ exports.LIQUIDATION_APPROVAL_BUFFER = require_sdk_accounts_liquidations_constant
|
|
|
34
38
|
exports.LIQUIDATION_COMPRESSOR_V313_ADDRESS = require_sdk_accounts_liquidations_constants.LIQUIDATION_COMPRESSOR_V313_ADDRESS;
|
|
35
39
|
exports.LiquidationsService = require_sdk_accounts_liquidations_LiquidationsService.LiquidationsService;
|
|
36
40
|
exports.MultichainLiquidationsService = require_sdk_accounts_liquidations_MultichainLiquidationsService.MultichainLiquidationsService;
|
|
41
|
+
exports.PeripheryCompressorV310Contract = require_sdk_accounts_bots_PeripheryCompressorV310Contract.PeripheryCompressorV310Contract;
|
|
37
42
|
exports.RedemptionLoggerV310Contract = require_sdk_accounts_withdrawal_compressor_RedemptionLoggerV310Contract.RedemptionLoggerV310Contract;
|
|
38
43
|
exports.WithdrawalCompressorV310Contract = require_sdk_accounts_withdrawal_compressor_WithdrawalCompressorV310Contract.WithdrawalCompressorV310Contract;
|
|
39
44
|
exports.WithdrawalCompressorV311Contract = require_sdk_accounts_withdrawal_compressor_WithdrawalCompressorV311Contract.WithdrawalCompressorV311Contract;
|
package/dist/cjs/sdk/index.js
CHANGED
|
@@ -43,6 +43,8 @@ const require_sdk_base_SDKConstruct = require("./base/SDKConstruct.js");
|
|
|
43
43
|
const require_sdk_base_token_types = require("./base/token-types.js");
|
|
44
44
|
const require_sdk_base_types = require("./base/types.js");
|
|
45
45
|
require("./base/index.js");
|
|
46
|
+
const require_sdk_accounts_bots_PeripheryCompressorV310Contract = require("./accounts/bots/PeripheryCompressorV310Contract.js");
|
|
47
|
+
const require_sdk_accounts_bots_AccountBotsService = require("./accounts/bots/AccountBotsService.js");
|
|
46
48
|
const require_sdk_market_adapters_PlaceholderAdapterContracts = require("./market/adapters/PlaceholderAdapterContracts.js");
|
|
47
49
|
const require_sdk_market_adapters_createAdapter = require("./market/adapters/createAdapter.js");
|
|
48
50
|
const require_sdk_market_credit_CreditConfiguratorV310Contract = require("./market/credit/CreditConfiguratorV310Contract.js");
|
|
@@ -185,6 +187,7 @@ exports.AP_ZERO_PRICE_FEED = require_sdk_constants_address_provider.AP_ZERO_PRIC
|
|
|
185
187
|
exports.AbstractLPPriceFeedContract = require_sdk_market_pricefeeds_AbstractLPPriceFeed.AbstractLPPriceFeedContract;
|
|
186
188
|
exports.AbstractPriceFeedContract = require_sdk_market_pricefeeds_AbstractPriceFeed.AbstractPriceFeedContract;
|
|
187
189
|
exports.AbstractWithdrawalCompressorContract = require_sdk_accounts_withdrawal_compressor_AbstractWithdrawalCompressorContract.AbstractWithdrawalCompressorContract;
|
|
190
|
+
exports.AccountBotsService = require_sdk_accounts_bots_AccountBotsService.AccountBotsService;
|
|
188
191
|
exports.AddressMap = require_sdk_utils_AddressMap.AddressMap;
|
|
189
192
|
exports.AddressProviderV310Contract = require_sdk_core_AddressProviderV310Contract.AddressProviderV310Contract;
|
|
190
193
|
exports.AddressSet = require_sdk_utils_AddressSet.AddressSet;
|
|
@@ -261,6 +264,7 @@ exports.PRICE_DECIMALS = require_sdk_constants_math.PRICE_DECIMALS;
|
|
|
261
264
|
exports.PRICE_DECIMALS_POW = require_sdk_constants_math.PRICE_DECIMALS_POW;
|
|
262
265
|
exports.PartialPriceFeedInitError = require_sdk_market_pricefeeds_AbstractPriceFeed.PartialPriceFeedInitError;
|
|
263
266
|
exports.PendleTWAPPTPriceFeed = require_sdk_market_pricefeeds_PendleTWAPPTPriceFeed.PendleTWAPPTPriceFeed;
|
|
267
|
+
exports.PeripheryCompressorV310Contract = require_sdk_accounts_bots_PeripheryCompressorV310Contract.PeripheryCompressorV310Contract;
|
|
264
268
|
exports.PlaceholderAdapterContract = require_sdk_market_adapters_PlaceholderAdapterContracts.PlaceholderAdapterContract;
|
|
265
269
|
exports.PlaceholderContract = require_sdk_base_PlaceholderContract.PlaceholderContract;
|
|
266
270
|
exports.PluginStateVersionError = require_sdk_plugins_errors.PluginStateVersionError;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_abi_compressors_peripheryCompressor = require("../../abi/compressors/peripheryCompressor.js");
|
|
3
2
|
const require_sdk_utils_AddressMap = require("../utils/AddressMap.js");
|
|
4
3
|
const require_sdk_constants_address_provider = require("../constants/address-provider.js");
|
|
5
4
|
const require_sdk_constants_versions = require("../constants/versions.js");
|
|
@@ -8,6 +7,7 @@ const require_sdk_utils_hex = require("../utils/hex.js");
|
|
|
8
7
|
require("../utils/index.js");
|
|
9
8
|
const require_sdk_base_SDKConstruct = require("../base/SDKConstruct.js");
|
|
10
9
|
require("../base/index.js");
|
|
10
|
+
const require_abi_compressors_peripheryCompressor = require("../../abi/compressors/peripheryCompressor.js");
|
|
11
11
|
const require_sdk_market_zapper_createZapper = require("./zapper/createZapper.js");
|
|
12
12
|
require("./zapper/index.js");
|
|
13
13
|
//#region src/sdk/market/ZapperRegister.ts
|
|
@@ -90,6 +90,37 @@ var CreditSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
|
|
|
90
90
|
return this.market.configurator;
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
|
+
* Factory that opens and manages the accounts of this suite, defined only
|
|
94
|
+
* for RWA markets.
|
|
95
|
+
*/
|
|
96
|
+
get rwaFactory() {
|
|
97
|
+
return this.market.rwaFactory;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Builds a transaction that executes a multicall on one of this suite's
|
|
101
|
+
* credit accounts.
|
|
102
|
+
*
|
|
103
|
+
* @param creditAccount - Account to operate on.
|
|
104
|
+
* @param calls - Multicall body.
|
|
105
|
+
* @param rwaOptions - Factory-specific args, ignored on non-RWA markets.
|
|
106
|
+
*/
|
|
107
|
+
multicallTx(creditAccount, calls, rwaOptions) {
|
|
108
|
+
const { rwaFactory } = this;
|
|
109
|
+
return rwaFactory ? rwaFactory.multicall(creditAccount, calls, rwaOptions) : this.creditFacade.multicall(creditAccount, calls);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Builds a transaction that opens a new credit account in this suite.
|
|
113
|
+
*
|
|
114
|
+
* @param to - Owner of the new account.
|
|
115
|
+
* @param calls - Multicall body executed on the new account.
|
|
116
|
+
* @param referralCode - Referral code, facade path only.
|
|
117
|
+
* @param rwaOptions - Factory-specific args, ignored on non-RWA markets.
|
|
118
|
+
*/
|
|
119
|
+
openCreditAccountTx(to, calls, referralCode, rwaOptions) {
|
|
120
|
+
const { rwaFactory } = this;
|
|
121
|
+
return rwaFactory ? rwaFactory.openCreditAccount(this.creditManager.address, calls, rwaOptions) : this.creditFacade.openCreditAccount(to, calls, referralCode ?? 0n);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
93
124
|
* Router configured for this credit suite.
|
|
94
125
|
*/
|
|
95
126
|
get router() {
|