@gearbox-protocol/sdk 10.4.2 → 10.4.4
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/sdk/accounts/CreditAccountsServiceV310.js +4 -2
- package/dist/cjs/sdk/router/RouterV310Contract.js +5 -0
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +4 -2
- package/dist/esm/sdk/router/RouterV310Contract.js +5 -0
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
- package/dist/types/sdk/accounts/types.d.ts +1 -0
- package/dist/types/sdk/router/types.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/dev/providers.js +0 -147
- package/dist/esm/dev/providers.js +0 -119
- package/dist/types/dev/providers.d.ts +0 -6
|
@@ -172,14 +172,16 @@ class CreditAccountServiceV310 extends import_AbstractCreditAccountsService.Abst
|
|
|
172
172
|
creditAccount: ca,
|
|
173
173
|
minQuota,
|
|
174
174
|
averageQuota,
|
|
175
|
-
tokensToClaim
|
|
175
|
+
tokensToClaim,
|
|
176
|
+
forceCalls
|
|
176
177
|
}) {
|
|
177
178
|
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
178
179
|
const router = this.sdk.routerFor(ca);
|
|
179
180
|
const claimPath = await router.findClaimAllRewards({
|
|
180
181
|
calls: legacyCalls,
|
|
181
182
|
tokensToClaim,
|
|
182
|
-
creditAccount: ca
|
|
183
|
+
creditAccount: ca,
|
|
184
|
+
forceCalls
|
|
183
185
|
});
|
|
184
186
|
if (claimPath.calls.length === 0) throw new Error("No path to execute");
|
|
185
187
|
const priceUpdatesCalls = await this.getPriceUpdatesForFacade({
|
|
@@ -146,6 +146,11 @@ class RouterV310Contract extends import_AbstractRouterContract.AbstractRouterCon
|
|
|
146
146
|
* Implements {@link IRouterContract.findClaimAllRewards}
|
|
147
147
|
*/
|
|
148
148
|
async findClaimAllRewards(props) {
|
|
149
|
+
if (props.calls.length > 0 && !!props.forceCalls) {
|
|
150
|
+
return {
|
|
151
|
+
calls: [...props.calls]
|
|
152
|
+
};
|
|
153
|
+
}
|
|
149
154
|
const tData = props.tokensToClaim.map((a) => ({
|
|
150
155
|
balance: 0n,
|
|
151
156
|
claimRewards: true,
|
|
@@ -149,14 +149,16 @@ class CreditAccountServiceV310 extends AbstractCreditAccountService {
|
|
|
149
149
|
creditAccount: ca,
|
|
150
150
|
minQuota,
|
|
151
151
|
averageQuota,
|
|
152
|
-
tokensToClaim
|
|
152
|
+
tokensToClaim,
|
|
153
|
+
forceCalls
|
|
153
154
|
}) {
|
|
154
155
|
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
155
156
|
const router = this.sdk.routerFor(ca);
|
|
156
157
|
const claimPath = await router.findClaimAllRewards({
|
|
157
158
|
calls: legacyCalls,
|
|
158
159
|
tokensToClaim,
|
|
159
|
-
creditAccount: ca
|
|
160
|
+
creditAccount: ca,
|
|
161
|
+
forceCalls
|
|
160
162
|
});
|
|
161
163
|
if (claimPath.calls.length === 0) throw new Error("No path to execute");
|
|
162
164
|
const priceUpdatesCalls = await this.getPriceUpdatesForFacade({
|
|
@@ -123,6 +123,11 @@ class RouterV310Contract extends AbstractRouterContract {
|
|
|
123
123
|
* Implements {@link IRouterContract.findClaimAllRewards}
|
|
124
124
|
*/
|
|
125
125
|
async findClaimAllRewards(props) {
|
|
126
|
+
if (props.calls.length > 0 && !!props.forceCalls) {
|
|
127
|
+
return {
|
|
128
|
+
calls: [...props.calls]
|
|
129
|
+
};
|
|
130
|
+
}
|
|
126
131
|
const tData = props.tokensToClaim.map((a) => ({
|
|
127
132
|
balance: 0n,
|
|
128
133
|
claimRewards: true,
|
|
@@ -20,5 +20,5 @@ export declare class CreditAccountServiceV310 extends AbstractCreditAccountServi
|
|
|
20
20
|
/**
|
|
21
21
|
* Implements {@link ICreditAccountsService.claimFarmRewards}
|
|
22
22
|
*/
|
|
23
|
-
claimFarmRewards({ calls: legacyCalls, creditAccount: ca, minQuota, averageQuota, tokensToClaim, }: ClaimFarmRewardsProps): Promise<CreditAccountOperationResult>;
|
|
23
|
+
claimFarmRewards({ calls: legacyCalls, creditAccount: ca, minQuota, averageQuota, tokensToClaim, forceCalls, }: ClaimFarmRewardsProps): Promise<CreditAccountOperationResult>;
|
|
24
24
|
}
|
package/package.json
CHANGED
|
@@ -1,147 +0,0 @@
|
|
|
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 providers_exports = {};
|
|
20
|
-
__export(providers_exports, {
|
|
21
|
-
getAlchemyUrl: () => getAlchemyUrl,
|
|
22
|
-
getAnkrUrl: () => getAnkrUrl,
|
|
23
|
-
getDrpcUrl: () => getDrpcUrl,
|
|
24
|
-
getProviderUrl: () => getProviderUrl,
|
|
25
|
-
getThirdWebUrl: () => getThirdWebUrl
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(providers_exports);
|
|
28
|
-
var import_sdk = require("../sdk/index.js");
|
|
29
|
-
function getProviderUrl(provider, network, apiKey, protocol) {
|
|
30
|
-
switch (provider) {
|
|
31
|
-
case "alchemy":
|
|
32
|
-
return getAlchemyUrl(network, apiKey, protocol);
|
|
33
|
-
case "drpc":
|
|
34
|
-
return getDrpcUrl(network, apiKey, protocol);
|
|
35
|
-
case "ankr":
|
|
36
|
-
return getAnkrUrl(network, apiKey, protocol);
|
|
37
|
-
case "thirdweb":
|
|
38
|
-
return getThirdWebUrl(network, apiKey, protocol);
|
|
39
|
-
default: {
|
|
40
|
-
if (!apiKey.startsWith(protocol)) {
|
|
41
|
-
throw new Error(
|
|
42
|
-
`generic provider's ${provider} key must start with ${protocol}`
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
return apiKey;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function getAlchemyUrl(network, apiKey, protocol) {
|
|
50
|
-
const alchemyDomain = ALCHEMY_DOMAINS[network];
|
|
51
|
-
if (!alchemyDomain) {
|
|
52
|
-
return void 0;
|
|
53
|
-
}
|
|
54
|
-
return `${protocol}s://${alchemyDomain}.g.alchemy.com/v2/${apiKey}`;
|
|
55
|
-
}
|
|
56
|
-
const DRPC_NETS = {
|
|
57
|
-
Arbitrum: "arbitrum",
|
|
58
|
-
Base: "base",
|
|
59
|
-
BNB: "bsc",
|
|
60
|
-
Mainnet: "ethereum",
|
|
61
|
-
Optimism: "optimism",
|
|
62
|
-
Sonic: "sonic",
|
|
63
|
-
WorldChain: "worldchain",
|
|
64
|
-
Berachain: "berachain",
|
|
65
|
-
Avalanche: "avalanche",
|
|
66
|
-
Monad: "monad-testnet",
|
|
67
|
-
Hemi: "hemi",
|
|
68
|
-
Lisk: "lisk",
|
|
69
|
-
MegaETH: null,
|
|
70
|
-
Etherlink: null,
|
|
71
|
-
Plasma: "plasma"
|
|
72
|
-
};
|
|
73
|
-
const ALCHEMY_DOMAINS = {
|
|
74
|
-
Mainnet: "eth-mainnet",
|
|
75
|
-
Arbitrum: "arb-mainnet",
|
|
76
|
-
Optimism: "opt-mainnet",
|
|
77
|
-
Base: "base-mainnet",
|
|
78
|
-
Sonic: "sonic-mainnet",
|
|
79
|
-
Monad: "monad-testnet",
|
|
80
|
-
Berachain: "berachain-mainnet",
|
|
81
|
-
Avalanche: "avax-mainnet",
|
|
82
|
-
BNB: "bnb-mainnet",
|
|
83
|
-
WorldChain: "worldchain-mainnet",
|
|
84
|
-
MegaETH: null,
|
|
85
|
-
Etherlink: null,
|
|
86
|
-
Hemi: null,
|
|
87
|
-
Lisk: null,
|
|
88
|
-
Plasma: "plasma-mainnet"
|
|
89
|
-
};
|
|
90
|
-
function getDrpcUrl(network, apiKey, protocol) {
|
|
91
|
-
const net = DRPC_NETS[network];
|
|
92
|
-
return net ? `${protocol}s://lb.drpc.org/${net}/${apiKey}` : void 0;
|
|
93
|
-
}
|
|
94
|
-
const ANKR_DOMAINS = {
|
|
95
|
-
Arbitrum: "arbitrum",
|
|
96
|
-
Avalanche: "avalanche",
|
|
97
|
-
Base: "base",
|
|
98
|
-
Berachain: null,
|
|
99
|
-
BNB: "bsc",
|
|
100
|
-
Etherlink: "etherlink_mainnet",
|
|
101
|
-
Hemi: null,
|
|
102
|
-
Lisk: null,
|
|
103
|
-
Mainnet: "eth",
|
|
104
|
-
MegaETH: null,
|
|
105
|
-
Monad: "monad_testnet",
|
|
106
|
-
Optimism: "optimism",
|
|
107
|
-
Plasma: null,
|
|
108
|
-
Sonic: "sonic_mainnet",
|
|
109
|
-
WorldChain: null
|
|
110
|
-
};
|
|
111
|
-
function getAnkrUrl(network, apiKey, protocol) {
|
|
112
|
-
const net = ANKR_DOMAINS[network];
|
|
113
|
-
const sep = protocol === "ws" ? "/ws/" : "/";
|
|
114
|
-
return net ? `${protocol}s://rpc.ankr.com/${net}${sep}${apiKey}` : void 0;
|
|
115
|
-
}
|
|
116
|
-
const THIRDWEB_DOMAINS = {
|
|
117
|
-
Arbitrum: import_sdk.chains.Arbitrum.id.toString(),
|
|
118
|
-
Avalanche: import_sdk.chains.Avalanche.id.toString(),
|
|
119
|
-
Base: import_sdk.chains.Base.id.toString(),
|
|
120
|
-
Berachain: import_sdk.chains.Berachain.id.toString(),
|
|
121
|
-
BNB: import_sdk.chains.BNB.id.toString(),
|
|
122
|
-
Etherlink: import_sdk.chains.Etherlink.id.toString(),
|
|
123
|
-
Hemi: import_sdk.chains.Hemi.id.toString(),
|
|
124
|
-
Lisk: import_sdk.chains.Lisk.id.toString(),
|
|
125
|
-
Mainnet: import_sdk.chains.Mainnet.id.toString(),
|
|
126
|
-
MegaETH: import_sdk.chains.MegaETH.id.toString(),
|
|
127
|
-
Monad: import_sdk.chains.Monad.id.toString(),
|
|
128
|
-
Optimism: import_sdk.chains.Optimism.id.toString(),
|
|
129
|
-
Plasma: import_sdk.chains.Plasma.id.toString(),
|
|
130
|
-
Sonic: import_sdk.chains.Sonic.id.toString(),
|
|
131
|
-
WorldChain: import_sdk.chains.WorldChain.id.toString()
|
|
132
|
-
};
|
|
133
|
-
function getThirdWebUrl(network, apiKey, protocol) {
|
|
134
|
-
if (protocol === "ws") {
|
|
135
|
-
return void 0;
|
|
136
|
-
}
|
|
137
|
-
const net = THIRDWEB_DOMAINS[network];
|
|
138
|
-
return `https://${net}.rpc.thirdweb.com/${apiKey}`;
|
|
139
|
-
}
|
|
140
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
141
|
-
0 && (module.exports = {
|
|
142
|
-
getAlchemyUrl,
|
|
143
|
-
getAnkrUrl,
|
|
144
|
-
getDrpcUrl,
|
|
145
|
-
getProviderUrl,
|
|
146
|
-
getThirdWebUrl
|
|
147
|
-
});
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { chains } from "../sdk/index.js";
|
|
2
|
-
function getProviderUrl(provider, network, apiKey, protocol) {
|
|
3
|
-
switch (provider) {
|
|
4
|
-
case "alchemy":
|
|
5
|
-
return getAlchemyUrl(network, apiKey, protocol);
|
|
6
|
-
case "drpc":
|
|
7
|
-
return getDrpcUrl(network, apiKey, protocol);
|
|
8
|
-
case "ankr":
|
|
9
|
-
return getAnkrUrl(network, apiKey, protocol);
|
|
10
|
-
case "thirdweb":
|
|
11
|
-
return getThirdWebUrl(network, apiKey, protocol);
|
|
12
|
-
default: {
|
|
13
|
-
if (!apiKey.startsWith(protocol)) {
|
|
14
|
-
throw new Error(
|
|
15
|
-
`generic provider's ${provider} key must start with ${protocol}`
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
return apiKey;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function getAlchemyUrl(network, apiKey, protocol) {
|
|
23
|
-
const alchemyDomain = ALCHEMY_DOMAINS[network];
|
|
24
|
-
if (!alchemyDomain) {
|
|
25
|
-
return void 0;
|
|
26
|
-
}
|
|
27
|
-
return `${protocol}s://${alchemyDomain}.g.alchemy.com/v2/${apiKey}`;
|
|
28
|
-
}
|
|
29
|
-
const DRPC_NETS = {
|
|
30
|
-
Arbitrum: "arbitrum",
|
|
31
|
-
Base: "base",
|
|
32
|
-
BNB: "bsc",
|
|
33
|
-
Mainnet: "ethereum",
|
|
34
|
-
Optimism: "optimism",
|
|
35
|
-
Sonic: "sonic",
|
|
36
|
-
WorldChain: "worldchain",
|
|
37
|
-
Berachain: "berachain",
|
|
38
|
-
Avalanche: "avalanche",
|
|
39
|
-
Monad: "monad-testnet",
|
|
40
|
-
Hemi: "hemi",
|
|
41
|
-
Lisk: "lisk",
|
|
42
|
-
MegaETH: null,
|
|
43
|
-
Etherlink: null,
|
|
44
|
-
Plasma: "plasma"
|
|
45
|
-
};
|
|
46
|
-
const ALCHEMY_DOMAINS = {
|
|
47
|
-
Mainnet: "eth-mainnet",
|
|
48
|
-
Arbitrum: "arb-mainnet",
|
|
49
|
-
Optimism: "opt-mainnet",
|
|
50
|
-
Base: "base-mainnet",
|
|
51
|
-
Sonic: "sonic-mainnet",
|
|
52
|
-
Monad: "monad-testnet",
|
|
53
|
-
Berachain: "berachain-mainnet",
|
|
54
|
-
Avalanche: "avax-mainnet",
|
|
55
|
-
BNB: "bnb-mainnet",
|
|
56
|
-
WorldChain: "worldchain-mainnet",
|
|
57
|
-
MegaETH: null,
|
|
58
|
-
Etherlink: null,
|
|
59
|
-
Hemi: null,
|
|
60
|
-
Lisk: null,
|
|
61
|
-
Plasma: "plasma-mainnet"
|
|
62
|
-
};
|
|
63
|
-
function getDrpcUrl(network, apiKey, protocol) {
|
|
64
|
-
const net = DRPC_NETS[network];
|
|
65
|
-
return net ? `${protocol}s://lb.drpc.org/${net}/${apiKey}` : void 0;
|
|
66
|
-
}
|
|
67
|
-
const ANKR_DOMAINS = {
|
|
68
|
-
Arbitrum: "arbitrum",
|
|
69
|
-
Avalanche: "avalanche",
|
|
70
|
-
Base: "base",
|
|
71
|
-
Berachain: null,
|
|
72
|
-
BNB: "bsc",
|
|
73
|
-
Etherlink: "etherlink_mainnet",
|
|
74
|
-
Hemi: null,
|
|
75
|
-
Lisk: null,
|
|
76
|
-
Mainnet: "eth",
|
|
77
|
-
MegaETH: null,
|
|
78
|
-
Monad: "monad_testnet",
|
|
79
|
-
Optimism: "optimism",
|
|
80
|
-
Plasma: null,
|
|
81
|
-
Sonic: "sonic_mainnet",
|
|
82
|
-
WorldChain: null
|
|
83
|
-
};
|
|
84
|
-
function getAnkrUrl(network, apiKey, protocol) {
|
|
85
|
-
const net = ANKR_DOMAINS[network];
|
|
86
|
-
const sep = protocol === "ws" ? "/ws/" : "/";
|
|
87
|
-
return net ? `${protocol}s://rpc.ankr.com/${net}${sep}${apiKey}` : void 0;
|
|
88
|
-
}
|
|
89
|
-
const THIRDWEB_DOMAINS = {
|
|
90
|
-
Arbitrum: chains.Arbitrum.id.toString(),
|
|
91
|
-
Avalanche: chains.Avalanche.id.toString(),
|
|
92
|
-
Base: chains.Base.id.toString(),
|
|
93
|
-
Berachain: chains.Berachain.id.toString(),
|
|
94
|
-
BNB: chains.BNB.id.toString(),
|
|
95
|
-
Etherlink: chains.Etherlink.id.toString(),
|
|
96
|
-
Hemi: chains.Hemi.id.toString(),
|
|
97
|
-
Lisk: chains.Lisk.id.toString(),
|
|
98
|
-
Mainnet: chains.Mainnet.id.toString(),
|
|
99
|
-
MegaETH: chains.MegaETH.id.toString(),
|
|
100
|
-
Monad: chains.Monad.id.toString(),
|
|
101
|
-
Optimism: chains.Optimism.id.toString(),
|
|
102
|
-
Plasma: chains.Plasma.id.toString(),
|
|
103
|
-
Sonic: chains.Sonic.id.toString(),
|
|
104
|
-
WorldChain: chains.WorldChain.id.toString()
|
|
105
|
-
};
|
|
106
|
-
function getThirdWebUrl(network, apiKey, protocol) {
|
|
107
|
-
if (protocol === "ws") {
|
|
108
|
-
return void 0;
|
|
109
|
-
}
|
|
110
|
-
const net = THIRDWEB_DOMAINS[network];
|
|
111
|
-
return `https://${net}.rpc.thirdweb.com/${apiKey}`;
|
|
112
|
-
}
|
|
113
|
-
export {
|
|
114
|
-
getAlchemyUrl,
|
|
115
|
-
getAnkrUrl,
|
|
116
|
-
getDrpcUrl,
|
|
117
|
-
getProviderUrl,
|
|
118
|
-
getThirdWebUrl
|
|
119
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type NetworkType } from "../sdk/index.js";
|
|
2
|
-
export declare function getProviderUrl(provider: string, network: NetworkType, apiKey: string, protocol: "http" | "ws"): string | undefined;
|
|
3
|
-
export declare function getAlchemyUrl(network: NetworkType, apiKey: string, protocol: "http" | "ws"): string | undefined;
|
|
4
|
-
export declare function getDrpcUrl(network: NetworkType, apiKey: string, protocol: "http" | "ws"): string | undefined;
|
|
5
|
-
export declare function getAnkrUrl(network: NetworkType, apiKey: string, protocol: "http" | "ws"): string | undefined;
|
|
6
|
-
export declare function getThirdWebUrl(network: NetworkType, apiKey: string, protocol: "http" | "ws"): string | undefined;
|