@gearbox-protocol/sdk 1.2.9 → 1.3.1
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/creditAccount.js +1 -0
- package/lib/core/creditManager.js +10 -8
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/tokens/normal.d.ts +1 -1
- package/lib/tokens/normal.js +4 -4
- package/lib/tokens/token.js +6 -6
- package/lib/tokens/tokenType.d.ts +9 -10
- package/lib/tokens/tokenType.js +10 -10
- package/lib/types/contracts/interfaces/V1/{IPriceOracle.sol/IPriceOracleV2.d.ts → IPriceOracle.d.ts} +4 -4
- package/lib/types/contracts/interfaces/V1/{IPriceOracle.sol/IPriceOracleV2.js → IPriceOracle.js} +0 -0
- package/lib/types/contracts/interfaces/V1/index.d.ts +1 -2
- package/lib/types/contracts/pathfinder/interfaces/IDepositor.sol/IDepositorOptions.d.ts +31 -8
- package/lib/types/contracts/pathfinder/interfaces/IPathFinder.d.ts +36 -7
- package/lib/types/contracts/test/index.d.ts +2 -0
- package/lib/types/contracts/test/suites/index.d.ts +2 -0
- package/lib/types/contracts/{interfaces/V1/IPriceOracle.sol → test/suites}/index.js +0 -0
- package/lib/types/contracts/test/suites/mainnet/IPriceFeedsRegistry.d.ts +42 -0
- package/lib/types/contracts/test/suites/mainnet/IPriceFeedsRegistry.js +2 -0
- package/lib/types/contracts/test/suites/mainnet/ITokenTestSuite.d.ts +58 -0
- package/lib/types/contracts/test/suites/mainnet/ITokenTestSuite.js +2 -0
- package/lib/types/contracts/test/suites/mainnet/index.d.ts +2 -0
- package/lib/types/contracts/test/suites/mainnet/index.js +2 -0
- package/lib/types/factories/contracts/interfaces/V1/{IPriceOracle.sol/IPriceOracleV2__factory.d.ts → IPriceOracle__factory.d.ts} +4 -4
- package/lib/types/factories/contracts/interfaces/V1/{IPriceOracle.sol/IPriceOracleV2__factory.js → IPriceOracle__factory.js} +8 -8
- package/lib/types/factories/contracts/interfaces/V1/index.d.ts +1 -1
- package/lib/types/factories/contracts/interfaces/V1/index.js +3 -25
- package/lib/types/factories/contracts/pathfinder/interfaces/IDepositor.sol/IDepositorOptions__factory.js +235 -0
- package/lib/types/factories/contracts/pathfinder/interfaces/IPathFinder__factory.js +45 -28
- package/lib/types/factories/contracts/support/MultiCall.sol/Multicall2__factory.d.ts +1 -1
- package/lib/types/factories/contracts/support/MultiCall.sol/Multicall2__factory.js +1 -1
- package/lib/types/factories/contracts/test/index.d.ts +1 -0
- package/lib/types/factories/contracts/test/index.js +2 -1
- package/lib/types/factories/contracts/test/suites/index.d.ts +1 -0
- package/lib/types/factories/contracts/test/suites/index.js +30 -0
- package/lib/types/factories/contracts/test/suites/mainnet/IPriceFeedsRegistry__factory.d.ts +32 -0
- package/lib/types/factories/contracts/test/suites/mainnet/IPriceFeedsRegistry__factory.js +52 -0
- package/lib/types/factories/contracts/test/suites/mainnet/ITokenTestSuite__factory.d.ts +32 -0
- package/lib/types/factories/contracts/test/suites/mainnet/ITokenTestSuite__factory.js +90 -0
- package/lib/types/factories/contracts/test/suites/mainnet/index.d.ts +2 -0
- package/lib/types/factories/contracts/test/suites/mainnet/index.js +10 -0
- package/lib/types/index.d.ts +6 -0
- package/lib/types/index.js +7 -1
- package/lib/utils/extracter.d.ts +1 -1
- package/lib/utils/loading.js +1 -1
- package/package.json +1 -1
- package/lib/pathfinder/contracts.d.ts +0 -3
- package/lib/pathfinder/contracts.js +0 -15
- package/lib/pathfinder/convexLP.d.ts +0 -4
- package/lib/pathfinder/convexLP.js +0 -77
- package/lib/pathfinder/curveLP.d.ts +0 -9
- package/lib/pathfinder/curveLP.js +0 -95
- package/lib/pathfinder/path.d.ts +0 -34
- package/lib/pathfinder/path.js +0 -178
- package/lib/pathfinder/priority.d.ts +0 -2
- package/lib/pathfinder/priority.js +0 -17
- package/lib/pathfinder/trade.d.ts +0 -34
- package/lib/pathfinder/trade.js +0 -62
- package/lib/pathfinder/yVault.d.ts +0 -10
- package/lib/pathfinder/yVault.js +0 -100
- package/lib/types/contracts/interfaces/V1/IPriceOracle.sol/index.d.ts +0 -1
- package/lib/types/factories/contracts/interfaces/V1/IPriceOracle.sol/index.d.ts +0 -1
- package/lib/types/factories/contracts/interfaces/V1/IPriceOracle.sol/index.js +0 -8
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { BigNumber, BytesLike } from "ethers";
|
|
2
|
-
import { SwapType } from "./tradeTypes";
|
|
3
|
-
export interface CloseTradePath {
|
|
4
|
-
path: Array<string>;
|
|
5
|
-
amountOutMin: BigNumber;
|
|
6
|
-
}
|
|
7
|
-
export declare class TradePath {
|
|
8
|
-
readonly swapType: SwapType;
|
|
9
|
-
readonly amount: BigNumber;
|
|
10
|
-
readonly rate: BigNumber;
|
|
11
|
-
readonly path: Array<string>;
|
|
12
|
-
readonly expectedAmount: BigNumber;
|
|
13
|
-
readonly pathUniV3: BytesLike | undefined;
|
|
14
|
-
readonly i: number | undefined;
|
|
15
|
-
readonly j: number | undefined;
|
|
16
|
-
readonly operationName: string | undefined;
|
|
17
|
-
constructor(params: {
|
|
18
|
-
swapType: SwapType;
|
|
19
|
-
amount: BigNumber;
|
|
20
|
-
path: Array<string>;
|
|
21
|
-
expectedAmount: BigNumber;
|
|
22
|
-
pathUniV3?: BytesLike;
|
|
23
|
-
i?: number;
|
|
24
|
-
j?: number;
|
|
25
|
-
operationName?: string;
|
|
26
|
-
});
|
|
27
|
-
getExpectedAmountWithSlippage(slippage: number): BigNumber;
|
|
28
|
-
getAmountInMax(slippage: number): BigNumber;
|
|
29
|
-
getAmountOutMin(slippage: number): BigNumber;
|
|
30
|
-
get from(): string;
|
|
31
|
-
get to(): string;
|
|
32
|
-
getFromAmount(slippage: number): BigNumber;
|
|
33
|
-
getToAmount(slippage: number): BigNumber;
|
|
34
|
-
}
|
package/lib/pathfinder/trade.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TradePath = void 0;
|
|
4
|
-
var constants_1 = require("../core/constants");
|
|
5
|
-
var tradeTypes_1 = require("./tradeTypes");
|
|
6
|
-
var TradePath = /** @class */ (function () {
|
|
7
|
-
function TradePath(params) {
|
|
8
|
-
this.swapType = params.swapType;
|
|
9
|
-
this.amount = params.amount;
|
|
10
|
-
this.path = params.path;
|
|
11
|
-
this.expectedAmount = params.expectedAmount;
|
|
12
|
-
this.pathUniV3 = params.pathUniV3;
|
|
13
|
-
this.rate =
|
|
14
|
-
params.swapType !== tradeTypes_1.SwapType.ExactInput
|
|
15
|
-
? params.expectedAmount.mul(constants_1.WAD).div(params.amount)
|
|
16
|
-
: constants_1.WAD.mul(params.amount).div(params.expectedAmount);
|
|
17
|
-
this.i = params.i;
|
|
18
|
-
this.j = params.j;
|
|
19
|
-
this.operationName = params.operationName;
|
|
20
|
-
}
|
|
21
|
-
TradePath.prototype.getExpectedAmountWithSlippage = function (slippage) {
|
|
22
|
-
return this.swapType === tradeTypes_1.SwapType.ExactInput
|
|
23
|
-
? this.getAmountOutMin(slippage)
|
|
24
|
-
: this.getAmountInMax(slippage);
|
|
25
|
-
};
|
|
26
|
-
TradePath.prototype.getAmountInMax = function (slippage) {
|
|
27
|
-
return this.expectedAmount
|
|
28
|
-
.mul(constants_1.PERCENTAGE_FACTOR + slippage)
|
|
29
|
-
.div(constants_1.PERCENTAGE_FACTOR);
|
|
30
|
-
};
|
|
31
|
-
TradePath.prototype.getAmountOutMin = function (slippage) {
|
|
32
|
-
return this.expectedAmount
|
|
33
|
-
.mul(constants_1.PERCENTAGE_FACTOR)
|
|
34
|
-
.div(constants_1.PERCENTAGE_FACTOR + slippage);
|
|
35
|
-
};
|
|
36
|
-
Object.defineProperty(TradePath.prototype, "from", {
|
|
37
|
-
get: function () {
|
|
38
|
-
return this.path[0];
|
|
39
|
-
},
|
|
40
|
-
enumerable: false,
|
|
41
|
-
configurable: true
|
|
42
|
-
});
|
|
43
|
-
Object.defineProperty(TradePath.prototype, "to", {
|
|
44
|
-
get: function () {
|
|
45
|
-
return this.path[this.path.length - 1];
|
|
46
|
-
},
|
|
47
|
-
enumerable: false,
|
|
48
|
-
configurable: true
|
|
49
|
-
});
|
|
50
|
-
TradePath.prototype.getFromAmount = function (slippage) {
|
|
51
|
-
return this.swapType === tradeTypes_1.SwapType.ExactInput
|
|
52
|
-
? this.amount
|
|
53
|
-
: this.getExpectedAmountWithSlippage(slippage);
|
|
54
|
-
};
|
|
55
|
-
TradePath.prototype.getToAmount = function (slippage) {
|
|
56
|
-
return this.swapType === tradeTypes_1.SwapType.ExactOutput
|
|
57
|
-
? this.amount
|
|
58
|
-
: this.getExpectedAmountWithSlippage(slippage);
|
|
59
|
-
};
|
|
60
|
-
return TradePath;
|
|
61
|
-
}());
|
|
62
|
-
exports.TradePath = TradePath;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { CurveLPToken } from "../tokens/curveLP";
|
|
2
|
-
import { NormalToken } from "../tokens/normal";
|
|
3
|
-
import { YearnLPToken } from "../tokens/yearn";
|
|
4
|
-
import type { LPWithdrawPathFinder, Path } from "./path";
|
|
5
|
-
export declare class YearnVaultPathFinder implements LPWithdrawPathFinder {
|
|
6
|
-
_vault: YearnLPToken;
|
|
7
|
-
token: NormalToken | CurveLPToken;
|
|
8
|
-
constructor(vault: YearnLPToken);
|
|
9
|
-
findWithdrawPaths(path: Path): Promise<Array<Path>>;
|
|
10
|
-
}
|
package/lib/pathfinder/yVault.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.YearnVaultPathFinder = void 0;
|
|
40
|
-
var ethers_1 = require("ethers");
|
|
41
|
-
var token_1 = require("../tokens/token");
|
|
42
|
-
var yearn_1 = require("../tokens/yearn");
|
|
43
|
-
var types_1 = require("../types");
|
|
44
|
-
var mappers_1 = require("../utils/mappers");
|
|
45
|
-
var multicall_1 = require("../utils/multicall");
|
|
46
|
-
var YearnVaultPathFinder = /** @class */ (function () {
|
|
47
|
-
function YearnVaultPathFinder(vault) {
|
|
48
|
-
this._vault = vault;
|
|
49
|
-
var currentTokenData = yearn_1.yearnTokens[vault];
|
|
50
|
-
// Yearn Vault only has one lp action
|
|
51
|
-
this.token = currentTokenData.underlying;
|
|
52
|
-
}
|
|
53
|
-
// eslint-disable-next-line class-methods-use-this
|
|
54
|
-
YearnVaultPathFinder.prototype.findWithdrawPaths = function (path) {
|
|
55
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
-
var p, vaultBalances, vaultList, multicallData, prices, i, vault, vb, tokenAddress, adapterAddress, callData;
|
|
57
|
-
return __generator(this, function (_a) {
|
|
58
|
-
switch (_a.label) {
|
|
59
|
-
case 0:
|
|
60
|
-
p = Object.assign(Object.create(Object.getPrototypeOf(path)), path);
|
|
61
|
-
vaultBalances = (0, mappers_1.objectEntries)(yearn_1.yearnTokens).reduce(function (acc, _a) {
|
|
62
|
-
var yVault = _a[0], tokenData = _a[1];
|
|
63
|
-
var typedVault = yVault;
|
|
64
|
-
var currentBalance = p.popBalance(typedVault);
|
|
65
|
-
if (currentBalance.gt(1)) {
|
|
66
|
-
acc[typedVault] = {
|
|
67
|
-
token: tokenData.underlying,
|
|
68
|
-
balance: currentBalance,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
return acc;
|
|
72
|
-
}, {});
|
|
73
|
-
vaultList = Object.keys(vaultBalances);
|
|
74
|
-
multicallData = vaultList
|
|
75
|
-
.map(function (t) { return token_1.tokenDataByNetwork[p.networkType][t]; })
|
|
76
|
-
.map(function (addr) { return ({
|
|
77
|
-
address: addr,
|
|
78
|
-
interface: types_1.IYVault__factory.createInterface(),
|
|
79
|
-
method: "pricePerShare()",
|
|
80
|
-
}); });
|
|
81
|
-
return [4 /*yield*/, (0, multicall_1.multicall)(multicallData, p.provider)];
|
|
82
|
-
case 1:
|
|
83
|
-
prices = _a.sent();
|
|
84
|
-
for (i = 0; i < vaultList.length; i += 1) {
|
|
85
|
-
vault = vaultList[i];
|
|
86
|
-
vb = vaultBalances[vault];
|
|
87
|
-
p.balances[vb.token] = (p.balances[vb.token] || ethers_1.BigNumber.from(0)).add(ethers_1.BigNumber.from((vb === null || vb === void 0 ? void 0 : vb.balance) || 0).mul(prices[i]));
|
|
88
|
-
tokenAddress = token_1.tokenDataByNetwork[p.networkType][vault];
|
|
89
|
-
adapterAddress = p.creditManager.adapters[tokenAddress];
|
|
90
|
-
callData = types_1.IYVault__factory.createInterface().encodeFunctionData("withdraw()");
|
|
91
|
-
p.calls.push({ target: adapterAddress, callData: callData });
|
|
92
|
-
}
|
|
93
|
-
return [2 /*return*/, p.withdrawTokens()];
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
return YearnVaultPathFinder;
|
|
99
|
-
}());
|
|
100
|
-
exports.YearnVaultPathFinder = YearnVaultPathFinder;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type { IPriceOracleV2 } from "./IPriceOracleV2";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { IPriceOracleV2__factory } from "./IPriceOracleV2__factory";
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IPriceOracleV2__factory = void 0;
|
|
4
|
-
/* Autogenerated file. Do not edit manually. */
|
|
5
|
-
/* tslint:disable */
|
|
6
|
-
/* eslint-disable */
|
|
7
|
-
var IPriceOracleV2__factory_1 = require("./IPriceOracleV2__factory");
|
|
8
|
-
Object.defineProperty(exports, "IPriceOracleV2__factory", { enumerable: true, get: function () { return IPriceOracleV2__factory_1.IPriceOracleV2__factory; } });
|