@gearbox-protocol/sdk 8.30.0 → 8.30.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.
|
@@ -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) {
|
|
@@ -74,8 +74,6 @@ const BLOCK_DURATION_LOCAL = {
|
|
|
74
74
|
const DEFAULT_DURATION = 12e3;
|
|
75
75
|
const BLOCK_DURATION = Object.values(import_chain.chains).reduce(
|
|
76
76
|
(acc, chain) => {
|
|
77
|
-
if (!chain.blockTime || chain.blockTime === 0)
|
|
78
|
-
console.error(`Block time for ${chain.name} is unknown`);
|
|
79
77
|
const blockTime = chain.blockTime || BLOCK_DURATION_LOCAL[chain.network] || DEFAULT_DURATION;
|
|
80
78
|
acc[chain.network] = blockTime / 1e3;
|
|
81
79
|
return acc;
|
|
@@ -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) {
|
|
@@ -49,8 +49,6 @@ const BLOCK_DURATION_LOCAL = {
|
|
|
49
49
|
const DEFAULT_DURATION = 12e3;
|
|
50
50
|
const BLOCK_DURATION = Object.values(CHAINS).reduce(
|
|
51
51
|
(acc, chain) => {
|
|
52
|
-
if (!chain.blockTime || chain.blockTime === 0)
|
|
53
|
-
console.error(`Block time for ${chain.name} is unknown`);
|
|
54
52
|
const blockTime = chain.blockTime || BLOCK_DURATION_LOCAL[chain.network] || DEFAULT_DURATION;
|
|
55
53
|
acc[chain.network] = blockTime / 1e3;
|
|
56
54
|
return acc;
|
|
@@ -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 {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "8.30.
|
|
3
|
+
"version": "8.30.2",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/cjs/sdk/index.js",
|
|
@@ -54,25 +54,25 @@
|
|
|
54
54
|
"@redstone-finance/evm-connector": "^0.7.5",
|
|
55
55
|
"@redstone-finance/protocol": "^0.7.5",
|
|
56
56
|
"@types/bn.js": "^5.2.0",
|
|
57
|
-
"abitype": "^1.0
|
|
57
|
+
"abitype": "^1.1.0",
|
|
58
58
|
"bn.js": "^5.2.2",
|
|
59
59
|
"buffer": "^6.0.3",
|
|
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": "^4.1.
|
|
63
|
+
"zod": "^4.1.7"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@biomejs/biome": "^2.2.
|
|
66
|
+
"@biomejs/biome": "^2.2.4",
|
|
67
67
|
"@commitlint/cli": "^19.8.1",
|
|
68
68
|
"@commitlint/config-conventional": "^19.8.1",
|
|
69
|
-
"@gearbox-protocol/biome-config": "^1.0.
|
|
69
|
+
"@gearbox-protocol/biome-config": "^1.0.2",
|
|
70
70
|
"@types/cross-spawn": "^6.0.6",
|
|
71
71
|
"axios": "^1.11.0",
|
|
72
72
|
"cross-spawn": "^7.0.6",
|
|
73
73
|
"husky": "^9.1.7",
|
|
74
|
-
"lint-staged": "^16.1.
|
|
75
|
-
"pino": "^9.9.
|
|
74
|
+
"lint-staged": "^16.1.6",
|
|
75
|
+
"pino": "^9.9.5",
|
|
76
76
|
"pino-pretty": "^13.1.1",
|
|
77
77
|
"tsup": "^8.5.0",
|
|
78
78
|
"tsx": "^4.20.5",
|