@gearbox-protocol/sdk 3.0.0-vfour.243 → 3.0.0-vfour.244
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/dev/index.cjs +47 -13
- package/dist/esm/dev/index.mjs +48 -14
- package/package.json +1 -1
package/dist/cjs/dev/index.cjs
CHANGED
|
@@ -283,24 +283,58 @@ var AccountOpener = class extends sdk.SDKConstruct {
|
|
|
283
283
|
this.#logger?.debug(`created depositor ${depositor.address}`);
|
|
284
284
|
await this.#claimFromFaucet(depositor, totalUSD);
|
|
285
285
|
for (const [pool, amount] of deposits) {
|
|
286
|
-
const poolName = this.sdk.provider.addressLabels.get(pool.address);
|
|
287
|
-
const amnt = this.sdk.tokensMeta.formatBN(pool.underlying, amount) + " " + this.sdk.tokensMeta.symbol(pool.underlying);
|
|
288
|
-
this.#logger?.debug(`depositing ${amnt} into pool ${poolName}`);
|
|
289
286
|
try {
|
|
290
|
-
await this.#
|
|
291
|
-
account: depositor,
|
|
292
|
-
chain: this.#anvil.chain,
|
|
293
|
-
address: pool.address,
|
|
294
|
-
abi: sdk.iPoolV300Abi,
|
|
295
|
-
functionName: "deposit",
|
|
296
|
-
args: [amount, depositor.address]
|
|
297
|
-
});
|
|
298
|
-
this.#logger?.debug(`deposited ${amnt} into ${poolName}`);
|
|
287
|
+
await this.#depositToPool(pool, depositor, amount);
|
|
299
288
|
} catch (e) {
|
|
300
|
-
this.#logger?.warn(`failed to deposit
|
|
289
|
+
this.#logger?.warn(`failed to deposit into ${pool.name}: ${e}`);
|
|
301
290
|
}
|
|
302
291
|
}
|
|
303
292
|
}
|
|
293
|
+
async #depositToPool(pool, depositor, amount) {
|
|
294
|
+
const { underlying, address } = pool;
|
|
295
|
+
const poolName = this.sdk.provider.addressLabels.get(address);
|
|
296
|
+
const amnt = this.sdk.tokensMeta.formatBN(pool.underlying, amount) + " " + this.sdk.tokensMeta.symbol(pool.underlying);
|
|
297
|
+
this.#logger?.debug(`depositing ${amnt} into pool ${poolName}`);
|
|
298
|
+
const allowance = await this.#anvil.readContract({
|
|
299
|
+
address: underlying,
|
|
300
|
+
abi: sdk.ierc20Abi,
|
|
301
|
+
functionName: "balanceOf",
|
|
302
|
+
args: [depositor.address]
|
|
303
|
+
});
|
|
304
|
+
this.#logger?.debug(
|
|
305
|
+
`depositor balance in underlying: ${this.sdk.tokensMeta.formatBN(pool.underlying, allowance)}`
|
|
306
|
+
);
|
|
307
|
+
let hash = await this.#anvil.writeContract({
|
|
308
|
+
account: depositor,
|
|
309
|
+
address: underlying,
|
|
310
|
+
abi: sdk.ierc20Abi,
|
|
311
|
+
functionName: "approve",
|
|
312
|
+
args: [address, allowance],
|
|
313
|
+
chain: this.#anvil.chain
|
|
314
|
+
});
|
|
315
|
+
let receipt = await this.#anvil.waitForTransactionReceipt({ hash });
|
|
316
|
+
if (receipt.status === "reverted") {
|
|
317
|
+
throw new Error(
|
|
318
|
+
`tx ${hash} that approves underlying from depositor for pool ${poolName} reverted`
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
this.#logger?.debug(
|
|
322
|
+
`depositor approved underlying for pool ${poolName}: ${hash}`
|
|
323
|
+
);
|
|
324
|
+
hash = await this.#anvil.writeContract({
|
|
325
|
+
account: depositor,
|
|
326
|
+
address,
|
|
327
|
+
abi: sdk.iPoolV300Abi,
|
|
328
|
+
functionName: "deposit",
|
|
329
|
+
args: [amount, depositor.address],
|
|
330
|
+
chain: this.#anvil.chain
|
|
331
|
+
});
|
|
332
|
+
receipt = await this.#anvil.waitForTransactionReceipt({ hash });
|
|
333
|
+
if (receipt.status === "reverted") {
|
|
334
|
+
throw new Error(`tx ${hash} that deposits to pool ${poolName} reverted`);
|
|
335
|
+
}
|
|
336
|
+
this.#logger?.debug(`deposited ${amnt} into ${poolName}`);
|
|
337
|
+
}
|
|
304
338
|
/**
|
|
305
339
|
* Creates borrower wallet,
|
|
306
340
|
* Sets ETH balance,
|
package/dist/esm/dev/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createTestClient, publicActions, walletActions, toHex, parseEventLogs, isAddress, parseEther, createWalletClient, http, createPublicClient, stringToHex } from 'viem';
|
|
2
2
|
import { privateKeyToAccount, generatePrivateKey } from 'viem/accounts';
|
|
3
|
-
import { SDKConstruct, childLogger, AddressMap, sendRawTx, iCreditFacadeV300Abi, PERCENTAGE_FACTOR, formatBN, iPoolV300Abi, ADDRESS_0X0,
|
|
3
|
+
import { SDKConstruct, childLogger, AddressMap, sendRawTx, iCreditFacadeV300Abi, PERCENTAGE_FACTOR, formatBN, ierc20Abi, iPoolV300Abi, ADDRESS_0X0, MAX_UINT256, iDegenNftv2Abi, AP_PRICE_FEED_COMPRESSOR, iPriceFeedCompressorAbi, rawTxToMulticallPriceUpdate, GearboxSDK, json_stringify, iAddressProviderV300Abi, ADDRESS_PROVIDER, iAddressProviderV310Abi, WAD } from '../sdk/index.mjs';
|
|
4
4
|
import { writeFile, readFile } from 'node:fs/promises';
|
|
5
5
|
|
|
6
6
|
// src/dev/AccountOpener.ts
|
|
@@ -281,24 +281,58 @@ var AccountOpener = class extends SDKConstruct {
|
|
|
281
281
|
this.#logger?.debug(`created depositor ${depositor.address}`);
|
|
282
282
|
await this.#claimFromFaucet(depositor, totalUSD);
|
|
283
283
|
for (const [pool, amount] of deposits) {
|
|
284
|
-
const poolName = this.sdk.provider.addressLabels.get(pool.address);
|
|
285
|
-
const amnt = this.sdk.tokensMeta.formatBN(pool.underlying, amount) + " " + this.sdk.tokensMeta.symbol(pool.underlying);
|
|
286
|
-
this.#logger?.debug(`depositing ${amnt} into pool ${poolName}`);
|
|
287
284
|
try {
|
|
288
|
-
await this.#
|
|
289
|
-
account: depositor,
|
|
290
|
-
chain: this.#anvil.chain,
|
|
291
|
-
address: pool.address,
|
|
292
|
-
abi: iPoolV300Abi,
|
|
293
|
-
functionName: "deposit",
|
|
294
|
-
args: [amount, depositor.address]
|
|
295
|
-
});
|
|
296
|
-
this.#logger?.debug(`deposited ${amnt} into ${poolName}`);
|
|
285
|
+
await this.#depositToPool(pool, depositor, amount);
|
|
297
286
|
} catch (e) {
|
|
298
|
-
this.#logger?.warn(`failed to deposit
|
|
287
|
+
this.#logger?.warn(`failed to deposit into ${pool.name}: ${e}`);
|
|
299
288
|
}
|
|
300
289
|
}
|
|
301
290
|
}
|
|
291
|
+
async #depositToPool(pool, depositor, amount) {
|
|
292
|
+
const { underlying, address } = pool;
|
|
293
|
+
const poolName = this.sdk.provider.addressLabels.get(address);
|
|
294
|
+
const amnt = this.sdk.tokensMeta.formatBN(pool.underlying, amount) + " " + this.sdk.tokensMeta.symbol(pool.underlying);
|
|
295
|
+
this.#logger?.debug(`depositing ${amnt} into pool ${poolName}`);
|
|
296
|
+
const allowance = await this.#anvil.readContract({
|
|
297
|
+
address: underlying,
|
|
298
|
+
abi: ierc20Abi,
|
|
299
|
+
functionName: "balanceOf",
|
|
300
|
+
args: [depositor.address]
|
|
301
|
+
});
|
|
302
|
+
this.#logger?.debug(
|
|
303
|
+
`depositor balance in underlying: ${this.sdk.tokensMeta.formatBN(pool.underlying, allowance)}`
|
|
304
|
+
);
|
|
305
|
+
let hash = await this.#anvil.writeContract({
|
|
306
|
+
account: depositor,
|
|
307
|
+
address: underlying,
|
|
308
|
+
abi: ierc20Abi,
|
|
309
|
+
functionName: "approve",
|
|
310
|
+
args: [address, allowance],
|
|
311
|
+
chain: this.#anvil.chain
|
|
312
|
+
});
|
|
313
|
+
let receipt = await this.#anvil.waitForTransactionReceipt({ hash });
|
|
314
|
+
if (receipt.status === "reverted") {
|
|
315
|
+
throw new Error(
|
|
316
|
+
`tx ${hash} that approves underlying from depositor for pool ${poolName} reverted`
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
this.#logger?.debug(
|
|
320
|
+
`depositor approved underlying for pool ${poolName}: ${hash}`
|
|
321
|
+
);
|
|
322
|
+
hash = await this.#anvil.writeContract({
|
|
323
|
+
account: depositor,
|
|
324
|
+
address,
|
|
325
|
+
abi: iPoolV300Abi,
|
|
326
|
+
functionName: "deposit",
|
|
327
|
+
args: [amount, depositor.address],
|
|
328
|
+
chain: this.#anvil.chain
|
|
329
|
+
});
|
|
330
|
+
receipt = await this.#anvil.waitForTransactionReceipt({ hash });
|
|
331
|
+
if (receipt.status === "reverted") {
|
|
332
|
+
throw new Error(`tx ${hash} that deposits to pool ${poolName} reverted`);
|
|
333
|
+
}
|
|
334
|
+
this.#logger?.debug(`deposited ${amnt} into ${poolName}`);
|
|
335
|
+
}
|
|
302
336
|
/**
|
|
303
337
|
* Creates borrower wallet,
|
|
304
338
|
* Sets ETH balance,
|