@gearbox-protocol/sdk 1.5.4 → 1.5.7
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/contracts/contracts.d.ts +1 -0
- package/lib/contracts/contracts.js +3 -0
- package/lib/oracles/oracles.d.ts +0 -1
- package/lib/oracles/priceFeeds.js +0 -24
- package/lib/parsers/curveAdapterParser.d.ts +1 -0
- package/lib/parsers/curveAdapterParser.js +17 -3
- package/lib/parsers/curveAdapterParser.spec.js +1 -1
- package/lib/parsers/uniV3AdapterParser.js +15 -3
- package/lib/parsers/uniV3AdapterParser.spec.js +23 -0
- package/package.json +1 -1
|
@@ -29,6 +29,7 @@ export declare type CurveParams = {
|
|
|
29
29
|
type: AdapterInterface.CURVE_V1_2ASSETS | AdapterInterface.CURVE_V1_3ASSETS | AdapterInterface.CURVE_V1_4ASSETS | AdapterInterface.CURVE_V1_WRAPPER;
|
|
30
30
|
lpToken: CurveLPToken;
|
|
31
31
|
tokens: Array<NormalToken | CurveLPToken>;
|
|
32
|
+
underlyings?: Array<NormalToken>;
|
|
32
33
|
wrapper?: CurvePoolContract;
|
|
33
34
|
} & BaseContractParams;
|
|
34
35
|
export declare type CurveSteCRVPoolParams = {
|
|
@@ -126,6 +126,7 @@ exports.contractParams = {
|
|
|
126
126
|
type: adapters_1.AdapterInterface.CURVE_V1_2ASSETS,
|
|
127
127
|
lpToken: "FRAX3CRV",
|
|
128
128
|
tokens: ["FRAX", "3Crv"],
|
|
129
|
+
underlyings: ["FRAX", "DAI", "USDC", "USDT"],
|
|
129
130
|
},
|
|
130
131
|
CURVE_LUSD_POOL: {
|
|
131
132
|
name: "Curve LUSD",
|
|
@@ -133,6 +134,7 @@ exports.contractParams = {
|
|
|
133
134
|
type: adapters_1.AdapterInterface.CURVE_V1_2ASSETS,
|
|
134
135
|
lpToken: "LUSD3CRV",
|
|
135
136
|
tokens: ["LUSD", "3Crv"],
|
|
137
|
+
underlyings: ["LUSD", "DAI", "USDC", "USDT"],
|
|
136
138
|
},
|
|
137
139
|
CURVE_SUSD_POOL: {
|
|
138
140
|
name: "Curve SUSD",
|
|
@@ -155,6 +157,7 @@ exports.contractParams = {
|
|
|
155
157
|
type: adapters_1.AdapterInterface.CURVE_V1_2ASSETS,
|
|
156
158
|
lpToken: "gusd3CRV",
|
|
157
159
|
tokens: ["GUSD", "3Crv"],
|
|
160
|
+
underlyings: ["GUSD", "DAI", "USDC", "USDT"],
|
|
158
161
|
},
|
|
159
162
|
YEARN_DAI_VAULT: {
|
|
160
163
|
name: "Yearn DAI",
|
package/lib/oracles/oracles.d.ts
CHANGED
|
@@ -378,56 +378,32 @@ exports.priceFeedsByNetwork = {
|
|
|
378
378
|
priceFeedETH: {
|
|
379
379
|
type: oracles_1.OracleType.YEARN_TOKEN_ORACLE,
|
|
380
380
|
token: "DAI",
|
|
381
|
-
address: {
|
|
382
|
-
Mainnet: "",
|
|
383
|
-
Goerli: "TODO: DEPLOY ME",
|
|
384
|
-
},
|
|
385
381
|
},
|
|
386
382
|
priceFeedUSD: {
|
|
387
383
|
type: oracles_1.OracleType.YEARN_TOKEN_ORACLE,
|
|
388
384
|
token: "DAI",
|
|
389
|
-
address: {
|
|
390
|
-
Mainnet: "",
|
|
391
|
-
Goerli: "TODO: DEPLOY ME",
|
|
392
|
-
},
|
|
393
385
|
},
|
|
394
386
|
},
|
|
395
387
|
yvUSDC: {
|
|
396
388
|
priceFeedETH: {
|
|
397
389
|
type: oracles_1.OracleType.YEARN_TOKEN_ORACLE,
|
|
398
390
|
token: "USDC",
|
|
399
|
-
address: {
|
|
400
|
-
Mainnet: "",
|
|
401
|
-
Goerli: "TODO: DEPLOY ME",
|
|
402
|
-
},
|
|
403
391
|
},
|
|
404
392
|
priceFeedUSD: {
|
|
405
393
|
type: oracles_1.OracleType.YEARN_TOKEN_ORACLE,
|
|
406
394
|
token: "USDC",
|
|
407
|
-
address: {
|
|
408
|
-
Mainnet: "",
|
|
409
|
-
Goerli: "TODO: DEPLOY ME",
|
|
410
|
-
},
|
|
411
395
|
},
|
|
412
396
|
},
|
|
413
397
|
yvWETH: {
|
|
414
398
|
priceFeedUSD: {
|
|
415
399
|
type: oracles_1.OracleType.YEARN_TOKEN_ORACLE,
|
|
416
400
|
token: "WETH",
|
|
417
|
-
address: {
|
|
418
|
-
Mainnet: "",
|
|
419
|
-
Goerli: "TODO: DEPLOY ME",
|
|
420
|
-
},
|
|
421
401
|
},
|
|
422
402
|
},
|
|
423
403
|
yvWBTC: {
|
|
424
404
|
priceFeedUSD: {
|
|
425
405
|
type: oracles_1.OracleType.YEARN_TOKEN_ORACLE,
|
|
426
406
|
token: "WBTC",
|
|
427
|
-
address: {
|
|
428
|
-
Mainnet: "",
|
|
429
|
-
Goerli: "TODO: DEPLOY ME",
|
|
430
|
-
},
|
|
431
407
|
},
|
|
432
408
|
},
|
|
433
409
|
// CURVE LP TOKENS
|
|
@@ -8,5 +8,6 @@ export declare class CurveAdapterParser extends AbstractParser implements IParse
|
|
|
8
8
|
constructor(contract: SupportedContract, isContract: boolean);
|
|
9
9
|
parse(calldata: string): string;
|
|
10
10
|
getTokenByIndex(index: number): SupportedToken;
|
|
11
|
+
getUnderlyingTokenByIndex(index: number): SupportedToken;
|
|
11
12
|
convertAmounts(amounts: Array<BigNumberish>): string;
|
|
12
13
|
}
|
|
@@ -53,14 +53,24 @@ var CurveAdapterParser = /** @class */ (function (_super) {
|
|
|
53
53
|
case "exchange":
|
|
54
54
|
case "exchange_underlying": {
|
|
55
55
|
var _b = this.decodeFunctionData(functionFragment, calldata), i = _b[0], j = _b[1], dx = _b[2], min_dy = _b[3];
|
|
56
|
-
var iSym =
|
|
57
|
-
|
|
56
|
+
var iSym = functionFragment.name === "exchange_underlying"
|
|
57
|
+
? this.getUnderlyingTokenByIndex(i)
|
|
58
|
+
: this.getTokenByIndex(i);
|
|
59
|
+
var jSym = functionFragment.name === "exchange_underlying"
|
|
60
|
+
? this.getUnderlyingTokenByIndex(j)
|
|
61
|
+
: this.getTokenByIndex(j);
|
|
58
62
|
return "".concat(functionName, "(i ,j: ").concat(iSym, " => ").concat(jSym, ", dx: ").concat(this.formatBN(dx, iSym), ", min_dy: ").concat(this.formatBN(min_dy, jSym), ")");
|
|
59
63
|
}
|
|
60
64
|
case "exchange_all":
|
|
61
65
|
case "exchange_all_underlying": {
|
|
62
66
|
var _c = this.decodeFunctionData(functionFragment, calldata), i = _c[0], j = _c[1], rateMinRAY = _c[2];
|
|
63
|
-
|
|
67
|
+
var iSym = functionFragment.name === "exchange_all_underlying"
|
|
68
|
+
? this.getUnderlyingTokenByIndex(i)
|
|
69
|
+
: this.getTokenByIndex(i);
|
|
70
|
+
var jSym = functionFragment.name === "exchange_all_underlying"
|
|
71
|
+
? this.getUnderlyingTokenByIndex(j)
|
|
72
|
+
: this.getTokenByIndex(j);
|
|
73
|
+
return "".concat(functionName, "(i: ").concat(iSym, ", j: ").concat(jSym, ", rateMinRAY: ").concat((0, formatter_1.formatBN)(rateMinRAY, 27));
|
|
64
74
|
}
|
|
65
75
|
case "add_liquidity_one_coin": {
|
|
66
76
|
var _d = this.decodeFunctionData(functionFragment, calldata), amount = _d[0], i = _d[1], minAmount = _d[2];
|
|
@@ -92,6 +102,10 @@ var CurveAdapterParser = /** @class */ (function (_super) {
|
|
|
92
102
|
return contracts_1.contractParams[this.contract]
|
|
93
103
|
.tokens[index];
|
|
94
104
|
};
|
|
105
|
+
CurveAdapterParser.prototype.getUnderlyingTokenByIndex = function (index) {
|
|
106
|
+
return contracts_1.contractParams[this.contract]
|
|
107
|
+
.underlyings[index];
|
|
108
|
+
};
|
|
95
109
|
CurveAdapterParser.prototype.convertAmounts = function (amounts) {
|
|
96
110
|
var _this = this;
|
|
97
111
|
return amounts
|
|
@@ -16,7 +16,7 @@ describe("CurveAdapterParser test", function () {
|
|
|
16
16
|
constants_1.WAD.mul(3),
|
|
17
17
|
constants_1.WAD.mul(32),
|
|
18
18
|
]));
|
|
19
|
-
(0, chai_1.expect)(parsed).to.be.eq("Curve2AssetsAdapter[CURVE_FRAX_POOL].exchange_underlying(i ,j: FRAX =>
|
|
19
|
+
(0, chai_1.expect)(parsed).to.be.eq("Curve2AssetsAdapter[CURVE_FRAX_POOL].exchange_underlying(i ,j: FRAX => DAI, dx: 3.00 [3000000000000000000], min_dy: 32.00 [32000000000000000000])", "Curve2AssetsAdapter: Incorrect parse exchange_underlying");
|
|
20
20
|
parsed = parser.parse(ifc.encodeFunctionData("add_liquidity_one_coin", [
|
|
21
21
|
constants_1.WAD.mul(3),
|
|
22
22
|
0,
|
|
@@ -17,6 +17,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.UniswapV3AdapterParser = void 0;
|
|
19
19
|
var types_1 = require("../types");
|
|
20
|
+
var formatter_1 = require("../utils/formatter");
|
|
20
21
|
var abstractParser_1 = require("./abstractParser");
|
|
21
22
|
var UniswapV3AdapterParser = /** @class */ (function (_super) {
|
|
22
23
|
__extends(UniswapV3AdapterParser, _super);
|
|
@@ -38,22 +39,33 @@ var UniswapV3AdapterParser = /** @class */ (function (_super) {
|
|
|
38
39
|
var amountOutMinimumStr = this.formatBN(amountOutMinimum, tokenOut);
|
|
39
40
|
return "".concat(functionName, "(amountIn: ").concat(amountInStr, ", amountOutMinimum: ").concat(amountOutMinimumStr, ", path: ").concat(tokenInSym, " ==(fee: ").concat(fee, ")==> ").concat(tokenOutSym, ")");
|
|
40
41
|
}
|
|
42
|
+
case "exactAllInputSingle": {
|
|
43
|
+
var _c = this.decodeFunctionData(functionFragment, calldata).params, tokenIn = _c.tokenIn, tokenOut = _c.tokenOut, fee = _c.fee, rateMinRAY = _c.rateMinRAY;
|
|
44
|
+
var tokenInSym = this.tokenSymbol(tokenIn);
|
|
45
|
+
var tokenOutSym = this.tokenSymbol(tokenOut);
|
|
46
|
+
return "".concat(functionName, "(rate: ").concat((0, formatter_1.formatBN)(rateMinRAY, 27), ", path: ").concat(tokenInSym, " ==(fee: ").concat(fee, ")==> ").concat(tokenOutSym, ")");
|
|
47
|
+
}
|
|
41
48
|
case "exactInput": {
|
|
42
|
-
var
|
|
49
|
+
var _d = this.decodeFunctionData(functionFragment, calldata).params, amountIn = _d.amountIn, amountOutMinimum = _d.amountOutMinimum, path = _d.path;
|
|
43
50
|
var pathStr = this.trackInputPath(path);
|
|
44
51
|
var amountInStr = this.formatBN(amountIn, this.tokenSymbol("0x".concat(path.replace("0x", "").slice(0, 40))));
|
|
45
52
|
var amountOutMinimumStr = this.formatBN(amountOutMinimum, this.tokenSymbol("0x".concat(path.slice(-40, path.length))));
|
|
46
53
|
return "".concat(functionName, "(amountIn: ").concat(amountInStr, ", amountOutMinimum: ").concat(amountOutMinimumStr, ", path: ").concat(pathStr);
|
|
47
54
|
}
|
|
55
|
+
case "exactAllInput": {
|
|
56
|
+
var _e = this.decodeFunctionData(functionFragment, calldata).params, rateMinRAY = _e.rateMinRAY, path = _e.path;
|
|
57
|
+
var pathStr = this.trackInputPath(path);
|
|
58
|
+
return "".concat(functionName, "(rate: ").concat((0, formatter_1.formatBN)(rateMinRAY, 27), ", path: ").concat(pathStr);
|
|
59
|
+
}
|
|
48
60
|
case "exactOutput": {
|
|
49
|
-
var
|
|
61
|
+
var _f = this.decodeFunctionData(functionFragment, calldata).params, amountInMaximum = _f.amountInMaximum, amountOut = _f.amountOut, path = _f.path;
|
|
50
62
|
var pathStr = this.trackOutputPath(path);
|
|
51
63
|
var amountInMaximumStr = this.formatBN(amountInMaximum, this.tokenSymbol("0x".concat(path.slice(-40, path.length))));
|
|
52
64
|
var amountOutStr = this.formatBN(amountOut, this.tokenSymbol("0x".concat(path.replace("0x", "").slice(0, 40))));
|
|
53
65
|
return "".concat(functionName, "(amountInMaximum: ").concat(amountInMaximumStr, ", amountOut: ").concat(amountOutStr, ", path: ").concat(pathStr);
|
|
54
66
|
}
|
|
55
67
|
case "exactOutputSingle": {
|
|
56
|
-
var
|
|
68
|
+
var _g = this.decodeFunctionData(functionFragment, calldata)[0], tokenIn = _g[0], tokenOut = _g[1], fee = _g[2], amountOut = _g[5], amountInMaximum = _g[6];
|
|
57
69
|
var tokenInSym = this.tokenSymbol(tokenIn);
|
|
58
70
|
var tokenOutSym = this.tokenSymbol(tokenOut);
|
|
59
71
|
var amountInMaximumStr = this.formatBN(amountInMaximum, tokenInSym);
|
|
@@ -37,6 +37,17 @@ describe("UniswapV3AdapterParser test", function () {
|
|
|
37
37
|
},
|
|
38
38
|
]));
|
|
39
39
|
(0, chai_1.expect)(parsed).to.be.eq("UniswapV3Adapter[UNISWAP_V3_ROUTER].exactInputSingle(amountIn: 1.29M [1299000000000000000000000], amountOutMinimum: 10.20K [10200000000000000000000], path: 1INCH ==(fee: 3000)==> 3Crv)", "Incorrect parse swapExactTokensForTokens");
|
|
40
|
+
parsed = parser.parse(ifc.encodeFunctionData("exactAllInputSingle", [
|
|
41
|
+
{
|
|
42
|
+
tokenIn: token_1.tokenDataByNetwork.Goerli["1INCH"],
|
|
43
|
+
tokenOut: token_1.tokenDataByNetwork.Goerli["3Crv"],
|
|
44
|
+
fee: 3000,
|
|
45
|
+
deadline: 12300,
|
|
46
|
+
rateMinRAY: constants_1.RAY.mul(1200),
|
|
47
|
+
sqrtPriceLimitX96: 0,
|
|
48
|
+
},
|
|
49
|
+
]));
|
|
50
|
+
(0, chai_1.expect)(parsed).to.be.eq("UniswapV3Adapter[UNISWAP_V3_ROUTER].exactAllInputSingle(rate: 1.20K, path: 1INCH ==(fee: 3000)==> 3Crv)", "Incorrect parse swapExactTokensForTokens");
|
|
40
51
|
parsed = parser.parse(ifc.encodeFunctionData("exactInput", [
|
|
41
52
|
{
|
|
42
53
|
path: pathToUniV3Path([
|
|
@@ -51,6 +62,18 @@ describe("UniswapV3AdapterParser test", function () {
|
|
|
51
62
|
},
|
|
52
63
|
]));
|
|
53
64
|
(0, chai_1.expect)(parsed).to.be.eq("UniswapV3Adapter[UNISWAP_V3_ROUTER].exactInput(amountIn: 12.39K [12399000000000000000000], amountOutMinimum: 122.00 [122000000], path: AAVE ==(fee: 3000)==> LINK ==(fee: 3000)==> USDC", "Incorrect parse swapExactTokensForTokens");
|
|
65
|
+
parsed = parser.parse(ifc.encodeFunctionData("exactAllInput", [
|
|
66
|
+
{
|
|
67
|
+
path: pathToUniV3Path([
|
|
68
|
+
token_1.tokenDataByNetwork.Mainnet.AAVE,
|
|
69
|
+
token_1.tokenDataByNetwork.Mainnet.LINK,
|
|
70
|
+
token_1.tokenDataByNetwork.Mainnet.USDC,
|
|
71
|
+
]),
|
|
72
|
+
rateMinRAY: constants_1.RAY.mul(1200),
|
|
73
|
+
deadline: 1232131,
|
|
74
|
+
},
|
|
75
|
+
]));
|
|
76
|
+
(0, chai_1.expect)(parsed).to.be.eq("UniswapV3Adapter[UNISWAP_V3_ROUTER].exactAllInput(rate: 1.20K, path: AAVE ==(fee: 3000)==> LINK ==(fee: 3000)==> USDC", "Incorrect parse swapExactTokensForTokens");
|
|
54
77
|
parsed = parser.parse(ifc.encodeFunctionData("exactOutputSingle", [
|
|
55
78
|
{
|
|
56
79
|
tokenIn: token_1.tokenDataByNetwork.Goerli["1INCH"],
|