@gearbox-protocol/deploy-tools 5.3.27 → 5.3.28
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/index.mjs +64 -39
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -376023,7 +376023,7 @@ var PoolQuotaKeeperContract = class extends BaseContract {
|
|
|
376023
376023
|
}
|
|
376024
376024
|
}
|
|
376025
376025
|
};
|
|
376026
|
-
var
|
|
376026
|
+
var PoolSuite = class extends SDKConstruct {
|
|
376027
376027
|
pool;
|
|
376028
376028
|
pqk;
|
|
376029
376029
|
gauge;
|
|
@@ -383506,7 +383506,7 @@ var PriceOracleV310Contract = class extends PriceOracleBaseContract {
|
|
|
383506
383506
|
var MarketSuite = class extends SDKConstruct {
|
|
383507
383507
|
acl;
|
|
383508
383508
|
configurator;
|
|
383509
|
-
|
|
383509
|
+
pool;
|
|
383510
383510
|
priceOracle;
|
|
383511
383511
|
creditManagers = [];
|
|
383512
383512
|
/**
|
|
@@ -383536,7 +383536,7 @@ var MarketSuite = class extends SDKConstruct {
|
|
|
383536
383536
|
sdk.tokensMeta.upsert(t.addr, t);
|
|
383537
383537
|
sdk.provider.addressLabels.set(t.addr, t.symbol);
|
|
383538
383538
|
}
|
|
383539
|
-
this.
|
|
383539
|
+
this.pool = new PoolSuite(sdk, marketData);
|
|
383540
383540
|
this.zappers = marketData.zappers;
|
|
383541
383541
|
for (let i = 0; i < marketData.creditManagers.length; i++) {
|
|
383542
383542
|
this.creditManagers.push(new CreditSuite(sdk, marketData, i));
|
|
@@ -383556,11 +383556,11 @@ var MarketSuite = class extends SDKConstruct {
|
|
|
383556
383556
|
}
|
|
383557
383557
|
}
|
|
383558
383558
|
get dirty() {
|
|
383559
|
-
return this.configurator.dirty || this.
|
|
383559
|
+
return this.configurator.dirty || this.pool.dirty || this.priceOracle.dirty || this.creditManagers.some((cm) => cm.dirty);
|
|
383560
383560
|
}
|
|
383561
383561
|
stateHuman(raw = true) {
|
|
383562
383562
|
return {
|
|
383563
|
-
pool: this.
|
|
383563
|
+
pool: this.pool.stateHuman(raw),
|
|
383564
383564
|
creditManagers: this.creditManagers.map((cm) => cm.stateHuman(raw)),
|
|
383565
383565
|
priceOracle: this.priceOracle.stateHuman(raw),
|
|
383566
383566
|
pausableAdmins: this.state.pausableAdmins.map((a) => this.labelAddress(a)),
|
|
@@ -383606,7 +383606,7 @@ var MarketRegister = class extends SDKConstruct {
|
|
|
383606
383606
|
await this.#loadMarkets(marketConfigurators, [], ignoreUpdateablePrices);
|
|
383607
383607
|
}
|
|
383608
383608
|
async syncState() {
|
|
383609
|
-
const pools = this.markets.filter((m) => m.dirty).map((m) => m.
|
|
383609
|
+
const pools = this.markets.filter((m) => m.dirty).map((m) => m.pool.pool.address);
|
|
383610
383610
|
if (pools.length) {
|
|
383611
383611
|
this.#logger?.debug(`need to reload ${pools.length} markets`);
|
|
383612
383612
|
await this.#loadMarkets([], pools);
|
|
@@ -383691,7 +383691,7 @@ var MarketRegister = class extends SDKConstruct {
|
|
|
383691
383691
|
return this.markets.map((market) => market.stateHuman(raw));
|
|
383692
383692
|
}
|
|
383693
383693
|
get pools() {
|
|
383694
|
-
return this.markets.map((market) => market.
|
|
383694
|
+
return this.markets.map((market) => market.pool);
|
|
383695
383695
|
}
|
|
383696
383696
|
get creditManagers() {
|
|
383697
383697
|
return this.markets.flatMap((market) => market.creditManagers);
|
|
@@ -384586,8 +384586,8 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
384586
384586
|
to,
|
|
384587
384587
|
calls: openPathCalls
|
|
384588
384588
|
} = props;
|
|
384589
|
-
const
|
|
384590
|
-
const cm =
|
|
384589
|
+
const cmSuite = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
384590
|
+
const cm = cmSuite.creditManager;
|
|
384591
384591
|
const priceUpdatesCalls = await this.getPriceUpdatesForFacade(
|
|
384592
384592
|
cm.address,
|
|
384593
384593
|
void 0,
|
|
@@ -384601,13 +384601,9 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
384601
384601
|
...openPathCalls,
|
|
384602
384602
|
...withdrawDebt ? [this.#prepareWithdrawToken(cm.creditFacade, cm.underlying, debt, to)] : []
|
|
384603
384603
|
];
|
|
384604
|
-
const tx =
|
|
384605
|
-
to,
|
|
384606
|
-
calls,
|
|
384607
|
-
referralCode
|
|
384608
|
-
);
|
|
384604
|
+
const tx = cmSuite.creditFacade.openCreditAccount(to, calls, referralCode);
|
|
384609
384605
|
tx.value = ethAmount.toString(10);
|
|
384610
|
-
return { calls, tx, creditFacade:
|
|
384606
|
+
return { calls, tx, creditFacade: cmSuite.creditFacade };
|
|
384611
384607
|
}
|
|
384612
384608
|
/**
|
|
384613
384609
|
* Internal wrapper for CreditAccountCompressor.getCreditAccounts + price updates wrapped into multicall
|
|
@@ -384658,7 +384654,7 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
384658
384654
|
const market = this.sdk.marketRegister.findByCreditManager(
|
|
384659
384655
|
acc.creditManager
|
|
384660
384656
|
);
|
|
384661
|
-
const pool = market.
|
|
384657
|
+
const pool = market.pool.pool.address;
|
|
384662
384658
|
oracleByPool.set(pool, market.priceOracle);
|
|
384663
384659
|
for (const t of acc.tokens) {
|
|
384664
384660
|
if (t.balance > 10n) {
|
|
@@ -384669,9 +384665,9 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
384669
384665
|
}
|
|
384670
384666
|
}
|
|
384671
384667
|
const priceFeeds = [];
|
|
384672
|
-
for (const [pool,
|
|
384668
|
+
for (const [pool, oracle] of oracleByPool.entries()) {
|
|
384673
384669
|
const tokens = Array.from(tokensByPool.get(pool) ?? []);
|
|
384674
|
-
priceFeeds.push(...
|
|
384670
|
+
priceFeeds.push(...oracle.priceFeedsForTokens(tokens));
|
|
384675
384671
|
}
|
|
384676
384672
|
return this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(priceFeeds);
|
|
384677
384673
|
}
|
|
@@ -384682,7 +384678,7 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
384682
384678
|
const caBalancesRecord = creditAccount ? assetsMap(creditAccount.tokens) : creditAccount;
|
|
384683
384679
|
const market = this.sdk.marketRegister.findByCreditManager(creditManager);
|
|
384684
384680
|
const cm = this.sdk.marketRegister.findCreditManager(creditManager).creditManager;
|
|
384685
|
-
const pool = market.
|
|
384681
|
+
const pool = market.pool.pool.address;
|
|
384686
384682
|
oracleByPool.set(pool, market.priceOracle);
|
|
384687
384683
|
const insertToken = (p, t) => {
|
|
384688
384684
|
const tokens = tokensByPool.get(p) ?? /* @__PURE__ */ new Set();
|
|
@@ -409449,13 +409445,14 @@ async function evmMineDetailed(client, timestamp) {
|
|
|
409449
409445
|
return void 0;
|
|
409450
409446
|
}
|
|
409451
409447
|
}
|
|
409452
|
-
var AccountOpener = class {
|
|
409448
|
+
var AccountOpener = class extends SDKConstruct {
|
|
409453
409449
|
#service;
|
|
409454
409450
|
#anvil;
|
|
409455
409451
|
#logger;
|
|
409456
409452
|
#borrower;
|
|
409457
409453
|
#faucet;
|
|
409458
409454
|
constructor(service, options = {}) {
|
|
409455
|
+
super(service.sdk);
|
|
409459
409456
|
this.#service = service;
|
|
409460
409457
|
this.#logger = childLogger("AccountOpener", service.sdk.logger);
|
|
409461
409458
|
this.#anvil = createAnvilClient({
|
|
@@ -409533,22 +409530,23 @@ var AccountOpener = class {
|
|
|
409533
409530
|
});
|
|
409534
409531
|
logger2?.debug(strategy, "found open strategy");
|
|
409535
409532
|
const debt = minDebt * BigInt(leverage - 1);
|
|
409536
|
-
const
|
|
409537
|
-
|
|
409533
|
+
const averageQuota = this.#getCollateralQuota(
|
|
409534
|
+
cm,
|
|
409535
|
+
collateral,
|
|
409536
|
+
strategy.amount,
|
|
409537
|
+
debt
|
|
409538
|
+
);
|
|
409539
|
+
const minQuota = this.#getCollateralQuota(
|
|
409540
|
+
cm,
|
|
409541
|
+
collateral,
|
|
409542
|
+
strategy.minAmount,
|
|
409543
|
+
debt
|
|
409544
|
+
);
|
|
409545
|
+
logger2?.debug({ averageQuota, minQuota }, "calculated quotas");
|
|
409538
409546
|
const { tx, calls } = await this.#service.openCA({
|
|
409539
409547
|
creditManager: cm.creditManager.address,
|
|
409540
|
-
averageQuota
|
|
409541
|
-
|
|
409542
|
-
token: collateral,
|
|
409543
|
-
balance: this.#calcQuota(strategy.amount, debt, collateralLT)
|
|
409544
|
-
}
|
|
409545
|
-
],
|
|
409546
|
-
minQuota: inUnderlying ? [] : [
|
|
409547
|
-
{
|
|
409548
|
-
token: collateral,
|
|
409549
|
-
balance: this.#calcQuota(strategy.minAmount, debt, collateralLT)
|
|
409550
|
-
}
|
|
409551
|
-
],
|
|
409548
|
+
averageQuota,
|
|
409549
|
+
minQuota,
|
|
409552
409550
|
collateral: [{ token: underlying, balance: minDebt }],
|
|
409553
409551
|
debt,
|
|
409554
409552
|
calls: strategy.calls,
|
|
@@ -409743,15 +409741,37 @@ var AccountOpener = class {
|
|
|
409743
409741
|
}
|
|
409744
409742
|
return this.#borrower;
|
|
409745
409743
|
}
|
|
409744
|
+
#getCollateralQuota(cm, collateral, amount, debt) {
|
|
409745
|
+
const { underlying, collateralTokens } = cm;
|
|
409746
|
+
const inUnderlying = collateral.toLowerCase() === underlying.toLowerCase();
|
|
409747
|
+
if (inUnderlying) {
|
|
409748
|
+
return [];
|
|
409749
|
+
}
|
|
409750
|
+
const collateralLT = BigInt(collateralTokens[collateral]);
|
|
409751
|
+
const market = this.sdk.marketRegister.findByCreditManager(
|
|
409752
|
+
cm.creditManager.address
|
|
409753
|
+
);
|
|
409754
|
+
const quotaInfo = market.pool.pqk.quotas.mustGet(collateral);
|
|
409755
|
+
const availableQuota = quotaInfo.limit - quotaInfo.totalQuoted;
|
|
409756
|
+
if (availableQuota <= 0n) {
|
|
409757
|
+
throw new Error(
|
|
409758
|
+
`quota exceeded for asset ${this.labelAddress(collateral)} in ${cm.name}`
|
|
409759
|
+
);
|
|
409760
|
+
}
|
|
409761
|
+
const desiredQuota = this.#calcQuota(amount, debt, collateralLT);
|
|
409762
|
+
return [
|
|
409763
|
+
{
|
|
409764
|
+
token: collateral,
|
|
409765
|
+
balance: desiredQuota < availableQuota ? desiredQuota : availableQuota
|
|
409766
|
+
}
|
|
409767
|
+
];
|
|
409768
|
+
}
|
|
409746
409769
|
#calcQuota(amount, debt, lt) {
|
|
409747
409770
|
let quota = amount * lt / PERCENTAGE_FACTOR;
|
|
409748
409771
|
quota = debt < quota ? debt : quota;
|
|
409749
409772
|
quota = quota * (PERCENTAGE_FACTOR + 500n) / PERCENTAGE_FACTOR;
|
|
409750
409773
|
return quota / PERCENTAGE_FACTOR * PERCENTAGE_FACTOR;
|
|
409751
409774
|
}
|
|
409752
|
-
get sdk() {
|
|
409753
|
-
return this.#service.sdk;
|
|
409754
|
-
}
|
|
409755
409775
|
};
|
|
409756
409776
|
var SDKExample = class {
|
|
409757
409777
|
#sdk;
|
|
@@ -418116,6 +418136,11 @@ function openAccounts() {
|
|
|
418116
418136
|
"stateAfter.human.json"
|
|
418117
418137
|
)
|
|
418118
418138
|
});
|
|
418139
|
+
await writeFile5(
|
|
418140
|
+
path8.resolve(sharedDir, "deploy-state", "stateAfter.json"),
|
|
418141
|
+
json_stringify(sdkExample2.sdk.state),
|
|
418142
|
+
"utf-8"
|
|
418143
|
+
);
|
|
418119
418144
|
const faucetAddr = await sdkExample2.sdk.provider.publicClient.readContract({
|
|
418120
418145
|
address: ADDRESS_PROVIDER[sdkExample2.sdk.provider.networkType],
|
|
418121
418146
|
abi: iAddressProviderV3_1Abi,
|
|
@@ -418233,7 +418258,7 @@ function getRenderer(opts) {
|
|
|
418233
418258
|
var package_default = {
|
|
418234
418259
|
name: "@gearbox-protocol/deploy-tools",
|
|
418235
418260
|
description: "Gearbox deploy tools",
|
|
418236
|
-
version: "5.3.
|
|
418261
|
+
version: "5.3.28",
|
|
418237
418262
|
homepage: "https://gearbox.fi",
|
|
418238
418263
|
keywords: [
|
|
418239
418264
|
"gearbox"
|
|
@@ -418276,7 +418301,7 @@ var package_default = {
|
|
|
418276
418301
|
"@gearbox-protocol/deploy-tools-node": "0.0.0",
|
|
418277
418302
|
"@gearbox-protocol/deploy-tools-shared": "0.0.0",
|
|
418278
418303
|
"@gearbox-protocol/deploy-tools-types": "0.0.0",
|
|
418279
|
-
"@gearbox-protocol/sdk": "^3.0.0-vfour.
|
|
418304
|
+
"@gearbox-protocol/sdk": "^3.0.0-vfour.174",
|
|
418280
418305
|
"@gearbox-protocol/sdk-gov": "^2.33.2",
|
|
418281
418306
|
"@types/lodash-es": "^4.17.12",
|
|
418282
418307
|
"@types/node": "^22.10.6",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/deploy-tools",
|
|
3
3
|
"description": "Gearbox deploy tools",
|
|
4
|
-
"version": "5.3.
|
|
4
|
+
"version": "5.3.28",
|
|
5
5
|
"homepage": "https://gearbox.fi",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"gearbox"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@gearbox-protocol/deploy-tools-node": "0.0.0",
|
|
45
45
|
"@gearbox-protocol/deploy-tools-shared": "0.0.0",
|
|
46
46
|
"@gearbox-protocol/deploy-tools-types": "0.0.0",
|
|
47
|
-
"@gearbox-protocol/sdk": "^3.0.0-vfour.
|
|
47
|
+
"@gearbox-protocol/sdk": "^3.0.0-vfour.174",
|
|
48
48
|
"@gearbox-protocol/sdk-gov": "^2.33.2",
|
|
49
49
|
"@types/lodash-es": "^4.17.12",
|
|
50
50
|
"@types/node": "^22.10.6",
|