@gearbox-protocol/sdk 11.8.4 → 11.8.6
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.
|
@@ -77,6 +77,18 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
77
77
|
this.#poolDepositMultiplier = BigInt(poolDepositMultiplier);
|
|
78
78
|
this.#minDebtMultiplier = BigInt(minDebtMultiplier);
|
|
79
79
|
this.#leverageDelta = BigInt(leverageDelta);
|
|
80
|
+
this.#logger?.info(
|
|
81
|
+
{
|
|
82
|
+
borrower: (0, import_accounts.privateKeyToAccount)(this.borrowerKey).address,
|
|
83
|
+
depositor: (0, import_accounts.privateKeyToAccount)(this.depositorKey).address,
|
|
84
|
+
faucet: this.faucet,
|
|
85
|
+
poolDepositMultiplier: this.#poolDepositMultiplier.toString(),
|
|
86
|
+
minDebtMultiplier: this.#minDebtMultiplier.toString(),
|
|
87
|
+
leverageDelta: this.#leverageDelta.toString(),
|
|
88
|
+
allowMint: this.#allowMint
|
|
89
|
+
},
|
|
90
|
+
"account opener options"
|
|
91
|
+
);
|
|
80
92
|
}
|
|
81
93
|
get borrower() {
|
|
82
94
|
if (!this.#borrower) {
|
|
@@ -94,6 +106,14 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
94
106
|
* Tries to open account with underlying only in each CM
|
|
95
107
|
*/
|
|
96
108
|
async openCreditAccounts(targets, depositIntoPools = true, claimFromFaucet2 = true) {
|
|
109
|
+
this.#logger?.info(
|
|
110
|
+
{
|
|
111
|
+
targets,
|
|
112
|
+
depositIntoPools,
|
|
113
|
+
claimFromFaucet: claimFromFaucet2
|
|
114
|
+
},
|
|
115
|
+
"opening credit accounts"
|
|
116
|
+
);
|
|
97
117
|
let deposits = [];
|
|
98
118
|
if (depositIntoPools) {
|
|
99
119
|
try {
|
|
@@ -364,8 +384,8 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
364
384
|
`target #${i + 1} (${this.labelAddress(t.target)}) needs ${this.sdk.tokensMeta.formatBN(cm.underlying, amount, { symbol: true })} in pool (leverage: ${Number(leverage / import_sdk.PERCENTAGE_FACTOR)}%)`
|
|
365
385
|
);
|
|
366
386
|
}
|
|
367
|
-
let totalUSD = 0n;
|
|
368
387
|
const deposits = [];
|
|
388
|
+
const claims = new import_sdk.AddressMap();
|
|
369
389
|
for (const [p, minAvailable] of Object.entries(minAvailableByPool)) {
|
|
370
390
|
const market = this.sdk.marketRegister.findByPool(p);
|
|
371
391
|
const pool = market.pool.pool;
|
|
@@ -383,17 +403,15 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
383
403
|
);
|
|
384
404
|
if (diff > 0n) {
|
|
385
405
|
deposits.push([pool, diff]);
|
|
386
|
-
|
|
406
|
+
let claim = claims.get(pool.underlying) ?? 0n;
|
|
407
|
+
claim += diff * import_sdk.PERCENTAGE_FACTOR / 8950n;
|
|
408
|
+
claims.upsert(pool.underlying, claim);
|
|
387
409
|
}
|
|
388
410
|
}
|
|
389
|
-
totalUSD = totalUSD * import_sdk.PERCENTAGE_FACTOR / 8950n;
|
|
390
|
-
this.#logger?.debug(
|
|
391
|
-
`total USD to claim from faucet: ${(0, import_sdk.formatBN)(totalUSD, 8)}`
|
|
392
|
-
);
|
|
393
411
|
const depositor = await this.#getDepositor();
|
|
394
412
|
this.#logger?.debug(`depositor: ${depositor.address}`);
|
|
395
413
|
try {
|
|
396
|
-
await this.#claimFromFaucet(depositor, "depositor",
|
|
414
|
+
await this.#claimFromFaucet(depositor, "depositor", claims);
|
|
397
415
|
} catch (e) {
|
|
398
416
|
if (this.#allowMint) {
|
|
399
417
|
this.#logger?.error(`depositor failed to claim from faucet: ${e}`);
|
|
@@ -510,8 +528,8 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
510
528
|
*/
|
|
511
529
|
async #prepareBorrower(targets) {
|
|
512
530
|
const borrower = await this.#getBorrower();
|
|
513
|
-
let claimUSD = 0n;
|
|
514
531
|
const degenNFTS = {};
|
|
532
|
+
const claims = new import_sdk.AddressMap();
|
|
515
533
|
for (const target of targets) {
|
|
516
534
|
const cm = this.sdk.marketRegister.findCreditManager(
|
|
517
535
|
target.creditManager
|
|
@@ -521,27 +539,28 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
521
539
|
);
|
|
522
540
|
const { degenNFT } = cm.creditFacade;
|
|
523
541
|
const minDebt = this.#minDebtMultiplier * cm.creditFacade.minDebt / import_sdk.PERCENTAGE_FACTOR;
|
|
524
|
-
|
|
542
|
+
const claim = claims.get(cm.underlying) ?? 0n;
|
|
543
|
+
claims.upsert(cm.underlying, claim + minDebt * 11n / 10n);
|
|
525
544
|
if ((0, import_viem.isAddress)(degenNFT) && degenNFT !== import_sdk.ADDRESS_0X0) {
|
|
526
545
|
degenNFTS[degenNFT] = (degenNFTS[degenNFT] ?? 0) + 1;
|
|
527
546
|
}
|
|
528
547
|
}
|
|
529
|
-
|
|
530
|
-
await this.#claimFromFaucet(borrower, "borrower", claimUSD);
|
|
548
|
+
await this.#claimFromFaucet(borrower, "borrower", claims);
|
|
531
549
|
for (const [degenNFT, amount] of Object.entries(degenNFTS)) {
|
|
532
550
|
await this.#mintDegenNft(degenNFT, borrower.address, amount);
|
|
533
551
|
}
|
|
534
552
|
this.#logger?.debug("prepared borrower");
|
|
535
553
|
return borrower;
|
|
536
554
|
}
|
|
537
|
-
async #claimFromFaucet(claimer, role,
|
|
555
|
+
async #claimFromFaucet(claimer, role, claims) {
|
|
538
556
|
await (0, import_claimFromFaucet.claimFromFaucet)({
|
|
557
|
+
sdk: this.sdk,
|
|
539
558
|
publicClient: this.#anvil,
|
|
540
559
|
wallet: this.#anvil,
|
|
541
560
|
faucet: this.faucet,
|
|
542
561
|
claimer,
|
|
543
562
|
role,
|
|
544
|
-
|
|
563
|
+
amount: claims.entries().map(([k, v]) => ({ token: k, amount: v })),
|
|
545
564
|
logger: this.#logger
|
|
546
565
|
});
|
|
547
566
|
}
|
|
@@ -677,6 +696,7 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
677
696
|
value: (0, import_viem.parseEther)("100")
|
|
678
697
|
});
|
|
679
698
|
await (0, import_claimFromFaucet.claimFromFaucet)({
|
|
699
|
+
sdk: this.sdk,
|
|
680
700
|
publicClient: this.#anvil,
|
|
681
701
|
wallet: this.#anvil,
|
|
682
702
|
faucet: this.faucet,
|
|
@@ -27,53 +27,66 @@ var import_sdk = require("../sdk/index.js");
|
|
|
27
27
|
const faucetAbi = (0, import_viem.parseAbi)([
|
|
28
28
|
"function minAmountUSD() external view returns (uint256)",
|
|
29
29
|
"function claim() external",
|
|
30
|
-
"function claim(uint256 amountUSD) external"
|
|
30
|
+
"function claim(uint256 amountUSD) external",
|
|
31
|
+
"function claim((address token, uint256 amount)[] claims) external"
|
|
31
32
|
]);
|
|
32
33
|
async function claimFromFaucet(opts) {
|
|
33
34
|
const {
|
|
35
|
+
sdk,
|
|
34
36
|
publicClient,
|
|
35
37
|
wallet,
|
|
36
38
|
faucet,
|
|
37
39
|
claimer,
|
|
38
40
|
role,
|
|
39
|
-
|
|
41
|
+
amount,
|
|
40
42
|
logger,
|
|
41
43
|
gasMultiplier = 10n
|
|
42
44
|
} = opts;
|
|
43
|
-
let
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
let amnt = "default amount";
|
|
46
|
+
let args;
|
|
47
|
+
if (Array.isArray(amount)) {
|
|
48
|
+
args = [amount];
|
|
49
|
+
amnt = amount.map((v) => {
|
|
50
|
+
try {
|
|
51
|
+
return sdk.tokensMeta.formatBN(v.token, v.amount, { symbol: true });
|
|
52
|
+
} catch {
|
|
53
|
+
return `${v.amount} of ${v.token}`;
|
|
54
|
+
}
|
|
55
|
+
}).join(", ");
|
|
56
|
+
} else if (typeof amount === "bigint") {
|
|
57
|
+
args = [amount];
|
|
58
|
+
amnt = `${(0, import_sdk.formatBN)(args[0], 8)} USD`;
|
|
59
|
+
} else if (typeof amount === "function") {
|
|
60
|
+
const minAmountUSD = await (0, import_actions.readContract)(publicClient, {
|
|
48
61
|
address: faucet,
|
|
49
62
|
abi: faucetAbi,
|
|
50
63
|
functionName: "minAmountUSD"
|
|
51
64
|
});
|
|
52
|
-
logger?.debug(`faucet min amount USD: ${
|
|
53
|
-
|
|
65
|
+
logger?.debug(`faucet min amount USD: ${minAmountUSD}`);
|
|
66
|
+
args = [amount(minAmountUSD)];
|
|
67
|
+
amnt = `${(0, import_sdk.formatBN)(args[0], 8)} USD`;
|
|
68
|
+
} else {
|
|
69
|
+
args = [];
|
|
54
70
|
}
|
|
55
|
-
if (
|
|
71
|
+
if (args[0] === 0n) {
|
|
56
72
|
logger?.debug("amount is 0, skipping claim");
|
|
57
73
|
return;
|
|
58
74
|
}
|
|
59
|
-
const [
|
|
60
|
-
|
|
61
|
-
toClaimUSD ? (0, import_sdk.formatBN)(toClaimUSD, 8) : "default amount"
|
|
62
|
-
];
|
|
63
|
-
logger?.debug(`${usr} claiming ${amnt} USD from faucet`);
|
|
75
|
+
const usr = [role, claimer.address].filter(Boolean).join(" ");
|
|
76
|
+
logger?.debug(`${usr} claiming ${amnt} from faucet`);
|
|
64
77
|
const gas = await publicClient.estimateContractGas({
|
|
65
78
|
account: claimer,
|
|
66
79
|
address: faucet,
|
|
67
80
|
abi: faucetAbi,
|
|
68
81
|
functionName: "claim",
|
|
69
|
-
args
|
|
82
|
+
args
|
|
70
83
|
});
|
|
71
84
|
const hash = await wallet.writeContract({
|
|
72
85
|
account: claimer,
|
|
73
86
|
address: faucet,
|
|
74
87
|
abi: faucetAbi,
|
|
75
88
|
functionName: "claim",
|
|
76
|
-
args
|
|
89
|
+
args,
|
|
77
90
|
chain: wallet.chain,
|
|
78
91
|
gas: gas * gasMultiplier
|
|
79
92
|
});
|
|
@@ -82,12 +95,10 @@ async function claimFromFaucet(opts) {
|
|
|
82
95
|
});
|
|
83
96
|
if (receipt.status === "reverted") {
|
|
84
97
|
throw new Error(
|
|
85
|
-
`${usr} failed to claimed
|
|
98
|
+
`${usr} failed to claimed ${amnt} from faucet, tx: ${hash}`
|
|
86
99
|
);
|
|
87
100
|
}
|
|
88
|
-
logger?.debug(
|
|
89
|
-
`${usr} claimed equivalent of ${amnt} USD from faucet, tx: ${hash}`
|
|
90
|
-
);
|
|
101
|
+
logger?.debug(`${usr} claimed ${amnt} from faucet, tx: ${hash}`);
|
|
91
102
|
}
|
|
92
103
|
// Annotate the CommonJS export names for ESM import in node:
|
|
93
104
|
0 && (module.exports = {
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
AddressMap,
|
|
14
14
|
AddressSet,
|
|
15
15
|
childLogger,
|
|
16
|
-
formatBN,
|
|
17
16
|
MAX_UINT256,
|
|
18
17
|
PERCENTAGE_FACTOR,
|
|
19
18
|
SDKConstruct,
|
|
@@ -69,6 +68,18 @@ class AccountOpener extends SDKConstruct {
|
|
|
69
68
|
this.#poolDepositMultiplier = BigInt(poolDepositMultiplier);
|
|
70
69
|
this.#minDebtMultiplier = BigInt(minDebtMultiplier);
|
|
71
70
|
this.#leverageDelta = BigInt(leverageDelta);
|
|
71
|
+
this.#logger?.info(
|
|
72
|
+
{
|
|
73
|
+
borrower: privateKeyToAccount(this.borrowerKey).address,
|
|
74
|
+
depositor: privateKeyToAccount(this.depositorKey).address,
|
|
75
|
+
faucet: this.faucet,
|
|
76
|
+
poolDepositMultiplier: this.#poolDepositMultiplier.toString(),
|
|
77
|
+
minDebtMultiplier: this.#minDebtMultiplier.toString(),
|
|
78
|
+
leverageDelta: this.#leverageDelta.toString(),
|
|
79
|
+
allowMint: this.#allowMint
|
|
80
|
+
},
|
|
81
|
+
"account opener options"
|
|
82
|
+
);
|
|
72
83
|
}
|
|
73
84
|
get borrower() {
|
|
74
85
|
if (!this.#borrower) {
|
|
@@ -86,6 +97,14 @@ class AccountOpener extends SDKConstruct {
|
|
|
86
97
|
* Tries to open account with underlying only in each CM
|
|
87
98
|
*/
|
|
88
99
|
async openCreditAccounts(targets, depositIntoPools = true, claimFromFaucet2 = true) {
|
|
100
|
+
this.#logger?.info(
|
|
101
|
+
{
|
|
102
|
+
targets,
|
|
103
|
+
depositIntoPools,
|
|
104
|
+
claimFromFaucet: claimFromFaucet2
|
|
105
|
+
},
|
|
106
|
+
"opening credit accounts"
|
|
107
|
+
);
|
|
89
108
|
let deposits = [];
|
|
90
109
|
if (depositIntoPools) {
|
|
91
110
|
try {
|
|
@@ -356,8 +375,8 @@ class AccountOpener extends SDKConstruct {
|
|
|
356
375
|
`target #${i + 1} (${this.labelAddress(t.target)}) needs ${this.sdk.tokensMeta.formatBN(cm.underlying, amount, { symbol: true })} in pool (leverage: ${Number(leverage / PERCENTAGE_FACTOR)}%)`
|
|
357
376
|
);
|
|
358
377
|
}
|
|
359
|
-
let totalUSD = 0n;
|
|
360
378
|
const deposits = [];
|
|
379
|
+
const claims = new AddressMap();
|
|
361
380
|
for (const [p, minAvailable] of Object.entries(minAvailableByPool)) {
|
|
362
381
|
const market = this.sdk.marketRegister.findByPool(p);
|
|
363
382
|
const pool = market.pool.pool;
|
|
@@ -375,17 +394,15 @@ class AccountOpener extends SDKConstruct {
|
|
|
375
394
|
);
|
|
376
395
|
if (diff > 0n) {
|
|
377
396
|
deposits.push([pool, diff]);
|
|
378
|
-
|
|
397
|
+
let claim = claims.get(pool.underlying) ?? 0n;
|
|
398
|
+
claim += diff * PERCENTAGE_FACTOR / 8950n;
|
|
399
|
+
claims.upsert(pool.underlying, claim);
|
|
379
400
|
}
|
|
380
401
|
}
|
|
381
|
-
totalUSD = totalUSD * PERCENTAGE_FACTOR / 8950n;
|
|
382
|
-
this.#logger?.debug(
|
|
383
|
-
`total USD to claim from faucet: ${formatBN(totalUSD, 8)}`
|
|
384
|
-
);
|
|
385
402
|
const depositor = await this.#getDepositor();
|
|
386
403
|
this.#logger?.debug(`depositor: ${depositor.address}`);
|
|
387
404
|
try {
|
|
388
|
-
await this.#claimFromFaucet(depositor, "depositor",
|
|
405
|
+
await this.#claimFromFaucet(depositor, "depositor", claims);
|
|
389
406
|
} catch (e) {
|
|
390
407
|
if (this.#allowMint) {
|
|
391
408
|
this.#logger?.error(`depositor failed to claim from faucet: ${e}`);
|
|
@@ -502,8 +519,8 @@ class AccountOpener extends SDKConstruct {
|
|
|
502
519
|
*/
|
|
503
520
|
async #prepareBorrower(targets) {
|
|
504
521
|
const borrower = await this.#getBorrower();
|
|
505
|
-
let claimUSD = 0n;
|
|
506
522
|
const degenNFTS = {};
|
|
523
|
+
const claims = new AddressMap();
|
|
507
524
|
for (const target of targets) {
|
|
508
525
|
const cm = this.sdk.marketRegister.findCreditManager(
|
|
509
526
|
target.creditManager
|
|
@@ -513,27 +530,28 @@ class AccountOpener extends SDKConstruct {
|
|
|
513
530
|
);
|
|
514
531
|
const { degenNFT } = cm.creditFacade;
|
|
515
532
|
const minDebt = this.#minDebtMultiplier * cm.creditFacade.minDebt / PERCENTAGE_FACTOR;
|
|
516
|
-
|
|
533
|
+
const claim = claims.get(cm.underlying) ?? 0n;
|
|
534
|
+
claims.upsert(cm.underlying, claim + minDebt * 11n / 10n);
|
|
517
535
|
if (isAddress(degenNFT) && degenNFT !== ADDRESS_0X0) {
|
|
518
536
|
degenNFTS[degenNFT] = (degenNFTS[degenNFT] ?? 0) + 1;
|
|
519
537
|
}
|
|
520
538
|
}
|
|
521
|
-
|
|
522
|
-
await this.#claimFromFaucet(borrower, "borrower", claimUSD);
|
|
539
|
+
await this.#claimFromFaucet(borrower, "borrower", claims);
|
|
523
540
|
for (const [degenNFT, amount] of Object.entries(degenNFTS)) {
|
|
524
541
|
await this.#mintDegenNft(degenNFT, borrower.address, amount);
|
|
525
542
|
}
|
|
526
543
|
this.#logger?.debug("prepared borrower");
|
|
527
544
|
return borrower;
|
|
528
545
|
}
|
|
529
|
-
async #claimFromFaucet(claimer, role,
|
|
546
|
+
async #claimFromFaucet(claimer, role, claims) {
|
|
530
547
|
await claimFromFaucet({
|
|
548
|
+
sdk: this.sdk,
|
|
531
549
|
publicClient: this.#anvil,
|
|
532
550
|
wallet: this.#anvil,
|
|
533
551
|
faucet: this.faucet,
|
|
534
552
|
claimer,
|
|
535
553
|
role,
|
|
536
|
-
|
|
554
|
+
amount: claims.entries().map(([k, v]) => ({ token: k, amount: v })),
|
|
537
555
|
logger: this.#logger
|
|
538
556
|
});
|
|
539
557
|
}
|
|
@@ -669,6 +687,7 @@ class AccountOpener extends SDKConstruct {
|
|
|
669
687
|
value: parseEther("100")
|
|
670
688
|
});
|
|
671
689
|
await claimFromFaucet({
|
|
690
|
+
sdk: this.sdk,
|
|
672
691
|
publicClient: this.#anvil,
|
|
673
692
|
wallet: this.#anvil,
|
|
674
693
|
faucet: this.faucet,
|
|
@@ -6,53 +6,66 @@ import { formatBN } from "../sdk/index.js";
|
|
|
6
6
|
const faucetAbi = parseAbi([
|
|
7
7
|
"function minAmountUSD() external view returns (uint256)",
|
|
8
8
|
"function claim() external",
|
|
9
|
-
"function claim(uint256 amountUSD) external"
|
|
9
|
+
"function claim(uint256 amountUSD) external",
|
|
10
|
+
"function claim((address token, uint256 amount)[] claims) external"
|
|
10
11
|
]);
|
|
11
12
|
async function claimFromFaucet(opts) {
|
|
12
13
|
const {
|
|
14
|
+
sdk,
|
|
13
15
|
publicClient,
|
|
14
16
|
wallet,
|
|
15
17
|
faucet,
|
|
16
18
|
claimer,
|
|
17
19
|
role,
|
|
18
|
-
|
|
20
|
+
amount,
|
|
19
21
|
logger,
|
|
20
22
|
gasMultiplier = 10n
|
|
21
23
|
} = opts;
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
let amnt = "default amount";
|
|
25
|
+
let args;
|
|
26
|
+
if (Array.isArray(amount)) {
|
|
27
|
+
args = [amount];
|
|
28
|
+
amnt = amount.map((v) => {
|
|
29
|
+
try {
|
|
30
|
+
return sdk.tokensMeta.formatBN(v.token, v.amount, { symbol: true });
|
|
31
|
+
} catch {
|
|
32
|
+
return `${v.amount} of ${v.token}`;
|
|
33
|
+
}
|
|
34
|
+
}).join(", ");
|
|
35
|
+
} else if (typeof amount === "bigint") {
|
|
36
|
+
args = [amount];
|
|
37
|
+
amnt = `${formatBN(args[0], 8)} USD`;
|
|
38
|
+
} else if (typeof amount === "function") {
|
|
39
|
+
const minAmountUSD = await readContract(publicClient, {
|
|
27
40
|
address: faucet,
|
|
28
41
|
abi: faucetAbi,
|
|
29
42
|
functionName: "minAmountUSD"
|
|
30
43
|
});
|
|
31
|
-
logger?.debug(`faucet min amount USD: ${
|
|
32
|
-
|
|
44
|
+
logger?.debug(`faucet min amount USD: ${minAmountUSD}`);
|
|
45
|
+
args = [amount(minAmountUSD)];
|
|
46
|
+
amnt = `${formatBN(args[0], 8)} USD`;
|
|
47
|
+
} else {
|
|
48
|
+
args = [];
|
|
33
49
|
}
|
|
34
|
-
if (
|
|
50
|
+
if (args[0] === 0n) {
|
|
35
51
|
logger?.debug("amount is 0, skipping claim");
|
|
36
52
|
return;
|
|
37
53
|
}
|
|
38
|
-
const [
|
|
39
|
-
|
|
40
|
-
toClaimUSD ? formatBN(toClaimUSD, 8) : "default amount"
|
|
41
|
-
];
|
|
42
|
-
logger?.debug(`${usr} claiming ${amnt} USD from faucet`);
|
|
54
|
+
const usr = [role, claimer.address].filter(Boolean).join(" ");
|
|
55
|
+
logger?.debug(`${usr} claiming ${amnt} from faucet`);
|
|
43
56
|
const gas = await publicClient.estimateContractGas({
|
|
44
57
|
account: claimer,
|
|
45
58
|
address: faucet,
|
|
46
59
|
abi: faucetAbi,
|
|
47
60
|
functionName: "claim",
|
|
48
|
-
args
|
|
61
|
+
args
|
|
49
62
|
});
|
|
50
63
|
const hash = await wallet.writeContract({
|
|
51
64
|
account: claimer,
|
|
52
65
|
address: faucet,
|
|
53
66
|
abi: faucetAbi,
|
|
54
67
|
functionName: "claim",
|
|
55
|
-
args
|
|
68
|
+
args,
|
|
56
69
|
chain: wallet.chain,
|
|
57
70
|
gas: gas * gasMultiplier
|
|
58
71
|
});
|
|
@@ -61,12 +74,10 @@ async function claimFromFaucet(opts) {
|
|
|
61
74
|
});
|
|
62
75
|
if (receipt.status === "reverted") {
|
|
63
76
|
throw new Error(
|
|
64
|
-
`${usr} failed to claimed
|
|
77
|
+
`${usr} failed to claimed ${amnt} from faucet, tx: ${hash}`
|
|
65
78
|
);
|
|
66
79
|
}
|
|
67
|
-
logger?.debug(
|
|
68
|
-
`${usr} claimed equivalent of ${amnt} USD from faucet, tx: ${hash}`
|
|
69
|
-
);
|
|
80
|
+
logger?.debug(`${usr} claimed ${amnt} from faucet, tx: ${hash}`);
|
|
70
81
|
}
|
|
71
82
|
export {
|
|
72
83
|
claimFromFaucet
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import { type Account, type Address, type PublicClient, type WalletClient } from "viem";
|
|
2
|
-
import { type ILogger } from "../sdk/index.js";
|
|
2
|
+
import { type GearboxSDK, type ILogger } from "../sdk/index.js";
|
|
3
|
+
interface TokenClaim {
|
|
4
|
+
token: Address;
|
|
5
|
+
amount: bigint;
|
|
6
|
+
}
|
|
3
7
|
interface ClaimFromFaucetOptions {
|
|
8
|
+
sdk: GearboxSDK;
|
|
4
9
|
publicClient: PublicClient;
|
|
5
10
|
wallet: WalletClient;
|
|
6
11
|
faucet: Address;
|
|
7
12
|
claimer: Account;
|
|
8
13
|
role?: string;
|
|
9
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Either:
|
|
16
|
+
* - List of tokens with exact amounts to claim
|
|
17
|
+
* - Amount in USD
|
|
18
|
+
* - Function that returns amount in USD
|
|
19
|
+
* - Undefined (will claim default amount)
|
|
20
|
+
*/
|
|
21
|
+
amount?: TokenClaim[] | bigint | ((minAmountUSD: bigint) => bigint);
|
|
10
22
|
gasMultiplier?: bigint;
|
|
11
23
|
logger?: ILogger;
|
|
12
24
|
}
|