@gearbox-protocol/sdk 8.29.1 → 8.30.1
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 +8 -3
- package/dist/cjs/plugins/zappers/ZappersPlugin.js +2 -1
- package/dist/cjs/sdk/constants/networks.js +3 -2
- package/dist/cjs/sdk/index.js +2 -0
- package/dist/cjs/sdk/poolMigration/index.js +55 -0
- package/dist/esm/dev/AccountOpener.js +8 -3
- package/dist/esm/plugins/zappers/ZappersPlugin.js +2 -1
- package/dist/esm/sdk/constants/networks.js +3 -2
- package/dist/esm/sdk/index.js +1 -0
- package/dist/esm/sdk/poolMigration/index.js +31 -0
- package/dist/types/dev/AccountOpener.d.ts +1 -0
- package/dist/types/sdk/index.d.ts +1 -0
- package/dist/types/sdk/poolMigration/index.d.ts +11 -0
- package/package.json +1 -1
|
@@ -50,6 +50,7 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
50
50
|
#poolDepositMultiplier;
|
|
51
51
|
#minDebtMultiplier;
|
|
52
52
|
#allowMint;
|
|
53
|
+
#leverageDelta;
|
|
53
54
|
constructor(service, options_ = {}) {
|
|
54
55
|
super(service.sdk);
|
|
55
56
|
const {
|
|
@@ -58,6 +59,7 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
58
59
|
faucet,
|
|
59
60
|
poolDepositMultiplier = 30000n,
|
|
60
61
|
minDebtMultiplier = 10100n,
|
|
62
|
+
leverageDelta = 500n,
|
|
61
63
|
allowMint = false
|
|
62
64
|
} = options_;
|
|
63
65
|
this.#service = service;
|
|
@@ -76,6 +78,7 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
76
78
|
this.depositorKey = depositorKey ?? (0, import_accounts.generatePrivateKey)();
|
|
77
79
|
this.#poolDepositMultiplier = BigInt(poolDepositMultiplier);
|
|
78
80
|
this.#minDebtMultiplier = BigInt(minDebtMultiplier);
|
|
81
|
+
this.#leverageDelta = BigInt(leverageDelta);
|
|
79
82
|
}
|
|
80
83
|
get borrower() {
|
|
81
84
|
if (!this.#borrower) {
|
|
@@ -829,9 +832,11 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
829
832
|
}
|
|
830
833
|
const cm = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
831
834
|
const lt = BigInt(cm.creditManager.liquidationThresholds.mustGet(target));
|
|
832
|
-
const d =
|
|
833
|
-
|
|
834
|
-
|
|
835
|
+
const d = this.#leverageDelta;
|
|
836
|
+
let result = import_sdk.PERCENTAGE_FACTOR * (1n + (lt - d) / (import_sdk.PERCENTAGE_FACTOR - lt));
|
|
837
|
+
result = result > import_sdk.PERCENTAGE_FACTOR * 10n ? import_sdk.PERCENTAGE_FACTOR * 10n : result;
|
|
838
|
+
result = BigInt(Math.floor(Number(result) / 1e3) * 1e3);
|
|
839
|
+
return result;
|
|
835
840
|
}
|
|
836
841
|
get faucet() {
|
|
837
842
|
if (!this.#faucet) {
|
|
@@ -93,7 +93,8 @@ class ZappersPlugin extends import_sdk.BasePlugin {
|
|
|
93
93
|
}
|
|
94
94
|
get extraZappers() {
|
|
95
95
|
if (!this.#extraZappers) {
|
|
96
|
-
|
|
96
|
+
console.error("extra zappers not attached");
|
|
97
|
+
return new import_sdk.AddressMap();
|
|
97
98
|
}
|
|
98
99
|
return this.#extraZappers;
|
|
99
100
|
}
|
|
@@ -71,11 +71,12 @@ const BLOCK_DURATION_LOCAL = {
|
|
|
71
71
|
Hemi: 12e3,
|
|
72
72
|
Lisk: 2e3
|
|
73
73
|
};
|
|
74
|
+
const DEFAULT_DURATION = 12e3;
|
|
74
75
|
const BLOCK_DURATION = Object.values(import_chain.chains).reduce(
|
|
75
76
|
(acc, chain) => {
|
|
76
|
-
|
|
77
|
-
if (blockTime === 0)
|
|
77
|
+
if (!chain.blockTime || chain.blockTime === 0)
|
|
78
78
|
console.error(`Block time for ${chain.name} is unknown`);
|
|
79
|
+
const blockTime = chain.blockTime || BLOCK_DURATION_LOCAL[chain.network] || DEFAULT_DURATION;
|
|
79
80
|
acc[chain.network] = blockTime / 1e3;
|
|
80
81
|
return acc;
|
|
81
82
|
},
|
package/dist/cjs/sdk/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __reExport(sdk_exports, require("./gauges/index.js"), module.exports);
|
|
|
26
26
|
__reExport(sdk_exports, require("./market/index.js"), module.exports);
|
|
27
27
|
__reExport(sdk_exports, require("./options.js"), module.exports);
|
|
28
28
|
__reExport(sdk_exports, require("./plugins/index.js"), module.exports);
|
|
29
|
+
__reExport(sdk_exports, require("./poolMigration/index.js"), module.exports);
|
|
29
30
|
__reExport(sdk_exports, require("./router/index.js"), module.exports);
|
|
30
31
|
__reExport(sdk_exports, require("./sdk-gov-legacy/index.js"), module.exports);
|
|
31
32
|
__reExport(sdk_exports, require("./sdk-legacy/index.js"), module.exports);
|
|
@@ -45,6 +46,7 @@ __reExport(sdk_exports, require("./utils/viem/index.js"), module.exports);
|
|
|
45
46
|
...require("./market/index.js"),
|
|
46
47
|
...require("./options.js"),
|
|
47
48
|
...require("./plugins/index.js"),
|
|
49
|
+
...require("./poolMigration/index.js"),
|
|
48
50
|
...require("./router/index.js"),
|
|
49
51
|
...require("./sdk-gov-legacy/index.js"),
|
|
50
52
|
...require("./sdk-legacy/index.js"),
|
|
@@ -0,0 +1,55 @@
|
|
|
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 poolMigration_exports = {};
|
|
20
|
+
__export(poolMigration_exports, {
|
|
21
|
+
POOL_DELAYED_MIGRATION_CONTRACTS: () => POOL_DELAYED_MIGRATION_CONTRACTS
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(poolMigration_exports);
|
|
24
|
+
const POOL_DELAYED_MIGRATION_CONTRACTS = {
|
|
25
|
+
Mainnet: [
|
|
26
|
+
{
|
|
27
|
+
// TODO: fix address
|
|
28
|
+
address: "0xc155444481854c60e7a29f4150373f479988f32d",
|
|
29
|
+
// "dUSDCV3" "Trade USDC v3"
|
|
30
|
+
poolIn: "0xda00000035fef4082f78def6a8903bee419fbf8e",
|
|
31
|
+
// "USDC" "invariant"
|
|
32
|
+
poolOut: "0xc155444481854c60e7a29f4150373f479988f32d"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
// TODO: fix address
|
|
36
|
+
address: "0xf0795c47fa58d00f5f77f4d5c01f31ee891e21b4",
|
|
37
|
+
// "dUSDCV3" "Trade USDC v3"
|
|
38
|
+
poolIn: "0xda00000035fef4082f78def6a8903bee419fbf8e",
|
|
39
|
+
// "USDC" "tulipa"
|
|
40
|
+
poolOut: "0xf0795c47fa58d00f5f77f4d5c01f31ee891e21b4"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
// TODO: fix address
|
|
44
|
+
address: "0xf00b548f1b69cb5ee559d891e03a196fb5101d4a",
|
|
45
|
+
// "dWETHV3" "Trade WETH v3"
|
|
46
|
+
poolIn: "0xda0002859b2d05f66a753d8241fcde8623f26f4f",
|
|
47
|
+
// "dWETHV3-cp0x" "Gearbox WETH v3"
|
|
48
|
+
poolOut: "0xf00b548f1b69cb5ee559d891e03a196fb5101d4a"
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
};
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
POOL_DELAYED_MIGRATION_CONTRACTS
|
|
55
|
+
});
|
|
@@ -43,6 +43,7 @@ class AccountOpener extends SDKConstruct {
|
|
|
43
43
|
#poolDepositMultiplier;
|
|
44
44
|
#minDebtMultiplier;
|
|
45
45
|
#allowMint;
|
|
46
|
+
#leverageDelta;
|
|
46
47
|
constructor(service, options_ = {}) {
|
|
47
48
|
super(service.sdk);
|
|
48
49
|
const {
|
|
@@ -51,6 +52,7 @@ class AccountOpener extends SDKConstruct {
|
|
|
51
52
|
faucet,
|
|
52
53
|
poolDepositMultiplier = 30000n,
|
|
53
54
|
minDebtMultiplier = 10100n,
|
|
55
|
+
leverageDelta = 500n,
|
|
54
56
|
allowMint = false
|
|
55
57
|
} = options_;
|
|
56
58
|
this.#service = service;
|
|
@@ -69,6 +71,7 @@ class AccountOpener extends SDKConstruct {
|
|
|
69
71
|
this.depositorKey = depositorKey ?? generatePrivateKey();
|
|
70
72
|
this.#poolDepositMultiplier = BigInt(poolDepositMultiplier);
|
|
71
73
|
this.#minDebtMultiplier = BigInt(minDebtMultiplier);
|
|
74
|
+
this.#leverageDelta = BigInt(leverageDelta);
|
|
72
75
|
}
|
|
73
76
|
get borrower() {
|
|
74
77
|
if (!this.#borrower) {
|
|
@@ -822,9 +825,11 @@ class AccountOpener extends SDKConstruct {
|
|
|
822
825
|
}
|
|
823
826
|
const cm = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
824
827
|
const lt = BigInt(cm.creditManager.liquidationThresholds.mustGet(target));
|
|
825
|
-
const d =
|
|
826
|
-
|
|
827
|
-
|
|
828
|
+
const d = this.#leverageDelta;
|
|
829
|
+
let result = PERCENTAGE_FACTOR * (1n + (lt - d) / (PERCENTAGE_FACTOR - lt));
|
|
830
|
+
result = result > PERCENTAGE_FACTOR * 10n ? PERCENTAGE_FACTOR * 10n : result;
|
|
831
|
+
result = BigInt(Math.floor(Number(result) / 1e3) * 1e3);
|
|
832
|
+
return result;
|
|
828
833
|
}
|
|
829
834
|
get faucet() {
|
|
830
835
|
if (!this.#faucet) {
|
|
@@ -76,7 +76,8 @@ class ZappersPlugin extends BasePlugin {
|
|
|
76
76
|
}
|
|
77
77
|
get extraZappers() {
|
|
78
78
|
if (!this.#extraZappers) {
|
|
79
|
-
|
|
79
|
+
console.error("extra zappers not attached");
|
|
80
|
+
return new AddressMap();
|
|
80
81
|
}
|
|
81
82
|
return this.#extraZappers;
|
|
82
83
|
}
|
|
@@ -46,11 +46,12 @@ const BLOCK_DURATION_LOCAL = {
|
|
|
46
46
|
Hemi: 12e3,
|
|
47
47
|
Lisk: 2e3
|
|
48
48
|
};
|
|
49
|
+
const DEFAULT_DURATION = 12e3;
|
|
49
50
|
const BLOCK_DURATION = Object.values(CHAINS).reduce(
|
|
50
51
|
(acc, chain) => {
|
|
51
|
-
|
|
52
|
-
if (blockTime === 0)
|
|
52
|
+
if (!chain.blockTime || chain.blockTime === 0)
|
|
53
53
|
console.error(`Block time for ${chain.name} is unknown`);
|
|
54
|
+
const blockTime = chain.blockTime || BLOCK_DURATION_LOCAL[chain.network] || DEFAULT_DURATION;
|
|
54
55
|
acc[chain.network] = blockTime / 1e3;
|
|
55
56
|
return acc;
|
|
56
57
|
},
|
package/dist/esm/sdk/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./gauges/index.js";
|
|
|
9
9
|
export * from "./market/index.js";
|
|
10
10
|
export * from "./options.js";
|
|
11
11
|
export * from "./plugins/index.js";
|
|
12
|
+
export * from "./poolMigration/index.js";
|
|
12
13
|
export * from "./router/index.js";
|
|
13
14
|
export * from "./sdk-gov-legacy/index.js";
|
|
14
15
|
export * from "./sdk-legacy/index.js";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const POOL_DELAYED_MIGRATION_CONTRACTS = {
|
|
2
|
+
Mainnet: [
|
|
3
|
+
{
|
|
4
|
+
// TODO: fix address
|
|
5
|
+
address: "0xc155444481854c60e7a29f4150373f479988f32d",
|
|
6
|
+
// "dUSDCV3" "Trade USDC v3"
|
|
7
|
+
poolIn: "0xda00000035fef4082f78def6a8903bee419fbf8e",
|
|
8
|
+
// "USDC" "invariant"
|
|
9
|
+
poolOut: "0xc155444481854c60e7a29f4150373f479988f32d"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
// TODO: fix address
|
|
13
|
+
address: "0xf0795c47fa58d00f5f77f4d5c01f31ee891e21b4",
|
|
14
|
+
// "dUSDCV3" "Trade USDC v3"
|
|
15
|
+
poolIn: "0xda00000035fef4082f78def6a8903bee419fbf8e",
|
|
16
|
+
// "USDC" "tulipa"
|
|
17
|
+
poolOut: "0xf0795c47fa58d00f5f77f4d5c01f31ee891e21b4"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
// TODO: fix address
|
|
21
|
+
address: "0xf00b548f1b69cb5ee559d891e03a196fb5101d4a",
|
|
22
|
+
// "dWETHV3" "Trade WETH v3"
|
|
23
|
+
poolIn: "0xda0002859b2d05f66a753d8241fcde8623f26f4f",
|
|
24
|
+
// "dWETHV3-cp0x" "Gearbox WETH v3"
|
|
25
|
+
poolOut: "0xf00b548f1b69cb5ee559d891e03a196fb5101d4a"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
POOL_DELAYED_MIGRATION_CONTRACTS
|
|
31
|
+
};
|
|
@@ -12,6 +12,7 @@ export interface AccountOpenerOptions {
|
|
|
12
12
|
depositorKey?: Hex;
|
|
13
13
|
poolDepositMultiplier?: bigint | string | number;
|
|
14
14
|
minDebtMultiplier?: bigint | string | number;
|
|
15
|
+
leverageDelta?: bigint | string | number;
|
|
15
16
|
allowMint?: boolean;
|
|
16
17
|
}
|
|
17
18
|
export interface TargetAccount {
|
|
@@ -9,6 +9,7 @@ export * from "./gauges/index.js";
|
|
|
9
9
|
export * from "./market/index.js";
|
|
10
10
|
export * from "./options.js";
|
|
11
11
|
export * from "./plugins/index.js";
|
|
12
|
+
export * from "./poolMigration/index.js";
|
|
12
13
|
export * from "./router/index.js";
|
|
13
14
|
export * from "./sdk-gov-legacy/index.js";
|
|
14
15
|
export * from "./sdk-legacy/index.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Address } from "abitype";
|
|
2
|
+
import type { NetworkType } from "../chain/chains.js";
|
|
3
|
+
export interface PoolMigrationContract {
|
|
4
|
+
address: Address;
|
|
5
|
+
poolIn: Address;
|
|
6
|
+
poolOut: Address;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Temporary contracts
|
|
10
|
+
*/
|
|
11
|
+
export declare const POOL_DELAYED_MIGRATION_CONTRACTS: Partial<Record<NetworkType, PoolMigrationContract[]>>;
|