@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,19 +1,19 @@
|
|
|
1
1
|
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
2
2
|
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
3
|
-
import {
|
|
4
|
-
import { peripheryCompressorAbi } from "../../abi/compressors/peripheryCompressor.js";
|
|
5
|
-
import { rewardsCompressorAbi } from "../../abi/compressors/rewardsCompressor.js";
|
|
6
|
-
import { AP_PERIPHERY_COMPRESSOR, AP_REWARDS_COMPRESSOR } from "../constants/address-provider.js";
|
|
3
|
+
import { AP_REWARDS_COMPRESSOR } from "../constants/address-provider.js";
|
|
7
4
|
import { ADDRESS_0X0 } from "../constants/addresses.js";
|
|
8
5
|
import { MAX_UINT256 } from "../constants/math.js";
|
|
9
6
|
import { VERSION_RANGE_310 } from "../constants/versions.js";
|
|
10
7
|
import "../constants/index.js";
|
|
11
8
|
import { SDKConstruct } from "../base/SDKConstruct.js";
|
|
12
9
|
import "../base/index.js";
|
|
10
|
+
import { AccountBotsService } from "./bots/AccountBotsService.js";
|
|
11
|
+
import "./bots/index.js";
|
|
12
|
+
import { rewardsCompressorAbi } from "../../abi/compressors/rewardsCompressor.js";
|
|
13
13
|
import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
|
|
14
14
|
import "./credit-account-compressor/index.js";
|
|
15
15
|
import { extractPriceUpdates, extractQuotaTokens, mergePriceUpdates } from "./multicall-utils.js";
|
|
16
|
-
import { encodeFunctionData
|
|
16
|
+
import { encodeFunctionData } from "viem";
|
|
17
17
|
//#region src/sdk/accounts/CreditAccountsServiceV310.ts
|
|
18
18
|
/**
|
|
19
19
|
* Service for querying and operating on Gearbox credit accounts.
|
|
@@ -26,9 +26,14 @@ import { encodeFunctionData, getContract } from "viem";
|
|
|
26
26
|
**/
|
|
27
27
|
var CreditAccountsServiceV310 = class extends SDKConstruct {
|
|
28
28
|
#compressor;
|
|
29
|
+
/**
|
|
30
|
+
* {@inheritDoc ICreditAccountsService.bots}
|
|
31
|
+
**/
|
|
32
|
+
bots;
|
|
29
33
|
constructor(sdk) {
|
|
30
34
|
super(sdk);
|
|
31
35
|
this.#compressor = new CreditAccountCompressor(sdk);
|
|
36
|
+
this.bots = new AccountBotsService(sdk);
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
34
39
|
* {@inheritDoc ICreditAccountsService.getCreditAccountData}
|
|
@@ -92,76 +97,6 @@ var CreditAccountsServiceV310 = class extends SDKConstruct {
|
|
|
92
97
|
return Object.values(r);
|
|
93
98
|
}
|
|
94
99
|
/**
|
|
95
|
-
* {@inheritDoc ICreditAccountsService.getConnectedBots}
|
|
96
|
-
**/
|
|
97
|
-
async getConnectedBots(accountsToCheck, legacyMigrationBot, additionalBots) {
|
|
98
|
-
const allResp = await this.client.multicall({
|
|
99
|
-
contracts: [
|
|
100
|
-
...accountsToCheck.map((o) => {
|
|
101
|
-
const pool = this.sdk.marketRegister.findByCreditManager(o.creditManager);
|
|
102
|
-
return {
|
|
103
|
-
abi: peripheryCompressorAbi,
|
|
104
|
-
address: this.peripheryCompressor,
|
|
105
|
-
functionName: "getConnectedBots",
|
|
106
|
-
args: [pool.configurator.address, o.creditAccount]
|
|
107
|
-
};
|
|
108
|
-
}),
|
|
109
|
-
...legacyMigrationBot ? accountsToCheck.map((ca) => {
|
|
110
|
-
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
111
|
-
return {
|
|
112
|
-
abi: iBotListV310Abi,
|
|
113
|
-
address: cm.creditFacade.botList,
|
|
114
|
-
functionName: "getBotStatus",
|
|
115
|
-
args: [legacyMigrationBot, ca.creditAccount]
|
|
116
|
-
};
|
|
117
|
-
}) : [],
|
|
118
|
-
...accountsToCheck.flatMap((ca) => {
|
|
119
|
-
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
120
|
-
return additionalBots.map((bot) => {
|
|
121
|
-
return {
|
|
122
|
-
abi: iBotListV310Abi,
|
|
123
|
-
address: cm.creditFacade.botList,
|
|
124
|
-
functionName: "getBotStatus",
|
|
125
|
-
args: [bot, ca.creditAccount]
|
|
126
|
-
};
|
|
127
|
-
});
|
|
128
|
-
})
|
|
129
|
-
],
|
|
130
|
-
allowFailure: true,
|
|
131
|
-
batchSize: 0
|
|
132
|
-
});
|
|
133
|
-
const legacyStart = 0;
|
|
134
|
-
const legacyEnd = accountsToCheck.length;
|
|
135
|
-
const legacy = allResp.slice(legacyStart, legacyEnd);
|
|
136
|
-
const migrationStart = legacyEnd;
|
|
137
|
-
const migrationEnd = legacyMigrationBot ? migrationStart + accountsToCheck.length : migrationStart;
|
|
138
|
-
const migrationResp = allResp.slice(migrationStart, migrationEnd);
|
|
139
|
-
const additionalStart = migrationEnd;
|
|
140
|
-
const additionalResp = allResp.slice(additionalStart);
|
|
141
|
-
return {
|
|
142
|
-
legacy,
|
|
143
|
-
additionalBots: this.#getActiveBots(accountsToCheck, additionalBots, additionalResp),
|
|
144
|
-
legacyMigration: this.#getActiveMigrationBots(accountsToCheck, legacyMigrationBot, migrationResp)
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
#getActiveBots(accountsToCheck, bots, result) {
|
|
148
|
-
if (result.length !== bots.length * accountsToCheck.length) console.error("result length mismatch", result.length, bots.length * accountsToCheck.length);
|
|
149
|
-
return accountsToCheck.reduce((acc, _, index) => {
|
|
150
|
-
const r = result.slice(index * bots.length, (index + 1) * bots.length);
|
|
151
|
-
acc.push({ result: r });
|
|
152
|
-
return acc;
|
|
153
|
-
}, []);
|
|
154
|
-
}
|
|
155
|
-
#getActiveMigrationBots(accountsToCheck, bot, result) {
|
|
156
|
-
if (bot) {
|
|
157
|
-
if (result.length !== accountsToCheck.length) console.error("result length mismatch for migration bots", result.length, accountsToCheck.length);
|
|
158
|
-
return {
|
|
159
|
-
result,
|
|
160
|
-
botAddress: bot
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
100
|
* {@inheritDoc ICreditAccountsService.fullyLiquidate}
|
|
166
101
|
**/
|
|
167
102
|
async fullyLiquidate(props) {
|
|
@@ -288,15 +223,13 @@ var CreditAccountsServiceV310 = class extends SDKConstruct {
|
|
|
288
223
|
async getApprovalAddress(options) {
|
|
289
224
|
const { creditManager } = options;
|
|
290
225
|
const suite = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
291
|
-
|
|
292
|
-
if (factory) return factory.getApprovalAddress(options);
|
|
293
|
-
return suite.creditManager.address;
|
|
226
|
+
return suite.rwaFactory ? suite.rwaFactory.getApprovalAddress(options) : suite.creditManager.address;
|
|
294
227
|
}
|
|
295
228
|
/**
|
|
296
229
|
* {@inheritDoc ICreditAccountsService.getOpenAccountRequirements}
|
|
297
230
|
*/
|
|
298
231
|
async getOpenAccountRequirements(borrower, creditManager, props) {
|
|
299
|
-
const { rwaFactory } = this.sdk.marketRegister.
|
|
232
|
+
const { rwaFactory } = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
300
233
|
if (!rwaFactory) return;
|
|
301
234
|
return rwaFactory.getOpenAccountRequirements(borrower, props);
|
|
302
235
|
}
|
|
@@ -323,9 +256,7 @@ var CreditAccountsServiceV310 = class extends SDKConstruct {
|
|
|
323
256
|
...callsAfter ?? []
|
|
324
257
|
];
|
|
325
258
|
const calls = await this.prependPriceUpdates(cm.address, operationCalls);
|
|
326
|
-
|
|
327
|
-
if (reopenCreditAccount) tx = await this.#multicallTx(cmSuite, reopenCreditAccount, calls);
|
|
328
|
-
else tx = await this.#openCreditAccountTx(cmSuite, to, calls, referralCode, rwaOptions);
|
|
259
|
+
const tx = reopenCreditAccount ? cmSuite.multicallTx(reopenCreditAccount, calls) : cmSuite.openCreditAccountTx(to, calls, referralCode, rwaOptions);
|
|
329
260
|
tx.value = ethAmount.toString(10);
|
|
330
261
|
return tx;
|
|
331
262
|
}
|
|
@@ -400,34 +331,6 @@ var CreditAccountsServiceV310 = class extends SDKConstruct {
|
|
|
400
331
|
return this.#rwaVaultCalls("depositDiff", amount, creditManager);
|
|
401
332
|
}
|
|
402
333
|
/**
|
|
403
|
-
* {@inheritDoc ICreditAccountsService.setBot}
|
|
404
|
-
*/
|
|
405
|
-
async setBot({ botAddress, permissions: defaultPermissions, targetContract }) {
|
|
406
|
-
const cm = this.sdk.marketRegister.findCreditManager(targetContract.creditManager);
|
|
407
|
-
const permissions = defaultPermissions !== null ? defaultPermissions : await getContract({
|
|
408
|
-
address: botAddress,
|
|
409
|
-
client: this.sdk.client,
|
|
410
|
-
abi: [{
|
|
411
|
-
type: "function",
|
|
412
|
-
name: "requiredPermissions",
|
|
413
|
-
inputs: [],
|
|
414
|
-
outputs: [{
|
|
415
|
-
name: "",
|
|
416
|
-
type: "uint192",
|
|
417
|
-
internalType: "uint192"
|
|
418
|
-
}],
|
|
419
|
-
stateMutability: "view"
|
|
420
|
-
}]
|
|
421
|
-
}).read.requiredPermissions();
|
|
422
|
-
const addBotCall = cm.creditFacade.prepareSetBotPermissions(botAddress, permissions);
|
|
423
|
-
const calls = targetContract.type === "creditAccount" ? await this.prependPriceUpdates(targetContract.creditManager, [addBotCall], targetContract) : [addBotCall];
|
|
424
|
-
return {
|
|
425
|
-
tx: targetContract.type === "creditAccount" ? await this.#multicallTx(cm, targetContract.creditAccount, calls) : void 0,
|
|
426
|
-
calls,
|
|
427
|
-
creditFacade: cm.creditFacade
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
334
|
* {@inheritDoc ICreditAccountsService.assembleRepayCreditAccountCalls}
|
|
432
335
|
*/
|
|
433
336
|
async assembleRepayCreditAccountCalls({ collateralAssets, assetsToWithdraw, creditAccount: ca, permits, to, tokensToClaim, calls: wrapCalls = [] }) {
|
|
@@ -467,7 +370,7 @@ var CreditAccountsServiceV310 = class extends SDKConstruct {
|
|
|
467
370
|
averageQuota
|
|
468
371
|
})];
|
|
469
372
|
const calls = await this.prependPriceUpdates(ca.creditManager, operationCalls, ca);
|
|
470
|
-
return
|
|
373
|
+
return cm.multicallTx(ca.creditAccount, calls);
|
|
471
374
|
}
|
|
472
375
|
/**
|
|
473
376
|
* Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
|
|
@@ -540,7 +443,7 @@ var CreditAccountsServiceV310 = class extends SDKConstruct {
|
|
|
540
443
|
async executeCaUpdate(creditAccount, calls, options) {
|
|
541
444
|
const cm = this.sdk.marketRegister.findCreditManager(creditAccount.creditManager);
|
|
542
445
|
const callsWithPrices = await this.prependPriceUpdates(creditAccount.creditManager, calls, creditAccount, { ignoreReservePrices: options?.ignoreReservePrices });
|
|
543
|
-
const tx =
|
|
446
|
+
const tx = cm.multicallTx(creditAccount.creditAccount, callsWithPrices);
|
|
544
447
|
if (options?.ethAmount && options.ethAmount > 0n) tx.value = options.ethAmount.toString(10);
|
|
545
448
|
return tx;
|
|
546
449
|
}
|
|
@@ -577,36 +480,6 @@ var CreditAccountsServiceV310 = class extends SDKConstruct {
|
|
|
577
480
|
get rewardCompressor() {
|
|
578
481
|
return this.sdk.addressProvider.mustGetLatest(AP_REWARDS_COMPRESSOR, VERSION_RANGE_310)[0];
|
|
579
482
|
}
|
|
580
|
-
get peripheryCompressor() {
|
|
581
|
-
return this.sdk.addressProvider.mustGetLatest(AP_PERIPHERY_COMPRESSOR, VERSION_RANGE_310)[0];
|
|
582
|
-
}
|
|
583
|
-
/**
|
|
584
|
-
* Wrapper that selects between credit facade and RWA factory
|
|
585
|
-
* @param suite
|
|
586
|
-
* @param to
|
|
587
|
-
* @param calls
|
|
588
|
-
* @param referralCode
|
|
589
|
-
* @param rwaOptions
|
|
590
|
-
* @returns
|
|
591
|
-
*/
|
|
592
|
-
async #openCreditAccountTx(suite, to, calls, referralCode, rwaOptions) {
|
|
593
|
-
const factory = this.sdk.marketRegister.findByPool(suite.pool).rwaFactory;
|
|
594
|
-
if (factory) return factory.openCreditAccount(suite.creditManager.address, calls, rwaOptions);
|
|
595
|
-
return suite.creditFacade.openCreditAccount(to, calls, referralCode ?? 0n);
|
|
596
|
-
}
|
|
597
|
-
/**
|
|
598
|
-
* Wrapper that selects between credit facade and RWA factory
|
|
599
|
-
* @param suite
|
|
600
|
-
* @param creditAccount
|
|
601
|
-
* @param calls
|
|
602
|
-
* @param rwaOptions
|
|
603
|
-
* @returns
|
|
604
|
-
*/
|
|
605
|
-
async #multicallTx(suite, creditAccount, calls, rwaOptions) {
|
|
606
|
-
const factory = this.sdk.marketRegister.findByCreditManager(suite.creditManager.address).rwaFactory;
|
|
607
|
-
if (factory) return factory.multicall(creditAccount, calls, rwaOptions);
|
|
608
|
-
return suite.creditFacade.multicall(creditAccount, calls);
|
|
609
|
-
}
|
|
610
483
|
/**
|
|
611
484
|
* Withdrawal compressor of the current chain.
|
|
612
485
|
* @throws If no withdrawal compressor is supported on the current chain.
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { iBotListV310Abi } from "../../../abi/310/generated.js";
|
|
2
|
+
import { AP_PERIPHERY_COMPRESSOR } from "../../constants/address-provider.js";
|
|
3
|
+
import { VERSION_RANGE_310 } from "../../constants/versions.js";
|
|
4
|
+
import "../../constants/index.js";
|
|
5
|
+
import { SDKConstruct } from "../../base/SDKConstruct.js";
|
|
6
|
+
import "../../base/index.js";
|
|
7
|
+
import { iBotAbi } from "./abi.js";
|
|
8
|
+
import { PeripheryCompressorV310Contract } from "./PeripheryCompressorV310Contract.js";
|
|
9
|
+
//#region src/sdk/accounts/bots/AccountBotsService.ts
|
|
10
|
+
/**
|
|
11
|
+
* Bots of credit accounts.
|
|
12
|
+
*
|
|
13
|
+
* Reads which bots are connected to an account and with which permissions,
|
|
14
|
+
* and builds the transactions that connect or disconnect one.
|
|
15
|
+
**/
|
|
16
|
+
var AccountBotsService = class extends SDKConstruct {
|
|
17
|
+
/**
|
|
18
|
+
* Reads the bots connected to each of the given credit accounts.
|
|
19
|
+
*
|
|
20
|
+
* All reads go out as a single multicall, split into three groups: the
|
|
21
|
+
* periphery compressor's view of each account, the status of the legacy
|
|
22
|
+
* migration bot on each account, and the status of every bot in
|
|
23
|
+
* `additionalBots` on every account.
|
|
24
|
+
*
|
|
25
|
+
* @param accountsToCheck - Accounts to read, with their credit managers.
|
|
26
|
+
* @param legacyMigrationBot - Legacy migration bot to check, if any.
|
|
27
|
+
* @param additionalBots - Bots to check on every account.
|
|
28
|
+
**/
|
|
29
|
+
async getConnectedBots(accountsToCheck, legacyMigrationBot, additionalBots) {
|
|
30
|
+
const compressor = this.#compressor;
|
|
31
|
+
const compressorCalls = accountsToCheck.map(({ creditManager, creditAccount }) => {
|
|
32
|
+
const { configurator } = this.sdk.marketRegister.findByCreditManager(creditManager);
|
|
33
|
+
return compressor.connectedBotsCall(configurator.address, creditAccount);
|
|
34
|
+
});
|
|
35
|
+
const migrationCalls = legacyMigrationBot ? accountsToCheck.map((account) => this.#botStatusCall(account, legacyMigrationBot)) : [];
|
|
36
|
+
const additionalCalls = accountsToCheck.flatMap((account) => additionalBots.map((bot) => this.#botStatusCall(account, bot)));
|
|
37
|
+
const responses = await this.client.multicall({
|
|
38
|
+
contracts: [
|
|
39
|
+
...compressorCalls,
|
|
40
|
+
...migrationCalls,
|
|
41
|
+
...additionalCalls
|
|
42
|
+
],
|
|
43
|
+
allowFailure: true,
|
|
44
|
+
batchSize: 0
|
|
45
|
+
});
|
|
46
|
+
const migrationStart = compressorCalls.length;
|
|
47
|
+
const additionalStart = migrationStart + migrationCalls.length;
|
|
48
|
+
return {
|
|
49
|
+
legacy: responses.slice(0, migrationStart),
|
|
50
|
+
legacyMigration: this.#migrationBotStatuses(legacyMigrationBot, accountsToCheck.length, responses.slice(migrationStart, additionalStart)),
|
|
51
|
+
additionalBots: this.#botStatusesPerAccount(accountsToCheck.length, additionalBots.length, responses.slice(additionalStart))
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Connects or disconnects a bot, and updates prices when the bot is set on a
|
|
56
|
+
* credit account.
|
|
57
|
+
*
|
|
58
|
+
* @param props - {@link SetBotProps}
|
|
59
|
+
* @returns Everything needed to execute the operation. Setting a bot on a
|
|
60
|
+
* credit manager only yields calls, since it is not a standalone transaction.
|
|
61
|
+
**/
|
|
62
|
+
async setBot({ botAddress, permissions: defaultPermissions, targetContract }) {
|
|
63
|
+
const cm = this.sdk.marketRegister.findCreditManager(targetContract.creditManager);
|
|
64
|
+
const permissions = defaultPermissions !== null ? defaultPermissions : await this.client.readContract({
|
|
65
|
+
address: botAddress,
|
|
66
|
+
abi: iBotAbi,
|
|
67
|
+
functionName: "requiredPermissions"
|
|
68
|
+
});
|
|
69
|
+
const addBotCall = cm.creditFacade.prepareSetBotPermissions(botAddress, permissions);
|
|
70
|
+
if (targetContract.type !== "creditAccount") return {
|
|
71
|
+
calls: [addBotCall],
|
|
72
|
+
creditFacade: cm.creditFacade
|
|
73
|
+
};
|
|
74
|
+
const calls = await this.sdk.accounts.prependPriceUpdates(targetContract.creditManager, [addBotCall], targetContract);
|
|
75
|
+
return {
|
|
76
|
+
tx: cm.multicallTx(targetContract.creditAccount, calls),
|
|
77
|
+
calls,
|
|
78
|
+
creditFacade: cm.creditFacade
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Descriptor of a `getBotStatus` call on the bot list of an account's
|
|
83
|
+
* credit facade.
|
|
84
|
+
**/
|
|
85
|
+
#botStatusCall({ creditManager, creditAccount }, bot) {
|
|
86
|
+
const { creditFacade } = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
87
|
+
return {
|
|
88
|
+
abi: iBotListV310Abi,
|
|
89
|
+
address: creditFacade.botList,
|
|
90
|
+
functionName: "getBotStatus",
|
|
91
|
+
args: [bot, creditAccount]
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Regroups the flat `additionalBots` responses into one entry per account,
|
|
96
|
+
* keeping the order the bots were requested in.
|
|
97
|
+
**/
|
|
98
|
+
#botStatusesPerAccount(accounts, botsPerAccount, responses) {
|
|
99
|
+
this.#checkLength(responses, accounts * botsPerAccount, "bots");
|
|
100
|
+
const perAccount = [];
|
|
101
|
+
for (let i = 0; i < accounts; i++) perAccount.push({ result: responses.slice(i * botsPerAccount, (i + 1) * botsPerAccount) });
|
|
102
|
+
return perAccount;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Migration bot statuses, or `undefined` when no migration bot was queried.
|
|
106
|
+
**/
|
|
107
|
+
#migrationBotStatuses(bot, accounts, responses) {
|
|
108
|
+
if (!bot) return;
|
|
109
|
+
this.#checkLength(responses, accounts, "migration bots");
|
|
110
|
+
return {
|
|
111
|
+
result: responses,
|
|
112
|
+
botAddress: bot
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
#checkLength(responses, expected, what) {
|
|
116
|
+
if (responses.length !== expected) this.logger?.error(`result length mismatch for ${what}: got ${responses.length}, expected ${expected}`);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Periphery compressor of the current chain.
|
|
120
|
+
*
|
|
121
|
+
* Resolved on every access, because the address provider is only populated
|
|
122
|
+
* once the SDK is attached or hydrated; the contracts register acts as the
|
|
123
|
+
* cache.
|
|
124
|
+
**/
|
|
125
|
+
get #compressor() {
|
|
126
|
+
const [address] = this.sdk.addressProvider.mustGetLatest(AP_PERIPHERY_COMPRESSOR, VERSION_RANGE_310);
|
|
127
|
+
return this.sdk.getContract(address) ?? new PeripheryCompressorV310Contract(this.sdk, address);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
//#endregion
|
|
131
|
+
export { AccountBotsService };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BaseContract } from "../../base/BaseContract.js";
|
|
2
|
+
import "../../base/index.js";
|
|
3
|
+
import { peripheryCompressorAbi } from "../../../abi/compressors/peripheryCompressor.js";
|
|
4
|
+
//#region src/sdk/accounts/bots/PeripheryCompressorV310Contract.ts
|
|
5
|
+
const abi = peripheryCompressorAbi;
|
|
6
|
+
var PeripheryCompressorV310Contract = class extends 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
|
+
export { PeripheryCompressorV310Contract };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/sdk/accounts/bots/abi.ts
|
|
2
|
+
/**
|
|
3
|
+
* Minimal bot interface: the permissions a bot needs to operate on a credit
|
|
4
|
+
* account, which the SDK reads when the caller does not specify them.
|
|
5
|
+
**/
|
|
6
|
+
const iBotAbi = [{
|
|
7
|
+
type: "function",
|
|
8
|
+
name: "requiredPermissions",
|
|
9
|
+
inputs: [],
|
|
10
|
+
outputs: [{
|
|
11
|
+
name: "",
|
|
12
|
+
type: "uint192",
|
|
13
|
+
internalType: "uint192"
|
|
14
|
+
}],
|
|
15
|
+
stateMutability: "view"
|
|
16
|
+
}];
|
|
17
|
+
//#endregion
|
|
18
|
+
export { iBotAbi };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { PeripheryCompressorV310Contract } from "./bots/PeripheryCompressorV310Contract.js";
|
|
2
|
+
import { AccountBotsService } from "./bots/AccountBotsService.js";
|
|
3
|
+
import "./bots/index.js";
|
|
1
4
|
import { CreditAccountCompressorV310Contract } from "./credit-account-compressor/CreditAccountCompressorV310Contract.js";
|
|
2
5
|
import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
|
|
3
6
|
import "./credit-account-compressor/index.js";
|
|
@@ -21,4 +24,4 @@ import { toWithdrawalStatus } from "./withdrawal-compressor/types.js";
|
|
|
21
24
|
import { WithdrawalCompressorV313Contract } from "./withdrawal-compressor/WithdrawalCompressorV313Contract.js";
|
|
22
25
|
import { createWithdrawalCompressor } from "./withdrawal-compressor/createWithdrawalCompressor.js";
|
|
23
26
|
import "./withdrawal-compressor/index.js";
|
|
24
|
-
export { AbstractWithdrawalCompressorContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, InvalidDelayedIntentError, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LiquidationsService, MultichainLiquidationsService, RedemptionLoggerV310Contract, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, getWithdrawalCompressorAddress, iCreditAccountAbi, primaryInstantOutput, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
|
|
27
|
+
export { AbstractWithdrawalCompressorContract, AccountBotsService, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, InvalidDelayedIntentError, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LiquidationsService, MultichainLiquidationsService, PeripheryCompressorV310Contract, RedemptionLoggerV310Contract, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, getWithdrawalCompressorAddress, iCreditAccountAbi, primaryInstantOutput, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
|
package/dist/esm/sdk/index.js
CHANGED
|
@@ -42,6 +42,8 @@ import { SDKConstruct } from "./base/SDKConstruct.js";
|
|
|
42
42
|
import { PHANTOM_TOKEN_CONTRACT_TYPES, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND } from "./base/token-types.js";
|
|
43
43
|
import { VotingContractStatus } from "./base/types.js";
|
|
44
44
|
import "./base/index.js";
|
|
45
|
+
import { PeripheryCompressorV310Contract } from "./accounts/bots/PeripheryCompressorV310Contract.js";
|
|
46
|
+
import { AccountBotsService } from "./accounts/bots/AccountBotsService.js";
|
|
45
47
|
import { PlaceholderAdapterContract } from "./market/adapters/PlaceholderAdapterContracts.js";
|
|
46
48
|
import { createAdapter } from "./market/adapters/createAdapter.js";
|
|
47
49
|
import { CreditConfiguratorV310Contract } from "./market/credit/CreditConfiguratorV310Contract.js";
|
|
@@ -145,4 +147,4 @@ import { OnchainSDK, STATE_VERSION } from "./OnchainSDK.js";
|
|
|
145
147
|
import { MultichainSDK } from "./MultichainSDK.js";
|
|
146
148
|
import { attachOptionsSchema, onchainSDKOptionsSchema } from "./options.js";
|
|
147
149
|
import "./types/index.js";
|
|
148
|
-
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, Erc4626PriceFeedContract, ExternalPriceFeedContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InvalidDelayedIntentError, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendleTWAPPTPriceFeed, PlaceholderAdapterContract, PlaceholderContract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeRWAFactory, SimulateWithPriceUpdatesError, SimulationError, TokensMeta, TypedObjectUtils, UnsupportedZapperFunctionError, VERSION_RANGE_310, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodHex, additionalBorrowApyBps, assetsMap, attachOptionsSchema, borrowApyBps, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, fetchPythPayloads, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, healthFactorBps, hexEq, hydrateAddressProvider, iCreditAccountAbi, isDust, isLPPriceFeed, isPublicNetwork, isRWAFactory, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, json_parse, json_stringify, maxLeverage, minSeizedAmount, mustGetDominantCollateral, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, percentFmt, positionLeverage, primaryInstantOutput, rayToBps, rayToNumber, retry, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, toAddress, toBN, toBigInt, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toWithdrawalStatus, usdToNumber, utilizationBps, watchBlocksAsync };
|
|
150
|
+
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, Erc4626PriceFeedContract, ExternalPriceFeedContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InvalidDelayedIntentError, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendleTWAPPTPriceFeed, PeripheryCompressorV310Contract, PlaceholderAdapterContract, PlaceholderContract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeRWAFactory, SimulateWithPriceUpdatesError, SimulationError, TokensMeta, TypedObjectUtils, UnsupportedZapperFunctionError, VERSION_RANGE_310, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodHex, additionalBorrowApyBps, assetsMap, attachOptionsSchema, borrowApyBps, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, fetchPythPayloads, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, healthFactorBps, hexEq, hydrateAddressProvider, iCreditAccountAbi, isDust, isLPPriceFeed, isPublicNetwork, isRWAFactory, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, json_parse, json_stringify, maxLeverage, minSeizedAmount, mustGetDominantCollateral, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, percentFmt, positionLeverage, primaryInstantOutput, rayToBps, rayToNumber, retry, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, toAddress, toBN, toBigInt, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toWithdrawalStatus, usdToNumber, utilizationBps, watchBlocksAsync };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { peripheryCompressorAbi } from "../../abi/compressors/peripheryCompressor.js";
|
|
2
1
|
import { AddressMap } from "../utils/AddressMap.js";
|
|
3
2
|
import { AP_PERIPHERY_COMPRESSOR } from "../constants/address-provider.js";
|
|
4
3
|
import { VERSION_RANGE_310 } from "../constants/versions.js";
|
|
@@ -7,6 +6,7 @@ import { hexEq } from "../utils/hex.js";
|
|
|
7
6
|
import "../utils/index.js";
|
|
8
7
|
import { SDKConstruct } from "../base/SDKConstruct.js";
|
|
9
8
|
import "../base/index.js";
|
|
9
|
+
import { peripheryCompressorAbi } from "../../abi/compressors/peripheryCompressor.js";
|
|
10
10
|
import { createZapper } from "./zapper/createZapper.js";
|
|
11
11
|
import "./zapper/index.js";
|
|
12
12
|
//#region src/sdk/market/ZapperRegister.ts
|
|
@@ -89,6 +89,37 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
89
89
|
return this.market.configurator;
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
|
+
* Factory that opens and manages the accounts of this suite, defined only
|
|
93
|
+
* for RWA markets.
|
|
94
|
+
*/
|
|
95
|
+
get rwaFactory() {
|
|
96
|
+
return this.market.rwaFactory;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Builds a transaction that executes a multicall on one of this suite's
|
|
100
|
+
* credit accounts.
|
|
101
|
+
*
|
|
102
|
+
* @param creditAccount - Account to operate on.
|
|
103
|
+
* @param calls - Multicall body.
|
|
104
|
+
* @param rwaOptions - Factory-specific args, ignored on non-RWA markets.
|
|
105
|
+
*/
|
|
106
|
+
multicallTx(creditAccount, calls, rwaOptions) {
|
|
107
|
+
const { rwaFactory } = this;
|
|
108
|
+
return rwaFactory ? rwaFactory.multicall(creditAccount, calls, rwaOptions) : this.creditFacade.multicall(creditAccount, calls);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Builds a transaction that opens a new credit account in this suite.
|
|
112
|
+
*
|
|
113
|
+
* @param to - Owner of the new account.
|
|
114
|
+
* @param calls - Multicall body executed on the new account.
|
|
115
|
+
* @param referralCode - Referral code, facade path only.
|
|
116
|
+
* @param rwaOptions - Factory-specific args, ignored on non-RWA markets.
|
|
117
|
+
*/
|
|
118
|
+
openCreditAccountTx(to, calls, referralCode, rwaOptions) {
|
|
119
|
+
const { rwaFactory } = this;
|
|
120
|
+
return rwaFactory ? rwaFactory.openCreditAccount(this.creditManager.address, calls, rwaOptions) : this.creditFacade.openCreditAccount(to, calls, referralCode ?? 0n);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
92
123
|
* Router configured for this credit suite.
|
|
93
124
|
*/
|
|
94
125
|
get router() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ChainId } from "../model/primitives.js";
|
|
2
|
-
import "../model/index.js";
|
|
3
1
|
import { ILogger } from "../sdk/types/logger.js";
|
|
2
|
+
import { ChainId } from "../model/primitives.js";
|
|
4
3
|
import { NetworkType } from "../sdk/chain/chains.js";
|
|
5
4
|
import { MultichainNetworkMeta } from "../sdk/types/multichain.js";
|
|
5
|
+
import "../model/index.js";
|
|
6
6
|
import { MultichainSDK } from "../sdk/MultichainSDK.js";
|
|
7
7
|
import "../sdk/index.js";
|
|
8
8
|
import { OffchainResult } from "../offchain/types.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { ILogger } from "../../sdk/types/logger.js";
|
|
1
2
|
import { Opportunity, OpportunityFilter, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef } from "../../model/opportunities.js";
|
|
2
3
|
import { PoolHistoryMetric, StrategyHistoryMetric } from "../../model/history.js";
|
|
3
4
|
import "../../model/index.js";
|
|
4
|
-
import { ILogger } from "../../sdk/types/logger.js";
|
|
5
5
|
import { MultichainSDK } from "../../sdk/MultichainSDK.js";
|
|
6
6
|
import "../../sdk/index.js";
|
|
7
7
|
import { GearboxAPI } from "../../offchain/GearboxAPI.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { ILogger } from "../../sdk/types/logger.js";
|
|
1
2
|
import { PoolPositionRef, Position, PositionFilter, StrategyPositionRef } from "../../model/positions.js";
|
|
2
3
|
import { PoolPositionHistoryMetric, StrategyPositionHistoryMetric } from "../../model/history.js";
|
|
3
4
|
import "../../model/index.js";
|
|
4
|
-
import { ILogger } from "../../sdk/types/logger.js";
|
|
5
5
|
import { MultichainSDK } from "../../sdk/MultichainSDK.js";
|
|
6
6
|
import "../../sdk/index.js";
|
|
7
7
|
import { GearboxAPI } from "../../offchain/GearboxAPI.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { StrategyPosition } from "../../model/positions.js";
|
|
2
|
-
import "../../model/index.js";
|
|
3
1
|
import { RequestableWithdrawal } from "./withdrawal-compressor/types.js";
|
|
4
2
|
import { Asset, CreditAccountData, CreditAccountTokensSlice } from "../base/types.js";
|
|
3
|
+
import { StrategyPosition } from "../../model/positions.js";
|
|
4
|
+
import "../../model/index.js";
|
|
5
5
|
import { RWAOpenAccountRequirements } from "../market/rwa/types.js";
|
|
6
6
|
import "../market/rwa/index.js";
|
|
7
7
|
import { RouterCASlice } from "../router/types.js";
|
|
@@ -9,7 +9,7 @@ import "../router/index.js";
|
|
|
9
9
|
import { GetCreditAccountsOptions, ListStrategyPositionsProps } from "./credit-account-compressor/types.js";
|
|
10
10
|
import "./credit-account-compressor/index.js";
|
|
11
11
|
import "./withdrawal-compressor/index.js";
|
|
12
|
-
import {
|
|
12
|
+
import { AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, ClaimFarmRewardsProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, ICreditAccountsService, OpenCAProps, PartiallyLiquidateProps, PermitResult, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, Rewards } from "./types.js";
|
|
13
13
|
import { PriceUpdate } from "../market/pricefeeds/types.js";
|
|
14
14
|
import "../market/index.js";
|
|
15
15
|
import { MultiCall, RawTx } from "../types/transactions.js";
|
|
@@ -17,6 +17,8 @@ import { OnchainSDK } from "../OnchainSDK.js";
|
|
|
17
17
|
import "../types/index.js";
|
|
18
18
|
import { SDKConstruct } from "../base/SDKConstruct.js";
|
|
19
19
|
import "../base/index.js";
|
|
20
|
+
import { AccountBotsService } from "./bots/AccountBotsService.js";
|
|
21
|
+
import "./bots/index.js";
|
|
20
22
|
import { Address } from "viem";
|
|
21
23
|
//#region src/sdk/accounts/CreditAccountsServiceV310.d.ts
|
|
22
24
|
/**
|
|
@@ -30,6 +32,10 @@ import { Address } from "viem";
|
|
|
30
32
|
**/
|
|
31
33
|
declare class CreditAccountsServiceV310 extends SDKConstruct implements ICreditAccountsService {
|
|
32
34
|
#private;
|
|
35
|
+
/**
|
|
36
|
+
* {@inheritDoc ICreditAccountsService.bots}
|
|
37
|
+
**/
|
|
38
|
+
readonly bots: AccountBotsService;
|
|
33
39
|
constructor(sdk: OnchainSDK);
|
|
34
40
|
/**
|
|
35
41
|
* {@inheritDoc ICreditAccountsService.getCreditAccountData}
|
|
@@ -51,14 +57,6 @@ declare class CreditAccountsServiceV310 extends SDKConstruct implements ICreditA
|
|
|
51
57
|
* {@inheritDoc ICreditAccountsService.getRewards}
|
|
52
58
|
**/
|
|
53
59
|
getRewards(creditAccount: Address): Promise<Array<Rewards>>;
|
|
54
|
-
/**
|
|
55
|
-
* {@inheritDoc ICreditAccountsService.getConnectedBots}
|
|
56
|
-
**/
|
|
57
|
-
getConnectedBots(accountsToCheck: Array<AccountToCheck>, legacyMigrationBot: Address | undefined, additionalBots: Array<Address>): Promise<{
|
|
58
|
-
legacy: GetConnectedBotsResult;
|
|
59
|
-
legacyMigration: GetConnectedMigrationBotsResult;
|
|
60
|
-
additionalBots: Array<Omit<NonNullable<GetConnectedMigrationBotsResult>, "botAddress">>;
|
|
61
|
-
}>;
|
|
62
60
|
/**
|
|
63
61
|
* {@inheritDoc ICreditAccountsService.fullyLiquidate}
|
|
64
62
|
**/
|
|
@@ -115,10 +113,6 @@ declare class CreditAccountsServiceV310 extends SDKConstruct implements ICreditA
|
|
|
115
113
|
* {@inheritDoc ICreditAccountsService.assembleDepositDiffCalls}
|
|
116
114
|
*/
|
|
117
115
|
assembleDepositDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
118
|
-
/**
|
|
119
|
-
* {@inheritDoc ICreditAccountsService.setBot}
|
|
120
|
-
*/
|
|
121
|
-
setBot({ botAddress, permissions: defaultPermissions, targetContract }: SetBotProps): Promise<CreditAccountOperationResult | CreditManagerOperationResult>;
|
|
122
116
|
/**
|
|
123
117
|
* {@inheritDoc ICreditAccountsService.assembleRepayCreditAccountCalls}
|
|
124
118
|
*/
|
|
@@ -170,7 +164,6 @@ declare class CreditAccountsServiceV310 extends SDKConstruct implements ICreditA
|
|
|
170
164
|
*/
|
|
171
165
|
prepareAddCollateral(creditFacade: Address, assets: Array<Asset>, permits: Record<string, PermitResult>): Array<MultiCall>;
|
|
172
166
|
private get rewardCompressor();
|
|
173
|
-
private get peripheryCompressor();
|
|
174
167
|
}
|
|
175
168
|
//#endregion
|
|
176
169
|
export { CreditAccountsServiceV310 };
|