@sonarwatch/portfolio-plugins 0.12.80 → 0.12.81
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/plugins/drift/perpHelpers/getOraclePrice.js +14 -1
- package/src/plugins/drift/perpHelpers/getOraclePrice.js.map +1 -1
- package/src/plugins/drift/perpHelpers/idls.d.ts +180 -0
- package/src/plugins/drift/perpHelpers/idls.js +625 -0
- package/src/plugins/drift/perpHelpers/idls.js.map +1 -0
- package/src/plugins/drift/perpHelpers/pythPull.d.ts +5 -0
- package/src/plugins/drift/perpHelpers/pythPull.js +51 -0
- package/src/plugins/drift/perpHelpers/pythPull.js.map +1 -0
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
4
4
|
|
5
|
+
## [0.12.81](https://github.com/sonarwatch/portfolio/compare/plugins-0.12.80...plugins-0.12.81) (2024-07-19)
|
6
|
+
|
7
|
+
|
8
|
+
|
5
9
|
## [0.12.80](https://github.com/sonarwatch/portfolio/compare/plugins-0.12.79...plugins-0.12.80) (2024-07-19)
|
6
10
|
|
7
11
|
|
package/package.json
CHANGED
@@ -16,6 +16,7 @@ const struct_1 = require("../struct");
|
|
16
16
|
const pyth_1 = require("./pyth");
|
17
17
|
const switchboard_1 = require("./switchboard");
|
18
18
|
const prelaunchOracle_1 = require("./prelaunchOracle");
|
19
|
+
const pythPull_1 = require("./pythPull");
|
19
20
|
const oraclePrices = new Map();
|
20
21
|
const lastUpdates = new Map();
|
21
22
|
const oraclePriceTtl = 90000;
|
@@ -47,8 +48,20 @@ function getOraclePrice(oracle, oracleSource, connection) {
|
|
47
48
|
case struct_1.OracleSource.Prelaunch:
|
48
49
|
coPriceData = (0, prelaunchOracle_1.getPreLaunchOraclePriceDataFromBuffer)(acc.data);
|
49
50
|
break;
|
51
|
+
case struct_1.OracleSource.PythPull:
|
52
|
+
coPriceData = (0, pythPull_1.getPythPullOraclePriceDataFromBuffer)(acc.data, new bn_js_1.BN(1), false);
|
53
|
+
break;
|
54
|
+
case struct_1.OracleSource.Pyth1KPull:
|
55
|
+
coPriceData = (0, pythPull_1.getPythPullOraclePriceDataFromBuffer)(acc.data, new bn_js_1.BN(1000), false);
|
56
|
+
break;
|
57
|
+
case struct_1.OracleSource.Pyth1MPull:
|
58
|
+
coPriceData = (0, pythPull_1.getPythPullOraclePriceDataFromBuffer)(acc.data, new bn_js_1.BN(1000000), false);
|
59
|
+
break;
|
60
|
+
case struct_1.OracleSource.PythStableCoinPull:
|
61
|
+
coPriceData = (0, pythPull_1.getPythPullOraclePriceDataFromBuffer)(acc.data, new bn_js_1.BN(1), true);
|
62
|
+
break;
|
50
63
|
default:
|
51
|
-
throw new Error(
|
64
|
+
throw new Error(`Unsupported OracleSource: ${oracleSource}`);
|
52
65
|
}
|
53
66
|
oraclePrices.set(oracle, coPriceData);
|
54
67
|
lastUpdates.set(oracle, Date.now());
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getOraclePrice.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/drift/perpHelpers/getOraclePrice.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA4C;AAC5C,iCAA2B;AAE3B,sCAAyC;AAEzC,iCAA0D;AAC1D,+CAAwE;AACxE,uDAA0E;
|
1
|
+
{"version":3,"file":"getOraclePrice.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/drift/perpHelpers/getOraclePrice.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA4C;AAC5C,iCAA2B;AAE3B,sCAAyC;AAEzC,iCAA0D;AAC1D,+CAAwE;AACxE,uDAA0E;AAC1E,yCAAkE;AAElE,MAAM,YAAY,GAAiC,IAAI,GAAG,EAAE,CAAC;AAC7D,MAAM,WAAW,GAAwB,IAAI,GAAG,EAAE,CAAC;AACnD,MAAM,cAAc,GAAG,KAAK,CAAC;AAE7B,SAAsB,cAAc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CAAC,IAAI,CAAC,CAAC;oBAChE,MAAM;gBACR,KAAK,qBAAY,CAAC,SAAS;oBACzB,WAAW,GAAG,IAAA,uDAAqC,EAAC,GAAG,CAAC,IAAI,CAAC,CAAC;oBAC9D,MAAM;gBACR,KAAK,qBAAY,CAAC,QAAQ;oBACxB,WAAW,GAAG,IAAA,+CAAoC,EAChD,GAAG,CAAC,IAAI,EACR,IAAI,UAAE,CAAC,CAAC,CAAC,EACT,KAAK,CACN,CAAC;oBACF,MAAM;gBACR,KAAK,qBAAY,CAAC,UAAU;oBAC1B,WAAW,GAAG,IAAA,+CAAoC,EAChD,GAAG,CAAC,IAAI,EACR,IAAI,UAAE,CAAC,IAAI,CAAC,EACZ,KAAK,CACN,CAAC;oBACF,MAAM;gBACR,KAAK,qBAAY,CAAC,UAAU;oBAC1B,WAAW,GAAG,IAAA,+CAAoC,EAChD,GAAG,CAAC,IAAI,EACR,IAAI,UAAE,CAAC,OAAO,CAAC,EACf,KAAK,CACN,CAAC;oBACF,MAAM;gBACR,KAAK,qBAAY,CAAC,kBAAkB;oBAClC,WAAW,GAAG,IAAA,+CAAoC,EAChD,GAAG,CAAC,IAAI,EACR,IAAI,UAAE,CAAC,CAAC,CAAC,EACT,IAAI,CACL,CAAC;oBACF,MAAM;gBACR;oBACE,MAAM,IAAI,KAAK,CAAC,6BAA6B,YAAY,EAAE,CAAC,CAAC;YACjE,CAAC;YAED,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YACtC,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;YACpC,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;CAAA;AAnFD,wCAmFC"}
|
@@ -0,0 +1,180 @@
|
|
1
|
+
import { IdlItem } from '@solanafm/explorer-kit-idls';
|
2
|
+
export declare const pythSolanaReceiverIdl: {
|
3
|
+
version: string;
|
4
|
+
name: string;
|
5
|
+
instructions: ({
|
6
|
+
name: string;
|
7
|
+
accounts: {
|
8
|
+
name: string;
|
9
|
+
isMut: boolean;
|
10
|
+
isSigner: boolean;
|
11
|
+
}[];
|
12
|
+
args: {
|
13
|
+
name: string;
|
14
|
+
type: {
|
15
|
+
defined: string;
|
16
|
+
};
|
17
|
+
}[];
|
18
|
+
docs?: undefined;
|
19
|
+
} | {
|
20
|
+
name: string;
|
21
|
+
accounts: {
|
22
|
+
name: string;
|
23
|
+
isMut: boolean;
|
24
|
+
isSigner: boolean;
|
25
|
+
}[];
|
26
|
+
args: {
|
27
|
+
name: string;
|
28
|
+
type: string;
|
29
|
+
}[];
|
30
|
+
docs?: undefined;
|
31
|
+
} | {
|
32
|
+
name: string;
|
33
|
+
accounts: {
|
34
|
+
name: string;
|
35
|
+
isMut: boolean;
|
36
|
+
isSigner: boolean;
|
37
|
+
}[];
|
38
|
+
args: {
|
39
|
+
name: string;
|
40
|
+
type: {
|
41
|
+
vec: {
|
42
|
+
defined: string;
|
43
|
+
};
|
44
|
+
};
|
45
|
+
}[];
|
46
|
+
docs?: undefined;
|
47
|
+
} | {
|
48
|
+
name: string;
|
49
|
+
docs: string[];
|
50
|
+
accounts: ({
|
51
|
+
name: string;
|
52
|
+
isMut: boolean;
|
53
|
+
isSigner: boolean;
|
54
|
+
docs?: undefined;
|
55
|
+
} | {
|
56
|
+
name: string;
|
57
|
+
isMut: boolean;
|
58
|
+
isSigner: boolean;
|
59
|
+
docs: string[];
|
60
|
+
})[];
|
61
|
+
args: {
|
62
|
+
name: string;
|
63
|
+
type: {
|
64
|
+
defined: string;
|
65
|
+
};
|
66
|
+
}[];
|
67
|
+
})[];
|
68
|
+
accounts: ({
|
69
|
+
name: string;
|
70
|
+
type: {
|
71
|
+
kind: string;
|
72
|
+
fields: ({
|
73
|
+
name: string;
|
74
|
+
type: string;
|
75
|
+
} | {
|
76
|
+
name: string;
|
77
|
+
type: {
|
78
|
+
option: string;
|
79
|
+
vec?: undefined;
|
80
|
+
};
|
81
|
+
} | {
|
82
|
+
name: string;
|
83
|
+
type: {
|
84
|
+
vec: {
|
85
|
+
defined: string;
|
86
|
+
};
|
87
|
+
option?: undefined;
|
88
|
+
};
|
89
|
+
})[];
|
90
|
+
};
|
91
|
+
} | {
|
92
|
+
name: string;
|
93
|
+
type: {
|
94
|
+
kind: string;
|
95
|
+
fields: ({
|
96
|
+
name: string;
|
97
|
+
type: string;
|
98
|
+
} | {
|
99
|
+
name: string;
|
100
|
+
type: {
|
101
|
+
defined: string;
|
102
|
+
};
|
103
|
+
})[];
|
104
|
+
};
|
105
|
+
})[];
|
106
|
+
types: ({
|
107
|
+
name: string;
|
108
|
+
type: {
|
109
|
+
kind: string;
|
110
|
+
fields: ({
|
111
|
+
name: string;
|
112
|
+
type: {
|
113
|
+
array: (string | number)[];
|
114
|
+
};
|
115
|
+
} | {
|
116
|
+
name: string;
|
117
|
+
type: string;
|
118
|
+
})[];
|
119
|
+
variants?: undefined;
|
120
|
+
};
|
121
|
+
docs?: undefined;
|
122
|
+
} | {
|
123
|
+
name: string;
|
124
|
+
type: {
|
125
|
+
kind: string;
|
126
|
+
fields: ({
|
127
|
+
name: string;
|
128
|
+
type: string;
|
129
|
+
} | {
|
130
|
+
name: string;
|
131
|
+
type: {
|
132
|
+
vec: {
|
133
|
+
array: (string | number)[];
|
134
|
+
};
|
135
|
+
};
|
136
|
+
})[];
|
137
|
+
variants?: undefined;
|
138
|
+
};
|
139
|
+
docs?: undefined;
|
140
|
+
} | {
|
141
|
+
name: string;
|
142
|
+
type: {
|
143
|
+
kind: string;
|
144
|
+
fields: ({
|
145
|
+
name: string;
|
146
|
+
type: string;
|
147
|
+
} | {
|
148
|
+
name: string;
|
149
|
+
type: {
|
150
|
+
defined: string;
|
151
|
+
};
|
152
|
+
})[];
|
153
|
+
variants?: undefined;
|
154
|
+
};
|
155
|
+
docs?: undefined;
|
156
|
+
} | {
|
157
|
+
name: string;
|
158
|
+
docs: string[];
|
159
|
+
type: {
|
160
|
+
kind: string;
|
161
|
+
variants: ({
|
162
|
+
name: string;
|
163
|
+
fields: {
|
164
|
+
name: string;
|
165
|
+
type: string;
|
166
|
+
}[];
|
167
|
+
} | {
|
168
|
+
name: string;
|
169
|
+
fields?: undefined;
|
170
|
+
})[];
|
171
|
+
fields?: undefined;
|
172
|
+
};
|
173
|
+
})[];
|
174
|
+
errors: {
|
175
|
+
code: number;
|
176
|
+
name: string;
|
177
|
+
msg: string;
|
178
|
+
}[];
|
179
|
+
};
|
180
|
+
export declare const pythSolanaReceiverIdlItem: IdlItem;
|
@@ -0,0 +1,625 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.pythSolanaReceiverIdlItem = exports.pythSolanaReceiverIdl = void 0;
|
4
|
+
exports.pythSolanaReceiverIdl = {
|
5
|
+
version: '0.1.0',
|
6
|
+
name: 'pyth_solana_receiver',
|
7
|
+
instructions: [
|
8
|
+
{
|
9
|
+
name: 'initialize',
|
10
|
+
accounts: [
|
11
|
+
{
|
12
|
+
name: 'payer',
|
13
|
+
isMut: true,
|
14
|
+
isSigner: true,
|
15
|
+
},
|
16
|
+
{
|
17
|
+
name: 'config',
|
18
|
+
isMut: true,
|
19
|
+
isSigner: false,
|
20
|
+
},
|
21
|
+
{
|
22
|
+
name: 'systemProgram',
|
23
|
+
isMut: false,
|
24
|
+
isSigner: false,
|
25
|
+
},
|
26
|
+
],
|
27
|
+
args: [
|
28
|
+
{
|
29
|
+
name: 'initialConfig',
|
30
|
+
type: {
|
31
|
+
defined: 'Config',
|
32
|
+
},
|
33
|
+
},
|
34
|
+
],
|
35
|
+
},
|
36
|
+
{
|
37
|
+
name: 'requestGovernanceAuthorityTransfer',
|
38
|
+
accounts: [
|
39
|
+
{
|
40
|
+
name: 'payer',
|
41
|
+
isMut: false,
|
42
|
+
isSigner: true,
|
43
|
+
},
|
44
|
+
{
|
45
|
+
name: 'config',
|
46
|
+
isMut: true,
|
47
|
+
isSigner: false,
|
48
|
+
},
|
49
|
+
],
|
50
|
+
args: [
|
51
|
+
{
|
52
|
+
name: 'targetGovernanceAuthority',
|
53
|
+
type: 'publicKey',
|
54
|
+
},
|
55
|
+
],
|
56
|
+
},
|
57
|
+
{
|
58
|
+
name: 'acceptGovernanceAuthorityTransfer',
|
59
|
+
accounts: [
|
60
|
+
{
|
61
|
+
name: 'payer',
|
62
|
+
isMut: false,
|
63
|
+
isSigner: true,
|
64
|
+
},
|
65
|
+
{
|
66
|
+
name: 'config',
|
67
|
+
isMut: true,
|
68
|
+
isSigner: false,
|
69
|
+
},
|
70
|
+
],
|
71
|
+
args: [],
|
72
|
+
},
|
73
|
+
{
|
74
|
+
name: 'setDataSources',
|
75
|
+
accounts: [
|
76
|
+
{
|
77
|
+
name: 'payer',
|
78
|
+
isMut: false,
|
79
|
+
isSigner: true,
|
80
|
+
},
|
81
|
+
{
|
82
|
+
name: 'config',
|
83
|
+
isMut: true,
|
84
|
+
isSigner: false,
|
85
|
+
},
|
86
|
+
],
|
87
|
+
args: [
|
88
|
+
{
|
89
|
+
name: 'validDataSources',
|
90
|
+
type: {
|
91
|
+
vec: {
|
92
|
+
defined: 'DataSource',
|
93
|
+
},
|
94
|
+
},
|
95
|
+
},
|
96
|
+
],
|
97
|
+
},
|
98
|
+
{
|
99
|
+
name: 'setFee',
|
100
|
+
accounts: [
|
101
|
+
{
|
102
|
+
name: 'payer',
|
103
|
+
isMut: false,
|
104
|
+
isSigner: true,
|
105
|
+
},
|
106
|
+
{
|
107
|
+
name: 'config',
|
108
|
+
isMut: true,
|
109
|
+
isSigner: false,
|
110
|
+
},
|
111
|
+
],
|
112
|
+
args: [
|
113
|
+
{
|
114
|
+
name: 'singleUpdateFeeInLamports',
|
115
|
+
type: 'u64',
|
116
|
+
},
|
117
|
+
],
|
118
|
+
},
|
119
|
+
{
|
120
|
+
name: 'setWormholeAddress',
|
121
|
+
accounts: [
|
122
|
+
{
|
123
|
+
name: 'payer',
|
124
|
+
isMut: false,
|
125
|
+
isSigner: true,
|
126
|
+
},
|
127
|
+
{
|
128
|
+
name: 'config',
|
129
|
+
isMut: true,
|
130
|
+
isSigner: false,
|
131
|
+
},
|
132
|
+
],
|
133
|
+
args: [
|
134
|
+
{
|
135
|
+
name: 'wormhole',
|
136
|
+
type: 'publicKey',
|
137
|
+
},
|
138
|
+
],
|
139
|
+
},
|
140
|
+
{
|
141
|
+
name: 'setMinimumSignatures',
|
142
|
+
accounts: [
|
143
|
+
{
|
144
|
+
name: 'payer',
|
145
|
+
isMut: false,
|
146
|
+
isSigner: true,
|
147
|
+
},
|
148
|
+
{
|
149
|
+
name: 'config',
|
150
|
+
isMut: true,
|
151
|
+
isSigner: false,
|
152
|
+
},
|
153
|
+
],
|
154
|
+
args: [
|
155
|
+
{
|
156
|
+
name: 'minimumSignatures',
|
157
|
+
type: 'u8',
|
158
|
+
},
|
159
|
+
],
|
160
|
+
},
|
161
|
+
{
|
162
|
+
name: 'postUpdateAtomic',
|
163
|
+
docs: [
|
164
|
+
'Post a price update using a VAA and a MerklePriceUpdate.',
|
165
|
+
'This function allows you to post a price update in a single transaction.',
|
166
|
+
"Compared to post_update, it is less secure since you won't be able to verify all guardian signatures if you use this function because of transaction size limitations.",
|
167
|
+
'Typically, you can fit 5 guardian signatures in a transaction that uses this.',
|
168
|
+
],
|
169
|
+
accounts: [
|
170
|
+
{
|
171
|
+
name: 'payer',
|
172
|
+
isMut: true,
|
173
|
+
isSigner: true,
|
174
|
+
},
|
175
|
+
{
|
176
|
+
name: 'guardianSet',
|
177
|
+
isMut: false,
|
178
|
+
isSigner: false,
|
179
|
+
docs: [
|
180
|
+
'Instead we do the same steps in deserialize_guardian_set_checked.',
|
181
|
+
],
|
182
|
+
},
|
183
|
+
{
|
184
|
+
name: 'config',
|
185
|
+
isMut: false,
|
186
|
+
isSigner: false,
|
187
|
+
},
|
188
|
+
{
|
189
|
+
name: 'treasury',
|
190
|
+
isMut: true,
|
191
|
+
isSigner: false,
|
192
|
+
},
|
193
|
+
{
|
194
|
+
name: 'priceUpdateAccount',
|
195
|
+
isMut: true,
|
196
|
+
isSigner: true,
|
197
|
+
docs: [
|
198
|
+
'The contraint is such that either the price_update_account is uninitialized or the payer is the write_authority.',
|
199
|
+
"Pubkey::default() is the SystemProgram on Solana and it can't sign so it's impossible that price_update_account.write_authority == Pubkey::default() once the account is initialized",
|
200
|
+
],
|
201
|
+
},
|
202
|
+
{
|
203
|
+
name: 'systemProgram',
|
204
|
+
isMut: false,
|
205
|
+
isSigner: false,
|
206
|
+
},
|
207
|
+
{
|
208
|
+
name: 'writeAuthority',
|
209
|
+
isMut: false,
|
210
|
+
isSigner: true,
|
211
|
+
},
|
212
|
+
],
|
213
|
+
args: [
|
214
|
+
{
|
215
|
+
name: 'params',
|
216
|
+
type: {
|
217
|
+
defined: 'PostUpdateAtomicParams',
|
218
|
+
},
|
219
|
+
},
|
220
|
+
],
|
221
|
+
},
|
222
|
+
{
|
223
|
+
name: 'postUpdate',
|
224
|
+
docs: [
|
225
|
+
'Post a price update using an encoded_vaa account and a MerklePriceUpdate calldata.',
|
226
|
+
'This should be called after the client has already verified the Vaa via the Wormhole contract.',
|
227
|
+
'Check out target_chains/solana/cli/src/main.rs for an example of how to do this.',
|
228
|
+
],
|
229
|
+
accounts: [
|
230
|
+
{
|
231
|
+
name: 'payer',
|
232
|
+
isMut: true,
|
233
|
+
isSigner: true,
|
234
|
+
},
|
235
|
+
{
|
236
|
+
name: 'encodedVaa',
|
237
|
+
isMut: false,
|
238
|
+
isSigner: false,
|
239
|
+
},
|
240
|
+
{
|
241
|
+
name: 'config',
|
242
|
+
isMut: false,
|
243
|
+
isSigner: false,
|
244
|
+
},
|
245
|
+
{
|
246
|
+
name: 'treasury',
|
247
|
+
isMut: true,
|
248
|
+
isSigner: false,
|
249
|
+
},
|
250
|
+
{
|
251
|
+
name: 'priceUpdateAccount',
|
252
|
+
isMut: true,
|
253
|
+
isSigner: true,
|
254
|
+
docs: [
|
255
|
+
'The contraint is such that either the price_update_account is uninitialized or the payer is the write_authority.',
|
256
|
+
"Pubkey::default() is the SystemProgram on Solana and it can't sign so it's impossible that price_update_account.write_authority == Pubkey::default() once the account is initialized",
|
257
|
+
],
|
258
|
+
},
|
259
|
+
{
|
260
|
+
name: 'systemProgram',
|
261
|
+
isMut: false,
|
262
|
+
isSigner: false,
|
263
|
+
},
|
264
|
+
{
|
265
|
+
name: 'writeAuthority',
|
266
|
+
isMut: false,
|
267
|
+
isSigner: true,
|
268
|
+
},
|
269
|
+
],
|
270
|
+
args: [
|
271
|
+
{
|
272
|
+
name: 'params',
|
273
|
+
type: {
|
274
|
+
defined: 'PostUpdateParams',
|
275
|
+
},
|
276
|
+
},
|
277
|
+
],
|
278
|
+
},
|
279
|
+
{
|
280
|
+
name: 'reclaimRent',
|
281
|
+
accounts: [
|
282
|
+
{
|
283
|
+
name: 'payer',
|
284
|
+
isMut: true,
|
285
|
+
isSigner: true,
|
286
|
+
},
|
287
|
+
{
|
288
|
+
name: 'priceUpdateAccount',
|
289
|
+
isMut: true,
|
290
|
+
isSigner: false,
|
291
|
+
},
|
292
|
+
],
|
293
|
+
args: [],
|
294
|
+
},
|
295
|
+
],
|
296
|
+
accounts: [
|
297
|
+
{
|
298
|
+
name: 'Config',
|
299
|
+
type: {
|
300
|
+
kind: 'struct',
|
301
|
+
fields: [
|
302
|
+
{
|
303
|
+
name: 'governanceAuthority',
|
304
|
+
type: 'publicKey',
|
305
|
+
},
|
306
|
+
{
|
307
|
+
name: 'targetGovernanceAuthority',
|
308
|
+
type: {
|
309
|
+
option: 'publicKey',
|
310
|
+
},
|
311
|
+
},
|
312
|
+
{
|
313
|
+
name: 'wormhole',
|
314
|
+
type: 'publicKey',
|
315
|
+
},
|
316
|
+
{
|
317
|
+
name: 'validDataSources',
|
318
|
+
type: {
|
319
|
+
vec: {
|
320
|
+
defined: 'DataSource',
|
321
|
+
},
|
322
|
+
},
|
323
|
+
},
|
324
|
+
{
|
325
|
+
name: 'singleUpdateFeeInLamports',
|
326
|
+
type: 'u64',
|
327
|
+
},
|
328
|
+
{
|
329
|
+
name: 'minimumSignatures',
|
330
|
+
type: 'u8',
|
331
|
+
},
|
332
|
+
],
|
333
|
+
},
|
334
|
+
},
|
335
|
+
{
|
336
|
+
name: 'priceUpdateV2',
|
337
|
+
type: {
|
338
|
+
kind: 'struct',
|
339
|
+
fields: [
|
340
|
+
{
|
341
|
+
name: 'writeAuthority',
|
342
|
+
type: 'publicKey',
|
343
|
+
},
|
344
|
+
{
|
345
|
+
name: 'verificationLevel',
|
346
|
+
type: {
|
347
|
+
defined: 'VerificationLevel',
|
348
|
+
},
|
349
|
+
},
|
350
|
+
{
|
351
|
+
name: 'priceMessage',
|
352
|
+
type: {
|
353
|
+
defined: 'PriceFeedMessage',
|
354
|
+
},
|
355
|
+
},
|
356
|
+
{
|
357
|
+
name: 'postedSlot',
|
358
|
+
type: 'u64',
|
359
|
+
},
|
360
|
+
],
|
361
|
+
},
|
362
|
+
},
|
363
|
+
],
|
364
|
+
types: [
|
365
|
+
{
|
366
|
+
name: 'PriceFeedMessage',
|
367
|
+
type: {
|
368
|
+
kind: 'struct',
|
369
|
+
fields: [
|
370
|
+
{
|
371
|
+
name: 'feedId',
|
372
|
+
type: {
|
373
|
+
array: ['u8', 32],
|
374
|
+
},
|
375
|
+
},
|
376
|
+
{
|
377
|
+
name: 'price',
|
378
|
+
type: 'i64',
|
379
|
+
},
|
380
|
+
{
|
381
|
+
name: 'conf',
|
382
|
+
type: 'u64',
|
383
|
+
},
|
384
|
+
{
|
385
|
+
name: 'exponent',
|
386
|
+
type: 'i32',
|
387
|
+
},
|
388
|
+
{
|
389
|
+
name: 'publishTime',
|
390
|
+
type: 'i64',
|
391
|
+
},
|
392
|
+
{
|
393
|
+
name: 'prevPublishTime',
|
394
|
+
type: 'i64',
|
395
|
+
},
|
396
|
+
{
|
397
|
+
name: 'emaPrice',
|
398
|
+
type: 'i64',
|
399
|
+
},
|
400
|
+
{
|
401
|
+
name: 'emaConf',
|
402
|
+
type: 'u64',
|
403
|
+
},
|
404
|
+
],
|
405
|
+
},
|
406
|
+
},
|
407
|
+
{
|
408
|
+
name: 'MerklePriceUpdate',
|
409
|
+
type: {
|
410
|
+
kind: 'struct',
|
411
|
+
fields: [
|
412
|
+
{
|
413
|
+
name: 'message',
|
414
|
+
type: 'bytes',
|
415
|
+
},
|
416
|
+
{
|
417
|
+
name: 'proof',
|
418
|
+
type: {
|
419
|
+
vec: {
|
420
|
+
array: ['u8', 20],
|
421
|
+
},
|
422
|
+
},
|
423
|
+
},
|
424
|
+
],
|
425
|
+
},
|
426
|
+
},
|
427
|
+
{
|
428
|
+
name: 'DataSource',
|
429
|
+
type: {
|
430
|
+
kind: 'struct',
|
431
|
+
fields: [
|
432
|
+
{
|
433
|
+
name: 'chain',
|
434
|
+
type: 'u16',
|
435
|
+
},
|
436
|
+
{
|
437
|
+
name: 'emitter',
|
438
|
+
type: 'publicKey',
|
439
|
+
},
|
440
|
+
],
|
441
|
+
},
|
442
|
+
},
|
443
|
+
{
|
444
|
+
name: 'PostUpdateAtomicParams',
|
445
|
+
type: {
|
446
|
+
kind: 'struct',
|
447
|
+
fields: [
|
448
|
+
{
|
449
|
+
name: 'vaa',
|
450
|
+
type: 'bytes',
|
451
|
+
},
|
452
|
+
{
|
453
|
+
name: 'merklePriceUpdate',
|
454
|
+
type: {
|
455
|
+
defined: 'MerklePriceUpdate',
|
456
|
+
},
|
457
|
+
},
|
458
|
+
{
|
459
|
+
name: 'treasuryId',
|
460
|
+
type: 'u8',
|
461
|
+
},
|
462
|
+
],
|
463
|
+
},
|
464
|
+
},
|
465
|
+
{
|
466
|
+
name: 'PostUpdateParams',
|
467
|
+
type: {
|
468
|
+
kind: 'struct',
|
469
|
+
fields: [
|
470
|
+
{
|
471
|
+
name: 'merklePriceUpdate',
|
472
|
+
type: {
|
473
|
+
defined: 'MerklePriceUpdate',
|
474
|
+
},
|
475
|
+
},
|
476
|
+
{
|
477
|
+
name: 'treasuryId',
|
478
|
+
type: 'u8',
|
479
|
+
},
|
480
|
+
],
|
481
|
+
},
|
482
|
+
},
|
483
|
+
{
|
484
|
+
name: 'VerificationLevel',
|
485
|
+
docs: [
|
486
|
+
'* This enum represents how many guardian signatures were checked for a Pythnet price update\n * If full, guardian quorum has been attained\n * If partial, at least config.minimum signatures have been verified, but in the case config.minimum_signatures changes in the future we also include the number of signatures that were checked',
|
487
|
+
],
|
488
|
+
type: {
|
489
|
+
kind: 'enum',
|
490
|
+
variants: [
|
491
|
+
{
|
492
|
+
name: 'Partial',
|
493
|
+
fields: [
|
494
|
+
{
|
495
|
+
name: 'numSignatures',
|
496
|
+
type: 'u8',
|
497
|
+
},
|
498
|
+
],
|
499
|
+
},
|
500
|
+
{
|
501
|
+
name: 'Full',
|
502
|
+
},
|
503
|
+
],
|
504
|
+
},
|
505
|
+
},
|
506
|
+
],
|
507
|
+
errors: [
|
508
|
+
{
|
509
|
+
code: 6000,
|
510
|
+
name: 'InvalidWormholeMessage',
|
511
|
+
msg: 'Received an invalid wormhole message',
|
512
|
+
},
|
513
|
+
{
|
514
|
+
code: 6001,
|
515
|
+
name: 'DeserializeMessageFailed',
|
516
|
+
msg: 'An error occurred when deserializing the message',
|
517
|
+
},
|
518
|
+
{
|
519
|
+
code: 6002,
|
520
|
+
name: 'InvalidPriceUpdate',
|
521
|
+
msg: 'Received an invalid price update',
|
522
|
+
},
|
523
|
+
{
|
524
|
+
code: 6003,
|
525
|
+
name: 'UnsupportedMessageType',
|
526
|
+
msg: 'This type of message is not supported currently',
|
527
|
+
},
|
528
|
+
{
|
529
|
+
code: 6004,
|
530
|
+
name: 'InvalidDataSource',
|
531
|
+
msg: "The tuple emitter chain, emitter doesn't match one of the valid data sources.",
|
532
|
+
},
|
533
|
+
{
|
534
|
+
code: 6005,
|
535
|
+
name: 'InsufficientFunds',
|
536
|
+
msg: 'Funds are insufficient to pay the receiving fee',
|
537
|
+
},
|
538
|
+
{
|
539
|
+
code: 6006,
|
540
|
+
name: 'WrongWriteAuthority',
|
541
|
+
msg: "This signer can't write to price update account",
|
542
|
+
},
|
543
|
+
{
|
544
|
+
code: 6007,
|
545
|
+
name: 'WrongVaaOwner',
|
546
|
+
msg: 'The posted VAA account has the wrong owner.',
|
547
|
+
},
|
548
|
+
{
|
549
|
+
code: 6008,
|
550
|
+
name: 'DeserializeVaaFailed',
|
551
|
+
msg: 'An error occurred when deserializing the VAA.',
|
552
|
+
},
|
553
|
+
{
|
554
|
+
code: 6009,
|
555
|
+
name: 'InsufficientGuardianSignatures',
|
556
|
+
msg: 'The number of guardian signatures is below the minimum',
|
557
|
+
},
|
558
|
+
{
|
559
|
+
code: 6010,
|
560
|
+
name: 'InvalidVaaVersion',
|
561
|
+
msg: 'Invalid VAA version',
|
562
|
+
},
|
563
|
+
{
|
564
|
+
code: 6011,
|
565
|
+
name: 'GuardianSetMismatch',
|
566
|
+
msg: "Guardian set version in the VAA doesn't match the guardian set passed",
|
567
|
+
},
|
568
|
+
{
|
569
|
+
code: 6012,
|
570
|
+
name: 'InvalidGuardianOrder',
|
571
|
+
msg: 'Guardian signature indices must be increasing',
|
572
|
+
},
|
573
|
+
{
|
574
|
+
code: 6013,
|
575
|
+
name: 'InvalidGuardianIndex',
|
576
|
+
msg: 'Guardian index exceeds the number of guardians in the set',
|
577
|
+
},
|
578
|
+
{
|
579
|
+
code: 6014,
|
580
|
+
name: 'InvalidSignature',
|
581
|
+
msg: 'A VAA signature is invalid',
|
582
|
+
},
|
583
|
+
{
|
584
|
+
code: 6015,
|
585
|
+
name: 'InvalidGuardianKeyRecovery',
|
586
|
+
msg: "The recovered guardian public key doesn't match the guardian set",
|
587
|
+
},
|
588
|
+
{
|
589
|
+
code: 6016,
|
590
|
+
name: 'WrongGuardianSetOwner',
|
591
|
+
msg: 'The guardian set account is owned by the wrong program',
|
592
|
+
},
|
593
|
+
{
|
594
|
+
code: 6017,
|
595
|
+
name: 'InvalidGuardianSetPda',
|
596
|
+
msg: "The Guardian Set account doesn't match the PDA derivation",
|
597
|
+
},
|
598
|
+
{
|
599
|
+
code: 6018,
|
600
|
+
name: 'GuardianSetExpired',
|
601
|
+
msg: 'The Guardian Set is expired',
|
602
|
+
},
|
603
|
+
{
|
604
|
+
code: 6019,
|
605
|
+
name: 'GovernanceAuthorityMismatch',
|
606
|
+
msg: 'The signer is not authorized to perform this governance action',
|
607
|
+
},
|
608
|
+
{
|
609
|
+
code: 6020,
|
610
|
+
name: 'TargetGovernanceAuthorityMismatch',
|
611
|
+
msg: 'The signer is not authorized to accept the governance authority',
|
612
|
+
},
|
613
|
+
{
|
614
|
+
code: 6021,
|
615
|
+
name: 'NonexistentGovernanceAuthorityTransferRequest',
|
616
|
+
msg: 'The governance authority needs to request a transfer first',
|
617
|
+
},
|
618
|
+
],
|
619
|
+
};
|
620
|
+
exports.pythSolanaReceiverIdlItem = {
|
621
|
+
programId: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha',
|
622
|
+
idl: exports.pythSolanaReceiverIdl,
|
623
|
+
idlType: 'anchor',
|
624
|
+
};
|
625
|
+
//# sourceMappingURL=idls.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"idls.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/drift/perpHelpers/idls.ts"],"names":[],"mappings":";;;AAEa,QAAA,qBAAqB,GAAG;IACnC,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,sBAAsB;IAC5B,YAAY,EAAE;QACZ;YACE,IAAI,EAAE,YAAY;YAClB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,IAAI;oBACX,QAAQ,EAAE,IAAI;iBACf;gBACD;oBACE,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,IAAI;oBACX,QAAQ,EAAE,KAAK;iBAChB;gBACD;oBACE,IAAI,EAAE,eAAe;oBACrB,KAAK,EAAE,KAAK;oBACZ,QAAQ,EAAE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ClC;QACD;YACE,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,4BAA4B;YAClC,GAAG,EAAE,kEAAkE;SACxE;QACD;YACE,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,uBAAuB;YAC7B,GAAG,EAAE,wDAAwD;SAC9D;QACD;YACE,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,uBAAuB;YAC7B,GAAG,EAAE,2DAA2D;SACjE;QACD;YACE,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,oBAAoB;YAC1B,GAAG,EAAE,6BAA6B;SACnC;QACD;YACE,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,6BAA6B;YACnC,GAAG,EAAE,gEAAgE;SACtE;QACD;YACE,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,mCAAmC;YACzC,GAAG,EAAE,iEAAiE;SACvE;QACD;YACE,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,+CAA+C;YACrD,GAAG,EAAE,4DAA4D;SAClE;KACF;CACF,CAAC;AAEW,QAAA,yBAAyB,GAAG;IACvC,SAAS,EAAE,8CAA8C;IACzD,GAAG,EAAE,6BAAqB;IAC1B,OAAO,EAAE,QAAQ;CACP,CAAC"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import BN from 'bn.js';
|
3
|
+
import { OraclePriceData } from './types';
|
4
|
+
export declare function getPythPullOraclePriceDataFromBuffer(buffer: Buffer, multiple: BN, stableCoin: boolean): OraclePriceData;
|
5
|
+
export declare function convertPythPrice(price: BN, exponent: number, multiple: BN): BN;
|
@@ -0,0 +1,51 @@
|
|
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
|
+
exports.convertPythPrice = exports.getPythPullOraclePriceDataFromBuffer = void 0;
|
7
|
+
/* eslint-disable no-param-reassign */
|
8
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
9
|
+
const explorer_kit_1 = require("@solanafm/explorer-kit");
|
10
|
+
const constants_1 = require("./constants");
|
11
|
+
const idls_1 = require("./idls");
|
12
|
+
const parser = new explorer_kit_1.SolanaFMParser(idls_1.pythSolanaReceiverIdlItem, idls_1.pythSolanaReceiverIdlItem.programId.toString());
|
13
|
+
function getPythPullOraclePriceDataFromBuffer(buffer, multiple, stableCoin) {
|
14
|
+
var _a, _b;
|
15
|
+
const eventParser = parser.createParser(explorer_kit_1.ParserType.ACCOUNT);
|
16
|
+
if (!eventParser || !(0, explorer_kit_1.checkIfAccountParser)(eventParser))
|
17
|
+
throw new Error('Failed to create event parser Pyth pull');
|
18
|
+
const parsedAccount = eventParser.parseAccount(buffer.toString('base64'));
|
19
|
+
const priceData = (_a = parsedAccount === null || parsedAccount === void 0 ? void 0 : parsedAccount.data) === null || _a === void 0 ? void 0 : _a.priceMessage;
|
20
|
+
const postedSlot = (_b = parsedAccount === null || parsedAccount === void 0 ? void 0 : parsedAccount.data) === null || _b === void 0 ? void 0 : _b.postedSlot;
|
21
|
+
if (!priceData || !postedSlot)
|
22
|
+
throw new Error('Failed to parseAccount Pyth pull');
|
23
|
+
const confidence = convertPythPrice(new bn_js_1.default(priceData.conf), priceData.exponent, multiple);
|
24
|
+
let price = convertPythPrice(new bn_js_1.default(priceData.price), priceData.exponent, multiple);
|
25
|
+
if (stableCoin) {
|
26
|
+
price = getStableCoinPrice(price, confidence);
|
27
|
+
}
|
28
|
+
return {
|
29
|
+
price,
|
30
|
+
slot: postedSlot,
|
31
|
+
confidence,
|
32
|
+
twap: convertPythPrice(new bn_js_1.default(priceData.price), priceData.exponent, multiple),
|
33
|
+
twapConfidence: convertPythPrice(new bn_js_1.default(priceData.price), priceData.exponent, multiple),
|
34
|
+
hasSufficientNumberOfDataPoints: true,
|
35
|
+
};
|
36
|
+
}
|
37
|
+
exports.getPythPullOraclePriceDataFromBuffer = getPythPullOraclePriceDataFromBuffer;
|
38
|
+
function convertPythPrice(price, exponent, multiple) {
|
39
|
+
exponent = Math.abs(exponent);
|
40
|
+
const pythPrecision = constants_1.TEN.pow(new bn_js_1.default(exponent).abs()).div(multiple);
|
41
|
+
return price.mul(constants_1.PRICE_PRECISION).div(pythPrecision);
|
42
|
+
}
|
43
|
+
exports.convertPythPrice = convertPythPrice;
|
44
|
+
const fiveBPS = new bn_js_1.default(500);
|
45
|
+
function getStableCoinPrice(price, confidence) {
|
46
|
+
if (price.sub(constants_1.QUOTE_PRECISION).abs().lt(bn_js_1.default.min(confidence, fiveBPS))) {
|
47
|
+
return constants_1.QUOTE_PRECISION;
|
48
|
+
}
|
49
|
+
return price;
|
50
|
+
}
|
51
|
+
//# sourceMappingURL=pythPull.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"pythPull.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/drift/perpHelpers/pythPull.ts"],"names":[],"mappings":";;;;;;AAAA,sCAAsC;AACtC,kDAAuB;AACvB,yDAIgC;AAChC,2CAAoE;AAEpE,iCAAmD;AAanD,MAAM,MAAM,GAAG,IAAI,6BAAc,CAC/B,gCAAyB,EACzB,gCAAyB,CAAC,SAAS,CAAC,QAAQ,EAAE,CAC/C,CAAC;AAEF,SAAgB,oCAAoC,CAClD,MAAc,EACd,QAAY,EACZ,UAAmB;;IAEnB,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,yBAAU,CAAC,OAAO,CAAC,CAAC;IAC5D,IAAI,CAAC,WAAW,IAAI,CAAC,IAAA,mCAAoB,EAAC,WAAW,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,MAAM,aAAa,GAAG,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1E,MAAM,SAAS,GAAG,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,IAAI,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