@gearbox-protocol/sdk 3.0.0-next.155 → 3.0.0-next.157
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/lib/pathfinder/pathOptions.d.ts +1 -2
- package/lib/pathfinder/pathOptions.js +1 -7
- package/lib/pathfinder/pathOptions.spec.js +1 -4
- package/lib/pathfinder/pathfinder.d.ts +2 -1
- package/lib/pathfinder/pathfinder.js +2 -2
- package/lib/pathfinder/v1/pathfinderv1.d.ts +1 -1
- package/lib/pathfinder/v1/pathfinderv1.js +2 -2
- package/lib/tokens/tokenData.js +4 -1
- package/package.json +2 -2
|
@@ -8,9 +8,8 @@ export interface PathOption {
|
|
|
8
8
|
export type PathOptionSerie = Array<PathOption>;
|
|
9
9
|
export type BalanceInterface = Pick<CaTokenBalance, "balance">;
|
|
10
10
|
export declare class PathOptionFactory {
|
|
11
|
-
static generatePathOptions(balances: Record<string, BalanceInterface>, loopsInTx: number): Array<PathOptionSerie>;
|
|
11
|
+
static generatePathOptions(balances: Record<string, BalanceInterface>, loopsInTx: number, network: NetworkType): Array<PathOptionSerie>;
|
|
12
12
|
static getCurvePools(balances: Record<string, BalanceInterface>): Array<CurveLPToken>;
|
|
13
13
|
static getBalancerPools(balances: Record<string, BalanceInterface>): Array<BalancerLPToken>;
|
|
14
14
|
static next(path: PathOptionSerie): PathOptionSerie;
|
|
15
|
-
static detectNetwork(underlying: string): NetworkType;
|
|
16
15
|
}
|
|
@@ -4,10 +4,9 @@ exports.PathOptionFactory = void 0;
|
|
|
4
4
|
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
5
5
|
const aura_1 = require("@gearbox-protocol/sdk-gov/lib/tokens/aura");
|
|
6
6
|
class PathOptionFactory {
|
|
7
|
-
static generatePathOptions(balances, loopsInTx) {
|
|
7
|
+
static generatePathOptions(balances, loopsInTx, network) {
|
|
8
8
|
const curvePools = PathOptionFactory.getCurvePools(balances);
|
|
9
9
|
const balancerPools = PathOptionFactory.getBalancerPools(balances);
|
|
10
|
-
const network = PathOptionFactory.detectNetwork(Object.keys(balances)[0]);
|
|
11
10
|
const curveInitPO = curvePools.map(symbol => {
|
|
12
11
|
return {
|
|
13
12
|
target: sdk_gov_1.tokenDataByNetwork[network][symbol],
|
|
@@ -90,10 +89,5 @@ class PathOptionFactory {
|
|
|
90
89
|
}
|
|
91
90
|
throw new Error("Path options overflow");
|
|
92
91
|
}
|
|
93
|
-
static detectNetwork(underlying) {
|
|
94
|
-
return sdk_gov_1.tokenDataByNetwork.Mainnet[sdk_gov_1.tokenSymbolByAddress[underlying.toLowerCase()]].toLowerCase() === underlying.toLowerCase()
|
|
95
|
-
? "Mainnet"
|
|
96
|
-
: "Arbitrum";
|
|
97
|
-
}
|
|
98
92
|
}
|
|
99
93
|
exports.PathOptionFactory = PathOptionFactory;
|
|
@@ -63,7 +63,7 @@ describe("PathOptionFactory test", () => {
|
|
|
63
63
|
[sdk_gov_1.tokenDataByNetwork.Mainnet.FRAX3CRV]: { balance: 200n },
|
|
64
64
|
[sdk_gov_1.tokenDataByNetwork.Mainnet["50OHM_50DAI"]]: { balance: 200n },
|
|
65
65
|
};
|
|
66
|
-
const result = pathOptions_1.PathOptionFactory.generatePathOptions(balances, 4);
|
|
66
|
+
const result = pathOptions_1.PathOptionFactory.generatePathOptions(balances, 4, "Mainnet");
|
|
67
67
|
const expected = [
|
|
68
68
|
{
|
|
69
69
|
target: sdk_gov_1.tokenDataByNetwork.Mainnet["3Crv"],
|
|
@@ -135,7 +135,4 @@ describe("PathOptionFactory test", () => {
|
|
|
135
135
|
expectedCurvePools = ["3Crv", "steCRV"];
|
|
136
136
|
(0, chai_1.expect)(pathOptions_1.PathOptionFactory.getCurvePools(balances)).to.be.eql(expectedCurvePools);
|
|
137
137
|
});
|
|
138
|
-
it("detectNetwork works correctly", () => {
|
|
139
|
-
(0, chai_1.expect)(pathOptions_1.PathOptionFactory.detectNetwork(sdk_gov_1.tokenDataByNetwork.Mainnet["1INCH"])).to.be.eq("Mainnet");
|
|
140
|
-
});
|
|
141
138
|
});
|
|
@@ -28,6 +28,7 @@ interface FindBestClosePathProps {
|
|
|
28
28
|
leftoverBalances: Record<string, Asset>;
|
|
29
29
|
slippage: number;
|
|
30
30
|
noConcurrency?: boolean;
|
|
31
|
+
network: NetworkType;
|
|
31
32
|
}
|
|
32
33
|
interface FindOpenStrategyPathProps {
|
|
33
34
|
creditManager: CreditManagerData;
|
|
@@ -64,7 +65,7 @@ export declare class PathFinder {
|
|
|
64
65
|
* - underlyingBalance - total balance of underlying token
|
|
65
66
|
* - calls - list of calls which should be done to swap & unwrap everything to underlying token
|
|
66
67
|
*/
|
|
67
|
-
findBestClosePath({ creditAccount, creditManager: cm, expectedBalances, leftoverBalances, slippage, noConcurrency, }: FindBestClosePathProps): Promise<PathFinderCloseResult>;
|
|
68
|
+
findBestClosePath({ creditAccount, creditManager: cm, expectedBalances, leftoverBalances, slippage, noConcurrency, network, }: FindBestClosePathProps): Promise<PathFinderCloseResult>;
|
|
68
69
|
static compare(r1: PathFinderResult, r2: PathFinderResult): PathFinderResult;
|
|
69
70
|
getAvailableConnectors(availableList: Record<string, bigint> | Record<string, true>): string[];
|
|
70
71
|
static getAvailableConnectors(availableList: Record<string, bigint> | Record<string, true>, connectors: string[]): string[];
|
|
@@ -105,9 +105,9 @@ class PathFinder {
|
|
|
105
105
|
* - underlyingBalance - total balance of underlying token
|
|
106
106
|
* - calls - list of calls which should be done to swap & unwrap everything to underlying token
|
|
107
107
|
*/
|
|
108
|
-
async findBestClosePath({ creditAccount, creditManager: cm, expectedBalances, leftoverBalances, slippage, noConcurrency = false, }) {
|
|
108
|
+
async findBestClosePath({ creditAccount, creditManager: cm, expectedBalances, leftoverBalances, slippage, noConcurrency = false, network, }) {
|
|
109
109
|
const loopsPerTx = Math.floor(GAS_PER_BLOCK / MAX_GAS_PER_ROUTE);
|
|
110
|
-
const pathOptions = pathOptions_1.PathOptionFactory.generatePathOptions(creditAccount.allBalances, loopsPerTx);
|
|
110
|
+
const pathOptions = pathOptions_1.PathOptionFactory.generatePathOptions(creditAccount.allBalances, loopsPerTx, network);
|
|
111
111
|
const expected = cm.collateralTokens.map(token => {
|
|
112
112
|
// When we pass expected balances explicitly, we need to mimic router behaviour by filtering out leftover tokens
|
|
113
113
|
// for example, we can have stETH balance of 2, because 1 transforms to 2 because of rebasing
|
|
@@ -39,7 +39,7 @@ export declare class PathFinderV1 {
|
|
|
39
39
|
* - underlyingBalance - total balance of underlying token
|
|
40
40
|
* - calls - list of calls which should be done to swap & unwrap everything to underlying token
|
|
41
41
|
*/
|
|
42
|
-
findBestClosePath(creditAccount: CreditAccountData, slippage: number, noConcurency
|
|
42
|
+
findBestClosePath(creditAccount: CreditAccountData, slippage: number, noConcurency: boolean | undefined, network: NetworkType): Promise<PathFinderV1CloseResult>;
|
|
43
43
|
static compare(r1: CloseResult, r2: CloseResult, gasPriceRAY: bigint): CloseResult;
|
|
44
44
|
getAvailableConnectors(availableList: Record<string, bigint> | Record<string, true>): string[];
|
|
45
45
|
static getAvailableConnectors(availableList: Record<string, bigint> | Record<string, true>, connectors: string[]): string[];
|
|
@@ -107,9 +107,9 @@ class PathFinderV1 {
|
|
|
107
107
|
* - underlyingBalance - total balance of underlying token
|
|
108
108
|
* - calls - list of calls which should be done to swap & unwrap everything to underlying token
|
|
109
109
|
*/
|
|
110
|
-
async findBestClosePath(creditAccount, slippage, noConcurency = false) {
|
|
110
|
+
async findBestClosePath(creditAccount, slippage, noConcurency = false, network) {
|
|
111
111
|
const loopsPerTx = Math.floor(GAS_PER_BLOCK / MAX_GAS_PER_ROUTE);
|
|
112
|
-
const pathOptions = pathOptions_1.PathOptionFactory.generatePathOptions(creditAccount.allBalances, loopsPerTx);
|
|
112
|
+
const pathOptions = pathOptions_1.PathOptionFactory.generatePathOptions(creditAccount.allBalances, loopsPerTx, network);
|
|
113
113
|
const connectors = this.getAvailableConnectors(creditAccount.balances);
|
|
114
114
|
let results = [];
|
|
115
115
|
if (noConcurency) {
|
package/lib/tokens/tokenData.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.157",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"test": "npx mocha -r ts-node/register -r dotenv/config 'src/**/*.spec.ts'"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@gearbox-protocol/sdk-gov": "^1.
|
|
33
|
+
"@gearbox-protocol/sdk-gov": "^1.55.2",
|
|
34
34
|
"axios": "^1.2.6",
|
|
35
35
|
"decimal.js-light": "^2.5.1",
|
|
36
36
|
"deep-eql": "^4.1.0",
|