@gearbox-protocol/sdk 0.0.53 → 0.0.56
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/core/contracts.d.ts +29 -16
- package/lib/core/contracts.js +45 -4
- package/lib/core/contractsRegister.js +24 -6
- package/lib/core/creditAccount.js +26 -20
- package/lib/core/events.d.ts +10 -10
- package/lib/core/events.js +22 -22
- package/lib/core/pathfinder.d.ts +35 -5
- package/lib/core/pathfinder.js +547 -67
- package/lib/core/priceFeeds.js +61 -0
- package/lib/core/token.d.ts +47 -15
- package/lib/core/token.js +204 -36
- package/lib/core/tradeTypes.d.ts +2 -0
- package/lib/core/transactions.d.ts +2 -2
- package/lib/core/transactions.js +10 -10
- package/lib/index.d.ts +2 -0
- package/lib/index.js +6 -1
- package/lib/pathfinder/connectorPathAsset.d.ts +7 -0
- package/lib/pathfinder/connectorPathAsset.js +144 -0
- package/lib/pathfinder/convexLPTokenPathAsset.d.ts +5 -0
- package/lib/pathfinder/convexLPTokenPathAsset.js +77 -0
- package/lib/pathfinder/curveLPPathAsset.d.ts +5 -0
- package/lib/pathfinder/curveLPPathAsset.js +72 -0
- package/lib/pathfinder/metaCurveLPPathAsset.d.ts +5 -0
- package/lib/pathfinder/metaCurveLPPathAsset.js +72 -0
- package/lib/pathfinder/normalTokenPathAsset.d.ts +5 -0
- package/lib/pathfinder/normalTokenPathAsset.js +136 -0
- package/lib/pathfinder/path.d.ts +41 -0
- package/lib/pathfinder/path.js +302 -0
- package/lib/pathfinder/pathfinder.d.ts +28 -0
- package/lib/pathfinder/pathfinder.js +519 -0
- package/lib/pathfinder/yearnVaultOfCurveLPPathAsset.d.ts +5 -0
- package/lib/pathfinder/yearnVaultOfCurveLPPathAsset.js +87 -0
- package/lib/pathfinder/yearnVaultOfMetaCurveLPPathAsset.d.ts +5 -0
- package/lib/pathfinder/yearnVaultOfMetaCurveLPPathAsset.js +87 -0
- package/lib/pathfinder/yearnVaultPathAsset.d.ts +5 -0
- package/lib/pathfinder/yearnVaultPathAsset.js +87 -0
- package/lib/utils/mappers.d.ts +6 -0
- package/lib/utils/mappers.js +33 -0
- package/lib/utils/types.d.ts +3 -0
- package/lib/utils/types.js +2 -0
- package/package.json +1 -1
- package/src/core/adapters.ts +13 -15
- package/src/core/contracts.ts +111 -44
- package/src/core/contractsRegister.ts +16 -8
- package/src/core/creditAccount.ts +33 -19
- package/src/core/events.ts +30 -22
- package/src/core/priceFeeds.ts +66 -0
- package/src/core/token.ts +645 -370
- package/src/core/tradeTypes.ts +2 -0
- package/src/core/transactions.ts +10 -10
- package/src/index.ts +2 -0
- package/src/pathfinder/connectorPathAsset.ts +69 -0
- package/src/pathfinder/convexLPTokenPathAsset.ts +33 -0
- package/src/pathfinder/curveLPPathAsset.ts +10 -0
- package/src/pathfinder/metaCurveLPPathAsset.ts +12 -0
- package/src/pathfinder/normalTokenPathAsset.ts +68 -0
- package/src/pathfinder/path.ts +259 -0
- package/src/pathfinder/yearnVaultOfCurveLPPathAsset.ts +22 -0
- package/src/pathfinder/yearnVaultOfMetaCurveLPPathAsset.ts +22 -0
- package/src/pathfinder/yearnVaultPathAsset.ts +27 -0
- package/src/utils/mappers.ts +23 -0
- package/src/utils/types.ts +3 -0
- package/src/core/pathfinder.ts +0 -115
package/src/core/pathfinder.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { BigNumber } from "ethers";
|
|
2
|
-
import { CreditManagerData } from "./creditManager";
|
|
3
|
-
import { MultiCall } from "./multicall";
|
|
4
|
-
import { SupportedToken } from "./token";
|
|
5
|
-
|
|
6
|
-
// const path = new Path({gasUsed:0, balances: creditAccount.balances, })
|
|
7
|
-
// const closurePath = await path.getBestPath();
|
|
8
|
-
// closurePath.calls -> multicalls (!)
|
|
9
|
-
// closurePath.balances[path.pool] = (X)
|
|
10
|
-
// closurePath.balances[!path.pool] = 0 / 1;
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
// [0,0,0, 100]
|
|
14
|
-
// [ 12, 12, 12, 0]
|
|
15
|
-
|
|
16
|
-
export class Path {
|
|
17
|
-
public readonly calls: Array<MultiCall> = [];
|
|
18
|
-
public readonly balances: Record<SupportedToken, BigNumber>;
|
|
19
|
-
// usedTokens: Array<SupportedTokens>;
|
|
20
|
-
protected _gasUsed: number;
|
|
21
|
-
public readonly pool: SupportedToken;
|
|
22
|
-
public readonly creditManager: CreditManagerData;
|
|
23
|
-
|
|
24
|
-
constructor(opts: {
|
|
25
|
-
gasUsed: number;
|
|
26
|
-
balances: Record<SupportedToken, BigNumber>;
|
|
27
|
-
pool: SupportedToken;
|
|
28
|
-
creditManager: CreditManagerData;
|
|
29
|
-
}) {
|
|
30
|
-
this._gasUsed = opts.gasUsed;
|
|
31
|
-
this.balances = opts.balances;
|
|
32
|
-
this.pool = opts.pool;
|
|
33
|
-
this.creditManager = opts.creditManager;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async getBestPath(): Promise<Path> {
|
|
37
|
-
// const nextToken = Object.entries(this.balances).filter(([token, balance]) => balance.gt(1) ) //.sort((a,b) => {})
|
|
38
|
-
// if (nextToken.length ===1 ) {
|
|
39
|
-
|
|
40
|
-
// }
|
|
41
|
-
|
|
42
|
-
// Get balances and keep non-zero only
|
|
43
|
-
// Find token with highest priority
|
|
44
|
-
// Get token type of this token
|
|
45
|
-
// switch (type) {
|
|
46
|
-
// case TokenType.YearnValut:
|
|
47
|
-
// const assetPathClass = new YearnPathAsset();
|
|
48
|
-
// return assetPathClass.getBestPath(this);
|
|
49
|
-
// ...
|
|
50
|
-
|
|
51
|
-
//}
|
|
52
|
-
throw new Error("Not implmented");
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface PathAsset {
|
|
57
|
-
getBestPath(p: Path): Promise<Path>;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export class ConnectorPathAsset implements PathAsset {
|
|
61
|
-
getBestPath(p: Path): Promise<Path> {
|
|
62
|
-
console.log(p);
|
|
63
|
-
// How to unwrap
|
|
64
|
-
// set balance of current token to 0
|
|
65
|
-
// add balnace what we get
|
|
66
|
-
// add call
|
|
67
|
-
// create new Paths
|
|
68
|
-
|
|
69
|
-
// 3CRV:
|
|
70
|
-
// coinst balance3crv = p.balance["3rcv"];
|
|
71
|
-
// const p.balance["3rcv"] = 0;
|
|
72
|
-
// DAI
|
|
73
|
-
// const daiPath = {...p};
|
|
74
|
-
// const daiPath["Dai"] = await curve.getAmount(t balance3crv);
|
|
75
|
-
|
|
76
|
-
// const pathDai = new Path(daiPath)
|
|
77
|
-
// ...
|
|
78
|
-
// const bestPath = pathDai.balance[0] > pathUSDC.balance(0) ? pathDai : pathUsdc;
|
|
79
|
-
|
|
80
|
-
// --- DAI
|
|
81
|
-
// --|
|
|
82
|
-
// --- USDC
|
|
83
|
-
//
|
|
84
|
-
// NORMAL TOKEN
|
|
85
|
-
// ============
|
|
86
|
-
//
|
|
87
|
-
// - NORMAL -> POOL (1 pair) => #1
|
|
88
|
-
// for(let conn of connectors) {
|
|
89
|
-
// const result = getAmount([NORMAL, conn, pool])
|
|
90
|
-
// }
|
|
91
|
-
// => best Path to get max Pool tokens
|
|
92
|
-
// const resultInConnector = getAmount([NORMAL, conn]);
|
|
93
|
-
// calls.push("Uniswap.swap(NORMAL, conn)");
|
|
94
|
-
|
|
95
|
-
// CRV => CRV -> USDC -> DAI
|
|
96
|
-
// LINK => LINK -> USDC -> DAI
|
|
97
|
-
//
|
|
98
|
-
// [UniV2.swap("CRV", "USDC"),
|
|
99
|
-
// UniV3.swap("LINK", "USDC"),
|
|
100
|
-
// Curve.exchange("USDC", "DAI")]
|
|
101
|
-
//
|
|
102
|
-
// Below is not optimal:
|
|
103
|
-
// [ UniV2.swap("CRV -> USDC -> DAI"),
|
|
104
|
-
// UniV2.swap("LINK -> USDC -> DAI")]
|
|
105
|
-
//
|
|
106
|
-
//
|
|
107
|
-
// [ UniV2.swap("CRV -> USDC")
|
|
108
|
-
// UniV2.swap("USDC -> DAI"),
|
|
109
|
-
// UniV2.swap("LINK -> USDC"),
|
|
110
|
-
// UniV2.swap("USDC -> DAI") ]
|
|
111
|
-
|
|
112
|
-
// return maxValuable(new Paths.getBestPath())
|
|
113
|
-
throw new Error("Method not implemented.");
|
|
114
|
-
}
|
|
115
|
-
}
|