@gearbox-protocol/sdk 8.6.0 → 8.6.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/cjs/dev/AccountOpener.js +10 -36
- package/dist/cjs/dev/claimFromFaucet.js +87 -0
- package/dist/cjs/dev/index.js +2 -0
- package/dist/cjs/sdk/chain/chains.js +2 -2
- package/dist/cjs/sdk/core/BotListV3Contract.js +1 -1
- package/dist/cjs/sdk/core/address-provider/AddressProviderV300Contract.js +1 -2
- package/dist/cjs/sdk/plugins/V300StalenessPeriodPlugin.js +1 -1
- package/dist/esm/dev/AccountOpener.js +10 -36
- package/dist/esm/dev/claimFromFaucet.js +63 -0
- package/dist/esm/dev/index.js +1 -0
- package/dist/esm/sdk/chain/chains.js +1 -1
- package/dist/esm/sdk/core/BotListV3Contract.js +2 -5
- package/dist/esm/sdk/core/address-provider/AddressProviderV300Contract.js +1 -2
- package/dist/esm/sdk/plugins/V300StalenessPeriodPlugin.js +2 -2
- package/dist/types/dev/claimFromFaucet.d.ts +13 -0
- package/dist/types/dev/index.d.ts +1 -0
- package/dist/types/sdk/chain/Provider.d.ts +3 -3
- package/dist/types/sdk/chain/chains.d.ts +17 -2
- package/package.json +3 -3
|
@@ -28,6 +28,7 @@ var import_iERC20 = require("../abi/iERC20.js");
|
|
|
28
28
|
var import_v300 = require("../abi/v300.js");
|
|
29
29
|
var import_sdk = require("../sdk/index.js");
|
|
30
30
|
var import_abi = require("./abi.js");
|
|
31
|
+
var import_claimFromFaucet = require("./claimFromFaucet.js");
|
|
31
32
|
var import_createAnvilClient = require("./createAnvilClient.js");
|
|
32
33
|
class OpenTxRevertedError extends import_viem.BaseError {
|
|
33
34
|
txHash;
|
|
@@ -68,7 +69,7 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
68
69
|
/**
|
|
69
70
|
* Tries to open account with underlying only in each CM
|
|
70
71
|
*/
|
|
71
|
-
async openCreditAccounts(targets, depositIntoPools = true,
|
|
72
|
+
async openCreditAccounts(targets, depositIntoPools = true, claimFromFaucet2 = true) {
|
|
72
73
|
if (depositIntoPools) {
|
|
73
74
|
try {
|
|
74
75
|
await this.#depositIntoPools(targets);
|
|
@@ -76,7 +77,7 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
76
77
|
this.#logger?.warn(`failed to deposit into pools: ${e}`);
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
|
-
if (
|
|
80
|
+
if (claimFromFaucet2) {
|
|
80
81
|
await this.#prepareBorrower(targets);
|
|
81
82
|
}
|
|
82
83
|
const toApprove = new import_sdk.AddressMap();
|
|
@@ -386,41 +387,14 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
386
387
|
return borrower;
|
|
387
388
|
}
|
|
388
389
|
async #claimFromFaucet(claimer, role, amountUSD) {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
account: claimer,
|
|
397
|
-
address: this.faucet,
|
|
398
|
-
abi: [
|
|
399
|
-
{
|
|
400
|
-
type: "function",
|
|
401
|
-
inputs: [
|
|
402
|
-
{ name: "amountUSD", internalType: "uint256", type: "uint256" }
|
|
403
|
-
],
|
|
404
|
-
name: "claim",
|
|
405
|
-
outputs: [],
|
|
406
|
-
stateMutability: "nonpayable"
|
|
407
|
-
}
|
|
408
|
-
],
|
|
409
|
-
functionName: "claim",
|
|
410
|
-
args: [amountUSD],
|
|
411
|
-
chain: this.#anvil.chain
|
|
412
|
-
});
|
|
413
|
-
const receipt = await this.#anvil.waitForTransactionReceipt({
|
|
414
|
-
hash
|
|
390
|
+
await (0, import_claimFromFaucet.claimFromFaucet)({
|
|
391
|
+
anvil: this.#anvil,
|
|
392
|
+
faucet: this.faucet,
|
|
393
|
+
claimer,
|
|
394
|
+
role,
|
|
395
|
+
amountUSD,
|
|
396
|
+
logger: this.#logger
|
|
415
397
|
});
|
|
416
|
-
if (receipt.status === "reverted") {
|
|
417
|
-
throw new Error(
|
|
418
|
-
`${role} ${usr} failed to claimed equivalent of ${amnt} USD from faucet, tx: ${hash}`
|
|
419
|
-
);
|
|
420
|
-
}
|
|
421
|
-
this.#logger?.debug(
|
|
422
|
-
`${role} ${usr} claimed equivalent of ${amnt} USD from faucet, tx: ${hash}`
|
|
423
|
-
);
|
|
424
398
|
}
|
|
425
399
|
async #approve(token, cm) {
|
|
426
400
|
const borrower = await this.#getBorrower();
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var claimFromFaucet_exports = {};
|
|
20
|
+
__export(claimFromFaucet_exports, {
|
|
21
|
+
claimFromFaucet: () => claimFromFaucet
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(claimFromFaucet_exports);
|
|
24
|
+
var import_viem = require("viem");
|
|
25
|
+
var import_actions = require("viem/actions");
|
|
26
|
+
var import_sdk = require("../sdk/index.js");
|
|
27
|
+
const faucetAbi = (0, import_viem.parseAbi)([
|
|
28
|
+
"function minAmountUSD() external view returns (uint256)",
|
|
29
|
+
"function claim(uint256 amountUSD) external"
|
|
30
|
+
]);
|
|
31
|
+
async function claimFromFaucet(opts) {
|
|
32
|
+
const { anvil, faucet, claimer, role, amountUSD, logger } = opts;
|
|
33
|
+
let toClaimUSD;
|
|
34
|
+
if (typeof amountUSD === "function") {
|
|
35
|
+
toClaimUSD = await (0, import_actions.readContract)(anvil, {
|
|
36
|
+
address: faucet,
|
|
37
|
+
abi: faucetAbi,
|
|
38
|
+
functionName: "minAmountUSD"
|
|
39
|
+
});
|
|
40
|
+
logger?.debug(`faucet min amount USD: ${toClaimUSD}`);
|
|
41
|
+
toClaimUSD = amountUSD(toClaimUSD);
|
|
42
|
+
} else {
|
|
43
|
+
toClaimUSD = amountUSD;
|
|
44
|
+
}
|
|
45
|
+
if (toClaimUSD === 0n) {
|
|
46
|
+
logger?.debug("amount is 0, skipping claim");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const [usr, amnt] = [
|
|
50
|
+
[role, claimer.address].filter(Boolean).join(" "),
|
|
51
|
+
(0, import_sdk.formatBN)(toClaimUSD, 8)
|
|
52
|
+
];
|
|
53
|
+
logger?.debug(`${usr} claiming ${amnt} USD from faucet`);
|
|
54
|
+
const hash = await anvil.writeContract({
|
|
55
|
+
account: claimer,
|
|
56
|
+
address: faucet,
|
|
57
|
+
abi: [
|
|
58
|
+
{
|
|
59
|
+
type: "function",
|
|
60
|
+
inputs: [
|
|
61
|
+
{ name: "amountUSD", internalType: "uint256", type: "uint256" }
|
|
62
|
+
],
|
|
63
|
+
name: "claim",
|
|
64
|
+
outputs: [],
|
|
65
|
+
stateMutability: "nonpayable"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
functionName: "claim",
|
|
69
|
+
args: [toClaimUSD],
|
|
70
|
+
chain: anvil.chain
|
|
71
|
+
});
|
|
72
|
+
const receipt = await anvil.waitForTransactionReceipt({
|
|
73
|
+
hash
|
|
74
|
+
});
|
|
75
|
+
if (receipt.status === "reverted") {
|
|
76
|
+
throw new Error(
|
|
77
|
+
`${usr} failed to claimed equivalent of ${amnt} USD from faucet, tx: ${hash}`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
logger?.debug(
|
|
81
|
+
`${usr} claimed equivalent of ${amnt} USD from faucet, tx: ${hash}`
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
claimFromFaucet
|
|
87
|
+
});
|
package/dist/cjs/dev/index.js
CHANGED
|
@@ -18,6 +18,7 @@ module.exports = __toCommonJS(dev_exports);
|
|
|
18
18
|
__reExport(dev_exports, require("./AccountOpener.js"), module.exports);
|
|
19
19
|
__reExport(dev_exports, require("./CachedStateSubscriber.js"), module.exports);
|
|
20
20
|
__reExport(dev_exports, require("./calcLiquidatableLTs.js"), module.exports);
|
|
21
|
+
__reExport(dev_exports, require("./claimFromFaucet.js"), module.exports);
|
|
21
22
|
__reExport(dev_exports, require("./create2.js"), module.exports);
|
|
22
23
|
__reExport(dev_exports, require("./createAnvilClient.js"), module.exports);
|
|
23
24
|
__reExport(dev_exports, require("./createTransport.js"), module.exports);
|
|
@@ -29,6 +30,7 @@ __reExport(dev_exports, require("./migrateFaucet.js"), module.exports);
|
|
|
29
30
|
...require("./AccountOpener.js"),
|
|
30
31
|
...require("./CachedStateSubscriber.js"),
|
|
31
32
|
...require("./calcLiquidatableLTs.js"),
|
|
33
|
+
...require("./claimFromFaucet.js"),
|
|
32
34
|
...require("./create2.js"),
|
|
33
35
|
...require("./createAnvilClient.js"),
|
|
34
36
|
...require("./createTransport.js"),
|
|
@@ -29,7 +29,7 @@ __export(chains_exports, {
|
|
|
29
29
|
module.exports = __toCommonJS(chains_exports);
|
|
30
30
|
var import_viem = require("viem");
|
|
31
31
|
var import_chains = require("viem/chains");
|
|
32
|
-
var
|
|
32
|
+
var import_v4 = require("zod/v4");
|
|
33
33
|
const SUPPORTED_NETWORKS = [
|
|
34
34
|
"Mainnet",
|
|
35
35
|
"Arbitrum",
|
|
@@ -46,7 +46,7 @@ const SUPPORTED_NETWORKS = [
|
|
|
46
46
|
"Hemi",
|
|
47
47
|
"Lisk"
|
|
48
48
|
];
|
|
49
|
-
const NetworkType =
|
|
49
|
+
const NetworkType = import_v4.z.enum(SUPPORTED_NETWORKS);
|
|
50
50
|
function withPublicNode(chain, subdomain) {
|
|
51
51
|
return (0, import_viem.defineChain)({
|
|
52
52
|
...chain,
|
|
@@ -30,7 +30,7 @@ class BotListContract extends import_base.BaseContract {
|
|
|
30
30
|
#currentBlock;
|
|
31
31
|
constructor(sdk, address) {
|
|
32
32
|
super(sdk, { addr: address, name: "BotListV3", abi });
|
|
33
|
-
this.#currentBlock =
|
|
33
|
+
this.#currentBlock = sdk.provider.chain.firstBlock ?? 0n;
|
|
34
34
|
}
|
|
35
35
|
parseFunctionParams(params) {
|
|
36
36
|
switch (params.functionName) {
|
|
@@ -33,7 +33,6 @@ __export(AddressProviderV300Contract_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(AddressProviderV300Contract_exports);
|
|
34
34
|
var import_viem = require("viem");
|
|
35
35
|
var import_v300 = require("../../../abi/v300.js");
|
|
36
|
-
var import_constants = require("../../constants/index.js");
|
|
37
36
|
var import_viem2 = require("../../utils/viem/index.js");
|
|
38
37
|
var import_AbstractAddressProviderContract = __toESM(require("./AbstractAddressProviderContract.js"));
|
|
39
38
|
const abi = import_v300.iAddressProviderV300Abi;
|
|
@@ -86,7 +85,7 @@ class AddressProviderV300Contract extends import_AbstractAddressProviderContract
|
|
|
86
85
|
}
|
|
87
86
|
}
|
|
88
87
|
async syncState(blockNumber) {
|
|
89
|
-
const fromBlock =
|
|
88
|
+
const fromBlock = this.sdk.provider.chain.firstBlock;
|
|
90
89
|
this.logger?.debug(
|
|
91
90
|
`loading events from block ${fromBlock} to ${blockNumber}`
|
|
92
91
|
);
|
|
@@ -34,7 +34,7 @@ class V300StalenessPeriodPlugin extends import_BasePlugin.BasePlugin {
|
|
|
34
34
|
#events = [];
|
|
35
35
|
set sdk(sdk) {
|
|
36
36
|
super.sdk = sdk;
|
|
37
|
-
this.#syncedTo =
|
|
37
|
+
this.#syncedTo = (sdk.provider.chain.firstBlock ?? 1n) - 1n;
|
|
38
38
|
}
|
|
39
39
|
get sdk() {
|
|
40
40
|
return super.sdk;
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
sendRawTx
|
|
14
14
|
} from "../sdk/index.js";
|
|
15
15
|
import { iDegenNftv2Abi } from "./abi.js";
|
|
16
|
+
import { claimFromFaucet } from "./claimFromFaucet.js";
|
|
16
17
|
import { createAnvilClient } from "./createAnvilClient.js";
|
|
17
18
|
class OpenTxRevertedError extends BaseError {
|
|
18
19
|
txHash;
|
|
@@ -53,7 +54,7 @@ class AccountOpener extends SDKConstruct {
|
|
|
53
54
|
/**
|
|
54
55
|
* Tries to open account with underlying only in each CM
|
|
55
56
|
*/
|
|
56
|
-
async openCreditAccounts(targets, depositIntoPools = true,
|
|
57
|
+
async openCreditAccounts(targets, depositIntoPools = true, claimFromFaucet2 = true) {
|
|
57
58
|
if (depositIntoPools) {
|
|
58
59
|
try {
|
|
59
60
|
await this.#depositIntoPools(targets);
|
|
@@ -61,7 +62,7 @@ class AccountOpener extends SDKConstruct {
|
|
|
61
62
|
this.#logger?.warn(`failed to deposit into pools: ${e}`);
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
|
-
if (
|
|
65
|
+
if (claimFromFaucet2) {
|
|
65
66
|
await this.#prepareBorrower(targets);
|
|
66
67
|
}
|
|
67
68
|
const toApprove = new AddressMap();
|
|
@@ -371,41 +372,14 @@ class AccountOpener extends SDKConstruct {
|
|
|
371
372
|
return borrower;
|
|
372
373
|
}
|
|
373
374
|
async #claimFromFaucet(claimer, role, amountUSD) {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
account: claimer,
|
|
382
|
-
address: this.faucet,
|
|
383
|
-
abi: [
|
|
384
|
-
{
|
|
385
|
-
type: "function",
|
|
386
|
-
inputs: [
|
|
387
|
-
{ name: "amountUSD", internalType: "uint256", type: "uint256" }
|
|
388
|
-
],
|
|
389
|
-
name: "claim",
|
|
390
|
-
outputs: [],
|
|
391
|
-
stateMutability: "nonpayable"
|
|
392
|
-
}
|
|
393
|
-
],
|
|
394
|
-
functionName: "claim",
|
|
395
|
-
args: [amountUSD],
|
|
396
|
-
chain: this.#anvil.chain
|
|
397
|
-
});
|
|
398
|
-
const receipt = await this.#anvil.waitForTransactionReceipt({
|
|
399
|
-
hash
|
|
375
|
+
await claimFromFaucet({
|
|
376
|
+
anvil: this.#anvil,
|
|
377
|
+
faucet: this.faucet,
|
|
378
|
+
claimer,
|
|
379
|
+
role,
|
|
380
|
+
amountUSD,
|
|
381
|
+
logger: this.#logger
|
|
400
382
|
});
|
|
401
|
-
if (receipt.status === "reverted") {
|
|
402
|
-
throw new Error(
|
|
403
|
-
`${role} ${usr} failed to claimed equivalent of ${amnt} USD from faucet, tx: ${hash}`
|
|
404
|
-
);
|
|
405
|
-
}
|
|
406
|
-
this.#logger?.debug(
|
|
407
|
-
`${role} ${usr} claimed equivalent of ${amnt} USD from faucet, tx: ${hash}`
|
|
408
|
-
);
|
|
409
383
|
}
|
|
410
384
|
async #approve(token, cm) {
|
|
411
385
|
const borrower = await this.#getBorrower();
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { parseAbi } from "viem";
|
|
2
|
+
import { readContract } from "viem/actions";
|
|
3
|
+
import { formatBN } from "../sdk/index.js";
|
|
4
|
+
const faucetAbi = parseAbi([
|
|
5
|
+
"function minAmountUSD() external view returns (uint256)",
|
|
6
|
+
"function claim(uint256 amountUSD) external"
|
|
7
|
+
]);
|
|
8
|
+
async function claimFromFaucet(opts) {
|
|
9
|
+
const { anvil, faucet, claimer, role, amountUSD, logger } = opts;
|
|
10
|
+
let toClaimUSD;
|
|
11
|
+
if (typeof amountUSD === "function") {
|
|
12
|
+
toClaimUSD = await readContract(anvil, {
|
|
13
|
+
address: faucet,
|
|
14
|
+
abi: faucetAbi,
|
|
15
|
+
functionName: "minAmountUSD"
|
|
16
|
+
});
|
|
17
|
+
logger?.debug(`faucet min amount USD: ${toClaimUSD}`);
|
|
18
|
+
toClaimUSD = amountUSD(toClaimUSD);
|
|
19
|
+
} else {
|
|
20
|
+
toClaimUSD = amountUSD;
|
|
21
|
+
}
|
|
22
|
+
if (toClaimUSD === 0n) {
|
|
23
|
+
logger?.debug("amount is 0, skipping claim");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const [usr, amnt] = [
|
|
27
|
+
[role, claimer.address].filter(Boolean).join(" "),
|
|
28
|
+
formatBN(toClaimUSD, 8)
|
|
29
|
+
];
|
|
30
|
+
logger?.debug(`${usr} claiming ${amnt} USD from faucet`);
|
|
31
|
+
const hash = await anvil.writeContract({
|
|
32
|
+
account: claimer,
|
|
33
|
+
address: faucet,
|
|
34
|
+
abi: [
|
|
35
|
+
{
|
|
36
|
+
type: "function",
|
|
37
|
+
inputs: [
|
|
38
|
+
{ name: "amountUSD", internalType: "uint256", type: "uint256" }
|
|
39
|
+
],
|
|
40
|
+
name: "claim",
|
|
41
|
+
outputs: [],
|
|
42
|
+
stateMutability: "nonpayable"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
functionName: "claim",
|
|
46
|
+
args: [toClaimUSD],
|
|
47
|
+
chain: anvil.chain
|
|
48
|
+
});
|
|
49
|
+
const receipt = await anvil.waitForTransactionReceipt({
|
|
50
|
+
hash
|
|
51
|
+
});
|
|
52
|
+
if (receipt.status === "reverted") {
|
|
53
|
+
throw new Error(
|
|
54
|
+
`${usr} failed to claimed equivalent of ${amnt} USD from faucet, tx: ${hash}`
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
logger?.debug(
|
|
58
|
+
`${usr} claimed equivalent of ${amnt} USD from faucet, tx: ${hash}`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
claimFromFaucet
|
|
63
|
+
};
|
package/dist/esm/dev/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./AccountOpener.js";
|
|
2
2
|
export * from "./CachedStateSubscriber.js";
|
|
3
3
|
export * from "./calcLiquidatableLTs.js";
|
|
4
|
+
export * from "./claimFromFaucet.js";
|
|
4
5
|
export * from "./create2.js";
|
|
5
6
|
export * from "./createAnvilClient.js";
|
|
6
7
|
export * from "./createTransport.js";
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { iBotListV300Abi } from "../../abi/v300.js";
|
|
2
2
|
import { BaseContract } from "../base/index.js";
|
|
3
|
-
import {
|
|
4
|
-
ADDRESS_PROVIDER_BLOCK,
|
|
5
|
-
botPermissionsToString
|
|
6
|
-
} from "../constants/index.js";
|
|
3
|
+
import { botPermissionsToString } from "../constants/index.js";
|
|
7
4
|
const abi = iBotListV300Abi;
|
|
8
5
|
class BotListContract extends BaseContract {
|
|
9
6
|
#approvedCreditManagers;
|
|
10
7
|
#currentBlock;
|
|
11
8
|
constructor(sdk, address) {
|
|
12
9
|
super(sdk, { addr: address, name: "BotListV3", abi });
|
|
13
|
-
this.#currentBlock =
|
|
10
|
+
this.#currentBlock = sdk.provider.chain.firstBlock ?? 0n;
|
|
14
11
|
}
|
|
15
12
|
parseFunctionParams(params) {
|
|
16
13
|
switch (params.functionName) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { bytesToString, getAbiItem, parseEventLogs, toBytes } from "viem";
|
|
2
2
|
import { iAddressProviderV300Abi } from "../../../abi/v300.js";
|
|
3
|
-
import { ADDRESS_PROVIDER_BLOCK } from "../../constants/index.js";
|
|
4
3
|
import { getLogsSafe } from "../../utils/viem/index.js";
|
|
5
4
|
import AbstractAddressProviderContract from "./AbstractAddressProviderContract.js";
|
|
6
5
|
const abi = iAddressProviderV300Abi;
|
|
@@ -53,7 +52,7 @@ class AddressProviderV300Contract extends AbstractAddressProviderContract {
|
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
async syncState(blockNumber) {
|
|
56
|
-
const fromBlock =
|
|
55
|
+
const fromBlock = this.sdk.provider.chain.firstBlock;
|
|
57
56
|
this.logger?.debug(
|
|
58
57
|
`loading events from block ${fromBlock} to ${blockNumber}`
|
|
59
58
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getAbiItem, getAddress } from "viem";
|
|
2
2
|
import { iPriceOracleV300Abi } from "../../abi/v300.js";
|
|
3
|
-
import {
|
|
3
|
+
import { isV300 } from "../constants/index.js";
|
|
4
4
|
import { PriceFeedRef } from "../market/index.js";
|
|
5
5
|
import { AddressMap, formatDuration, hexEq } from "../utils/index.js";
|
|
6
6
|
import { getLogsSafe } from "../utils/viem/index.js";
|
|
@@ -11,7 +11,7 @@ class V300StalenessPeriodPlugin extends BasePlugin {
|
|
|
11
11
|
#events = [];
|
|
12
12
|
set sdk(sdk) {
|
|
13
13
|
super.sdk = sdk;
|
|
14
|
-
this.#syncedTo =
|
|
14
|
+
this.#syncedTo = (sdk.provider.chain.firstBlock ?? 1n) - 1n;
|
|
15
15
|
}
|
|
16
16
|
get sdk() {
|
|
17
17
|
return super.sdk;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Address, type PrivateKeyAccount } from "viem";
|
|
2
|
+
import { type ILogger } from "../sdk/index.js";
|
|
3
|
+
import type { AnvilClient } from "./createAnvilClient.js";
|
|
4
|
+
interface ClaimFromFaucetOptions {
|
|
5
|
+
anvil: AnvilClient;
|
|
6
|
+
faucet: Address;
|
|
7
|
+
claimer: PrivateKeyAccount;
|
|
8
|
+
role?: string;
|
|
9
|
+
amountUSD: bigint | ((minAmountUSD: bigint) => bigint);
|
|
10
|
+
logger?: ILogger;
|
|
11
|
+
}
|
|
12
|
+
export declare function claimFromFaucet(opts: ClaimFromFaucetOptions): Promise<void>;
|
|
13
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./AccountOpener.js";
|
|
2
2
|
export * from "./CachedStateSubscriber.js";
|
|
3
3
|
export * from "./calcLiquidatableLTs.js";
|
|
4
|
+
export * from "./claimFromFaucet.js";
|
|
4
5
|
export * from "./create2.js";
|
|
5
6
|
export * from "./createAnvilClient.js";
|
|
6
7
|
export * from "./createTransport.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PublicClient, Transport } from "viem";
|
|
2
2
|
import type { IAddressLabeller } from "../base/IAddressLabeller.js";
|
|
3
|
-
import type { NetworkType } from "./chains.js";
|
|
3
|
+
import type { GearboxChain, NetworkType } from "./chains.js";
|
|
4
4
|
export interface NetworkOptions {
|
|
5
5
|
/**
|
|
6
6
|
* Chain Id needs to be set, because we sometimemes use forked testnets with different chain ids
|
|
@@ -36,7 +36,7 @@ export declare function createTransport(opts: TransportOptions & ConnectionOptio
|
|
|
36
36
|
export declare class Provider {
|
|
37
37
|
#private;
|
|
38
38
|
readonly chainId: number;
|
|
39
|
-
readonly chain:
|
|
39
|
+
readonly chain: GearboxChain;
|
|
40
40
|
readonly networkType: NetworkType;
|
|
41
41
|
readonly addressLabels: IAddressLabeller;
|
|
42
42
|
constructor(opts: NetworkOptions & TransportOptions & ConnectionOptions);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Address, Chain } from "viem";
|
|
2
|
-
import { z } from "zod";
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
3
|
export type Curator = "Chaos Labs" | "K3" | "cp0x" | "Re7";
|
|
4
4
|
export interface GearboxChain extends Chain {
|
|
5
5
|
network: NetworkType;
|
|
@@ -28,7 +28,22 @@ export interface GearboxChain extends Chain {
|
|
|
28
28
|
firstBlock?: bigint;
|
|
29
29
|
}
|
|
30
30
|
export declare const SUPPORTED_NETWORKS: readonly ["Mainnet", "Arbitrum", "Optimism", "Base", "Sonic", "MegaETH", "Monad", "Berachain", "Avalanche", "BNB", "WorldChain", "Etherlink", "Hemi", "Lisk"];
|
|
31
|
-
export declare const NetworkType: z.ZodEnum<
|
|
31
|
+
export declare const NetworkType: z.ZodEnum<{
|
|
32
|
+
Mainnet: "Mainnet";
|
|
33
|
+
Arbitrum: "Arbitrum";
|
|
34
|
+
Optimism: "Optimism";
|
|
35
|
+
Base: "Base";
|
|
36
|
+
Sonic: "Sonic";
|
|
37
|
+
MegaETH: "MegaETH";
|
|
38
|
+
Monad: "Monad";
|
|
39
|
+
Berachain: "Berachain";
|
|
40
|
+
Avalanche: "Avalanche";
|
|
41
|
+
BNB: "BNB";
|
|
42
|
+
WorldChain: "WorldChain";
|
|
43
|
+
Etherlink: "Etherlink";
|
|
44
|
+
Hemi: "Hemi";
|
|
45
|
+
Lisk: "Lisk";
|
|
46
|
+
}>;
|
|
32
47
|
export type NetworkType = z.infer<typeof NetworkType>;
|
|
33
48
|
export declare const chains: Record<NetworkType, GearboxChain>;
|
|
34
49
|
export declare function getChain(chainIdOrNetworkType: number | bigint | NetworkType): GearboxChain;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "8.6.
|
|
3
|
+
"version": "8.6.2",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/cjs/sdk/index.js",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"date-fns": "^4.1.0",
|
|
61
61
|
"decimal.js-light": "^2.5.1",
|
|
62
62
|
"viem": ">=2.23.15 <3.0.0",
|
|
63
|
-
"zod": "^
|
|
63
|
+
"zod": "^4.0.5"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@biomejs/biome": "^2.
|
|
66
|
+
"@biomejs/biome": "^2.1.1",
|
|
67
67
|
"@commitlint/cli": "^19.8.1",
|
|
68
68
|
"@commitlint/config-conventional": "^19.8.1",
|
|
69
69
|
"@gearbox-protocol/biome-config": "^1.0.0",
|