@gearbox-protocol/deploy-tools 5.11.0 → 5.11.2
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 +53 -17
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -405577,6 +405577,7 @@ var AccountOpener = class extends SDKConstruct {
|
|
|
405577
405577
|
#logger;
|
|
405578
405578
|
#borrower;
|
|
405579
405579
|
#faucet;
|
|
405580
|
+
#poolDepositMultiplier;
|
|
405580
405581
|
constructor(service, options = {}) {
|
|
405581
405582
|
super(service.sdk);
|
|
405582
405583
|
this.#service = service;
|
|
@@ -405587,6 +405588,7 @@ var AccountOpener = class extends SDKConstruct {
|
|
|
405587
405588
|
});
|
|
405588
405589
|
this.#faucet = options.faucet ?? service.sdk.addressProvider.getAddress("FAUCET");
|
|
405589
405590
|
this.#borrower = options.borrower;
|
|
405591
|
+
this.#poolDepositMultiplier = options.poolDepositMultiplier ?? 11000n;
|
|
405590
405592
|
}
|
|
405591
405593
|
get borrower() {
|
|
405592
405594
|
if (!this.#borrower) {
|
|
@@ -405763,13 +405765,13 @@ var AccountOpener = class extends SDKConstruct {
|
|
|
405763
405765
|
owner: this.borrower
|
|
405764
405766
|
});
|
|
405765
405767
|
}
|
|
405766
|
-
async #depositIntoPools(targets
|
|
405768
|
+
async #depositIntoPools(targets) {
|
|
405767
405769
|
this.#logger?.debug("checking and topping up pools if necessary");
|
|
405768
405770
|
const minAvailableByPool = {};
|
|
405769
405771
|
for (const { leverage = DEFAULT_LEVERAGE, creditManager } of targets) {
|
|
405770
405772
|
const cm = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
405771
405773
|
const { minDebt } = cm.creditFacade;
|
|
405772
|
-
minAvailableByPool[cm.pool] = (minAvailableByPool[cm.pool] ?? 0n) + minDebt * BigInt(leverage - 1) *
|
|
405774
|
+
minAvailableByPool[cm.pool] = (minAvailableByPool[cm.pool] ?? 0n) + minDebt * BigInt(leverage - 1) * this.#poolDepositMultiplier / PERCENTAGE_FACTOR;
|
|
405773
405775
|
}
|
|
405774
405776
|
let totalUSD = 0n;
|
|
405775
405777
|
let deposits = [];
|
|
@@ -405799,24 +405801,58 @@ var AccountOpener = class extends SDKConstruct {
|
|
|
405799
405801
|
this.#logger?.debug(`created depositor ${depositor.address}`);
|
|
405800
405802
|
await this.#claimFromFaucet(depositor, totalUSD);
|
|
405801
405803
|
for (const [pool, amount] of deposits) {
|
|
405802
|
-
const poolName = this.sdk.provider.addressLabels.get(pool.address);
|
|
405803
|
-
const amnt = this.sdk.tokensMeta.formatBN(pool.underlying, amount) + " " + this.sdk.tokensMeta.symbol(pool.underlying);
|
|
405804
|
-
this.#logger?.debug(`depositing ${amnt} into pool ${poolName}`);
|
|
405805
405804
|
try {
|
|
405806
|
-
await this.#
|
|
405807
|
-
account: depositor,
|
|
405808
|
-
chain: this.#anvil.chain,
|
|
405809
|
-
address: pool.address,
|
|
405810
|
-
abi: iPoolV300Abi,
|
|
405811
|
-
functionName: "deposit",
|
|
405812
|
-
args: [amount, depositor.address]
|
|
405813
|
-
});
|
|
405814
|
-
this.#logger?.debug(`deposited ${amnt} into ${poolName}`);
|
|
405805
|
+
await this.#depositToPool(pool, depositor, amount);
|
|
405815
405806
|
} catch (e) {
|
|
405816
|
-
this.#logger?.warn(`failed to deposit
|
|
405807
|
+
this.#logger?.warn(`failed to deposit into ${pool.name}: ${e}`);
|
|
405817
405808
|
}
|
|
405818
405809
|
}
|
|
405819
405810
|
}
|
|
405811
|
+
async #depositToPool(pool, depositor, amount) {
|
|
405812
|
+
const { underlying, address } = pool;
|
|
405813
|
+
const poolName = this.sdk.provider.addressLabels.get(address);
|
|
405814
|
+
const amnt = this.sdk.tokensMeta.formatBN(pool.underlying, amount) + " " + this.sdk.tokensMeta.symbol(pool.underlying);
|
|
405815
|
+
this.#logger?.debug(`depositing ${amnt} into pool ${poolName}`);
|
|
405816
|
+
const allowance = await this.#anvil.readContract({
|
|
405817
|
+
address: underlying,
|
|
405818
|
+
abi: ierc20Abi,
|
|
405819
|
+
functionName: "balanceOf",
|
|
405820
|
+
args: [depositor.address]
|
|
405821
|
+
});
|
|
405822
|
+
this.#logger?.debug(
|
|
405823
|
+
`depositor balance in underlying: ${this.sdk.tokensMeta.formatBN(pool.underlying, allowance)}`
|
|
405824
|
+
);
|
|
405825
|
+
let hash2 = await this.#anvil.writeContract({
|
|
405826
|
+
account: depositor,
|
|
405827
|
+
address: underlying,
|
|
405828
|
+
abi: ierc20Abi,
|
|
405829
|
+
functionName: "approve",
|
|
405830
|
+
args: [address, allowance],
|
|
405831
|
+
chain: this.#anvil.chain
|
|
405832
|
+
});
|
|
405833
|
+
let receipt = await this.#anvil.waitForTransactionReceipt({ hash: hash2 });
|
|
405834
|
+
if (receipt.status === "reverted") {
|
|
405835
|
+
throw new Error(
|
|
405836
|
+
`tx ${hash2} that approves underlying from depositor for pool ${poolName} reverted`
|
|
405837
|
+
);
|
|
405838
|
+
}
|
|
405839
|
+
this.#logger?.debug(
|
|
405840
|
+
`depositor approved underlying for pool ${poolName}: ${hash2}`
|
|
405841
|
+
);
|
|
405842
|
+
hash2 = await this.#anvil.writeContract({
|
|
405843
|
+
account: depositor,
|
|
405844
|
+
address,
|
|
405845
|
+
abi: iPoolV300Abi,
|
|
405846
|
+
functionName: "deposit",
|
|
405847
|
+
args: [amount, depositor.address],
|
|
405848
|
+
chain: this.#anvil.chain
|
|
405849
|
+
});
|
|
405850
|
+
receipt = await this.#anvil.waitForTransactionReceipt({ hash: hash2 });
|
|
405851
|
+
if (receipt.status === "reverted") {
|
|
405852
|
+
throw new Error(`tx ${hash2} that deposits to pool ${poolName} reverted`);
|
|
405853
|
+
}
|
|
405854
|
+
this.#logger?.debug(`deposited ${amnt} into ${poolName}`);
|
|
405855
|
+
}
|
|
405820
405856
|
/**
|
|
405821
405857
|
* Creates borrower wallet,
|
|
405822
405858
|
* Sets ETH balance,
|
|
@@ -414207,7 +414243,7 @@ function getRenderer(opts) {
|
|
|
414207
414243
|
var package_default = {
|
|
414208
414244
|
name: "@gearbox-protocol/deploy-tools",
|
|
414209
414245
|
description: "Gearbox deploy tools",
|
|
414210
|
-
version: "5.11.
|
|
414246
|
+
version: "5.11.2",
|
|
414211
414247
|
homepage: "https://gearbox.fi",
|
|
414212
414248
|
keywords: [
|
|
414213
414249
|
"gearbox"
|
|
@@ -414250,7 +414286,7 @@ var package_default = {
|
|
|
414250
414286
|
"@gearbox-protocol/deploy-tools-node": "0.0.0",
|
|
414251
414287
|
"@gearbox-protocol/deploy-tools-shared": "0.0.0",
|
|
414252
414288
|
"@gearbox-protocol/deploy-tools-types": "0.0.0",
|
|
414253
|
-
"@gearbox-protocol/sdk": "3.0.0-vfour.
|
|
414289
|
+
"@gearbox-protocol/sdk": "3.0.0-vfour.245",
|
|
414254
414290
|
"@gearbox-protocol/sdk-gov": "^2.34.1",
|
|
414255
414291
|
"@types/lodash-es": "^4.17.12",
|
|
414256
414292
|
"@types/node": "^22.13.1",
|
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.11.
|
|
4
|
+
"version": "5.11.2",
|
|
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.245",
|
|
48
48
|
"@gearbox-protocol/sdk-gov": "^2.34.1",
|
|
49
49
|
"@types/lodash-es": "^4.17.12",
|
|
50
50
|
"@types/node": "^22.13.1",
|