@gearbox-protocol/sdk 1.27.12 → 2.0.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/PriceFeedDataLive.sol +317 -130
- package/contracts/PriceFeedType.sol +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/oracles/priceFeeds.d.ts +2 -2
- package/lib/oracles/priceFeeds.js +459 -218
- package/lib/oracles/priceFeeds.spec.js +35 -33
- package/lib/oracles/{oracles.d.ts → pricefeedType.d.ts} +27 -21
- package/lib/oracles/pricefeedType.js +24 -0
- package/lib/tokens/tokens.spec.js +1 -1
- package/package.json +1 -1
- package/lib/oracles/oracles.js +0 -24
|
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const chai_1 = require("chai");
|
|
7
7
|
const ethers_1 = require("ethers");
|
|
8
8
|
const chains_1 = require("../core/chains");
|
|
9
|
-
const token_1 = require("../tokens/token");
|
|
10
9
|
const types_1 = require("../types");
|
|
11
10
|
const formatter_1 = require("../utils/formatter");
|
|
12
11
|
const multicall_1 = __importDefault(require("../utils/multicall"));
|
|
13
|
-
const oracles_1 = require("./oracles");
|
|
14
12
|
const priceFeeds_1 = require("./priceFeeds");
|
|
13
|
+
const pricefeedType_1 = require("./pricefeedType");
|
|
14
|
+
const iFeed = types_1.AggregatorV3Interface__factory.createInterface();
|
|
15
15
|
class PriceFeedsSuite {
|
|
16
16
|
networkTypes;
|
|
17
17
|
calls;
|
|
@@ -31,54 +31,56 @@ class PriceFeedsSuite {
|
|
|
31
31
|
return resps.map((_, i) => this.buildDict(this.calls[i], resps[i]));
|
|
32
32
|
}
|
|
33
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
34
|
const calls = [];
|
|
45
|
-
for (const [symb,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
35
|
+
for (const [symb, data] of Object.entries(priceFeeds_1.priceFeedsByToken)) {
|
|
36
|
+
calls.push(...this.getCallsForToken(c, symb, data));
|
|
37
|
+
}
|
|
38
|
+
return calls;
|
|
39
|
+
}
|
|
40
|
+
getCallsForToken(network, token, data) {
|
|
41
|
+
const calls = [];
|
|
42
|
+
switch (data.type) {
|
|
43
|
+
case pricefeedType_1.PriceFeedType.NETWORK_DEPENDENT:
|
|
44
|
+
calls.push(...this.getCallsForToken(network, token, data.feeds[network]));
|
|
45
|
+
break;
|
|
46
|
+
case pricefeedType_1.PriceFeedType.CHAINLINK_ORACLE:
|
|
47
|
+
if (data.address.startsWith("0x")) {
|
|
52
48
|
calls.push({
|
|
53
|
-
address:
|
|
49
|
+
address: data.address,
|
|
54
50
|
interface: iFeed,
|
|
55
51
|
method: "latestRoundData()",
|
|
56
|
-
key:
|
|
52
|
+
key: token,
|
|
57
53
|
});
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
case pricefeedType_1.PriceFeedType.BOUNDED_ORACLE:
|
|
57
|
+
if (data.targetPriceFeed.startsWith("0x")) {
|
|
60
58
|
calls.push({
|
|
61
|
-
address:
|
|
59
|
+
address: data.targetPriceFeed,
|
|
62
60
|
interface: iFeed,
|
|
63
61
|
method: "latestRoundData()",
|
|
64
|
-
key:
|
|
62
|
+
key: token,
|
|
65
63
|
});
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
case pricefeedType_1.PriceFeedType.COMPOSITE_ORACLE:
|
|
67
|
+
if (data.baseToUsdPriceFeed.startsWith("0x")) {
|
|
68
68
|
calls.push({
|
|
69
|
-
address:
|
|
69
|
+
address: data.baseToUsdPriceFeed,
|
|
70
70
|
interface: iFeed,
|
|
71
71
|
method: "latestRoundData()",
|
|
72
|
-
key: `${
|
|
72
|
+
key: `${token}.baseToUsdPriceFeed`,
|
|
73
73
|
});
|
|
74
|
+
}
|
|
75
|
+
if (data.targetToBasePriceFeed.startsWith("0x")) {
|
|
74
76
|
calls.push({
|
|
75
|
-
address:
|
|
77
|
+
address: data.targetToBasePriceFeed,
|
|
76
78
|
interface: iFeed,
|
|
77
79
|
method: "latestRoundData()",
|
|
78
|
-
key: `${
|
|
80
|
+
key: `${token}.targetToBasePriceFeed`,
|
|
79
81
|
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
82
84
|
}
|
|
83
85
|
return calls;
|
|
84
86
|
}
|
|
@@ -6,7 +6,7 @@ export interface PriceFeed {
|
|
|
6
6
|
token: string;
|
|
7
7
|
priceFeed: string;
|
|
8
8
|
}
|
|
9
|
-
export declare enum
|
|
9
|
+
export declare enum PriceFeedType {
|
|
10
10
|
CHAINLINK_ORACLE = 0,
|
|
11
11
|
YEARN_ORACLE = 1,
|
|
12
12
|
CURVE_2LP_ORACLE = 2,
|
|
@@ -24,54 +24,60 @@ export declare enum OracleType {
|
|
|
24
24
|
THE_SAME_AS = 14,
|
|
25
25
|
REDSTONE_ORACLE = 15,
|
|
26
26
|
ERC4626_VAULT_ORACLE = 16,
|
|
27
|
-
|
|
27
|
+
NETWORK_DEPENDENT = 17
|
|
28
28
|
}
|
|
29
29
|
export type PriceFeedData = {
|
|
30
|
-
type:
|
|
31
|
-
address:
|
|
30
|
+
type: PriceFeedType.CHAINLINK_ORACLE;
|
|
31
|
+
address: string;
|
|
32
32
|
} | {
|
|
33
|
-
type:
|
|
33
|
+
type: PriceFeedType.YEARN_ORACLE;
|
|
34
34
|
token: SupportedToken;
|
|
35
35
|
} | {
|
|
36
|
-
type:
|
|
36
|
+
type: PriceFeedType.CURVE_2LP_ORACLE;
|
|
37
37
|
assets: Array<SupportedToken>;
|
|
38
38
|
} | {
|
|
39
|
-
type:
|
|
39
|
+
type: PriceFeedType.CURVE_3LP_ORACLE;
|
|
40
40
|
assets: Array<SupportedToken>;
|
|
41
41
|
} | {
|
|
42
|
-
type:
|
|
42
|
+
type: PriceFeedType.CURVE_4LP_ORACLE;
|
|
43
43
|
assets: Array<SupportedToken>;
|
|
44
44
|
} | {
|
|
45
|
-
type:
|
|
45
|
+
type: PriceFeedType.ZERO_ORACLE;
|
|
46
46
|
} | {
|
|
47
|
-
type:
|
|
48
|
-
targetPriceFeed:
|
|
47
|
+
type: PriceFeedType.BOUNDED_ORACLE;
|
|
48
|
+
targetPriceFeed: string;
|
|
49
49
|
upperBound: bigint;
|
|
50
50
|
} | {
|
|
51
|
-
type:
|
|
51
|
+
type: PriceFeedType.WSTETH_ORACLE;
|
|
52
52
|
token: SupportedToken;
|
|
53
53
|
} | {
|
|
54
|
-
type:
|
|
55
|
-
targetToBasePriceFeed:
|
|
56
|
-
baseToUsdPriceFeed:
|
|
54
|
+
type: PriceFeedType.COMPOSITE_ORACLE;
|
|
55
|
+
targetToBasePriceFeed: string;
|
|
56
|
+
baseToUsdPriceFeed: string;
|
|
57
57
|
} | {
|
|
58
|
-
type:
|
|
58
|
+
type: PriceFeedType.CURVE_CRYPTO_ORACLE;
|
|
59
59
|
assets: Array<SupportedToken>;
|
|
60
60
|
} | {
|
|
61
|
-
type:
|
|
61
|
+
type: PriceFeedType.BALANCER_WEIGHTED_LP_ORACLE;
|
|
62
62
|
assets: Array<SupportedToken>;
|
|
63
63
|
} | {
|
|
64
|
-
type:
|
|
64
|
+
type: PriceFeedType.THE_SAME_AS;
|
|
65
65
|
token: SupportedToken;
|
|
66
66
|
} | {
|
|
67
|
-
type:
|
|
67
|
+
type: PriceFeedType.WRAPPED_AAVE_V2_ORACLE;
|
|
68
68
|
underlying: AaveV2LPToken;
|
|
69
69
|
} | {
|
|
70
|
-
type:
|
|
70
|
+
type: PriceFeedType.COMPOUND_V2_ORACLE;
|
|
71
71
|
underlying: NormalToken;
|
|
72
72
|
} | {
|
|
73
|
-
type:
|
|
73
|
+
type: PriceFeedType.ERC4626_VAULT_ORACLE;
|
|
74
|
+
underlying: NormalToken;
|
|
75
|
+
} | {
|
|
76
|
+
type: PriceFeedType.REDSTONE_ORACLE;
|
|
74
77
|
dataId: string;
|
|
75
78
|
signers: Array<string>;
|
|
76
79
|
signersThreshold: number;
|
|
80
|
+
} | {
|
|
81
|
+
type: PriceFeedType.NETWORK_DEPENDENT;
|
|
82
|
+
feeds: Record<NetworkType, PriceFeedData>;
|
|
77
83
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PriceFeedType = void 0;
|
|
4
|
+
var PriceFeedType;
|
|
5
|
+
(function (PriceFeedType) {
|
|
6
|
+
PriceFeedType[PriceFeedType["CHAINLINK_ORACLE"] = 0] = "CHAINLINK_ORACLE";
|
|
7
|
+
PriceFeedType[PriceFeedType["YEARN_ORACLE"] = 1] = "YEARN_ORACLE";
|
|
8
|
+
PriceFeedType[PriceFeedType["CURVE_2LP_ORACLE"] = 2] = "CURVE_2LP_ORACLE";
|
|
9
|
+
PriceFeedType[PriceFeedType["CURVE_3LP_ORACLE"] = 3] = "CURVE_3LP_ORACLE";
|
|
10
|
+
PriceFeedType[PriceFeedType["CURVE_4LP_ORACLE"] = 4] = "CURVE_4LP_ORACLE";
|
|
11
|
+
PriceFeedType[PriceFeedType["ZERO_ORACLE"] = 5] = "ZERO_ORACLE";
|
|
12
|
+
PriceFeedType[PriceFeedType["WSTETH_ORACLE"] = 6] = "WSTETH_ORACLE";
|
|
13
|
+
PriceFeedType[PriceFeedType["BOUNDED_ORACLE"] = 7] = "BOUNDED_ORACLE";
|
|
14
|
+
PriceFeedType[PriceFeedType["COMPOSITE_ORACLE"] = 8] = "COMPOSITE_ORACLE";
|
|
15
|
+
PriceFeedType[PriceFeedType["WRAPPED_AAVE_V2_ORACLE"] = 9] = "WRAPPED_AAVE_V2_ORACLE";
|
|
16
|
+
PriceFeedType[PriceFeedType["COMPOUND_V2_ORACLE"] = 10] = "COMPOUND_V2_ORACLE";
|
|
17
|
+
PriceFeedType[PriceFeedType["BALANCER_STABLE_LP_ORACLE"] = 11] = "BALANCER_STABLE_LP_ORACLE";
|
|
18
|
+
PriceFeedType[PriceFeedType["BALANCER_WEIGHTED_LP_ORACLE"] = 12] = "BALANCER_WEIGHTED_LP_ORACLE";
|
|
19
|
+
PriceFeedType[PriceFeedType["CURVE_CRYPTO_ORACLE"] = 13] = "CURVE_CRYPTO_ORACLE";
|
|
20
|
+
PriceFeedType[PriceFeedType["THE_SAME_AS"] = 14] = "THE_SAME_AS";
|
|
21
|
+
PriceFeedType[PriceFeedType["REDSTONE_ORACLE"] = 15] = "REDSTONE_ORACLE";
|
|
22
|
+
PriceFeedType[PriceFeedType["ERC4626_VAULT_ORACLE"] = 16] = "ERC4626_VAULT_ORACLE";
|
|
23
|
+
PriceFeedType[PriceFeedType["NETWORK_DEPENDENT"] = 17] = "NETWORK_DEPENDENT";
|
|
24
|
+
})(PriceFeedType = exports.PriceFeedType || (exports.PriceFeedType = {}));
|
|
@@ -117,7 +117,7 @@ class TokenSuite {
|
|
|
117
117
|
describe("Tokens", () => {
|
|
118
118
|
const suites = chains_1.supportedChains.map(n => new TokenSuite(n));
|
|
119
119
|
before(async function () {
|
|
120
|
-
this.timeout(
|
|
120
|
+
this.timeout(120000);
|
|
121
121
|
await Promise.all(suites.map(s => s.fetchSymbols()));
|
|
122
122
|
});
|
|
123
123
|
suites.forEach(suite => {
|
package/package.json
CHANGED
package/lib/oracles/oracles.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OracleType = void 0;
|
|
4
|
-
var OracleType;
|
|
5
|
-
(function (OracleType) {
|
|
6
|
-
OracleType[OracleType["CHAINLINK_ORACLE"] = 0] = "CHAINLINK_ORACLE";
|
|
7
|
-
OracleType[OracleType["YEARN_ORACLE"] = 1] = "YEARN_ORACLE";
|
|
8
|
-
OracleType[OracleType["CURVE_2LP_ORACLE"] = 2] = "CURVE_2LP_ORACLE";
|
|
9
|
-
OracleType[OracleType["CURVE_3LP_ORACLE"] = 3] = "CURVE_3LP_ORACLE";
|
|
10
|
-
OracleType[OracleType["CURVE_4LP_ORACLE"] = 4] = "CURVE_4LP_ORACLE";
|
|
11
|
-
OracleType[OracleType["ZERO_ORACLE"] = 5] = "ZERO_ORACLE";
|
|
12
|
-
OracleType[OracleType["WSTETH_ORACLE"] = 6] = "WSTETH_ORACLE";
|
|
13
|
-
OracleType[OracleType["BOUNDED_ORACLE"] = 7] = "BOUNDED_ORACLE";
|
|
14
|
-
OracleType[OracleType["COMPOSITE_ORACLE"] = 8] = "COMPOSITE_ORACLE";
|
|
15
|
-
OracleType[OracleType["WRAPPED_AAVE_V2_ORACLE"] = 9] = "WRAPPED_AAVE_V2_ORACLE";
|
|
16
|
-
OracleType[OracleType["COMPOUND_V2_ORACLE"] = 10] = "COMPOUND_V2_ORACLE";
|
|
17
|
-
OracleType[OracleType["BALANCER_STABLE_LP_ORACLE"] = 11] = "BALANCER_STABLE_LP_ORACLE";
|
|
18
|
-
OracleType[OracleType["BALANCER_WEIGHTED_LP_ORACLE"] = 12] = "BALANCER_WEIGHTED_LP_ORACLE";
|
|
19
|
-
OracleType[OracleType["CURVE_CRYPTO_ORACLE"] = 13] = "CURVE_CRYPTO_ORACLE";
|
|
20
|
-
OracleType[OracleType["THE_SAME_AS"] = 14] = "THE_SAME_AS";
|
|
21
|
-
OracleType[OracleType["REDSTONE_ORACLE"] = 15] = "REDSTONE_ORACLE";
|
|
22
|
-
OracleType[OracleType["ERC4626_VAULT_ORACLE"] = 16] = "ERC4626_VAULT_ORACLE";
|
|
23
|
-
OracleType[OracleType["NETWORK_DIFFERENT"] = 17] = "NETWORK_DIFFERENT";
|
|
24
|
-
})(OracleType = exports.OracleType || (exports.OracleType = {}));
|