@gearbox-protocol/sdk 3.0.0-vfour.301 → 3.0.0-vfour.302
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/dist/cjs/sdk/market/pricefeeds/AbstractLPPriceFeed.js +23 -6
- package/dist/cjs/sdk/market/pricefeeds/RedstonePriceFeed.js +27 -62
- package/dist/esm/sdk/market/pricefeeds/AbstractLPPriceFeed.js +23 -6
- package/dist/esm/sdk/market/pricefeeds/RedstonePriceFeed.js +27 -62
- package/dist/types/sdk/market/pricefeeds/AbstractLPPriceFeed.d.ts +3 -0
- package/dist/types/sdk/market/pricefeeds/RedstonePriceFeed.d.ts +2 -0
- package/dist/types/sdk/types/state-human.d.ts +5 -0
- package/package.json +1 -1
|
@@ -29,6 +29,10 @@ class AbstractLPPriceFeedContract extends import_AbstractPriceFeed.AbstractPrice
|
|
|
29
29
|
lpToken;
|
|
30
30
|
lowerBound;
|
|
31
31
|
upperBound;
|
|
32
|
+
// v3.0 optionals
|
|
33
|
+
exchangeRate;
|
|
34
|
+
aggregatePrice;
|
|
35
|
+
scale;
|
|
32
36
|
constructor(sdk, args) {
|
|
33
37
|
super(sdk, { ...args, decimals: 8 });
|
|
34
38
|
this.hasLowerBoundCap = true;
|
|
@@ -53,11 +57,17 @@ class AbstractLPPriceFeedContract extends import_AbstractPriceFeed.AbstractPrice
|
|
|
53
57
|
{ type: "address", name: "lpContract" },
|
|
54
58
|
{ type: "uint256", name: "lowerBound" },
|
|
55
59
|
{ type: "uint256", name: "upperBound" },
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
{
|
|
61
|
+
type: "tuple",
|
|
62
|
+
name: "price",
|
|
63
|
+
components: [
|
|
64
|
+
{ type: "uint256", name: "exchangeRate" },
|
|
65
|
+
{ type: "int256", name: "aggregatePrice" },
|
|
66
|
+
{ type: "uint256", name: "scale" },
|
|
67
|
+
{ type: "bool", name: "exchangeRateSuccess" },
|
|
68
|
+
{ type: "bool", name: "aggregatePriceSuccess" }
|
|
69
|
+
]
|
|
70
|
+
}
|
|
61
71
|
],
|
|
62
72
|
(0, import_viem.hexToBytes)(args.baseParams.serializedParams)
|
|
63
73
|
);
|
|
@@ -65,6 +75,9 @@ class AbstractLPPriceFeedContract extends import_AbstractPriceFeed.AbstractPrice
|
|
|
65
75
|
this.lpContract = decoder[1];
|
|
66
76
|
this.lowerBound = decoder[2];
|
|
67
77
|
this.upperBound = decoder[3];
|
|
78
|
+
this.exchangeRate = decoder[4].exchangeRate;
|
|
79
|
+
this.aggregatePrice = decoder[4].aggregatePrice;
|
|
80
|
+
this.scale = decoder[4].scale;
|
|
68
81
|
}
|
|
69
82
|
}
|
|
70
83
|
async getLowerBound() {
|
|
@@ -84,7 +97,11 @@ class AbstractLPPriceFeedContract extends import_AbstractPriceFeed.AbstractPrice
|
|
|
84
97
|
lpContract: this.lpContract,
|
|
85
98
|
lpToken: this.lpToken,
|
|
86
99
|
lowerBound: this.lowerBound,
|
|
87
|
-
upperBound: this.upperBound
|
|
100
|
+
upperBound: this.upperBound,
|
|
101
|
+
// v3.0 optionals
|
|
102
|
+
exchangeRate: this.exchangeRate?.toString(),
|
|
103
|
+
aggregatePrice: this.aggregatePrice?.toString(),
|
|
104
|
+
scale: this.scale?.toString()
|
|
88
105
|
};
|
|
89
106
|
}
|
|
90
107
|
}
|
|
@@ -30,6 +30,8 @@ class RedstonePriceFeedContract extends import_AbstractPriceFeed.AbstractPriceFe
|
|
|
30
30
|
dataId;
|
|
31
31
|
signers;
|
|
32
32
|
signersThreshold;
|
|
33
|
+
lastPrice;
|
|
34
|
+
lastPayloadTimestamp;
|
|
33
35
|
constructor(sdk, args) {
|
|
34
36
|
super(sdk, {
|
|
35
37
|
...args,
|
|
@@ -39,87 +41,48 @@ class RedstonePriceFeedContract extends import_AbstractPriceFeed.AbstractPriceFe
|
|
|
39
41
|
if (args.baseParams.version === 310n) {
|
|
40
42
|
const decoder = (0, import_viem.decodeAbiParameters)(
|
|
41
43
|
[
|
|
42
|
-
{ type: "address" },
|
|
43
|
-
|
|
44
|
-
{ type: "
|
|
45
|
-
|
|
46
|
-
{ type: "
|
|
47
|
-
|
|
48
|
-
{ type: "
|
|
49
|
-
// [3]: pf.signerAddress0(),
|
|
50
|
-
{ type: "address" },
|
|
51
|
-
// [4]: pf.signerAddress1(),
|
|
52
|
-
{ type: "address" },
|
|
53
|
-
// [5]: pf.signerAddress2(),
|
|
54
|
-
{ type: "address" },
|
|
55
|
-
// [6]: pf.signerAddress3(),
|
|
56
|
-
{ type: "address" },
|
|
57
|
-
// [7]: pf.signerAddress4(),
|
|
58
|
-
{ type: "address" },
|
|
59
|
-
// [8]: pf.signerAddress5()
|
|
60
|
-
{ type: "address" },
|
|
61
|
-
// [9]: pf.signerAddress6(),
|
|
62
|
-
{ type: "address" },
|
|
63
|
-
// [10]: pf.signerAddress7(),
|
|
64
|
-
{ type: "address" },
|
|
65
|
-
// [11]: pf.signerAddress8(),
|
|
66
|
-
{ type: "address" },
|
|
67
|
-
// [12]: pf.signerAddress9(),
|
|
68
|
-
{ type: "uint8" },
|
|
69
|
-
// [13]: pf.getUniqueSignersThreshold()
|
|
70
|
-
{ type: "uint128" },
|
|
71
|
-
// [14]: pf.lastPrice(),
|
|
72
|
-
{ type: "uint40" }
|
|
73
|
-
// [15]: pf.lastPayloadTimestamp()
|
|
44
|
+
{ type: "address", name: "token" },
|
|
45
|
+
{ type: "bytes32", name: "dataFeedId" },
|
|
46
|
+
{ type: "string", name: "dataServiceId" },
|
|
47
|
+
{ type: "address[10]", name: "signers" },
|
|
48
|
+
{ type: "uint8", name: "signersThreshold" },
|
|
49
|
+
{ type: "uint128", name: "lastPrice" },
|
|
50
|
+
{ type: "uint40", name: "lastPayloadTimestamp" }
|
|
74
51
|
],
|
|
75
52
|
args.baseParams.serializedParams
|
|
76
53
|
);
|
|
77
54
|
this.token = decoder[0];
|
|
78
55
|
this.dataId = (0, import_viem.bytesToString)((0, import_viem.toBytes)(decoder[1])).replaceAll("\0", "");
|
|
79
|
-
this.signers = decoder.slice(3, 13);
|
|
80
|
-
this.signersThreshold = Number(decoder[13]);
|
|
81
56
|
this.dataServiceId = decoder[2];
|
|
57
|
+
this.signers = [...decoder[3]];
|
|
58
|
+
this.signersThreshold = Number(decoder[4]);
|
|
59
|
+
this.lastPrice = decoder[5];
|
|
60
|
+
this.lastPayloadTimestamp = Number(decoder[6]);
|
|
82
61
|
} else {
|
|
83
62
|
const decoder = (0, import_viem.decodeAbiParameters)(
|
|
84
63
|
[
|
|
85
64
|
{ type: "address" },
|
|
86
|
-
//
|
|
65
|
+
// pf.token(),
|
|
87
66
|
{ type: "bytes32" },
|
|
88
|
-
//
|
|
89
|
-
{ type: "address" },
|
|
90
|
-
//
|
|
91
|
-
{ type: "address" },
|
|
92
|
-
// [3]: pf.signerAddress1(),
|
|
93
|
-
{ type: "address" },
|
|
94
|
-
// [4]: pf.signerAddress2(),
|
|
95
|
-
{ type: "address" },
|
|
96
|
-
// [5]: pf.signerAddress3(),
|
|
97
|
-
{ type: "address" },
|
|
98
|
-
// [6]: pf.signerAddress4(),
|
|
99
|
-
{ type: "address" },
|
|
100
|
-
// [7]: pf.signerAddress5()
|
|
101
|
-
{ type: "address" },
|
|
102
|
-
// [8]: pf.signerAddress6(),
|
|
103
|
-
{ type: "address" },
|
|
104
|
-
// [9]: pf.signerAddress7(),
|
|
105
|
-
{ type: "address" },
|
|
106
|
-
// [10]: pf.signerAddress8(),
|
|
107
|
-
{ type: "address" },
|
|
108
|
-
// [11]: pf.signerAddress9(),
|
|
67
|
+
// pf.dataFeedId(),
|
|
68
|
+
{ type: "address[10]" },
|
|
69
|
+
// signers,
|
|
109
70
|
{ type: "uint8" },
|
|
110
|
-
//
|
|
71
|
+
// pf.getUniqueSignersThreshold(),
|
|
111
72
|
{ type: "uint128" },
|
|
112
|
-
//
|
|
73
|
+
// pf.lastPrice(),
|
|
113
74
|
{ type: "uint40" }
|
|
114
|
-
//
|
|
75
|
+
// pf.lastPayloadTimestamp()
|
|
115
76
|
],
|
|
116
77
|
args.baseParams.serializedParams
|
|
117
78
|
);
|
|
118
79
|
this.token = decoder[0];
|
|
119
80
|
this.dataId = (0, import_viem.bytesToString)((0, import_viem.toBytes)(decoder[1])).replaceAll("\0", "");
|
|
120
|
-
this.signers = decoder
|
|
121
|
-
this.signersThreshold = Number(decoder[
|
|
81
|
+
this.signers = [...decoder[2]];
|
|
82
|
+
this.signersThreshold = Number(decoder[3]);
|
|
122
83
|
this.dataServiceId = ["GMX", "BAL"].includes(this.dataId) ? "redstone-arbitrum-prod" : "redstone-primary-prod";
|
|
84
|
+
this.lastPrice = decoder[4];
|
|
85
|
+
this.lastPayloadTimestamp = Number(decoder[5]);
|
|
123
86
|
}
|
|
124
87
|
}
|
|
125
88
|
stateHuman(raw = true) {
|
|
@@ -129,7 +92,9 @@ class RedstonePriceFeedContract extends import_AbstractPriceFeed.AbstractPriceFe
|
|
|
129
92
|
dataId: this.dataId,
|
|
130
93
|
signers: this.signers,
|
|
131
94
|
signersThreshold: this.signersThreshold,
|
|
132
|
-
skipCheck: true
|
|
95
|
+
skipCheck: true,
|
|
96
|
+
lastPrice: this.lastPrice.toString(),
|
|
97
|
+
lastPayloadTimestamp: this.lastPayloadTimestamp.toString()
|
|
133
98
|
};
|
|
134
99
|
}
|
|
135
100
|
}
|
|
@@ -8,6 +8,10 @@ class AbstractLPPriceFeedContract extends AbstractPriceFeedContract {
|
|
|
8
8
|
lpToken;
|
|
9
9
|
lowerBound;
|
|
10
10
|
upperBound;
|
|
11
|
+
// v3.0 optionals
|
|
12
|
+
exchangeRate;
|
|
13
|
+
aggregatePrice;
|
|
14
|
+
scale;
|
|
11
15
|
constructor(sdk, args) {
|
|
12
16
|
super(sdk, { ...args, decimals: 8 });
|
|
13
17
|
this.hasLowerBoundCap = true;
|
|
@@ -32,11 +36,17 @@ class AbstractLPPriceFeedContract extends AbstractPriceFeedContract {
|
|
|
32
36
|
{ type: "address", name: "lpContract" },
|
|
33
37
|
{ type: "uint256", name: "lowerBound" },
|
|
34
38
|
{ type: "uint256", name: "upperBound" },
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
{
|
|
40
|
+
type: "tuple",
|
|
41
|
+
name: "price",
|
|
42
|
+
components: [
|
|
43
|
+
{ type: "uint256", name: "exchangeRate" },
|
|
44
|
+
{ type: "int256", name: "aggregatePrice" },
|
|
45
|
+
{ type: "uint256", name: "scale" },
|
|
46
|
+
{ type: "bool", name: "exchangeRateSuccess" },
|
|
47
|
+
{ type: "bool", name: "aggregatePriceSuccess" }
|
|
48
|
+
]
|
|
49
|
+
}
|
|
40
50
|
],
|
|
41
51
|
hexToBytes(args.baseParams.serializedParams)
|
|
42
52
|
);
|
|
@@ -44,6 +54,9 @@ class AbstractLPPriceFeedContract extends AbstractPriceFeedContract {
|
|
|
44
54
|
this.lpContract = decoder[1];
|
|
45
55
|
this.lowerBound = decoder[2];
|
|
46
56
|
this.upperBound = decoder[3];
|
|
57
|
+
this.exchangeRate = decoder[4].exchangeRate;
|
|
58
|
+
this.aggregatePrice = decoder[4].aggregatePrice;
|
|
59
|
+
this.scale = decoder[4].scale;
|
|
47
60
|
}
|
|
48
61
|
}
|
|
49
62
|
async getLowerBound() {
|
|
@@ -63,7 +76,11 @@ class AbstractLPPriceFeedContract extends AbstractPriceFeedContract {
|
|
|
63
76
|
lpContract: this.lpContract,
|
|
64
77
|
lpToken: this.lpToken,
|
|
65
78
|
lowerBound: this.lowerBound,
|
|
66
|
-
upperBound: this.upperBound
|
|
79
|
+
upperBound: this.upperBound,
|
|
80
|
+
// v3.0 optionals
|
|
81
|
+
exchangeRate: this.exchangeRate?.toString(),
|
|
82
|
+
aggregatePrice: this.aggregatePrice?.toString(),
|
|
83
|
+
scale: this.scale?.toString()
|
|
67
84
|
};
|
|
68
85
|
}
|
|
69
86
|
}
|
|
@@ -7,6 +7,8 @@ class RedstonePriceFeedContract extends AbstractPriceFeedContract {
|
|
|
7
7
|
dataId;
|
|
8
8
|
signers;
|
|
9
9
|
signersThreshold;
|
|
10
|
+
lastPrice;
|
|
11
|
+
lastPayloadTimestamp;
|
|
10
12
|
constructor(sdk, args) {
|
|
11
13
|
super(sdk, {
|
|
12
14
|
...args,
|
|
@@ -16,87 +18,48 @@ class RedstonePriceFeedContract extends AbstractPriceFeedContract {
|
|
|
16
18
|
if (args.baseParams.version === 310n) {
|
|
17
19
|
const decoder = decodeAbiParameters(
|
|
18
20
|
[
|
|
19
|
-
{ type: "address" },
|
|
20
|
-
|
|
21
|
-
{ type: "
|
|
22
|
-
|
|
23
|
-
{ type: "
|
|
24
|
-
|
|
25
|
-
{ type: "
|
|
26
|
-
// [3]: pf.signerAddress0(),
|
|
27
|
-
{ type: "address" },
|
|
28
|
-
// [4]: pf.signerAddress1(),
|
|
29
|
-
{ type: "address" },
|
|
30
|
-
// [5]: pf.signerAddress2(),
|
|
31
|
-
{ type: "address" },
|
|
32
|
-
// [6]: pf.signerAddress3(),
|
|
33
|
-
{ type: "address" },
|
|
34
|
-
// [7]: pf.signerAddress4(),
|
|
35
|
-
{ type: "address" },
|
|
36
|
-
// [8]: pf.signerAddress5()
|
|
37
|
-
{ type: "address" },
|
|
38
|
-
// [9]: pf.signerAddress6(),
|
|
39
|
-
{ type: "address" },
|
|
40
|
-
// [10]: pf.signerAddress7(),
|
|
41
|
-
{ type: "address" },
|
|
42
|
-
// [11]: pf.signerAddress8(),
|
|
43
|
-
{ type: "address" },
|
|
44
|
-
// [12]: pf.signerAddress9(),
|
|
45
|
-
{ type: "uint8" },
|
|
46
|
-
// [13]: pf.getUniqueSignersThreshold()
|
|
47
|
-
{ type: "uint128" },
|
|
48
|
-
// [14]: pf.lastPrice(),
|
|
49
|
-
{ type: "uint40" }
|
|
50
|
-
// [15]: pf.lastPayloadTimestamp()
|
|
21
|
+
{ type: "address", name: "token" },
|
|
22
|
+
{ type: "bytes32", name: "dataFeedId" },
|
|
23
|
+
{ type: "string", name: "dataServiceId" },
|
|
24
|
+
{ type: "address[10]", name: "signers" },
|
|
25
|
+
{ type: "uint8", name: "signersThreshold" },
|
|
26
|
+
{ type: "uint128", name: "lastPrice" },
|
|
27
|
+
{ type: "uint40", name: "lastPayloadTimestamp" }
|
|
51
28
|
],
|
|
52
29
|
args.baseParams.serializedParams
|
|
53
30
|
);
|
|
54
31
|
this.token = decoder[0];
|
|
55
32
|
this.dataId = bytesToString(toBytes(decoder[1])).replaceAll("\0", "");
|
|
56
|
-
this.signers = decoder.slice(3, 13);
|
|
57
|
-
this.signersThreshold = Number(decoder[13]);
|
|
58
33
|
this.dataServiceId = decoder[2];
|
|
34
|
+
this.signers = [...decoder[3]];
|
|
35
|
+
this.signersThreshold = Number(decoder[4]);
|
|
36
|
+
this.lastPrice = decoder[5];
|
|
37
|
+
this.lastPayloadTimestamp = Number(decoder[6]);
|
|
59
38
|
} else {
|
|
60
39
|
const decoder = decodeAbiParameters(
|
|
61
40
|
[
|
|
62
41
|
{ type: "address" },
|
|
63
|
-
//
|
|
42
|
+
// pf.token(),
|
|
64
43
|
{ type: "bytes32" },
|
|
65
|
-
//
|
|
66
|
-
{ type: "address" },
|
|
67
|
-
//
|
|
68
|
-
{ type: "address" },
|
|
69
|
-
// [3]: pf.signerAddress1(),
|
|
70
|
-
{ type: "address" },
|
|
71
|
-
// [4]: pf.signerAddress2(),
|
|
72
|
-
{ type: "address" },
|
|
73
|
-
// [5]: pf.signerAddress3(),
|
|
74
|
-
{ type: "address" },
|
|
75
|
-
// [6]: pf.signerAddress4(),
|
|
76
|
-
{ type: "address" },
|
|
77
|
-
// [7]: pf.signerAddress5()
|
|
78
|
-
{ type: "address" },
|
|
79
|
-
// [8]: pf.signerAddress6(),
|
|
80
|
-
{ type: "address" },
|
|
81
|
-
// [9]: pf.signerAddress7(),
|
|
82
|
-
{ type: "address" },
|
|
83
|
-
// [10]: pf.signerAddress8(),
|
|
84
|
-
{ type: "address" },
|
|
85
|
-
// [11]: pf.signerAddress9(),
|
|
44
|
+
// pf.dataFeedId(),
|
|
45
|
+
{ type: "address[10]" },
|
|
46
|
+
// signers,
|
|
86
47
|
{ type: "uint8" },
|
|
87
|
-
//
|
|
48
|
+
// pf.getUniqueSignersThreshold(),
|
|
88
49
|
{ type: "uint128" },
|
|
89
|
-
//
|
|
50
|
+
// pf.lastPrice(),
|
|
90
51
|
{ type: "uint40" }
|
|
91
|
-
//
|
|
52
|
+
// pf.lastPayloadTimestamp()
|
|
92
53
|
],
|
|
93
54
|
args.baseParams.serializedParams
|
|
94
55
|
);
|
|
95
56
|
this.token = decoder[0];
|
|
96
57
|
this.dataId = bytesToString(toBytes(decoder[1])).replaceAll("\0", "");
|
|
97
|
-
this.signers = decoder
|
|
98
|
-
this.signersThreshold = Number(decoder[
|
|
58
|
+
this.signers = [...decoder[2]];
|
|
59
|
+
this.signersThreshold = Number(decoder[3]);
|
|
99
60
|
this.dataServiceId = ["GMX", "BAL"].includes(this.dataId) ? "redstone-arbitrum-prod" : "redstone-primary-prod";
|
|
61
|
+
this.lastPrice = decoder[4];
|
|
62
|
+
this.lastPayloadTimestamp = Number(decoder[5]);
|
|
100
63
|
}
|
|
101
64
|
}
|
|
102
65
|
stateHuman(raw = true) {
|
|
@@ -106,7 +69,9 @@ class RedstonePriceFeedContract extends AbstractPriceFeedContract {
|
|
|
106
69
|
dataId: this.dataId,
|
|
107
70
|
signers: this.signers,
|
|
108
71
|
signersThreshold: this.signersThreshold,
|
|
109
|
-
skipCheck: true
|
|
72
|
+
skipCheck: true,
|
|
73
|
+
lastPrice: this.lastPrice.toString(),
|
|
74
|
+
lastPayloadTimestamp: this.lastPayloadTimestamp.toString()
|
|
110
75
|
};
|
|
111
76
|
}
|
|
112
77
|
}
|
|
@@ -7,6 +7,9 @@ export declare abstract class AbstractLPPriceFeedContract<const abi extends Abi
|
|
|
7
7
|
readonly lpToken: Address;
|
|
8
8
|
readonly lowerBound: bigint;
|
|
9
9
|
readonly upperBound: bigint;
|
|
10
|
+
readonly exchangeRate?: bigint;
|
|
11
|
+
readonly aggregatePrice?: bigint;
|
|
12
|
+
readonly scale?: bigint;
|
|
10
13
|
constructor(sdk: GearboxSDK, args: PriceFeedConstructorArgs<abi>);
|
|
11
14
|
abstract getValue(): Promise<bigint>;
|
|
12
15
|
getLowerBound(): Promise<bigint>;
|
|
@@ -11,6 +11,8 @@ export declare class RedstonePriceFeedContract extends AbstractPriceFeedContract
|
|
|
11
11
|
readonly dataId: string;
|
|
12
12
|
readonly signers: Hex[];
|
|
13
13
|
readonly signersThreshold: number;
|
|
14
|
+
readonly lastPrice: bigint;
|
|
15
|
+
readonly lastPayloadTimestamp: number;
|
|
14
16
|
constructor(sdk: GearboxSDK, args: PartialPriceFeedTreeNode);
|
|
15
17
|
stateHuman(raw?: boolean): Omit<RedstonePriceFeedStateHuman, "stalenessPeriod">;
|
|
16
18
|
}
|
|
@@ -40,6 +40,9 @@ export interface LPPriceFeedStateHuman extends BasePriceFeedStateHuman {
|
|
|
40
40
|
lpToken: Address;
|
|
41
41
|
lowerBound: bigint;
|
|
42
42
|
upperBound: bigint;
|
|
43
|
+
exchangeRate?: string;
|
|
44
|
+
aggregatePrice?: string;
|
|
45
|
+
scale?: string;
|
|
43
46
|
}
|
|
44
47
|
export interface BalancerWeightedPriceFeedStateHuman extends LPPriceFeedStateHuman {
|
|
45
48
|
contractType: "PRICE_FEED::BALANCER_WEIGHTED";
|
|
@@ -52,6 +55,8 @@ export interface RedstonePriceFeedStateHuman extends BasePriceFeedStateHuman {
|
|
|
52
55
|
dataId: string;
|
|
53
56
|
signers: Array<string>;
|
|
54
57
|
signersThreshold: number;
|
|
58
|
+
lastPrice: string;
|
|
59
|
+
lastPayloadTimestamp: string;
|
|
55
60
|
}
|
|
56
61
|
export interface PriceOracleStateHuman extends BaseContractStateHuman {
|
|
57
62
|
mainPriceFeeds: Record<string, PriceFeedStateHuman>;
|