@gearbox-protocol/sdk 1.26.1 → 1.27.0
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/contracts/AdapterData.sol +76 -239
- package/contracts/AdapterType.sol +23 -23
- package/contracts/PriceFeedDataLive.sol +369 -284
- package/contracts/PriceFeedType.sol +19 -18
- package/contracts/SupportedContracts.sol +110 -262
- package/contracts/Tokens.sol +106 -90
- package/contracts/TokensData.sol +197 -664
- package/lib/apy/curveAPY.js +1 -1
- package/lib/apy/yearnAPY.js +1 -1
- package/lib/contracts/contracts.d.ts +21 -2
- package/lib/contracts/contracts.js +102 -2
- package/lib/contracts/contractsRegister.js +1 -1
- package/lib/contracts/protocols.d.ts +3 -1
- package/lib/contracts/protocols.js +10 -0
- package/lib/core/creditSession.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -5
- package/lib/oracles/oracles.d.ts +20 -6
- package/lib/oracles/oracles.js +4 -3
- package/lib/oracles/priceFeeds.js +106 -52
- package/lib/oracles/priceFeeds.spec.d.ts +1 -0
- package/lib/oracles/priceFeeds.spec.js +135 -0
- package/lib/parsers/txParser.js +2 -2
- package/lib/pathfinder/tradeTypes.d.ts +25 -2
- package/lib/pathfinder/tradeTypes.js +5 -0
- package/lib/tokens/aave.d.ts +23 -0
- package/lib/tokens/aave.js +119 -0
- package/lib/tokens/compound.d.ts +13 -0
- package/lib/tokens/compound.js +61 -0
- package/lib/tokens/decimals.js +13 -0
- package/lib/tokens/normal.d.ts +1 -1
- package/lib/tokens/normal.js +16 -0
- package/lib/tokens/token.d.ts +4 -2
- package/lib/tokens/token.js +43 -4
- package/lib/tokens/tokenType.d.ts +4 -2
- package/lib/tokens/tokenType.js +3 -1
- package/lib/tokens/tokens.spec.d.ts +1 -0
- package/lib/tokens/tokens.spec.js +110 -0
- package/lib/utils/mappers.d.ts +6 -5
- package/lib/utils/mappers.js +11 -12
- package/lib/utils/multicall.d.ts +14 -0
- package/lib/utils/multicall.js +34 -1
- package/package.json +3 -2
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const chai_1 = require("chai");
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const chains_1 = require("../core/chains");
|
|
9
|
+
const token_1 = require("../tokens/token");
|
|
10
|
+
const types_1 = require("../types");
|
|
11
|
+
const formatter_1 = require("../utils/formatter");
|
|
12
|
+
const multicall_1 = __importDefault(require("../utils/multicall"));
|
|
13
|
+
const oracles_1 = require("./oracles");
|
|
14
|
+
const priceFeeds_1 = require("./priceFeeds");
|
|
15
|
+
class PriceFeedsSuite {
|
|
16
|
+
networkTypes;
|
|
17
|
+
calls;
|
|
18
|
+
constructor(...networkTypes) {
|
|
19
|
+
this.networkTypes = networkTypes;
|
|
20
|
+
this.calls = networkTypes.map(c => this.collectCalls(c));
|
|
21
|
+
}
|
|
22
|
+
async getAnswers() {
|
|
23
|
+
const providers = this.networkTypes.map(c => {
|
|
24
|
+
const url = process.env[`${c.toUpperCase()}_TESTS_FORK`];
|
|
25
|
+
if (!url) {
|
|
26
|
+
throw new Error(`Provider for ${c} not found in env`);
|
|
27
|
+
}
|
|
28
|
+
return new ethers_1.ethers.providers.StaticJsonRpcProvider(url, chains_1.CHAINS[c]);
|
|
29
|
+
});
|
|
30
|
+
const resps = await Promise.all(this.networkTypes.map((_, i) => (0, multicall_1.default)(this.calls[i], providers[i])));
|
|
31
|
+
return resps.map((_, i) => this.buildDict(this.calls[i], resps[i]));
|
|
32
|
+
}
|
|
33
|
+
collectCalls(c) {
|
|
34
|
+
const iFeed = types_1.AggregatorV3Interface__factory.createInterface();
|
|
35
|
+
const entries = Object.entries(priceFeeds_1.priceFeedsByNetwork).filter(([_, f]) => {
|
|
36
|
+
return ((f.type === oracles_1.OracleType.CHAINLINK_ORACLE &&
|
|
37
|
+
f.address[c]?.startsWith("0x")) ||
|
|
38
|
+
(f.type === oracles_1.OracleType.COMPOSITE_ORACLE &&
|
|
39
|
+
f.baseToUsdPriceFeed[c]?.startsWith("0x") &&
|
|
40
|
+
f.targetToBasePriceFeed[c]?.startsWith("0x")) ||
|
|
41
|
+
(f.type === oracles_1.OracleType.BOUNDED_ORACLE &&
|
|
42
|
+
f.targetPriceFeed[c]?.startsWith("0x")));
|
|
43
|
+
});
|
|
44
|
+
const calls = [];
|
|
45
|
+
for (const [symb, f] of entries) {
|
|
46
|
+
const tok = token_1.tokenDataByNetwork[c][symb];
|
|
47
|
+
if (!tok.startsWith("0x")) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
switch (f.type) {
|
|
51
|
+
case oracles_1.OracleType.CHAINLINK_ORACLE:
|
|
52
|
+
calls.push({
|
|
53
|
+
address: f.address[c],
|
|
54
|
+
interface: iFeed,
|
|
55
|
+
method: "latestRoundData()",
|
|
56
|
+
key: symb,
|
|
57
|
+
});
|
|
58
|
+
break;
|
|
59
|
+
case oracles_1.OracleType.BOUNDED_ORACLE:
|
|
60
|
+
calls.push({
|
|
61
|
+
address: f.targetPriceFeed[c],
|
|
62
|
+
interface: iFeed,
|
|
63
|
+
method: "latestRoundData()",
|
|
64
|
+
key: symb,
|
|
65
|
+
});
|
|
66
|
+
break;
|
|
67
|
+
case oracles_1.OracleType.COMPOSITE_ORACLE:
|
|
68
|
+
calls.push({
|
|
69
|
+
address: f.baseToUsdPriceFeed[c],
|
|
70
|
+
interface: iFeed,
|
|
71
|
+
method: "latestRoundData()",
|
|
72
|
+
key: `${symb}.baseToUsdPriceFeed`,
|
|
73
|
+
});
|
|
74
|
+
calls.push({
|
|
75
|
+
address: f.targetToBasePriceFeed[c],
|
|
76
|
+
interface: iFeed,
|
|
77
|
+
method: "latestRoundData()",
|
|
78
|
+
key: `${symb}.targetToBasePriceFeed`,
|
|
79
|
+
});
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return calls;
|
|
84
|
+
}
|
|
85
|
+
buildDict(calls, responses) {
|
|
86
|
+
return calls.reduce((acc, call, i) => ({
|
|
87
|
+
...acc,
|
|
88
|
+
[call.key]: responses[i],
|
|
89
|
+
}), {});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
describe("Price feeds", () => {
|
|
93
|
+
const suite = new PriceFeedsSuite("Mainnet", "Arbitrum");
|
|
94
|
+
const PERCENTAGE_FACTOR = 1_00_00;
|
|
95
|
+
const THRESHOLD = 100; // 1%
|
|
96
|
+
let answers = [];
|
|
97
|
+
before(async function () {
|
|
98
|
+
this.timeout(10000);
|
|
99
|
+
answers = await suite.getAnswers();
|
|
100
|
+
});
|
|
101
|
+
describe(`should not deviate for more than ${(100 * THRESHOLD) / PERCENTAGE_FACTOR}% from mainnet`, () => {
|
|
102
|
+
// have to use suite.calls here, because answers are empty atm
|
|
103
|
+
// this is how mocha works, it builds test tree before execution
|
|
104
|
+
const [_, ...chainCalls] = suite.calls;
|
|
105
|
+
for (let i = 0; i < chainCalls.length; i++) {
|
|
106
|
+
const calls = chainCalls[i];
|
|
107
|
+
const chain = suite.networkTypes[i + 1];
|
|
108
|
+
for (const call of calls) {
|
|
109
|
+
it(`${chain}.${call.key} deviation`, () => {
|
|
110
|
+
const mainDict = answers[0];
|
|
111
|
+
const chainDict = answers[i + 1];
|
|
112
|
+
const chainPrice = chainDict[call.key].value?.answer;
|
|
113
|
+
const mainPrice = mainDict[call.key]?.value?.answer;
|
|
114
|
+
if (!mainPrice) {
|
|
115
|
+
// some tokens do not exist on mainnet
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const deviation = chainPrice
|
|
119
|
+
?.sub(mainPrice)
|
|
120
|
+
.mul(PERCENTAGE_FACTOR)
|
|
121
|
+
.div(mainPrice)
|
|
122
|
+
.abs()
|
|
123
|
+
.toNumber();
|
|
124
|
+
// console.log(
|
|
125
|
+
// call.key,
|
|
126
|
+
// deviation,
|
|
127
|
+
// chainPrice?.toNumber(),
|
|
128
|
+
// mainPrice.toNumber(),
|
|
129
|
+
// );
|
|
130
|
+
(0, chai_1.expect)(deviation, `Mainnet price: ${(0, formatter_1.formatBN)(mainPrice, 8)}$, ${chain} price: ${(0, formatter_1.formatBN)(chainPrice, 8)}$ at ${call.address}`).to.be.below(THRESHOLD);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
});
|
package/lib/parsers/txParser.js
CHANGED
|
@@ -58,7 +58,7 @@ class TxParser {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
static addContracts(network) {
|
|
61
|
-
|
|
61
|
+
mappers_1.TypedObjectUtils.entries(contracts_1.contractParams).forEach(([contract, contractData]) => {
|
|
62
62
|
const address = contracts_1.contractsByNetwork[network][contract];
|
|
63
63
|
TxParser.chooseContractParser(address, contract, contractData.type, true);
|
|
64
64
|
if (contractData.type === adapters_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL) {
|
|
@@ -77,7 +77,7 @@ class TxParser {
|
|
|
77
77
|
TxParser._addParser(creditFacade, new creditFacadeParser_1.CreditFacadeParser(underlying));
|
|
78
78
|
}
|
|
79
79
|
static addTokens(network) {
|
|
80
|
-
|
|
80
|
+
mappers_1.TypedObjectUtils.entries(token_1.tokenDataByNetwork[network]).forEach(([s, t]) => {
|
|
81
81
|
if (s === "STETH") {
|
|
82
82
|
TxParser._addParser(t, new lidoSTETHParser_1.LidoSTETHParser(s));
|
|
83
83
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { ConvexPoolContract, CurvePoolContract, UniswapV2Contract, YearnVaultContract } from "../contracts/contracts";
|
|
1
|
+
import type { AaveV2PoolContract, CompoundV2PoolContract, ConvexPoolContract, CurvePoolContract, UniswapV2Contract, YearnVaultContract } from "../contracts/contracts";
|
|
2
|
+
import { AaveV2LPToken } from "../tokens/aave";
|
|
2
3
|
import { BalancerLPToken } from "../tokens/balancer";
|
|
4
|
+
import { CompoundV2LPToken } from "../tokens/compound";
|
|
3
5
|
import type { ConvexLPToken, ConvexStakedPhantomToken } from "../tokens/convex";
|
|
4
6
|
import type { CurveLPToken } from "../tokens/curveLP";
|
|
5
7
|
import type { NormalToken } from "../tokens/normal";
|
|
@@ -21,7 +23,12 @@ export declare enum TradeType {
|
|
|
21
23
|
ConvexWithdraw = 13,
|
|
22
24
|
ConvexWithdrawAndUnwrap = 14,
|
|
23
25
|
BalancerJoin = 15,
|
|
24
|
-
BalancerExit = 16
|
|
26
|
+
BalancerExit = 16,
|
|
27
|
+
AaveV2Deposit = 17,
|
|
28
|
+
AaveV2Withdraw = 18,
|
|
29
|
+
AaveV2Unwrap = 19,
|
|
30
|
+
CompoundV2Deposit = 20,
|
|
31
|
+
CompoundV2Withdraw = 21
|
|
25
32
|
}
|
|
26
33
|
export type TradeAction = {
|
|
27
34
|
type: TradeType.UniswapV2Swap;
|
|
@@ -87,4 +94,20 @@ export type TradeAction = {
|
|
|
87
94
|
type: TradeType.BalancerExit;
|
|
88
95
|
contract: "BALANCER_VAULT";
|
|
89
96
|
tokenOut: Array<NormalToken | BalancerLPToken>;
|
|
97
|
+
} | {
|
|
98
|
+
type: TradeType.AaveV2Deposit;
|
|
99
|
+
contract: AaveV2PoolContract;
|
|
100
|
+
tokenOut: AaveV2LPToken;
|
|
101
|
+
} | {
|
|
102
|
+
type: TradeType.AaveV2Withdraw;
|
|
103
|
+
contract: AaveV2PoolContract;
|
|
104
|
+
tokenOut: NormalToken;
|
|
105
|
+
} | {
|
|
106
|
+
type: TradeType.CompoundV2Deposit;
|
|
107
|
+
contract: CompoundV2PoolContract;
|
|
108
|
+
tokenOut: CompoundV2LPToken;
|
|
109
|
+
} | {
|
|
110
|
+
type: TradeType.CompoundV2Withdraw;
|
|
111
|
+
contract: CompoundV2PoolContract;
|
|
112
|
+
tokenOut: NormalToken;
|
|
90
113
|
};
|
|
@@ -20,4 +20,9 @@ var TradeType;
|
|
|
20
20
|
TradeType[TradeType["ConvexWithdrawAndUnwrap"] = 14] = "ConvexWithdrawAndUnwrap";
|
|
21
21
|
TradeType[TradeType["BalancerJoin"] = 15] = "BalancerJoin";
|
|
22
22
|
TradeType[TradeType["BalancerExit"] = 16] = "BalancerExit";
|
|
23
|
+
TradeType[TradeType["AaveV2Deposit"] = 17] = "AaveV2Deposit";
|
|
24
|
+
TradeType[TradeType["AaveV2Withdraw"] = 18] = "AaveV2Withdraw";
|
|
25
|
+
TradeType[TradeType["AaveV2Unwrap"] = 19] = "AaveV2Unwrap";
|
|
26
|
+
TradeType[TradeType["CompoundV2Deposit"] = 20] = "CompoundV2Deposit";
|
|
27
|
+
TradeType[TradeType["CompoundV2Withdraw"] = 21] = "CompoundV2Withdraw";
|
|
23
28
|
})(TradeType = exports.TradeType || (exports.TradeType = {}));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AaveV2PoolContract } from "../contracts/contracts";
|
|
2
|
+
import { TradeAction } from "../pathfinder/tradeTypes";
|
|
3
|
+
import { NormalToken } from "./normal";
|
|
4
|
+
import type { TokenBase } from "./token";
|
|
5
|
+
import { TokenType } from "./tokenType";
|
|
6
|
+
export type AaveV2LPToken = "aDAI" | "aUSDC" | "aWETH" | "aUSDT";
|
|
7
|
+
export type WrappedAaveV2LPToken = "waDAI" | "waUSDC" | "waWETH" | "waUSDT";
|
|
8
|
+
export type AaveV2PoolTokenData = {
|
|
9
|
+
symbol: AaveV2LPToken;
|
|
10
|
+
type: TokenType.AAVE_V2_A_TOKEN;
|
|
11
|
+
underlying: NormalToken;
|
|
12
|
+
lpActions: Array<TradeAction>;
|
|
13
|
+
pool: AaveV2PoolContract;
|
|
14
|
+
} & TokenBase;
|
|
15
|
+
export type WrappedAaveV2PoolTokenData = {
|
|
16
|
+
symbol: WrappedAaveV2LPToken;
|
|
17
|
+
type: TokenType.WRAPPED_AAVE_V2_TOKEN;
|
|
18
|
+
underlying: AaveV2LPToken;
|
|
19
|
+
lpActions: Array<TradeAction>;
|
|
20
|
+
} & TokenBase;
|
|
21
|
+
export declare const aaveV2Tokens: Record<AaveV2LPToken, AaveV2PoolTokenData>;
|
|
22
|
+
export declare const wrappedAaveV2Tokens: Record<WrappedAaveV2LPToken, WrappedAaveV2PoolTokenData>;
|
|
23
|
+
export declare const isAaveV2LPToken: (t: unknown) => t is AaveV2LPToken;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAaveV2LPToken = exports.wrappedAaveV2Tokens = exports.aaveV2Tokens = void 0;
|
|
4
|
+
const tradeTypes_1 = require("../pathfinder/tradeTypes");
|
|
5
|
+
const tokenType_1 = require("./tokenType");
|
|
6
|
+
exports.aaveV2Tokens = {
|
|
7
|
+
aDAI: {
|
|
8
|
+
name: "AaveV2 aDAI",
|
|
9
|
+
symbol: "aDAI",
|
|
10
|
+
type: tokenType_1.TokenType.AAVE_V2_A_TOKEN,
|
|
11
|
+
underlying: "DAI",
|
|
12
|
+
pool: "AAVE_V2_DAI_POOL",
|
|
13
|
+
lpActions: [
|
|
14
|
+
{
|
|
15
|
+
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
16
|
+
contract: "AAVE_V2_DAI_POOL",
|
|
17
|
+
tokenOut: "DAI",
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
aUSDC: {
|
|
22
|
+
name: "AaveV2 aUSDC",
|
|
23
|
+
symbol: "aUSDC",
|
|
24
|
+
type: tokenType_1.TokenType.AAVE_V2_A_TOKEN,
|
|
25
|
+
underlying: "USDC",
|
|
26
|
+
pool: "AAVE_V2_USDC_POOL",
|
|
27
|
+
lpActions: [
|
|
28
|
+
{
|
|
29
|
+
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
30
|
+
contract: "AAVE_V2_USDC_POOL",
|
|
31
|
+
tokenOut: "USDC",
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
aUSDT: {
|
|
36
|
+
name: "AaveV2 aUSDT",
|
|
37
|
+
symbol: "aUSDT",
|
|
38
|
+
type: tokenType_1.TokenType.AAVE_V2_A_TOKEN,
|
|
39
|
+
underlying: "USDT",
|
|
40
|
+
pool: "AAVE_V2_USDT_POOL",
|
|
41
|
+
lpActions: [
|
|
42
|
+
{
|
|
43
|
+
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
44
|
+
contract: "AAVE_V2_USDT_POOL",
|
|
45
|
+
tokenOut: "USDT",
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
aWETH: {
|
|
50
|
+
name: "AaveV2 aWETH",
|
|
51
|
+
symbol: "aWETH",
|
|
52
|
+
type: tokenType_1.TokenType.AAVE_V2_A_TOKEN,
|
|
53
|
+
underlying: "WETH",
|
|
54
|
+
pool: "AAVE_V2_WETH_POOL",
|
|
55
|
+
lpActions: [
|
|
56
|
+
{
|
|
57
|
+
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
58
|
+
contract: "AAVE_V2_WETH_POOL",
|
|
59
|
+
tokenOut: "WETH",
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
exports.wrappedAaveV2Tokens = {
|
|
65
|
+
waDAI: {
|
|
66
|
+
name: "Wrapped AaveV2 aDAI",
|
|
67
|
+
symbol: "waDAI",
|
|
68
|
+
type: tokenType_1.TokenType.WRAPPED_AAVE_V2_TOKEN,
|
|
69
|
+
underlying: "aDAI",
|
|
70
|
+
lpActions: [
|
|
71
|
+
{
|
|
72
|
+
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
73
|
+
contract: "AAVE_V2_DAI_POOL",
|
|
74
|
+
tokenOut: "DAI",
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
waUSDC: {
|
|
79
|
+
name: "Wrapped AaveV2 aUSDC",
|
|
80
|
+
symbol: "waUSDC",
|
|
81
|
+
type: tokenType_1.TokenType.WRAPPED_AAVE_V2_TOKEN,
|
|
82
|
+
underlying: "aUSDC",
|
|
83
|
+
lpActions: [
|
|
84
|
+
{
|
|
85
|
+
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
86
|
+
contract: "AAVE_V2_USDC_POOL",
|
|
87
|
+
tokenOut: "USDC",
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
waUSDT: {
|
|
92
|
+
name: "Wrapped AaveV2 aUSDT",
|
|
93
|
+
symbol: "waUSDT",
|
|
94
|
+
type: tokenType_1.TokenType.WRAPPED_AAVE_V2_TOKEN,
|
|
95
|
+
underlying: "aUSDT",
|
|
96
|
+
lpActions: [
|
|
97
|
+
{
|
|
98
|
+
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
99
|
+
contract: "AAVE_V2_USDT_POOL",
|
|
100
|
+
tokenOut: "USDT",
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
waWETH: {
|
|
105
|
+
name: "Wrapped AaveV2 aWETH",
|
|
106
|
+
symbol: "waWETH",
|
|
107
|
+
type: tokenType_1.TokenType.WRAPPED_AAVE_V2_TOKEN,
|
|
108
|
+
underlying: "aWETH",
|
|
109
|
+
lpActions: [
|
|
110
|
+
{
|
|
111
|
+
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
112
|
+
contract: "AAVE_V2_WETH_POOL",
|
|
113
|
+
tokenOut: "WETH",
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
const isAaveV2LPToken = (t) => typeof t === "string" && !!exports.aaveV2Tokens[t];
|
|
119
|
+
exports.isAaveV2LPToken = isAaveV2LPToken;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TradeAction } from "../pathfinder/tradeTypes";
|
|
2
|
+
import { NormalToken } from "./normal";
|
|
3
|
+
import type { TokenBase } from "./token";
|
|
4
|
+
import { TokenType } from "./tokenType";
|
|
5
|
+
export type CompoundV2LPToken = "cDAI" | "cUSDC" | "cWETH" | "cUSDT";
|
|
6
|
+
export type CompoundV2PoolTokenData = {
|
|
7
|
+
symbol: CompoundV2LPToken;
|
|
8
|
+
type: TokenType.COMPOUND_V2_C_TOKEN;
|
|
9
|
+
underlying: NormalToken;
|
|
10
|
+
lpActions: Array<TradeAction>;
|
|
11
|
+
} & TokenBase;
|
|
12
|
+
export declare const compoundV2Tokens: Record<CompoundV2LPToken, CompoundV2PoolTokenData>;
|
|
13
|
+
export declare const isCompoundV2LPToken: (t: unknown) => t is CompoundV2LPToken;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCompoundV2LPToken = exports.compoundV2Tokens = void 0;
|
|
4
|
+
const tradeTypes_1 = require("../pathfinder/tradeTypes");
|
|
5
|
+
const tokenType_1 = require("./tokenType");
|
|
6
|
+
exports.compoundV2Tokens = {
|
|
7
|
+
cDAI: {
|
|
8
|
+
name: "CompoundV2 cDAI",
|
|
9
|
+
symbol: "cDAI",
|
|
10
|
+
type: tokenType_1.TokenType.COMPOUND_V2_C_TOKEN,
|
|
11
|
+
underlying: "DAI",
|
|
12
|
+
lpActions: [
|
|
13
|
+
{
|
|
14
|
+
type: tradeTypes_1.TradeType.CompoundV2Withdraw,
|
|
15
|
+
contract: "COMPOUND_V2_DAI_POOL",
|
|
16
|
+
tokenOut: "DAI",
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
cUSDC: {
|
|
21
|
+
name: "CompoundV2 cUSDC",
|
|
22
|
+
symbol: "cUSDC",
|
|
23
|
+
type: tokenType_1.TokenType.COMPOUND_V2_C_TOKEN,
|
|
24
|
+
underlying: "USDC",
|
|
25
|
+
lpActions: [
|
|
26
|
+
{
|
|
27
|
+
type: tradeTypes_1.TradeType.CompoundV2Withdraw,
|
|
28
|
+
contract: "COMPOUND_V2_USDC_POOL",
|
|
29
|
+
tokenOut: "USDC",
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
cUSDT: {
|
|
34
|
+
name: "CompoundV2 cUSDT",
|
|
35
|
+
symbol: "cUSDT",
|
|
36
|
+
type: tokenType_1.TokenType.COMPOUND_V2_C_TOKEN,
|
|
37
|
+
underlying: "USDT",
|
|
38
|
+
lpActions: [
|
|
39
|
+
{
|
|
40
|
+
type: tradeTypes_1.TradeType.CompoundV2Withdraw,
|
|
41
|
+
contract: "COMPOUND_V2_USDT_POOL",
|
|
42
|
+
tokenOut: "USDT",
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
cWETH: {
|
|
47
|
+
name: "CompoundV2 cWETH",
|
|
48
|
+
symbol: "cWETH",
|
|
49
|
+
type: tokenType_1.TokenType.COMPOUND_V2_C_TOKEN,
|
|
50
|
+
underlying: "WETH",
|
|
51
|
+
lpActions: [
|
|
52
|
+
{
|
|
53
|
+
type: tradeTypes_1.TradeType.CompoundV2Withdraw,
|
|
54
|
+
contract: "COMPOUND_V2_WETH_POOL",
|
|
55
|
+
tokenOut: "WETH",
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
const isCompoundV2LPToken = (t) => typeof t === "string" && !!exports.compoundV2Tokens[t];
|
|
61
|
+
exports.isCompoundV2LPToken = isCompoundV2LPToken;
|
package/lib/tokens/decimals.js
CHANGED
|
@@ -89,4 +89,17 @@ exports.decimals = {
|
|
|
89
89
|
"50OHM_50DAI": 18,
|
|
90
90
|
"50OHM_50WETH": 18,
|
|
91
91
|
OHM_wstETH: 18,
|
|
92
|
+
aDAI: 18,
|
|
93
|
+
aUSDC: 6,
|
|
94
|
+
aUSDT: 6,
|
|
95
|
+
aWETH: 18,
|
|
96
|
+
waDAI: 18,
|
|
97
|
+
waUSDC: 6,
|
|
98
|
+
waUSDT: 6,
|
|
99
|
+
waWETH: 18,
|
|
100
|
+
cDAI: 18,
|
|
101
|
+
cUSDC: 6,
|
|
102
|
+
cUSDT: 6,
|
|
103
|
+
cWETH: 18,
|
|
104
|
+
SHIB: 18,
|
|
92
105
|
};
|
package/lib/tokens/normal.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TradeAction } from "../pathfinder/tradeTypes";
|
|
2
2
|
import type { TokenBase } from "./token";
|
|
3
3
|
import { TokenType } from "./tokenType";
|
|
4
|
-
export type NormalToken = "1INCH" | "AAVE" | "COMP" | "CRV" | "DPI" | "FEI" | "LINK" | "SNX" | "UNI" | "USDT" | "USDC" | "DAI" | "WETH" | "WBTC" | "YFI" | "STETH" | "wstETH" | "CVX" | "FRAX" | "FXS" | "LDO" | "LUSD" | "sUSD" | "GUSD" | "LQTY" | "OHM" | "MIM" | "SPELL" | "GMX" | "ARB" | "RDNT" | "BAL";
|
|
4
|
+
export type NormalToken = "1INCH" | "AAVE" | "COMP" | "CRV" | "DPI" | "FEI" | "LINK" | "SNX" | "UNI" | "USDT" | "USDC" | "DAI" | "WETH" | "WBTC" | "YFI" | "STETH" | "wstETH" | "CVX" | "FRAX" | "FXS" | "LDO" | "LUSD" | "sUSD" | "GUSD" | "LQTY" | "OHM" | "MIM" | "SPELL" | "GMX" | "ARB" | "RDNT" | "BAL" | "ARB" | "SHIB";
|
|
5
5
|
export type NormalTokenData = {
|
|
6
6
|
symbol: NormalToken;
|
|
7
7
|
type: TokenType.NORMAL_TOKEN;
|
package/lib/tokens/normal.js
CHANGED
|
@@ -807,6 +807,22 @@ exports.normalTokens = {
|
|
|
807
807
|
],
|
|
808
808
|
lpActions: [],
|
|
809
809
|
},
|
|
810
|
+
SHIB: {
|
|
811
|
+
name: "SHIB",
|
|
812
|
+
symbol: "SHIB",
|
|
813
|
+
type: tokenType_1.TokenType.NORMAL_TOKEN,
|
|
814
|
+
swapActions: [
|
|
815
|
+
{
|
|
816
|
+
type: tradeTypes_1.TradeType.UniswapV3Swap,
|
|
817
|
+
contract: "UNISWAP_V3_ROUTER",
|
|
818
|
+
},
|
|
819
|
+
{
|
|
820
|
+
type: tradeTypes_1.TradeType.UniswapV2Swap,
|
|
821
|
+
contract: "UNISWAP_V2_ROUTER",
|
|
822
|
+
},
|
|
823
|
+
],
|
|
824
|
+
lpActions: [],
|
|
825
|
+
},
|
|
810
826
|
};
|
|
811
827
|
const isNormalToken = (t) => typeof t === "string" && !!exports.normalTokens[t];
|
|
812
828
|
exports.isNormalToken = isNormalToken;
|
package/lib/tokens/token.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { NetworkType } from "../core/chains";
|
|
2
|
+
import { AaveV2LPToken, AaveV2PoolTokenData, WrappedAaveV2LPToken, WrappedAaveV2PoolTokenData } from "./aave";
|
|
2
3
|
import { BalancerLPToken, BalancerLpTokenData } from "./balancer";
|
|
4
|
+
import { CompoundV2LPToken, CompoundV2PoolTokenData } from "./compound";
|
|
3
5
|
import { ConvexLPToken, ConvexLPTokenData, ConvexPhantomTokenData, ConvexStakedPhantomToken } from "./convex";
|
|
4
6
|
import { CurveLPToken, CurveLPTokenData, MetaCurveLPTokenData } from "./curveLP";
|
|
5
7
|
import { DieselTokenData, DieselTokenTypes, GearboxToken, GearboxTokenData } from "./gear";
|
|
6
8
|
import { NormalToken, NormalTokenData } from "./normal";
|
|
7
9
|
import { YearnLPToken, YearnVaultOfCurveLPTokenData, YearnVaultOfMetaCurveLPTokenData, YearnVaultTokenData } from "./yearn";
|
|
8
|
-
export type LPTokens = YearnLPToken | CurveLPToken | ConvexLPToken | ConvexStakedPhantomToken | BalancerLPToken;
|
|
10
|
+
export type LPTokens = YearnLPToken | CurveLPToken | ConvexLPToken | ConvexStakedPhantomToken | BalancerLPToken | AaveV2LPToken | WrappedAaveV2LPToken | CompoundV2LPToken;
|
|
9
11
|
export type SupportedToken = NormalToken | LPTokens | DieselTokenTypes | GearboxToken;
|
|
10
12
|
export interface TokenBase {
|
|
11
13
|
name: string;
|
|
12
14
|
symbol: string;
|
|
13
15
|
}
|
|
14
|
-
export type LPTokenDataI = CurveLPTokenData | MetaCurveLPTokenData | YearnVaultTokenData | YearnVaultOfCurveLPTokenData | YearnVaultOfMetaCurveLPTokenData | ConvexLPTokenData | ConvexPhantomTokenData | BalancerLpTokenData;
|
|
16
|
+
export type LPTokenDataI = CurveLPTokenData | MetaCurveLPTokenData | YearnVaultTokenData | YearnVaultOfCurveLPTokenData | YearnVaultOfMetaCurveLPTokenData | ConvexLPTokenData | ConvexPhantomTokenData | BalancerLpTokenData | AaveV2PoolTokenData | WrappedAaveV2PoolTokenData | CompoundV2PoolTokenData;
|
|
15
17
|
export type TokenDataI = NormalTokenData | LPTokenDataI | DieselTokenData | GearboxTokenData;
|
|
16
18
|
export declare const lpTokens: Record<LPTokens, LPTokenDataI>;
|
|
17
19
|
export declare const supportedTokens: Record<SupportedToken, TokenDataI>;
|
package/lib/tokens/token.js
CHANGED
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.extractTokenData = exports.getDecimals = exports.isLPToken = exports.isSupportedToken = exports.tokenSymbolByAddress = exports.tokenDataByNetwork = exports.supportedTokens = exports.lpTokens = void 0;
|
|
4
4
|
const constants_1 = require("../core/constants");
|
|
5
5
|
const mappers_1 = require("../utils/mappers");
|
|
6
|
+
const aave_1 = require("./aave");
|
|
6
7
|
const balancer_1 = require("./balancer");
|
|
8
|
+
const compound_1 = require("./compound");
|
|
7
9
|
const convex_1 = require("./convex");
|
|
8
10
|
const curveLP_1 = require("./curveLP");
|
|
9
11
|
const decimals_1 = require("./decimals");
|
|
@@ -15,6 +17,9 @@ exports.lpTokens = {
|
|
|
15
17
|
...convex_1.convexTokens,
|
|
16
18
|
...yearn_1.yearnTokens,
|
|
17
19
|
...balancer_1.balancerLpTokens,
|
|
20
|
+
...aave_1.aaveV2Tokens,
|
|
21
|
+
...aave_1.wrappedAaveV2Tokens,
|
|
22
|
+
...compound_1.compoundV2Tokens,
|
|
18
23
|
};
|
|
19
24
|
exports.supportedTokens = {
|
|
20
25
|
...normal_1.normalTokens,
|
|
@@ -44,9 +49,10 @@ exports.tokenDataByNetwork = {
|
|
|
44
49
|
MIM: "0x99D8a9C45b2ecA8864373A26D1459e3Dff1e17F3",
|
|
45
50
|
SPELL: "0x090185f2135308BaD17527004364eBcC2D37e5F6",
|
|
46
51
|
GMX: constants_1.NOT_DEPLOYED,
|
|
47
|
-
ARB:
|
|
52
|
+
ARB: "0xB50721BCf8d664c30412Cfbc6cf7a15145234ad1",
|
|
48
53
|
RDNT: constants_1.NOT_DEPLOYED,
|
|
49
54
|
BAL: "0xba100000625a3754423978a60c9317c58a424e3D",
|
|
55
|
+
SHIB: "0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE",
|
|
50
56
|
/// UPDATE
|
|
51
57
|
STETH: "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84",
|
|
52
58
|
wstETH: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0",
|
|
@@ -119,6 +125,19 @@ exports.tokenDataByNetwork = {
|
|
|
119
125
|
dwstETH: "0x2158034dB06f06dcB9A786D2F1F8c38781bA779d",
|
|
120
126
|
dFRAX: "0x8A1112AFef7F4FC7c066a77AABBc01b3Fff31D47",
|
|
121
127
|
GEAR: "0xBa3335588D9403515223F109EdC4eB7269a9Ab5D",
|
|
128
|
+
// AAVE
|
|
129
|
+
aUSDC: "0xBcca60bB61934080951369a648Fb03DF4F96263C",
|
|
130
|
+
aDAI: "0x028171bCA77440897B824Ca71D1c56caC55b68A3",
|
|
131
|
+
aUSDT: "0x3Ed3B47Dd13EC9a98b44e6204A523E766B225811",
|
|
132
|
+
aWETH: "0x030bA81f1c18d280636F32af80b9AAd02Cf0854e",
|
|
133
|
+
waDAI: constants_1.NOT_DEPLOYED,
|
|
134
|
+
waUSDC: constants_1.NOT_DEPLOYED,
|
|
135
|
+
waUSDT: constants_1.NOT_DEPLOYED,
|
|
136
|
+
waWETH: constants_1.NOT_DEPLOYED,
|
|
137
|
+
cDAI: constants_1.NOT_DEPLOYED,
|
|
138
|
+
cUSDC: constants_1.NOT_DEPLOYED,
|
|
139
|
+
cUSDT: constants_1.NOT_DEPLOYED,
|
|
140
|
+
cWETH: constants_1.NOT_DEPLOYED,
|
|
122
141
|
},
|
|
123
142
|
///
|
|
124
143
|
///
|
|
@@ -153,12 +172,14 @@ exports.tokenDataByNetwork = {
|
|
|
153
172
|
wstETH: "0x5979D7b546E38E414F7E9822514be443A4800529",
|
|
154
173
|
CVX: "0xb952A807345991BD529FDded05009F5e80Fe8F45",
|
|
155
174
|
FRAX: "0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F",
|
|
156
|
-
FXS: "
|
|
175
|
+
FXS: "0x9d2F299715D94d8A7E6F5eaa8E654E8c74a988A7",
|
|
157
176
|
LDO: "0x13Ad51ed4F1B7e9Dc168d8a00cB3f4dDD85EfA60",
|
|
158
177
|
LUSD: "0x93b346b6BC2548dA6A1E7d98E9a421B42541425b",
|
|
159
178
|
sUSD: "0xA970AF1a584579B618be4d69aD6F73459D112F95",
|
|
160
179
|
GUSD: constants_1.NOT_DEPLOYED,
|
|
161
180
|
LQTY: "0xfb9E5D956D889D91a82737B9bFCDaC1DCE3e1449",
|
|
181
|
+
// REDSTONE
|
|
182
|
+
SHIB: constants_1.NOT_DEPLOYED,
|
|
162
183
|
// YEARN TOKENS
|
|
163
184
|
yvDAI: constants_1.NOT_DEPLOYED,
|
|
164
185
|
yvUSDC: constants_1.NOT_DEPLOYED,
|
|
@@ -220,11 +241,29 @@ exports.tokenDataByNetwork = {
|
|
|
220
241
|
dwstETH: constants_1.NOT_DEPLOYED,
|
|
221
242
|
dFRAX: constants_1.NOT_DEPLOYED,
|
|
222
243
|
GEAR: constants_1.NOT_DEPLOYED,
|
|
244
|
+
// AAVE
|
|
245
|
+
aUSDC: "0x724dc807b04555b71ed48a6896b6F41593b8C637",
|
|
246
|
+
aDAI: "0x82E64f49Ed5EC1bC6e43DAD4FC8Af9bb3A2312EE",
|
|
247
|
+
aUSDT: "0x6ab707Aca953eDAeFBc4fD23bA73294241490620",
|
|
248
|
+
aWETH: "0xe50fA9b3c56FfB159cB0FCA61F5c9D750e8128c8",
|
|
249
|
+
waDAI: constants_1.NOT_DEPLOYED,
|
|
250
|
+
waUSDC: constants_1.NOT_DEPLOYED,
|
|
251
|
+
waUSDT: constants_1.NOT_DEPLOYED,
|
|
252
|
+
waWETH: constants_1.NOT_DEPLOYED,
|
|
253
|
+
cDAI: constants_1.NOT_DEPLOYED,
|
|
254
|
+
cUSDC: constants_1.NOT_DEPLOYED,
|
|
255
|
+
cUSDT: constants_1.NOT_DEPLOYED,
|
|
256
|
+
cWETH: constants_1.NOT_DEPLOYED,
|
|
223
257
|
},
|
|
224
258
|
};
|
|
225
|
-
exports.tokenSymbolByAddress =
|
|
259
|
+
exports.tokenSymbolByAddress = mappers_1.TypedObjectUtils.entries(exports.tokenDataByNetwork).reduce((acc, [, tokens]) => ({
|
|
226
260
|
...acc,
|
|
227
|
-
...
|
|
261
|
+
...{
|
|
262
|
+
...acc,
|
|
263
|
+
...mappers_1.TypedObjectUtils.fromEntries(mappers_1.TypedObjectUtils.entries(tokens)
|
|
264
|
+
.map(([k, v]) => [v.toLowerCase(), k])
|
|
265
|
+
.filter(k => !!k)),
|
|
266
|
+
},
|
|
228
267
|
}), {});
|
|
229
268
|
const isSupportedToken = (t) => typeof t === "string" && !!exports.supportedTokens[t];
|
|
230
269
|
exports.isSupportedToken = isSupportedToken;
|
package/lib/tokens/tokenType.js
CHANGED
|
@@ -12,6 +12,8 @@ var TokenType;
|
|
|
12
12
|
TokenType[TokenType["CONVEX_STAKED_TOKEN"] = 6] = "CONVEX_STAKED_TOKEN";
|
|
13
13
|
TokenType[TokenType["DIESEL_LP_TOKEN"] = 7] = "DIESEL_LP_TOKEN";
|
|
14
14
|
TokenType[TokenType["GEAR_TOKEN"] = 8] = "GEAR_TOKEN";
|
|
15
|
-
TokenType[TokenType["
|
|
15
|
+
TokenType[TokenType["COMPOUND_V2_C_TOKEN"] = 9] = "COMPOUND_V2_C_TOKEN";
|
|
16
16
|
TokenType[TokenType["BALANCER_LP_TOKEN"] = 10] = "BALANCER_LP_TOKEN";
|
|
17
|
+
TokenType[TokenType["AAVE_V2_A_TOKEN"] = 11] = "AAVE_V2_A_TOKEN";
|
|
18
|
+
TokenType[TokenType["WRAPPED_AAVE_V2_TOKEN"] = 12] = "WRAPPED_AAVE_V2_TOKEN";
|
|
17
19
|
})(TokenType = exports.TokenType || (exports.TokenType = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|