@gearbox-protocol/sdk 0.0.107 → 0.0.110
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/apy/convexAPY copy.d.ts +6 -0
- package/lib/apy/convexAPY copy.js +201 -0
- package/lib/apy/convexAPY.d.ts +9 -5
- package/lib/apy/convexAPY.js +29 -69
- package/lib/apy/curveAPY.d.ts +4 -0
- package/lib/apy/curveAPY.js +94 -0
- package/lib/apy/index.d.ts +6 -0
- package/lib/apy/index.js +20 -0
- package/lib/apy/lidoAPY.d.ts +1 -1
- package/lib/apy/lidoAPY.js +3 -3
- package/lib/apy/yearnAPY.d.ts +4 -0
- package/lib/apy/yearnAPY.js +90 -0
- package/lib/contracts/contractsRegister.js +2 -1
- package/lib/core/creditAccount.d.ts +2 -1
- package/lib/core/creditAccount.js +19 -12
- package/lib/core/creditManager.d.ts +3 -1
- package/lib/core/creditManager.js +25 -9
- package/lib/core/errors.d.ts +1 -1
- package/lib/core/pool.js +4 -4
- package/lib/core/strategy.d.ts +5 -3
- package/lib/core/strategy.js +6 -4
- package/lib/index.d.ts +4 -4
- package/lib/index.js +7 -6
- package/lib/strategies/curve.js +8 -10
- package/lib/strategies/yearn.js +8 -4
- package/lib/tokens/convex.d.ts +3 -0
- package/lib/tokens/convex.js +44 -18
- package/lib/tokens/curveLP.d.ts +1 -0
- package/lib/tokens/curveLP.js +11 -7
- package/lib/tokens/normal.d.ts +1 -0
- package/lib/tokens/normal.js +5 -1
- package/lib/tokens/token.d.ts +7 -2
- package/lib/tokens/token.js +10 -1
- package/lib/tokens/tokenData.js +2 -3
- package/lib/tokens/yearn.d.ts +1 -0
- package/lib/tokens/yearn.js +11 -7
- package/lib/utils/extracter.d.ts +11 -0
- package/lib/utils/extracter.js +19 -0
- package/lib/utils/mappers.d.ts +2 -2
- package/lib/utils/price.d.ts +8 -0
- package/lib/utils/price.js +26 -0
- package/package.json +1 -1
- package/src/apy/convexAPY.ts +47 -96
- package/src/apy/curveAPY.ts +68 -0
- package/src/apy/index.ts +8 -0
- package/src/apy/lidoAPY.ts +1 -1
- package/src/apy/yearnAPY.ts +66 -0
- package/src/contracts/contractsRegister.ts +2 -1
- package/src/core/creditAccount.ts +20 -12
- package/src/core/creditManager.ts +38 -11
- package/src/core/errors.ts +1 -0
- package/src/core/pool.ts +4 -4
- package/src/core/strategy.ts +16 -10
- package/src/index.ts +4 -4
- package/src/strategies/convex.ts +9 -3
- package/src/strategies/curve.ts +26 -18
- package/src/strategies/lido.ts +6 -2
- package/src/strategies/yearn.ts +17 -6
- package/src/tokens/convex.ts +43 -20
- package/src/tokens/curveLP.ts +9 -6
- package/src/tokens/normal.ts +3 -0
- package/src/tokens/token.ts +24 -6
- package/src/tokens/tokenData.ts +2 -4
- package/src/tokens/yearn.ts +9 -6
- package/src/utils/extracter.ts +30 -0
- package/src/utils/mappers.ts +2 -2
- package/src/utils/price.ts +33 -0
- package/lib/core/price.d.ts +0 -2
- package/lib/core/price.js +0 -14
- package/lib/types/@chainlink/contracts/src/v0.6/index.d.ts +0 -2
- package/lib/types/@chainlink/contracts/src/v0.6/index.js +0 -2
- package/lib/types/@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.d.ts +0 -146
- package/lib/types/@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.js +0 -2
- package/lib/types/@chainlink/contracts/src/v0.6/interfaces/index.d.ts +0 -1
- package/lib/types/@chainlink/contracts/src/v0.6/interfaces/index.js +0 -2
- package/lib/types/contracts/integrations/lido/IstETH.d.ts +0 -154
- package/lib/types/contracts/integrations/lido/IstETH.js +0 -2
- package/lib/types/contracts/interfaces/ICreditFacade.sol/ICreditFacadeBalanceChecker.d.ts +0 -50
- package/lib/types/contracts/interfaces/ICreditFacade.sol/ICreditFacadeBalanceChecker.js +0 -2
- package/lib/types/contracts/pathfinder/Balances.sol/BalanceOps.d.ts +0 -27
- package/lib/types/contracts/pathfinder/Balances.sol/BalanceOps.js +0 -2
- package/lib/types/contracts/pathfinder/Balances.sol/index.d.ts +0 -1
- package/lib/types/contracts/pathfinder/Balances.sol/index.js +0 -2
- package/lib/types/contracts/pathfinder/NormalTokenPathFinder.sol/PathFinder.d.ts +0 -269
- package/lib/types/contracts/pathfinder/NormalTokenPathFinder.sol/PathFinder.js +0 -2
- package/lib/types/contracts/pathfinder/NormalTokenPathFinder.sol/index.d.ts +0 -1
- package/lib/types/contracts/pathfinder/NormalTokenPathFinder.sol/index.js +0 -2
- package/lib/types/contracts/test/mocks/integrations/ConvexTokenRewardContractMock.sol/VirtualBalanceWrapper.d.ts +0 -58
- package/lib/types/contracts/test/mocks/integrations/ConvexTokenRewardContractMock.sol/VirtualBalanceWrapper.js +0 -2
- package/lib/types/contracts/test/pathfinder/UniswapV2PathFinder.t.sol/UniswapV2PathFinderAdapterTest.d.ts +0 -528
- package/lib/types/contracts/test/pathfinder/UniswapV2PathFinder.t.sol/UniswapV2PathFinderAdapterTest.js +0 -2
- package/lib/types/contracts/test/pathfinder/UniswapV3PathFinder.t.sol/UniswapV3PathFinderAdapterTest.d.ts +0 -528
- package/lib/types/contracts/test/pathfinder/UniswapV3PathFinder.t.sol/UniswapV3PathFinderAdapterTest.js +0 -2
- package/lib/types/factories/@chainlink/contracts/src/v0.6/index.d.ts +0 -1
- package/lib/types/factories/@chainlink/contracts/src/v0.6/index.js +0 -30
- package/lib/types/factories/@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface__factory.d.ts +0 -22
- package/lib/types/factories/@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface__factory.js +0 -133
- package/lib/types/factories/@chainlink/contracts/src/v0.6/interfaces/index.d.ts +0 -1
- package/lib/types/factories/@chainlink/contracts/src/v0.6/interfaces/index.js +0 -8
- package/lib/types/factories/contracts/integrations/lido/IstETH__factory.d.ts +0 -35
- package/lib/types/factories/contracts/integrations/lido/IstETH__factory.js +0 -224
- package/lib/types/factories/contracts/interfaces/ICreditFacade.sol/ICreditFacadeBalanceChecker__factory.d.ts +0 -18
- package/lib/types/factories/contracts/interfaces/ICreditFacade.sol/ICreditFacadeBalanceChecker__factory.js +0 -40
- package/lib/types/factories/contracts/pathfinder/Balances.sol/BalanceOps__factory.d.ts +0 -28
- package/lib/types/factories/contracts/pathfinder/Balances.sol/BalanceOps__factory.js +0 -76
- package/lib/types/factories/contracts/pathfinder/Balances.sol/index.d.ts +0 -1
- package/lib/types/factories/contracts/pathfinder/Balances.sol/index.js +0 -8
- package/lib/types/factories/contracts/pathfinder/NormalTokenPathFinder.sol/PathFinder__factory.d.ts +0 -144
- package/lib/types/factories/contracts/pathfinder/NormalTokenPathFinder.sol/PathFinder__factory.js +0 -522
- package/lib/types/factories/contracts/pathfinder/NormalTokenPathFinder.sol/index.d.ts +0 -1
- package/lib/types/factories/contracts/pathfinder/NormalTokenPathFinder.sol/index.js +0 -8
- package/lib/types/factories/contracts/test/mocks/integrations/ConvexTokenRewardContractMock.sol/VirtualBalanceWrapper__factory.d.ts +0 -34
- package/lib/types/factories/contracts/test/mocks/integrations/ConvexTokenRewardContractMock.sol/VirtualBalanceWrapper__factory.js +0 -110
- package/lib/types/factories/contracts/test/pathfinder/UniswapV2PathFinder.t.sol/UniswapV2PathFinderAdapterTest__factory.d.ts +0 -65
- package/lib/types/factories/contracts/test/pathfinder/UniswapV2PathFinder.t.sol/UniswapV2PathFinderAdapterTest__factory.js +0 -775
- package/lib/types/factories/contracts/test/pathfinder/UniswapV3PathFinder.t.sol/UniswapV3PathFinderAdapterTest__factory.d.ts +0 -65
- package/lib/types/factories/contracts/test/pathfinder/UniswapV3PathFinder.t.sol/UniswapV3PathFinderAdapterTest__factory.js +0 -775
- package/src/core/price.ts +0 -13
|
@@ -13,6 +13,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.getContractName = exports.deployedContracts = void 0;
|
|
15
15
|
var mappers_1 = require("../utils/mappers");
|
|
16
|
+
var formatter_1 = require("../utils/formatter");
|
|
16
17
|
var contracts_1 = require("./contracts");
|
|
17
18
|
exports.deployedContracts = {
|
|
18
19
|
// MAINNET
|
|
@@ -65,6 +66,6 @@ var contractNames = Object.entries(contracts_1.contractsByAddress).reduce(functi
|
|
|
65
66
|
}, {});
|
|
66
67
|
var contractsFullList = __assign(__assign({}, (0, mappers_1.keyToLowercase)(exports.deployedContracts)), contractNames);
|
|
67
68
|
function getContractName(address) {
|
|
68
|
-
return contractsFullList[address.toLowerCase()] || address;
|
|
69
|
+
return contractsFullList[address.toLowerCase()] || (0, formatter_1.shortAddress)(address);
|
|
69
70
|
}
|
|
70
71
|
exports.getContractName = getContractName;
|
|
@@ -25,8 +25,9 @@ export declare class CreditAccountData {
|
|
|
25
25
|
constructor(payload: CreditAccountDataPayload);
|
|
26
26
|
balancesSorted(prices: Record<string, BigNumber>, tokens: Record<string, TokenData>): Array<Balance>;
|
|
27
27
|
}
|
|
28
|
-
export declare function sortBalances(balances: Record<string, BigNumber>, prices: Record<string, BigNumber>, tokens: Record<string, TokenData>): [string, BigNumber]
|
|
28
|
+
export declare function sortBalances(balances: Record<string, BigNumber>, prices: Record<string, BigNumber>, tokens: Record<string, TokenData>): Array<[string, BigNumber]>;
|
|
29
29
|
export declare function tokensAbcComparator(t1?: TokenData, t2?: TokenData): 1 | -1;
|
|
30
|
+
export declare function amountAbcComparator(t1: BigNumber, t2: BigNumber): 1 | -1;
|
|
30
31
|
export declare class CreditAccountDataExtended extends CreditAccountData {
|
|
31
32
|
readonly repayAmount: BigNumber;
|
|
32
33
|
readonly liquidationAmount: BigNumber;
|
|
@@ -15,10 +15,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.CreditAccountDataExtended = exports.tokensAbcComparator = exports.sortBalances = exports.CreditAccountData = void 0;
|
|
18
|
+
exports.CreditAccountDataExtended = exports.amountAbcComparator = exports.tokensAbcComparator = exports.sortBalances = exports.CreditAccountData = void 0;
|
|
19
19
|
var ethers_1 = require("ethers");
|
|
20
|
+
var price_1 = require("../utils/price");
|
|
20
21
|
var constants_1 = require("./constants");
|
|
21
|
-
var price_1 = require("./price");
|
|
22
22
|
var CreditAccountData = /** @class */ (function () {
|
|
23
23
|
function CreditAccountData(payload) {
|
|
24
24
|
var _this = this;
|
|
@@ -27,12 +27,12 @@ var CreditAccountData = /** @class */ (function () {
|
|
|
27
27
|
this.balances = {};
|
|
28
28
|
this.allBalances = {};
|
|
29
29
|
this.version = 1;
|
|
30
|
-
this.id = payload.creditManager;
|
|
31
|
-
this.addr = payload.addr;
|
|
32
|
-
this.borrower = payload.borrower;
|
|
30
|
+
this.id = payload.creditManager.toLowerCase();
|
|
31
|
+
this.addr = payload.addr.toLowerCase();
|
|
32
|
+
this.borrower = payload.borrower.toLowerCase();
|
|
33
33
|
this.inUse = payload.inUse;
|
|
34
|
-
this.creditManager = payload.creditManager;
|
|
35
|
-
this.underlyingToken = payload.underlying;
|
|
34
|
+
this.creditManager = payload.creditManager.toLowerCase();
|
|
35
|
+
this.underlyingToken = payload.underlying.toLowerCase();
|
|
36
36
|
this.borrowedAmountPlusInterest = ethers_1.BigNumber.from(payload.borrowedAmountPlusInterest);
|
|
37
37
|
this.totalValue = ethers_1.BigNumber.from(payload.totalValue);
|
|
38
38
|
this.healthFactor =
|
|
@@ -44,12 +44,13 @@ var CreditAccountData = /** @class */ (function () {
|
|
|
44
44
|
.div(constants_1.RAY)
|
|
45
45
|
.toNumber() / constants_1.PERCENTAGE_FACTOR;
|
|
46
46
|
(payload.balances || []).forEach(function (b) {
|
|
47
|
+
var tokenLC = b.token.toLowerCase();
|
|
47
48
|
if (b.isAllowed) {
|
|
48
|
-
_this.balances[
|
|
49
|
-
_this.allowedTokens.push(
|
|
49
|
+
_this.balances[tokenLC] = ethers_1.BigNumber.from(b.balance);
|
|
50
|
+
_this.allowedTokens.push(tokenLC);
|
|
50
51
|
}
|
|
51
|
-
_this.allBalances[
|
|
52
|
-
_this.allTokens.push(
|
|
52
|
+
_this.allBalances[tokenLC] = ethers_1.BigNumber.from(b.balance);
|
|
53
|
+
_this.allTokens.push(tokenLC);
|
|
53
54
|
});
|
|
54
55
|
this.isDeleting = false;
|
|
55
56
|
}
|
|
@@ -75,7 +76,9 @@ function sortBalances(balances, prices, tokens) {
|
|
|
75
76
|
var totalPrice1 = (0, price_1.calcTotalPrice)(price1, amount1, token1 === null || token1 === void 0 ? void 0 : token1.decimals);
|
|
76
77
|
var totalPrice2 = (0, price_1.calcTotalPrice)(price2, amount2, token2 === null || token2 === void 0 ? void 0 : token2.decimals);
|
|
77
78
|
if (totalPrice1.eq(totalPrice2)) {
|
|
78
|
-
return
|
|
79
|
+
return amount1.eq(amount2)
|
|
80
|
+
? tokensAbcComparator(token1, token2)
|
|
81
|
+
: amountAbcComparator(amount1, amount2);
|
|
79
82
|
}
|
|
80
83
|
if (totalPrice1.gt(totalPrice2)) {
|
|
81
84
|
return -1;
|
|
@@ -90,6 +93,10 @@ function tokensAbcComparator(t1, t2) {
|
|
|
90
93
|
return symbol1 > symbol2 ? 1 : -1;
|
|
91
94
|
}
|
|
92
95
|
exports.tokensAbcComparator = tokensAbcComparator;
|
|
96
|
+
function amountAbcComparator(t1, t2) {
|
|
97
|
+
return (t1 === null || t1 === void 0 ? void 0 : t1.gt(t2)) ? -1 : 1;
|
|
98
|
+
}
|
|
99
|
+
exports.amountAbcComparator = amountAbcComparator;
|
|
93
100
|
var CreditAccountDataExtended = /** @class */ (function (_super) {
|
|
94
101
|
__extends(CreditAccountDataExtended, _super);
|
|
95
102
|
function CreditAccountDataExtended(payload) {
|
|
@@ -29,7 +29,9 @@ export declare class CreditManagerData {
|
|
|
29
29
|
encodeAddCollateral(accountAddress: string, tokenAddress: string, amount: BigNumber): MultiCall;
|
|
30
30
|
encodeIncreaseDebt(amount: BigNumber): MultiCall;
|
|
31
31
|
encodeDecreaseDebt(amount: BigNumber): MultiCall;
|
|
32
|
-
validateOpenAccount(
|
|
32
|
+
validateOpenAccount(collateral: BigNumber, debt: BigNumber): true;
|
|
33
|
+
protected validateOpenAccountV1(collateral: BigNumber, debt: BigNumber): true;
|
|
34
|
+
protected validateOpenAccountV2(debt: BigNumber): true;
|
|
33
35
|
}
|
|
34
36
|
export declare function calcMaxIncreaseBorrow(healthFactor: number, borrowAmountPlusInterest: BigNumber, maxLeverageFactor: number): BigNumber;
|
|
35
37
|
export declare function calcHealthFactorAfterIncreasingBorrow(healthFactor: number | undefined, borrowAmountPlusInterest: BigNumber | undefined, additional: BigNumber): number;
|
|
@@ -49,7 +49,9 @@ var CreditManagerData = /** @class */ (function () {
|
|
|
49
49
|
this.maxAmount = ethers_1.BigNumber.from(payload.maxAmount || 0);
|
|
50
50
|
this.maxLeverageFactor = ethers_1.BigNumber.from(payload.maxLeverageFactor || 0).toNumber();
|
|
51
51
|
this.availableLiquidity = ethers_1.BigNumber.from(payload.availableLiquidity || 0);
|
|
52
|
-
this.allowedTokens = (payload.collateralTokens || []).map(function (t) {
|
|
52
|
+
this.allowedTokens = (payload.collateralTokens || []).map(function (t) {
|
|
53
|
+
return t.toLowerCase();
|
|
54
|
+
});
|
|
53
55
|
this.adapters = (payload.adapters || []).reduce(function (acc, _a) {
|
|
54
56
|
var _b;
|
|
55
57
|
var allowedContract = _a.allowedContract, adapter = _a.adapter;
|
|
@@ -58,7 +60,7 @@ var CreditManagerData = /** @class */ (function () {
|
|
|
58
60
|
this.liquidationThresholds = (payload.liquidationThresholds || []).reduce(function (acc, threshold, index) {
|
|
59
61
|
var address = payload.collateralTokens[index];
|
|
60
62
|
if (address)
|
|
61
|
-
acc[address] = ethers_1.BigNumber.from(threshold);
|
|
63
|
+
acc[address.toLowerCase()] = ethers_1.BigNumber.from(threshold);
|
|
62
64
|
return acc;
|
|
63
65
|
}, {});
|
|
64
66
|
this.version = ethers_1.BigNumber.from(payload.version || 1).toNumber();
|
|
@@ -98,17 +100,31 @@ var CreditManagerData = /** @class */ (function () {
|
|
|
98
100
|
callData: types_1.ICreditFacade__factory.createInterface().encodeFunctionData("decreaseDebt", [amount])
|
|
99
101
|
};
|
|
100
102
|
};
|
|
101
|
-
CreditManagerData.prototype.validateOpenAccount = function (
|
|
102
|
-
|
|
103
|
+
CreditManagerData.prototype.validateOpenAccount = function (collateral, debt) {
|
|
104
|
+
return this.version === 2
|
|
105
|
+
? this.validateOpenAccountV2(debt)
|
|
106
|
+
: this.validateOpenAccountV1(collateral, debt);
|
|
107
|
+
};
|
|
108
|
+
CreditManagerData.prototype.validateOpenAccountV1 = function (collateral, debt) {
|
|
109
|
+
if (collateral.lt(this.minAmount))
|
|
103
110
|
throw new errors_1.OpenAccountError("amountLessMin", this.minAmount);
|
|
104
|
-
if (
|
|
111
|
+
if (collateral.gt(this.maxAmount))
|
|
105
112
|
throw new errors_1.OpenAccountError("amountGreaterMax", this.maxAmount);
|
|
113
|
+
var leverage = debt.mul(constants_1.LEVERAGE_DECIMALS).div(collateral).toNumber();
|
|
114
|
+
if (!leverage || leverage < 0)
|
|
115
|
+
throw new errors_1.OpenAccountError("wrongLeverage", ethers_1.BigNumber.from(0));
|
|
106
116
|
if (leverage > this.maxLeverageFactor)
|
|
107
117
|
throw new errors_1.OpenAccountError("leverageGreaterMax", ethers_1.BigNumber.from(this.maxLeverageFactor));
|
|
108
|
-
if (
|
|
109
|
-
.
|
|
110
|
-
|
|
111
|
-
|
|
118
|
+
if (debt.gt(this.availableLiquidity))
|
|
119
|
+
throw new errors_1.OpenAccountError("insufficientPoolLiquidity", ethers_1.BigNumber.from(this.availableLiquidity));
|
|
120
|
+
return true;
|
|
121
|
+
};
|
|
122
|
+
CreditManagerData.prototype.validateOpenAccountV2 = function (debt) {
|
|
123
|
+
if (debt.lt(this.minAmount))
|
|
124
|
+
throw new errors_1.OpenAccountError("amountLessMin", this.minAmount);
|
|
125
|
+
if (debt.gt(this.maxAmount))
|
|
126
|
+
throw new errors_1.OpenAccountError("amountGreaterMax", this.maxAmount);
|
|
127
|
+
if (debt.gt(this.availableLiquidity))
|
|
112
128
|
throw new errors_1.OpenAccountError("insufficientPoolLiquidity", ethers_1.BigNumber.from(this.availableLiquidity));
|
|
113
129
|
return true;
|
|
114
130
|
};
|
package/lib/core/errors.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare class PathNotFoundError extends Error {
|
|
|
25
25
|
export declare class AccountsInAlllCreditManagersError extends Error {
|
|
26
26
|
constructor();
|
|
27
27
|
}
|
|
28
|
-
export declare type OpenAccountErrorTypes = "insufficientPoolLiquidity" | "leverageGreaterMax" | "amountGreaterMax" | "amountLessMin";
|
|
28
|
+
export declare type OpenAccountErrorTypes = "insufficientPoolLiquidity" | "leverageGreaterMax" | "wrongLeverage" | "amountGreaterMax" | "amountLessMin";
|
|
29
29
|
export declare class OpenAccountError extends Error {
|
|
30
30
|
message: OpenAccountErrorTypes;
|
|
31
31
|
payload: {
|
package/lib/core/pool.js
CHANGED
|
@@ -8,10 +8,10 @@ var constants_1 = require("./constants");
|
|
|
8
8
|
var PoolData = /** @class */ (function () {
|
|
9
9
|
function PoolData(payload) {
|
|
10
10
|
this.isPaused = false;
|
|
11
|
-
this.id = payload.addr;
|
|
12
|
-
this.address = payload.addr;
|
|
13
|
-
this.underlyingToken = payload.underlying
|
|
14
|
-
this.dieselToken = payload.dieselToken
|
|
11
|
+
this.id = payload.addr.toLowerCase();
|
|
12
|
+
this.address = payload.addr.toLowerCase();
|
|
13
|
+
this.underlyingToken = payload.underlying.toLowerCase();
|
|
14
|
+
this.dieselToken = payload.dieselToken.toLowerCase();
|
|
15
15
|
this.isWETH = payload.isWETH || false;
|
|
16
16
|
this.expectedLiquidity = ethers_1.BigNumber.from(payload.expectedLiquidity);
|
|
17
17
|
this.expectedLiquidityLimit = ethers_1.BigNumber.from(payload.expectedLiquidityLimit || 0);
|
package/lib/core/strategy.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { BigNumber } from "ethers";
|
|
2
|
+
import { TokensWithAPY } from "../apy";
|
|
2
3
|
export interface StrategyPayload {
|
|
3
4
|
apy?: number;
|
|
5
|
+
apyTokenSymbol: TokensWithAPY;
|
|
4
6
|
name: string;
|
|
5
7
|
lpToken: string;
|
|
6
8
|
pools: Array<string>;
|
|
@@ -29,8 +31,8 @@ export declare class Strategy {
|
|
|
29
31
|
maxAPY(maxLeverage: number, poolApy: PoolList): number;
|
|
30
32
|
overallAPY(apy: number, leverage: number, depositCollateral: string, borrowAPY: number): number;
|
|
31
33
|
liquidationPrice(borrowed: TokenDescription, collateral: TokenDescription, lp: TokenDescription, ltCollateral: BigNumber): BigNumber;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
protected farmLev(leverage: number, depositCollateral: string): number;
|
|
35
|
+
protected inBaseAssets(depositCollateral: string): boolean;
|
|
36
|
+
protected inLeveragableAssets(depositCollateral: string): boolean;
|
|
35
37
|
}
|
|
36
38
|
export {};
|
package/lib/core/strategy.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Strategy = void 0;
|
|
4
4
|
var ethers_1 = require("ethers");
|
|
5
|
+
var price_1 = require("../utils/price");
|
|
5
6
|
var constants_1 = require("./constants");
|
|
6
|
-
var price_1 = require("./price");
|
|
7
7
|
var Strategy = /** @class */ (function () {
|
|
8
8
|
function Strategy(payload) {
|
|
9
9
|
this.apy = payload.apy;
|
|
@@ -29,9 +29,11 @@ var Strategy = /** @class */ (function () {
|
|
|
29
29
|
.mul(ltCollateral)
|
|
30
30
|
.div(constants_1.PERCENTAGE_FACTOR);
|
|
31
31
|
var lpMoney = (0, price_1.calcTotalPrice)(lp.price, lp.amount, lp.decimals);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
: ethers_1.BigNumber.from(0);
|
|
32
|
+
if (lpMoney.gt(0)) {
|
|
33
|
+
var lqPrice = borrowedMoney.sub(collateralMoney).mul(constants_1.WAD).div(lpMoney);
|
|
34
|
+
return lqPrice.gte(0) ? lqPrice : ethers_1.BigNumber.from(0);
|
|
35
|
+
}
|
|
36
|
+
return ethers_1.BigNumber.from(0);
|
|
35
37
|
};
|
|
36
38
|
Strategy.prototype.farmLev = function (leverage, depositCollateral) {
|
|
37
39
|
return this.inBaseAssets(depositCollateral) ||
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export * from "./core/constants";
|
|
2
|
-
export * from "./core/price";
|
|
3
2
|
export * from "./core/creditAccount";
|
|
4
3
|
export * from "./core/creditManager";
|
|
5
4
|
export * from "./core/creditSession";
|
|
@@ -36,12 +35,12 @@ export * from "./tokens/curveLP";
|
|
|
36
35
|
export * from "./tokens/gear";
|
|
37
36
|
export * from "./tokens/normal";
|
|
38
37
|
export * from "./tokens/yearn";
|
|
39
|
-
export * from "./apy
|
|
40
|
-
export * from "./apy/convexAPY";
|
|
38
|
+
export * from "./apy";
|
|
41
39
|
export * from "./core/history";
|
|
42
40
|
export * from "./utils/multicall";
|
|
43
41
|
export * from "./utils/types";
|
|
44
42
|
export * from "./utils/errors";
|
|
43
|
+
export * from "./utils/price";
|
|
45
44
|
export * from "./strategies/convex";
|
|
46
45
|
export * from "./strategies/creditFacade";
|
|
47
46
|
export * from "./strategies/curve";
|
|
@@ -53,4 +52,5 @@ export { callRepeater } from "./utils/repeater";
|
|
|
53
52
|
export { getContractName } from "./contracts/contractsRegister";
|
|
54
53
|
export { AdapterInterface } from "./contracts/adapters";
|
|
55
54
|
export { objectEntries, swapKeyValue, keyToLowercase } from "./utils/mappers";
|
|
56
|
-
export {
|
|
55
|
+
export { getPoolTokens, getUnderlyingToken } from "./utils/extracter";
|
|
56
|
+
export * from "./pathfinder/tradeTypes";
|
package/lib/index.js
CHANGED
|
@@ -14,9 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.getUnderlyingToken = exports.getPoolTokens = exports.keyToLowercase = exports.swapKeyValue = exports.objectEntries = exports.AdapterInterface = exports.getContractName = exports.callRepeater = exports.TokenType = void 0;
|
|
18
18
|
__exportStar(require("./core/constants"), exports);
|
|
19
|
-
__exportStar(require("./core/price"), exports);
|
|
20
19
|
__exportStar(require("./core/creditAccount"), exports);
|
|
21
20
|
__exportStar(require("./core/creditManager"), exports);
|
|
22
21
|
__exportStar(require("./core/creditSession"), exports);
|
|
@@ -55,12 +54,12 @@ __exportStar(require("./tokens/curveLP"), exports);
|
|
|
55
54
|
__exportStar(require("./tokens/gear"), exports);
|
|
56
55
|
__exportStar(require("./tokens/normal"), exports);
|
|
57
56
|
__exportStar(require("./tokens/yearn"), exports);
|
|
58
|
-
__exportStar(require("./apy
|
|
59
|
-
__exportStar(require("./apy/convexAPY"), exports);
|
|
57
|
+
__exportStar(require("./apy"), exports);
|
|
60
58
|
__exportStar(require("./core/history"), exports);
|
|
61
59
|
__exportStar(require("./utils/multicall"), exports);
|
|
62
60
|
__exportStar(require("./utils/types"), exports);
|
|
63
61
|
__exportStar(require("./utils/errors"), exports);
|
|
62
|
+
__exportStar(require("./utils/price"), exports);
|
|
64
63
|
__exportStar(require("./strategies/convex"), exports);
|
|
65
64
|
__exportStar(require("./strategies/creditFacade"), exports);
|
|
66
65
|
__exportStar(require("./strategies/curve"), exports);
|
|
@@ -78,5 +77,7 @@ var mappers_1 = require("./utils/mappers");
|
|
|
78
77
|
Object.defineProperty(exports, "objectEntries", { enumerable: true, get: function () { return mappers_1.objectEntries; } });
|
|
79
78
|
Object.defineProperty(exports, "swapKeyValue", { enumerable: true, get: function () { return mappers_1.swapKeyValue; } });
|
|
80
79
|
Object.defineProperty(exports, "keyToLowercase", { enumerable: true, get: function () { return mappers_1.keyToLowercase; } });
|
|
81
|
-
var
|
|
82
|
-
Object.defineProperty(exports, "
|
|
80
|
+
var extracter_1 = require("./utils/extracter");
|
|
81
|
+
Object.defineProperty(exports, "getPoolTokens", { enumerable: true, get: function () { return extracter_1.getPoolTokens; } });
|
|
82
|
+
Object.defineProperty(exports, "getUnderlyingToken", { enumerable: true, get: function () { return extracter_1.getUnderlyingToken; } });
|
|
83
|
+
__exportStar(require("./pathfinder/tradeTypes"), exports);
|
package/lib/strategies/curve.js
CHANGED
|
@@ -155,14 +155,12 @@ var CurveStrategies = /** @class */ (function () {
|
|
|
155
155
|
var calls = [];
|
|
156
156
|
var curveParams = contracts_1.contractParams[curvePool];
|
|
157
157
|
var tokenToDeposit = curveParams.tokens[0];
|
|
158
|
-
if (data.underlyingToken
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (data.underlyingToken === token_1.tokenDataByNetwork[network][tokenToDeposit]) {
|
|
162
|
-
calls.push(CurveMulticaller.connect(data.adapters[contracts_1.contractsByNetwork[network][curvePool].toLowerCase()]).add_liquidity_one_coin(underlyingAmount, 0, 0));
|
|
158
|
+
if (data.underlyingToken.toLowerCase() !==
|
|
159
|
+
token_1.tokenDataByNetwork[network][tokenToDeposit].toLowerCase()) {
|
|
160
|
+
calls.push(uniswapV2_1.UniswapV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network].UNISWAP_V2_ROUTER.toLowerCase()]).swapExactTokensForTokens(underlyingAmount, 0, [data.underlyingToken, token_1.tokenDataByNetwork[network][tokenToDeposit]], constants_1.ADDRESS_0X0, Math.floor(new Date().getTime() / 1000) + 3600), CurveMulticaller.connect(data.adapters[contracts_1.contractsByNetwork[network][curvePool].toLowerCase()]).add_all_liquidity_one_coin(0, 0));
|
|
163
161
|
}
|
|
164
162
|
else {
|
|
165
|
-
calls.push(CurveMulticaller.connect(data.adapters[contracts_1.contractsByNetwork[network][curvePool].toLowerCase()]).
|
|
163
|
+
calls.push(CurveMulticaller.connect(data.adapters[contracts_1.contractsByNetwork[network][curvePool].toLowerCase()]).add_liquidity_one_coin(underlyingAmount, 0, 0));
|
|
166
164
|
}
|
|
167
165
|
return calls;
|
|
168
166
|
};
|
|
@@ -179,8 +177,8 @@ var CurveStrategies = /** @class */ (function () {
|
|
|
179
177
|
data.adapters[contracts_1.contractsByNetwork[network][curvePool].toLowerCase()];
|
|
180
178
|
}
|
|
181
179
|
calls.push(CurveMulticaller.connect(curveContractAddress).remove_liquidity_one_coin(curveLPAmount, 0, 0));
|
|
182
|
-
if (token_1.tokenDataByNetwork[network][curveParams.tokens[0]] !==
|
|
183
|
-
data.underlyingToken) {
|
|
180
|
+
if (token_1.tokenDataByNetwork[network][curveParams.tokens[0]].toLowerCase() !==
|
|
181
|
+
data.underlyingToken.toLowerCase()) {
|
|
184
182
|
calls.push(uniswapV2_1.UniswapV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network].UNISWAP_V2_ROUTER.toLowerCase()]).swapAllTokensForTokens(0, [
|
|
185
183
|
token_1.tokenDataByNetwork[network][curveParams.tokens[0]],
|
|
186
184
|
data.underlyingToken
|
|
@@ -201,8 +199,8 @@ var CurveStrategies = /** @class */ (function () {
|
|
|
201
199
|
data.adapters[contracts_1.contractsByNetwork[network][curvePool].toLowerCase()];
|
|
202
200
|
}
|
|
203
201
|
calls.push(CurveMulticaller.connect(curveContractAddress).remove_all_liquidity_one_coin(0, 0));
|
|
204
|
-
if (token_1.tokenDataByNetwork[network][curveParams.tokens[0]] !==
|
|
205
|
-
data.underlyingToken) {
|
|
202
|
+
if (token_1.tokenDataByNetwork[network][curveParams.tokens[0]].toLowerCase() !==
|
|
203
|
+
data.underlyingToken.toLowerCase()) {
|
|
206
204
|
calls.push(uniswapV2_1.UniswapV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network].UNISWAP_V2_ROUTER.toLowerCase()]).swapAllTokensForTokens(0, [
|
|
207
205
|
token_1.tokenDataByNetwork[network][curveParams.tokens[0]],
|
|
208
206
|
data.underlyingToken
|
package/lib/strategies/yearn.js
CHANGED
|
@@ -85,14 +85,18 @@ var YearnV2Strategies = /** @class */ (function () {
|
|
|
85
85
|
var yearnToken = vaultParams.shareToken;
|
|
86
86
|
var yearnParams = token_1.supportedTokens[yearnToken];
|
|
87
87
|
if (yearnParams.type === tokenType_1.TokenType.YEARN_VAULT) {
|
|
88
|
-
if (data.underlyingToken !==
|
|
89
|
-
token_1.tokenDataByNetwork[network][yearnParams.underlying]) {
|
|
88
|
+
if (data.underlyingToken.toLowerCase() !==
|
|
89
|
+
token_1.tokenDataByNetwork[network][yearnParams.underlying].toLowerCase()) {
|
|
90
90
|
// This should be a pathfinder call
|
|
91
91
|
calls.push(uniswapV2_1.UniswapV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network].UNISWAP_V2_ROUTER.toLowerCase()]).swapExactTokensForTokens(underlyingAmount, 0, [
|
|
92
92
|
data.underlyingToken,
|
|
93
93
|
token_1.tokenDataByNetwork[network][yearnParams.underlying]
|
|
94
94
|
], constants_1.ADDRESS_0X0, Math.floor(new Date().getTime() / 1000) + 3600));
|
|
95
95
|
}
|
|
96
|
+
else {
|
|
97
|
+
calls.push(YearnV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network][yearnVault].toLowerCase()]).deposit(underlyingAmount));
|
|
98
|
+
return calls;
|
|
99
|
+
}
|
|
96
100
|
}
|
|
97
101
|
else if (yearnParams.type === tokenType_1.TokenType.YEARN_VAULT_OF_CURVE_LP ||
|
|
98
102
|
yearnParams.type === tokenType_1.TokenType.YEARN_VAULT_OF_META_CURVE_LP) {
|
|
@@ -113,8 +117,8 @@ var YearnV2Strategies = /** @class */ (function () {
|
|
|
113
117
|
var yearnParams = token_1.supportedTokens[yearnToken];
|
|
114
118
|
calls.push(YearnV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network][yearnVault].toLowerCase()]).withdraw(yearnSharesAmount));
|
|
115
119
|
if (yearnParams.type === tokenType_1.TokenType.YEARN_VAULT) {
|
|
116
|
-
if (data.underlyingToken !==
|
|
117
|
-
token_1.tokenDataByNetwork[network][yearnParams.underlying]) {
|
|
120
|
+
if (data.underlyingToken.toLowerCase() !==
|
|
121
|
+
token_1.tokenDataByNetwork[network][yearnParams.underlying].toLowerCase()) {
|
|
118
122
|
// This should be a pathfinder call
|
|
119
123
|
calls.push(uniswapV2_1.UniswapV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network].UNISWAP_V2_ROUTER.toLowerCase()]).swapAllTokensForTokens(0, [
|
|
120
124
|
token_1.tokenDataByNetwork[network][yearnParams.underlying],
|
package/lib/tokens/convex.d.ts
CHANGED
|
@@ -22,4 +22,7 @@ export declare type ConvexPhantomTokenData = {
|
|
|
22
22
|
lpToken: ConvexLPToken;
|
|
23
23
|
} & BaseConvexToken;
|
|
24
24
|
export declare const convexTokens: Record<ConvexLPToken | ConvexStakedPhantomToken, ConvexLPTokenData | ConvexPhantomTokenData>;
|
|
25
|
+
export declare const isConvexToken: (t: unknown) => t is ConvexLPToken | ConvexStakedPhantomToken;
|
|
26
|
+
export declare const isConvexLPToken: (t: unknown) => t is ConvexLPToken;
|
|
27
|
+
export declare const isConvexStakedPhantomToken: (t: unknown) => t is ConvexStakedPhantomToken;
|
|
25
28
|
export {};
|
package/lib/tokens/convex.js
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convexTokens = void 0;
|
|
14
|
+
exports.isConvexStakedPhantomToken = exports.isConvexLPToken = exports.isConvexToken = exports.convexTokens = void 0;
|
|
4
15
|
var tradeTypes_1 = require("../pathfinder/tradeTypes");
|
|
5
16
|
var tokenType_1 = require("./tokenType");
|
|
6
|
-
|
|
7
|
-
// CONVEX LP TOKENS
|
|
17
|
+
var convexLpTokens = {
|
|
8
18
|
cvx3Crv: {
|
|
9
|
-
name: "cvx3Crv",
|
|
19
|
+
name: "Convex cvx3Crv",
|
|
10
20
|
decimals: 18,
|
|
11
21
|
symbol: "cvx3Crv",
|
|
12
22
|
type: tokenType_1.TokenType.CONVEX_LP_TOKEN,
|
|
@@ -28,7 +38,7 @@ exports.convexTokens = {
|
|
|
28
38
|
]
|
|
29
39
|
},
|
|
30
40
|
cvxsteCRV: {
|
|
31
|
-
name: "cvxsteCRV",
|
|
41
|
+
name: "Convex cvxsteCRV",
|
|
32
42
|
decimals: 18,
|
|
33
43
|
symbol: "cvxsteCRV",
|
|
34
44
|
type: tokenType_1.TokenType.CONVEX_LP_TOKEN,
|
|
@@ -50,7 +60,7 @@ exports.convexTokens = {
|
|
|
50
60
|
]
|
|
51
61
|
},
|
|
52
62
|
cvxFRAX3CRV: {
|
|
53
|
-
name: "cvxFRAX3CRV-f",
|
|
63
|
+
name: "Convex cvxFRAX3CRV-f",
|
|
54
64
|
decimals: 18,
|
|
55
65
|
symbol: "cvxFRAX3CRV",
|
|
56
66
|
type: tokenType_1.TokenType.CONVEX_LP_TOKEN,
|
|
@@ -72,7 +82,7 @@ exports.convexTokens = {
|
|
|
72
82
|
]
|
|
73
83
|
},
|
|
74
84
|
cvxLUSD3CRV: {
|
|
75
|
-
name: "cvxLUSD3CRV-f",
|
|
85
|
+
name: "Convex cvxLUSD3CRV-f",
|
|
76
86
|
decimals: 18,
|
|
77
87
|
symbol: "cvxLUSD3CRV",
|
|
78
88
|
type: tokenType_1.TokenType.CONVEX_LP_TOKEN,
|
|
@@ -94,7 +104,7 @@ exports.convexTokens = {
|
|
|
94
104
|
]
|
|
95
105
|
},
|
|
96
106
|
cvxcrvPlain3andSUSD: {
|
|
97
|
-
name: "cvxcrvPlain3andSUSD",
|
|
107
|
+
name: "Convex cvxcrvPlain3andSUSD",
|
|
98
108
|
decimals: 18,
|
|
99
109
|
symbol: "cvxcrvPlain3andSUSD",
|
|
100
110
|
type: tokenType_1.TokenType.CONVEX_LP_TOKEN,
|
|
@@ -116,7 +126,7 @@ exports.convexTokens = {
|
|
|
116
126
|
]
|
|
117
127
|
},
|
|
118
128
|
cvxgusd3CRV: {
|
|
119
|
-
name: "cvxgusd3CRV",
|
|
129
|
+
name: "Convex cvxgusd3CRV",
|
|
120
130
|
decimals: 18,
|
|
121
131
|
symbol: "cvxgusd3CRV",
|
|
122
132
|
type: tokenType_1.TokenType.CONVEX_LP_TOKEN,
|
|
@@ -136,10 +146,11 @@ exports.convexTokens = {
|
|
|
136
146
|
tokenOut: "stkcvxgusd3CRV"
|
|
137
147
|
}
|
|
138
148
|
]
|
|
139
|
-
}
|
|
140
|
-
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
var convexStakedPhantomTokens = {
|
|
141
152
|
stkcvx3Crv: {
|
|
142
|
-
name: "stkcvx3Crv",
|
|
153
|
+
name: "Convex stkcvx3Crv",
|
|
143
154
|
decimals: 18,
|
|
144
155
|
symbol: "stkcvx3Crv",
|
|
145
156
|
type: tokenType_1.TokenType.CONVEX_STAKED_PHANTOM_TOKEN,
|
|
@@ -161,7 +172,7 @@ exports.convexTokens = {
|
|
|
161
172
|
]
|
|
162
173
|
},
|
|
163
174
|
stkcvxsteCRV: {
|
|
164
|
-
name: "stkcvxsteCRV",
|
|
175
|
+
name: "Convex stkcvxsteCRV",
|
|
165
176
|
decimals: 18,
|
|
166
177
|
symbol: "stkcvxsteCRV",
|
|
167
178
|
type: tokenType_1.TokenType.CONVEX_STAKED_PHANTOM_TOKEN,
|
|
@@ -183,7 +194,7 @@ exports.convexTokens = {
|
|
|
183
194
|
]
|
|
184
195
|
},
|
|
185
196
|
stkcvxFRAX3CRV: {
|
|
186
|
-
name: "stkcvxFRAX3CRV-f",
|
|
197
|
+
name: "Convex stkcvxFRAX3CRV-f",
|
|
187
198
|
decimals: 18,
|
|
188
199
|
symbol: "stkcvxFRAX3CRV",
|
|
189
200
|
type: tokenType_1.TokenType.CONVEX_STAKED_PHANTOM_TOKEN,
|
|
@@ -205,12 +216,12 @@ exports.convexTokens = {
|
|
|
205
216
|
]
|
|
206
217
|
},
|
|
207
218
|
stkcvxLUSD3CRV: {
|
|
208
|
-
name: "stkcvxLUSD3CRV-f",
|
|
219
|
+
name: "Convex stkcvxLUSD3CRV-f",
|
|
209
220
|
decimals: 18,
|
|
210
221
|
symbol: "stkcvxLUSD3CRV",
|
|
211
222
|
type: tokenType_1.TokenType.CONVEX_STAKED_PHANTOM_TOKEN,
|
|
212
223
|
pool: "CONVEX_LUSD3CRV_POOL",
|
|
213
|
-
pid:
|
|
224
|
+
pid: 33,
|
|
214
225
|
underlying: "LUSD3CRV",
|
|
215
226
|
lpToken: "cvxLUSD3CRV",
|
|
216
227
|
lpActions: [
|
|
@@ -227,7 +238,7 @@ exports.convexTokens = {
|
|
|
227
238
|
]
|
|
228
239
|
},
|
|
229
240
|
stkcvxcrvPlain3andSUSD: {
|
|
230
|
-
name: "stkcvxcrvPlain3andSUSD",
|
|
241
|
+
name: "Convex stkcvxcrvPlain3andSUSD",
|
|
231
242
|
decimals: 18,
|
|
232
243
|
symbol: "stkcvxcrvPlain3andSUSD",
|
|
233
244
|
type: tokenType_1.TokenType.CONVEX_STAKED_PHANTOM_TOKEN,
|
|
@@ -249,7 +260,7 @@ exports.convexTokens = {
|
|
|
249
260
|
]
|
|
250
261
|
},
|
|
251
262
|
stkcvxgusd3CRV: {
|
|
252
|
-
name: "stkcvxgusd3CRV",
|
|
263
|
+
name: "Convex stkcvxgusd3CRV",
|
|
253
264
|
decimals: 18,
|
|
254
265
|
symbol: "stkcvxgusd3CRV",
|
|
255
266
|
type: tokenType_1.TokenType.CONVEX_STAKED_PHANTOM_TOKEN,
|
|
@@ -271,3 +282,18 @@ exports.convexTokens = {
|
|
|
271
282
|
]
|
|
272
283
|
}
|
|
273
284
|
};
|
|
285
|
+
exports.convexTokens = __assign(__assign({}, convexLpTokens), convexStakedPhantomTokens);
|
|
286
|
+
var isConvexToken = function (t) {
|
|
287
|
+
return typeof t === "string" &&
|
|
288
|
+
!!exports.convexTokens[t];
|
|
289
|
+
};
|
|
290
|
+
exports.isConvexToken = isConvexToken;
|
|
291
|
+
var isConvexLPToken = function (t) {
|
|
292
|
+
return typeof t === "string" && !!convexLpTokens[t];
|
|
293
|
+
};
|
|
294
|
+
exports.isConvexLPToken = isConvexLPToken;
|
|
295
|
+
var isConvexStakedPhantomToken = function (t) {
|
|
296
|
+
return typeof t === "string" &&
|
|
297
|
+
!!convexStakedPhantomTokens[t];
|
|
298
|
+
};
|
|
299
|
+
exports.isConvexStakedPhantomToken = isConvexStakedPhantomToken;
|
package/lib/tokens/curveLP.d.ts
CHANGED
|
@@ -22,3 +22,4 @@ export declare type MetaCurveLPTokenData = {
|
|
|
22
22
|
} & TokenBase;
|
|
23
23
|
export declare const Curve3CrvUnderlyingTokenIndex: PartialRecord<SupportedToken, BigNumber>;
|
|
24
24
|
export declare const curveTokens: Record<CurveLPToken, CurveLPTokenData | MetaCurveLPTokenData>;
|
|
25
|
+
export declare const isCurveLPToken: (t: unknown) => t is CurveLPToken;
|
package/lib/tokens/curveLP.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.curveTokens = exports.Curve3CrvUnderlyingTokenIndex = void 0;
|
|
3
|
+
exports.isCurveLPToken = exports.curveTokens = exports.Curve3CrvUnderlyingTokenIndex = void 0;
|
|
4
4
|
var ethers_1 = require("ethers");
|
|
5
5
|
var tradeTypes_1 = require("../pathfinder/tradeTypes");
|
|
6
6
|
var tokenType_1 = require("./tokenType");
|
|
@@ -12,7 +12,7 @@ exports.Curve3CrvUnderlyingTokenIndex = {
|
|
|
12
12
|
exports.curveTokens = {
|
|
13
13
|
// CURVE LP TOKENS
|
|
14
14
|
"3Crv": {
|
|
15
|
-
name: "3Crv",
|
|
15
|
+
name: "Curve 3Crv",
|
|
16
16
|
decimals: 18,
|
|
17
17
|
symbol: "3Crv",
|
|
18
18
|
type: tokenType_1.TokenType.CURVE_LP,
|
|
@@ -36,7 +36,7 @@ exports.curveTokens = {
|
|
|
36
36
|
]
|
|
37
37
|
},
|
|
38
38
|
steCRV: {
|
|
39
|
-
name: "steCRV",
|
|
39
|
+
name: "Curve steCRV",
|
|
40
40
|
decimals: 18,
|
|
41
41
|
symbol: "steCRV",
|
|
42
42
|
type: tokenType_1.TokenType.CURVE_LP,
|
|
@@ -60,7 +60,7 @@ exports.curveTokens = {
|
|
|
60
60
|
]
|
|
61
61
|
},
|
|
62
62
|
crvPlain3andSUSD: {
|
|
63
|
-
name: "crvPlain3andSUSD",
|
|
63
|
+
name: "Curve crvPlain3andSUSD",
|
|
64
64
|
decimals: 18,
|
|
65
65
|
symbol: "crvPlain3andSUSD",
|
|
66
66
|
type: tokenType_1.TokenType.CURVE_LP,
|
|
@@ -86,7 +86,7 @@ exports.curveTokens = {
|
|
|
86
86
|
},
|
|
87
87
|
// META CURVE LP TOKENS
|
|
88
88
|
FRAX3CRV: {
|
|
89
|
-
name: "FRAX3CRV-f",
|
|
89
|
+
name: "Curve FRAX3CRV-f",
|
|
90
90
|
decimals: 18,
|
|
91
91
|
symbol: "FRAX3CRV",
|
|
92
92
|
type: tokenType_1.TokenType.META_CURVE_LP,
|
|
@@ -110,7 +110,7 @@ exports.curveTokens = {
|
|
|
110
110
|
]
|
|
111
111
|
},
|
|
112
112
|
LUSD3CRV: {
|
|
113
|
-
name: "LUSD3CRV-f",
|
|
113
|
+
name: "Curve LUSD3CRV-f",
|
|
114
114
|
decimals: 18,
|
|
115
115
|
symbol: "LUSD3CRV",
|
|
116
116
|
type: tokenType_1.TokenType.META_CURVE_LP,
|
|
@@ -124,7 +124,7 @@ exports.curveTokens = {
|
|
|
124
124
|
]
|
|
125
125
|
},
|
|
126
126
|
gusd3CRV: {
|
|
127
|
-
name: "gusd3CRV",
|
|
127
|
+
name: "Curve gusd3CRV",
|
|
128
128
|
decimals: 18,
|
|
129
129
|
symbol: "gusd3CRV",
|
|
130
130
|
type: tokenType_1.TokenType.META_CURVE_LP,
|
|
@@ -148,3 +148,7 @@ exports.curveTokens = {
|
|
|
148
148
|
]
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
|
+
var isCurveLPToken = function (t) {
|
|
152
|
+
return typeof t === "string" && !!exports.curveTokens[t];
|
|
153
|
+
};
|
|
154
|
+
exports.isCurveLPToken = isCurveLPToken;
|
package/lib/tokens/normal.d.ts
CHANGED
package/lib/tokens/normal.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalTokens = void 0;
|
|
3
|
+
exports.isNormalToken = exports.normalTokens = void 0;
|
|
4
4
|
var tradeTypes_1 = require("../pathfinder/tradeTypes");
|
|
5
5
|
var tokenType_1 = require("./tokenType");
|
|
6
6
|
exports.normalTokens = {
|
|
@@ -714,3 +714,7 @@ exports.normalTokens = {
|
|
|
714
714
|
]
|
|
715
715
|
}
|
|
716
716
|
};
|
|
717
|
+
var isNormalToken = function (t) {
|
|
718
|
+
return typeof t === "string" && !!exports.normalTokens[t];
|
|
719
|
+
};
|
|
720
|
+
exports.isNormalToken = isNormalToken;
|