@gearbox-protocol/sdk 13.0.0-next.25 → 13.0.0-next.27
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/providers.js +12 -0
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +14 -4
- package/dist/esm/dev/providers.js +12 -0
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +14 -4
- package/dist/types/dev/providers.d.ts +5 -5
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +1 -1
- package/dist/types/sdk/accounts/types.d.ts +2 -2
- package/package.json +1 -1
|
@@ -52,6 +52,9 @@ function getRpcProviderUrl(provider, network, apiKey, protocol = "http") {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
function getAlchemyUrl(network, apiKey, protocol = "http") {
|
|
55
|
+
if (!apiKey) {
|
|
56
|
+
return void 0;
|
|
57
|
+
}
|
|
55
58
|
const alchemyDomain = ALCHEMY_DOMAINS[network];
|
|
56
59
|
if (!alchemyDomain) {
|
|
57
60
|
return void 0;
|
|
@@ -95,6 +98,9 @@ const ALCHEMY_DOMAINS = {
|
|
|
95
98
|
Somnia: null
|
|
96
99
|
};
|
|
97
100
|
function getDrpcUrl(network, apiKey, protocol = "http") {
|
|
101
|
+
if (!apiKey) {
|
|
102
|
+
return void 0;
|
|
103
|
+
}
|
|
98
104
|
const net = DRPC_NETS[network];
|
|
99
105
|
return net ? `${protocol}s://lb.drpc.live/${net}/${apiKey}` : void 0;
|
|
100
106
|
}
|
|
@@ -117,6 +123,9 @@ const ANKR_DOMAINS = {
|
|
|
117
123
|
Somnia: "somnia_mainnet"
|
|
118
124
|
};
|
|
119
125
|
function getAnkrUrl(network, apiKey, protocol = "http") {
|
|
126
|
+
if (!apiKey) {
|
|
127
|
+
return void 0;
|
|
128
|
+
}
|
|
120
129
|
const net = ANKR_DOMAINS[network];
|
|
121
130
|
const sep = protocol === "ws" ? "/ws/" : "/";
|
|
122
131
|
return net ? `${protocol}s://rpc.ankr.com/${net}${sep}${apiKey}` : void 0;
|
|
@@ -140,6 +149,9 @@ const THIRDWEB_DOMAINS = {
|
|
|
140
149
|
Somnia: import_sdk.chains.Somnia.id.toString()
|
|
141
150
|
};
|
|
142
151
|
function getThirdWebUrl(network, apiKey, protocol = "http") {
|
|
152
|
+
if (!apiKey) {
|
|
153
|
+
return void 0;
|
|
154
|
+
}
|
|
143
155
|
if (protocol === "ws") {
|
|
144
156
|
return void 0;
|
|
145
157
|
}
|
|
@@ -600,7 +600,7 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
600
600
|
async changeDebt({
|
|
601
601
|
creditAccount,
|
|
602
602
|
amount,
|
|
603
|
-
|
|
603
|
+
collateral
|
|
604
604
|
}) {
|
|
605
605
|
if (amount === 0n) {
|
|
606
606
|
throw new Error("debt increase or decrease must be non-zero");
|
|
@@ -614,21 +614,31 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
614
614
|
creditManager: creditAccount.creditManager,
|
|
615
615
|
creditAccount
|
|
616
616
|
});
|
|
617
|
-
const addCollateralCalls =
|
|
617
|
+
const addCollateralCalls = collateral && isDecrease ? this.prepareAddCollateral(
|
|
618
618
|
creditAccount.creditFacade,
|
|
619
619
|
[
|
|
620
620
|
{
|
|
621
|
-
token:
|
|
622
|
-
balance:
|
|
621
|
+
token: collateral[0].token,
|
|
622
|
+
balance: collateral[0].balance
|
|
623
623
|
}
|
|
624
624
|
],
|
|
625
625
|
{}
|
|
626
626
|
) : [];
|
|
627
|
+
const unwrapCalls = collateral && isDecrease ? await this.getKYCUnwrapCalls(
|
|
628
|
+
collateral[0].balance,
|
|
629
|
+
creditAccount.creditManager
|
|
630
|
+
) || [] : [];
|
|
631
|
+
if (addCollateralCalls.length > 0 && unwrapCalls.length === 0 && collateral && collateral?.[0].token !== creditAccount.underlying) {
|
|
632
|
+
throw new Error(
|
|
633
|
+
"Can't use collateral other than underlying for non KYC market"
|
|
634
|
+
);
|
|
635
|
+
}
|
|
627
636
|
const underlyingEnabled = (creditAccount.enabledTokensMask & 1n) === 1n;
|
|
628
637
|
const shouldEnable = !isDecrease && !underlyingEnabled;
|
|
629
638
|
const calls = [
|
|
630
639
|
...priceUpdatesCalls,
|
|
631
640
|
...addCollateralCalls,
|
|
641
|
+
...unwrapCalls,
|
|
632
642
|
...shouldEnable ? this.#prepareEnableTokens(creditAccount.creditFacade, [
|
|
633
643
|
creditAccount.underlying
|
|
634
644
|
]) : [],
|
|
@@ -22,6 +22,9 @@ function getRpcProviderUrl(provider, network, apiKey, protocol = "http") {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
function getAlchemyUrl(network, apiKey, protocol = "http") {
|
|
25
|
+
if (!apiKey) {
|
|
26
|
+
return void 0;
|
|
27
|
+
}
|
|
25
28
|
const alchemyDomain = ALCHEMY_DOMAINS[network];
|
|
26
29
|
if (!alchemyDomain) {
|
|
27
30
|
return void 0;
|
|
@@ -65,6 +68,9 @@ const ALCHEMY_DOMAINS = {
|
|
|
65
68
|
Somnia: null
|
|
66
69
|
};
|
|
67
70
|
function getDrpcUrl(network, apiKey, protocol = "http") {
|
|
71
|
+
if (!apiKey) {
|
|
72
|
+
return void 0;
|
|
73
|
+
}
|
|
68
74
|
const net = DRPC_NETS[network];
|
|
69
75
|
return net ? `${protocol}s://lb.drpc.live/${net}/${apiKey}` : void 0;
|
|
70
76
|
}
|
|
@@ -87,6 +93,9 @@ const ANKR_DOMAINS = {
|
|
|
87
93
|
Somnia: "somnia_mainnet"
|
|
88
94
|
};
|
|
89
95
|
function getAnkrUrl(network, apiKey, protocol = "http") {
|
|
96
|
+
if (!apiKey) {
|
|
97
|
+
return void 0;
|
|
98
|
+
}
|
|
90
99
|
const net = ANKR_DOMAINS[network];
|
|
91
100
|
const sep = protocol === "ws" ? "/ws/" : "/";
|
|
92
101
|
return net ? `${protocol}s://rpc.ankr.com/${net}${sep}${apiKey}` : void 0;
|
|
@@ -110,6 +119,9 @@ const THIRDWEB_DOMAINS = {
|
|
|
110
119
|
Somnia: chains.Somnia.id.toString()
|
|
111
120
|
};
|
|
112
121
|
function getThirdWebUrl(network, apiKey, protocol = "http") {
|
|
122
|
+
if (!apiKey) {
|
|
123
|
+
return void 0;
|
|
124
|
+
}
|
|
113
125
|
if (protocol === "ws") {
|
|
114
126
|
return void 0;
|
|
115
127
|
}
|
|
@@ -590,7 +590,7 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
590
590
|
async changeDebt({
|
|
591
591
|
creditAccount,
|
|
592
592
|
amount,
|
|
593
|
-
|
|
593
|
+
collateral
|
|
594
594
|
}) {
|
|
595
595
|
if (amount === 0n) {
|
|
596
596
|
throw new Error("debt increase or decrease must be non-zero");
|
|
@@ -604,21 +604,31 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
604
604
|
creditManager: creditAccount.creditManager,
|
|
605
605
|
creditAccount
|
|
606
606
|
});
|
|
607
|
-
const addCollateralCalls =
|
|
607
|
+
const addCollateralCalls = collateral && isDecrease ? this.prepareAddCollateral(
|
|
608
608
|
creditAccount.creditFacade,
|
|
609
609
|
[
|
|
610
610
|
{
|
|
611
|
-
token:
|
|
612
|
-
balance:
|
|
611
|
+
token: collateral[0].token,
|
|
612
|
+
balance: collateral[0].balance
|
|
613
613
|
}
|
|
614
614
|
],
|
|
615
615
|
{}
|
|
616
616
|
) : [];
|
|
617
|
+
const unwrapCalls = collateral && isDecrease ? await this.getKYCUnwrapCalls(
|
|
618
|
+
collateral[0].balance,
|
|
619
|
+
creditAccount.creditManager
|
|
620
|
+
) || [] : [];
|
|
621
|
+
if (addCollateralCalls.length > 0 && unwrapCalls.length === 0 && collateral && collateral?.[0].token !== creditAccount.underlying) {
|
|
622
|
+
throw new Error(
|
|
623
|
+
"Can't use collateral other than underlying for non KYC market"
|
|
624
|
+
);
|
|
625
|
+
}
|
|
617
626
|
const underlyingEnabled = (creditAccount.enabledTokensMask & 1n) === 1n;
|
|
618
627
|
const shouldEnable = !isDecrease && !underlyingEnabled;
|
|
619
628
|
const calls = [
|
|
620
629
|
...priceUpdatesCalls,
|
|
621
630
|
...addCollateralCalls,
|
|
631
|
+
...unwrapCalls,
|
|
622
632
|
...shouldEnable ? this.#prepareEnableTokens(creditAccount.creditFacade, [
|
|
623
633
|
creditAccount.underlying
|
|
624
634
|
]) : [],
|
|
@@ -8,11 +8,11 @@ export declare const rpcProvidersSchema: z.ZodEnum<{
|
|
|
8
8
|
ankr: "ankr";
|
|
9
9
|
}>;
|
|
10
10
|
export type RpcProvider = z.infer<typeof rpcProvidersSchema>;
|
|
11
|
-
export declare function getRpcProviderUrl(provider: RpcProvider, network: NetworkType, apiKey
|
|
12
|
-
export declare function getAlchemyUrl(network: NetworkType, apiKey
|
|
13
|
-
export declare function getDrpcUrl(network: NetworkType, apiKey
|
|
14
|
-
export declare function getAnkrUrl(network: NetworkType, apiKey
|
|
15
|
-
export declare function getThirdWebUrl(network: NetworkType, apiKey
|
|
11
|
+
export declare function getRpcProviderUrl(provider: RpcProvider, network: NetworkType, apiKey?: string, protocol?: "http" | "ws"): string | undefined;
|
|
12
|
+
export declare function getAlchemyUrl(network: NetworkType, apiKey?: string, protocol?: "http" | "ws"): string | undefined;
|
|
13
|
+
export declare function getDrpcUrl(network: NetworkType, apiKey?: string, protocol?: "http" | "ws"): string | undefined;
|
|
14
|
+
export declare function getAnkrUrl(network: NetworkType, apiKey?: string, protocol?: "http" | "ws"): string | undefined;
|
|
15
|
+
export declare function getThirdWebUrl(network: NetworkType, apiKey?: string, protocol?: "http" | "ws"): string | undefined;
|
|
16
16
|
export declare function getErpcKey(network: NetworkType, projectId?: string, urlBase?: string): string | undefined;
|
|
17
17
|
/**
|
|
18
18
|
Non-existent event:
|
|
@@ -136,7 +136,7 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
136
136
|
positive value for debt increase.
|
|
137
137
|
* @returns All necessary data to execute the transaction (call, credit facade)
|
|
138
138
|
*/
|
|
139
|
-
changeDebt({ creditAccount, amount,
|
|
139
|
+
changeDebt({ creditAccount, amount, collateral, }: ChangeDeptProps): Promise<CreditAccountOperationResult>;
|
|
140
140
|
/**
|
|
141
141
|
* Executes swap specified by given calls, update quotas of affected tokens
|
|
142
142
|
- Swap is executed in the following order: price update -> execute swap path -> update quotas
|
|
@@ -326,9 +326,9 @@ export interface ChangeDeptProps {
|
|
|
326
326
|
*/
|
|
327
327
|
amount: bigint;
|
|
328
328
|
/**
|
|
329
|
-
*
|
|
329
|
+
* Assets to add as collateral
|
|
330
330
|
*/
|
|
331
|
-
|
|
331
|
+
collateral?: [Asset];
|
|
332
332
|
}
|
|
333
333
|
export interface FullyLiquidateProps {
|
|
334
334
|
/**
|