@gearbox-protocol/sdk 3.0.0-next.35 → 3.0.0-next.37
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CurveLPToken, NetworkType } from "@gearbox-protocol/sdk-gov";
|
|
1
|
+
import { BalancerLPToken, CurveLPToken, NetworkType } from "@gearbox-protocol/sdk-gov";
|
|
2
2
|
import { CaTokenBalance } from "../payload/creditAccount";
|
|
3
3
|
export interface PathOption {
|
|
4
4
|
target: string;
|
|
@@ -10,6 +10,7 @@ export type BalanceInterface = Pick<CaTokenBalance, "balance">;
|
|
|
10
10
|
export declare class PathOptionFactory {
|
|
11
11
|
static generatePathOptions(balances: Record<string, BalanceInterface>, loopsInTx: number): Array<PathOptionSerie>;
|
|
12
12
|
static getCurvePools(balances: Record<string, BalanceInterface>): Array<CurveLPToken>;
|
|
13
|
+
static getBalancerPools(balances: Record<string, BalanceInterface>): Array<BalancerLPToken>;
|
|
13
14
|
static next(path: PathOptionSerie): PathOptionSerie;
|
|
14
15
|
static detectNetwork(underlying: string): NetworkType;
|
|
15
16
|
}
|
|
@@ -5,8 +5,9 @@ const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
|
5
5
|
class PathOptionFactory {
|
|
6
6
|
static generatePathOptions(balances, loopsInTx) {
|
|
7
7
|
const curvePools = PathOptionFactory.getCurvePools(balances);
|
|
8
|
+
const balancerPools = PathOptionFactory.getBalancerPools(balances);
|
|
8
9
|
const network = PathOptionFactory.detectNetwork(Object.keys(balances)[0]);
|
|
9
|
-
const
|
|
10
|
+
const curveInitPO = curvePools.map(symbol => {
|
|
10
11
|
return {
|
|
11
12
|
target: sdk_gov_1.tokenDataByNetwork[network][symbol],
|
|
12
13
|
option: 0,
|
|
@@ -14,6 +15,14 @@ class PathOptionFactory {
|
|
|
14
15
|
.tokens.length,
|
|
15
16
|
};
|
|
16
17
|
});
|
|
18
|
+
const balancerInitPO = balancerPools.map(symbol => {
|
|
19
|
+
return {
|
|
20
|
+
target: sdk_gov_1.tokenDataByNetwork[network][symbol],
|
|
21
|
+
option: 0,
|
|
22
|
+
totalOptions: sdk_gov_1.balancerLpTokens[symbol].underlying.length,
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
const initPO = [...curveInitPO, ...balancerInitPO];
|
|
17
26
|
const totalLoops = initPO.reduce((acc, item) => acc * item.totalOptions, 1);
|
|
18
27
|
const result = [];
|
|
19
28
|
let currentPo = [...initPO];
|
|
@@ -56,6 +65,16 @@ class PathOptionFactory {
|
|
|
56
65
|
]);
|
|
57
66
|
return Array.from(curveSet.values());
|
|
58
67
|
}
|
|
68
|
+
static getBalancerPools(balances) {
|
|
69
|
+
const result = [];
|
|
70
|
+
for (const [token, { balance }] of Object.entries(balances)) {
|
|
71
|
+
const symbol = sdk_gov_1.tokenSymbolByAddress[token.toLowerCase()];
|
|
72
|
+
if ((0, sdk_gov_1.isBalancerLPToken)(symbol) && (0, sdk_gov_1.toBigInt)(balance) > 1) {
|
|
73
|
+
result.push(symbol);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
59
78
|
static next(path) {
|
|
60
79
|
let newPath = [...path];
|
|
61
80
|
for (let i = path.length - 1; i >= 0; i--) {
|
|
@@ -61,7 +61,7 @@ describe("PathOptionFactory test", () => {
|
|
|
61
61
|
[sdk_gov_1.tokenDataByNetwork.Mainnet["3Crv"]]: { balance: 200n },
|
|
62
62
|
[sdk_gov_1.tokenDataByNetwork.Mainnet.USDC]: { balance: 200n },
|
|
63
63
|
[sdk_gov_1.tokenDataByNetwork.Mainnet.FRAX3CRV]: { balance: 200n },
|
|
64
|
-
[sdk_gov_1.tokenDataByNetwork.Mainnet
|
|
64
|
+
[sdk_gov_1.tokenDataByNetwork.Mainnet["50OHM_50DAI"]]: { balance: 200n },
|
|
65
65
|
};
|
|
66
66
|
const result = pathOptions_1.PathOptionFactory.generatePathOptions(balances, 4);
|
|
67
67
|
const expected = [
|
|
@@ -76,7 +76,7 @@ describe("PathOptionFactory test", () => {
|
|
|
76
76
|
totalOptions: 2,
|
|
77
77
|
},
|
|
78
78
|
{
|
|
79
|
-
target: sdk_gov_1.tokenDataByNetwork.Mainnet
|
|
79
|
+
target: sdk_gov_1.tokenDataByNetwork.Mainnet["50OHM_50DAI"],
|
|
80
80
|
option: 0,
|
|
81
81
|
totalOptions: 2,
|
|
82
82
|
},
|
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.37",
|
|
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.11.
|
|
33
|
+
"@gearbox-protocol/sdk-gov": "^1.11.3",
|
|
34
34
|
"axios": "^1.2.6",
|
|
35
35
|
"decimal.js-light": "^2.5.1",
|
|
36
36
|
"deep-eql": "^4.1.0",
|