pangu-sdk 0.1.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/LICENSE +21 -0
- package/README.md +217 -0
- package/dist/accounts-BuD-oCcr.d.mts +206 -0
- package/dist/accounts-BuD-oCcr.d.ts +206 -0
- package/dist/dbc.d.mts +505 -0
- package/dist/dbc.d.ts +505 -0
- package/dist/dbc.js +3003 -0
- package/dist/dbc.js.map +1 -0
- package/dist/dbc.mjs +3027 -0
- package/dist/dbc.mjs.map +1 -0
- package/dist/feed-CY-pcUU2.d.mts +269 -0
- package/dist/feed-Zwu1irEx.d.ts +269 -0
- package/dist/index.d.mts +415 -0
- package/dist/index.d.ts +415 -0
- package/dist/index.js +2809 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2803 -0
- package/dist/index.mjs.map +1 -0
- package/dist/price.d.mts +86 -0
- package/dist/price.d.ts +86 -0
- package/dist/price.js +1554 -0
- package/dist/price.js.map +1 -0
- package/dist/price.mjs +1533 -0
- package/dist/price.mjs.map +1 -0
- package/package.json +104 -0
package/dist/price.mjs
ADDED
|
@@ -0,0 +1,1533 @@
|
|
|
1
|
+
// src/price.ts
|
|
2
|
+
import { PythSolanaReceiver } from "@pythnetwork/pyth-solana-receiver";
|
|
3
|
+
|
|
4
|
+
// src/addresses.ts
|
|
5
|
+
import { PublicKey as PublicKey3 } from "@solana/web3.js";
|
|
6
|
+
|
|
7
|
+
// src/constants.ts
|
|
8
|
+
import { PublicKey } from "@solana/web3.js";
|
|
9
|
+
import { TOKEN_2022_PROGRAM_ID } from "@solana/spl-token";
|
|
10
|
+
|
|
11
|
+
// src/idl/pangu.json
|
|
12
|
+
var pangu_default = {
|
|
13
|
+
address: "4Nd46mDiaTSkqXPAXKqT4jkahcz1TxVSdoirbBCAr5qG",
|
|
14
|
+
metadata: {
|
|
15
|
+
name: "pangu",
|
|
16
|
+
version: "0.1.0",
|
|
17
|
+
spec: "0.1.0",
|
|
18
|
+
description: "Rules for a fair first sale of a stock token on Meteora DBC"
|
|
19
|
+
},
|
|
20
|
+
docs: [
|
|
21
|
+
"Pangu holds the rules of a stock token's first sale on Meteora's Dynamic Bonding",
|
|
22
|
+
"Curve: a cap per wallet, an optional issuer-approved buyer list, an optional",
|
|
23
|
+
"ceiling against the real stock's live price, and no wallet-to-wallet movement",
|
|
24
|
+
"until the sale is over. DBC finds the price, Pangu decides who may receive",
|
|
25
|
+
"tokens and how many."
|
|
26
|
+
],
|
|
27
|
+
instructions: [
|
|
28
|
+
{
|
|
29
|
+
name: "approve_buyer",
|
|
30
|
+
discriminator: [
|
|
31
|
+
193,
|
|
32
|
+
6,
|
|
33
|
+
144,
|
|
34
|
+
245,
|
|
35
|
+
24,
|
|
36
|
+
184,
|
|
37
|
+
227,
|
|
38
|
+
19
|
|
39
|
+
],
|
|
40
|
+
accounts: [
|
|
41
|
+
{
|
|
42
|
+
name: "issuer",
|
|
43
|
+
writable: true,
|
|
44
|
+
signer: true,
|
|
45
|
+
relations: [
|
|
46
|
+
"rules"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "mint",
|
|
51
|
+
relations: [
|
|
52
|
+
"rules"
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "rules",
|
|
57
|
+
pda: {
|
|
58
|
+
seeds: [
|
|
59
|
+
{
|
|
60
|
+
kind: "const",
|
|
61
|
+
value: [
|
|
62
|
+
115,
|
|
63
|
+
97,
|
|
64
|
+
108,
|
|
65
|
+
101
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
kind: "account",
|
|
70
|
+
path: "mint"
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "record",
|
|
77
|
+
writable: true,
|
|
78
|
+
pda: {
|
|
79
|
+
seeds: [
|
|
80
|
+
{
|
|
81
|
+
kind: "const",
|
|
82
|
+
value: [
|
|
83
|
+
98,
|
|
84
|
+
117,
|
|
85
|
+
121,
|
|
86
|
+
101,
|
|
87
|
+
114
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
kind: "account",
|
|
92
|
+
path: "mint"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
kind: "arg",
|
|
96
|
+
path: "wallet"
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "system_program",
|
|
103
|
+
address: "11111111111111111111111111111111"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
args: [
|
|
107
|
+
{
|
|
108
|
+
name: "wallet",
|
|
109
|
+
type: "pubkey"
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "close_buyer_record",
|
|
115
|
+
discriminator: [
|
|
116
|
+
27,
|
|
117
|
+
105,
|
|
118
|
+
238,
|
|
119
|
+
144,
|
|
120
|
+
158,
|
|
121
|
+
212,
|
|
122
|
+
40,
|
|
123
|
+
114
|
|
124
|
+
],
|
|
125
|
+
accounts: [
|
|
126
|
+
{
|
|
127
|
+
name: "wallet",
|
|
128
|
+
writable: true,
|
|
129
|
+
signer: true,
|
|
130
|
+
relations: [
|
|
131
|
+
"record"
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "mint",
|
|
136
|
+
relations: [
|
|
137
|
+
"record"
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: "record",
|
|
142
|
+
writable: true,
|
|
143
|
+
pda: {
|
|
144
|
+
seeds: [
|
|
145
|
+
{
|
|
146
|
+
kind: "const",
|
|
147
|
+
value: [
|
|
148
|
+
98,
|
|
149
|
+
117,
|
|
150
|
+
121,
|
|
151
|
+
101,
|
|
152
|
+
114
|
|
153
|
+
]
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
kind: "account",
|
|
157
|
+
path: "mint"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
kind: "account",
|
|
161
|
+
path: "wallet"
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "rules",
|
|
168
|
+
docs: [
|
|
169
|
+
"offering period is over, and only when the bytes are a SaleRules in a",
|
|
170
|
+
"layout this build reads. Anything else, including rules written by an",
|
|
171
|
+
'older build, reads as "not over" and leaves the two older ways in exactly',
|
|
172
|
+
"as they were, so this account can never stop a close that worked before."
|
|
173
|
+
],
|
|
174
|
+
pda: {
|
|
175
|
+
seeds: [
|
|
176
|
+
{
|
|
177
|
+
kind: "const",
|
|
178
|
+
value: [
|
|
179
|
+
115,
|
|
180
|
+
97,
|
|
181
|
+
108,
|
|
182
|
+
101
|
|
183
|
+
]
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
kind: "account",
|
|
187
|
+
path: "mint"
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
],
|
|
193
|
+
args: []
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: "create_sale",
|
|
197
|
+
discriminator: [
|
|
198
|
+
137,
|
|
199
|
+
197,
|
|
200
|
+
124,
|
|
201
|
+
245,
|
|
202
|
+
254,
|
|
203
|
+
35,
|
|
204
|
+
17,
|
|
205
|
+
12
|
|
206
|
+
],
|
|
207
|
+
accounts: [
|
|
208
|
+
{
|
|
209
|
+
name: "issuer",
|
|
210
|
+
writable: true,
|
|
211
|
+
signer: true
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "pool",
|
|
215
|
+
docs: [
|
|
216
|
+
"owning program, the length and the discriminator before any field is used."
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: "mint",
|
|
221
|
+
docs: [
|
|
222
|
+
"owning program is checked there before the bytes are read."
|
|
223
|
+
]
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
name: "credential",
|
|
227
|
+
docs: [
|
|
228
|
+
"key named in `credential`, owned by the attestation service, and to carry",
|
|
229
|
+
"the credential discriminator. Refused outright in the other modes."
|
|
230
|
+
],
|
|
231
|
+
optional: true
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
name: "schema",
|
|
235
|
+
docs: [
|
|
236
|
+
"key named in `schema`, owned by the attestation service, to belong to",
|
|
237
|
+
"`credential`, and not to be paused. Refused outright in the other modes."
|
|
238
|
+
],
|
|
239
|
+
optional: true
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: "dbc_config",
|
|
243
|
+
docs: [
|
|
244
|
+
"template this pool names, owned by DBC and of the right kind. Its fee mode",
|
|
245
|
+
"and the supply its curve sells decide whether the sale may open at all, and",
|
|
246
|
+
"it names the paying token."
|
|
247
|
+
]
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: "quote_mint",
|
|
251
|
+
docs: [
|
|
252
|
+
"Required in every mode. Must be the paying token the template names. It is",
|
|
253
|
+
"stored in the rules, its freeze authority is checked, and on a banded sale",
|
|
254
|
+
"its decimals are stored so the hook can turn a curve price into dollars",
|
|
255
|
+
"without being handed a mint at buy time."
|
|
256
|
+
]
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: "rules",
|
|
260
|
+
writable: true,
|
|
261
|
+
pda: {
|
|
262
|
+
seeds: [
|
|
263
|
+
{
|
|
264
|
+
kind: "const",
|
|
265
|
+
value: [
|
|
266
|
+
115,
|
|
267
|
+
97,
|
|
268
|
+
108,
|
|
269
|
+
101
|
|
270
|
+
]
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
kind: "account",
|
|
274
|
+
path: "mint"
|
|
275
|
+
}
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
name: "extra_account_meta_list",
|
|
281
|
+
docs: [
|
|
282
|
+
"seeds the transfer-hook interface requires, and `init` makes it single-use."
|
|
283
|
+
],
|
|
284
|
+
writable: true,
|
|
285
|
+
pda: {
|
|
286
|
+
seeds: [
|
|
287
|
+
{
|
|
288
|
+
kind: "const",
|
|
289
|
+
value: [
|
|
290
|
+
101,
|
|
291
|
+
120,
|
|
292
|
+
116,
|
|
293
|
+
114,
|
|
294
|
+
97,
|
|
295
|
+
45,
|
|
296
|
+
97,
|
|
297
|
+
99,
|
|
298
|
+
99,
|
|
299
|
+
111,
|
|
300
|
+
117,
|
|
301
|
+
110,
|
|
302
|
+
116,
|
|
303
|
+
45,
|
|
304
|
+
109,
|
|
305
|
+
101,
|
|
306
|
+
116,
|
|
307
|
+
97,
|
|
308
|
+
115
|
|
309
|
+
]
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
kind: "account",
|
|
313
|
+
path: "mint"
|
|
314
|
+
}
|
|
315
|
+
]
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
name: "system_program",
|
|
320
|
+
address: "11111111111111111111111111111111"
|
|
321
|
+
}
|
|
322
|
+
],
|
|
323
|
+
args: [
|
|
324
|
+
{
|
|
325
|
+
name: "cap",
|
|
326
|
+
type: "u64"
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
name: "access_mode",
|
|
330
|
+
type: "u8"
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
name: "credential",
|
|
334
|
+
type: "pubkey"
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
name: "schema",
|
|
338
|
+
type: "pubkey"
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
name: "band",
|
|
342
|
+
type: {
|
|
343
|
+
defined: {
|
|
344
|
+
name: "PriceBand"
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
name: "ends_at",
|
|
350
|
+
type: "i64"
|
|
351
|
+
}
|
|
352
|
+
]
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
name: "execute",
|
|
356
|
+
discriminator: [
|
|
357
|
+
105,
|
|
358
|
+
37,
|
|
359
|
+
101,
|
|
360
|
+
197,
|
|
361
|
+
75,
|
|
362
|
+
251,
|
|
363
|
+
102,
|
|
364
|
+
26
|
|
365
|
+
],
|
|
366
|
+
accounts: [
|
|
367
|
+
{
|
|
368
|
+
name: "source_token",
|
|
369
|
+
docs: [
|
|
370
|
+
"owning program is checked. Nothing is read from it before that."
|
|
371
|
+
]
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
name: "mint",
|
|
375
|
+
docs: [
|
|
376
|
+
"the rules account is proven to be the one derived from it."
|
|
377
|
+
],
|
|
378
|
+
relations: [
|
|
379
|
+
"rules"
|
|
380
|
+
]
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
name: "destination_token",
|
|
384
|
+
docs: [
|
|
385
|
+
"owning program is checked."
|
|
386
|
+
]
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
name: "authority",
|
|
390
|
+
docs: [
|
|
391
|
+
"because a signature proves nothing about who is allowed to receive tokens."
|
|
392
|
+
]
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
name: "extra_account_meta_list",
|
|
396
|
+
docs: [
|
|
397
|
+
"Token-2022 resolves the extra accounts from it before the call. Pangu itself",
|
|
398
|
+
"reads nothing out of it, so it is carried, not trusted."
|
|
399
|
+
]
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
name: "rules",
|
|
403
|
+
writable: true,
|
|
404
|
+
pda: {
|
|
405
|
+
seeds: [
|
|
406
|
+
{
|
|
407
|
+
kind: "const",
|
|
408
|
+
value: [
|
|
409
|
+
115,
|
|
410
|
+
97,
|
|
411
|
+
108,
|
|
412
|
+
101
|
|
413
|
+
]
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
kind: "account",
|
|
417
|
+
path: "mint"
|
|
418
|
+
}
|
|
419
|
+
]
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
name: "destination_record",
|
|
424
|
+
docs: [
|
|
425
|
+
"program, discriminator, mint and wallet are all checked by hand below."
|
|
426
|
+
],
|
|
427
|
+
writable: true
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
name: "source_record",
|
|
431
|
+
docs: [
|
|
432
|
+
"program, discriminator, mint and wallet are all checked by hand below."
|
|
433
|
+
],
|
|
434
|
+
writable: true
|
|
435
|
+
}
|
|
436
|
+
],
|
|
437
|
+
args: [
|
|
438
|
+
{
|
|
439
|
+
name: "amount",
|
|
440
|
+
type: "u64"
|
|
441
|
+
}
|
|
442
|
+
]
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
name: "open_buyer_record",
|
|
446
|
+
discriminator: [
|
|
447
|
+
216,
|
|
448
|
+
212,
|
|
449
|
+
35,
|
|
450
|
+
190,
|
|
451
|
+
138,
|
|
452
|
+
99,
|
|
453
|
+
66,
|
|
454
|
+
197
|
|
455
|
+
],
|
|
456
|
+
accounts: [
|
|
457
|
+
{
|
|
458
|
+
name: "wallet",
|
|
459
|
+
writable: true,
|
|
460
|
+
signer: true
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
name: "mint"
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
name: "rules",
|
|
467
|
+
pda: {
|
|
468
|
+
seeds: [
|
|
469
|
+
{
|
|
470
|
+
kind: "const",
|
|
471
|
+
value: [
|
|
472
|
+
115,
|
|
473
|
+
97,
|
|
474
|
+
108,
|
|
475
|
+
101
|
|
476
|
+
]
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
kind: "account",
|
|
480
|
+
path: "mint"
|
|
481
|
+
}
|
|
482
|
+
]
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
name: "record",
|
|
487
|
+
writable: true,
|
|
488
|
+
pda: {
|
|
489
|
+
seeds: [
|
|
490
|
+
{
|
|
491
|
+
kind: "const",
|
|
492
|
+
value: [
|
|
493
|
+
98,
|
|
494
|
+
117,
|
|
495
|
+
121,
|
|
496
|
+
101,
|
|
497
|
+
114
|
|
498
|
+
]
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
kind: "account",
|
|
502
|
+
path: "mint"
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
kind: "account",
|
|
506
|
+
path: "wallet"
|
|
507
|
+
}
|
|
508
|
+
]
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
name: "system_program",
|
|
513
|
+
address: "11111111111111111111111111111111"
|
|
514
|
+
}
|
|
515
|
+
],
|
|
516
|
+
args: []
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
name: "revoke_buyer",
|
|
520
|
+
discriminator: [
|
|
521
|
+
78,
|
|
522
|
+
97,
|
|
523
|
+
108,
|
|
524
|
+
126,
|
|
525
|
+
172,
|
|
526
|
+
157,
|
|
527
|
+
228,
|
|
528
|
+
134
|
|
529
|
+
],
|
|
530
|
+
accounts: [
|
|
531
|
+
{
|
|
532
|
+
name: "issuer",
|
|
533
|
+
signer: true,
|
|
534
|
+
relations: [
|
|
535
|
+
"rules"
|
|
536
|
+
]
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
name: "mint",
|
|
540
|
+
relations: [
|
|
541
|
+
"rules",
|
|
542
|
+
"record"
|
|
543
|
+
]
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
name: "rules",
|
|
547
|
+
pda: {
|
|
548
|
+
seeds: [
|
|
549
|
+
{
|
|
550
|
+
kind: "const",
|
|
551
|
+
value: [
|
|
552
|
+
115,
|
|
553
|
+
97,
|
|
554
|
+
108,
|
|
555
|
+
101
|
|
556
|
+
]
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
kind: "account",
|
|
560
|
+
path: "mint"
|
|
561
|
+
}
|
|
562
|
+
]
|
|
563
|
+
}
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
name: "record",
|
|
567
|
+
writable: true,
|
|
568
|
+
pda: {
|
|
569
|
+
seeds: [
|
|
570
|
+
{
|
|
571
|
+
kind: "const",
|
|
572
|
+
value: [
|
|
573
|
+
98,
|
|
574
|
+
117,
|
|
575
|
+
121,
|
|
576
|
+
101,
|
|
577
|
+
114
|
|
578
|
+
]
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
kind: "account",
|
|
582
|
+
path: "mint"
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
kind: "arg",
|
|
586
|
+
path: "wallet"
|
|
587
|
+
}
|
|
588
|
+
]
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
],
|
|
592
|
+
args: [
|
|
593
|
+
{
|
|
594
|
+
name: "wallet",
|
|
595
|
+
type: "pubkey"
|
|
596
|
+
}
|
|
597
|
+
]
|
|
598
|
+
}
|
|
599
|
+
],
|
|
600
|
+
accounts: [
|
|
601
|
+
{
|
|
602
|
+
name: "BuyerRecord",
|
|
603
|
+
discriminator: [
|
|
604
|
+
107,
|
|
605
|
+
122,
|
|
606
|
+
54,
|
|
607
|
+
31,
|
|
608
|
+
4,
|
|
609
|
+
54,
|
|
610
|
+
209,
|
|
611
|
+
38
|
|
612
|
+
]
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
name: "SaleRules",
|
|
616
|
+
discriminator: [
|
|
617
|
+
39,
|
|
618
|
+
103,
|
|
619
|
+
95,
|
|
620
|
+
70,
|
|
621
|
+
15,
|
|
622
|
+
23,
|
|
623
|
+
201,
|
|
624
|
+
128
|
|
625
|
+
]
|
|
626
|
+
}
|
|
627
|
+
],
|
|
628
|
+
events: [
|
|
629
|
+
{
|
|
630
|
+
name: "Bought",
|
|
631
|
+
discriminator: [
|
|
632
|
+
193,
|
|
633
|
+
56,
|
|
634
|
+
215,
|
|
635
|
+
24,
|
|
636
|
+
156,
|
|
637
|
+
76,
|
|
638
|
+
42,
|
|
639
|
+
104
|
|
640
|
+
]
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
name: "BuyerApproved",
|
|
644
|
+
discriminator: [
|
|
645
|
+
146,
|
|
646
|
+
41,
|
|
647
|
+
51,
|
|
648
|
+
7,
|
|
649
|
+
192,
|
|
650
|
+
96,
|
|
651
|
+
249,
|
|
652
|
+
196
|
|
653
|
+
]
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
name: "BuyerRecordClosed",
|
|
657
|
+
discriminator: [
|
|
658
|
+
175,
|
|
659
|
+
245,
|
|
660
|
+
14,
|
|
661
|
+
122,
|
|
662
|
+
129,
|
|
663
|
+
113,
|
|
664
|
+
23,
|
|
665
|
+
155
|
|
666
|
+
]
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
name: "BuyerRecordOpened",
|
|
670
|
+
discriminator: [
|
|
671
|
+
249,
|
|
672
|
+
239,
|
|
673
|
+
77,
|
|
674
|
+
35,
|
|
675
|
+
176,
|
|
676
|
+
81,
|
|
677
|
+
45,
|
|
678
|
+
85
|
|
679
|
+
]
|
|
680
|
+
},
|
|
681
|
+
{
|
|
682
|
+
name: "BuyerRevoked",
|
|
683
|
+
discriminator: [
|
|
684
|
+
116,
|
|
685
|
+
129,
|
|
686
|
+
248,
|
|
687
|
+
92,
|
|
688
|
+
255,
|
|
689
|
+
222,
|
|
690
|
+
13,
|
|
691
|
+
59
|
|
692
|
+
]
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
name: "SaleCreated",
|
|
696
|
+
discriminator: [
|
|
697
|
+
164,
|
|
698
|
+
187,
|
|
699
|
+
32,
|
|
700
|
+
35,
|
|
701
|
+
143,
|
|
702
|
+
167,
|
|
703
|
+
235,
|
|
704
|
+
132
|
|
705
|
+
]
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
name: "SoldBack",
|
|
709
|
+
discriminator: [
|
|
710
|
+
153,
|
|
711
|
+
215,
|
|
712
|
+
200,
|
|
713
|
+
12,
|
|
714
|
+
194,
|
|
715
|
+
138,
|
|
716
|
+
190,
|
|
717
|
+
253
|
|
718
|
+
]
|
|
719
|
+
}
|
|
720
|
+
],
|
|
721
|
+
errors: [
|
|
722
|
+
{
|
|
723
|
+
code: 6e3,
|
|
724
|
+
name: "NotTransferring",
|
|
725
|
+
msg: "Token-2022 is not mid-transfer on both token accounts"
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
code: 6001,
|
|
729
|
+
name: "ReceivingAccountOwnerCanChange",
|
|
730
|
+
msg: "the receiving token account's owner can still be changed"
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
code: 6002,
|
|
734
|
+
name: "WrongMint",
|
|
735
|
+
msg: "the account does not belong to this sale's mint"
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
code: 6003,
|
|
739
|
+
name: "WrongBuyerRecord",
|
|
740
|
+
msg: "the buyer record is not the one for this wallet"
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
code: 6004,
|
|
744
|
+
name: "BuyerRecordMissing",
|
|
745
|
+
msg: "this wallet has no buyer record yet"
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
code: 6005,
|
|
749
|
+
name: "NotApproved",
|
|
750
|
+
msg: "this wallet is not on the issuer's approved list"
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
code: 6006,
|
|
754
|
+
name: "CredentialInvalid",
|
|
755
|
+
msg: "the attestation is not valid for this wallet, credential and schema"
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
code: 6007,
|
|
759
|
+
name: "CredentialExpired",
|
|
760
|
+
msg: "the attestation has expired"
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
code: 6008,
|
|
764
|
+
name: "CredentialSignerNotAuthorized",
|
|
765
|
+
msg: "the key that signed the attestation is no longer an authorized signer"
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
code: 6009,
|
|
769
|
+
name: "OverCap",
|
|
770
|
+
msg: "this buy would take the wallet over the per-wallet cap"
|
|
771
|
+
},
|
|
772
|
+
{
|
|
773
|
+
code: 6010,
|
|
774
|
+
name: "WalletToWalletDuringSale",
|
|
775
|
+
msg: "the token cannot move between wallets while the sale is running"
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
code: 6011,
|
|
779
|
+
name: "PriceStale",
|
|
780
|
+
msg: "the reference price is too old, missing or not a positive number"
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
code: 6012,
|
|
784
|
+
name: "PriceOutsideBand",
|
|
785
|
+
msg: "the price is outside the allowed band"
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
code: 6013,
|
|
789
|
+
name: "WrongPriceAccount",
|
|
790
|
+
msg: "the price account is not the one named in the rules, or does not hold a usable price"
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
code: 6014,
|
|
794
|
+
name: "PriceNotFullyVerified",
|
|
795
|
+
msg: "the price update has not been signed by two thirds of the guardians"
|
|
796
|
+
},
|
|
797
|
+
{
|
|
798
|
+
code: 6015,
|
|
799
|
+
name: "PriceTooUncertain",
|
|
800
|
+
msg: "the price carries a wider confidence interval than this sale accepts"
|
|
801
|
+
},
|
|
802
|
+
{
|
|
803
|
+
code: 6016,
|
|
804
|
+
name: "NotPoolCreator",
|
|
805
|
+
msg: "the signer did not create this pool"
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
code: 6017,
|
|
809
|
+
name: "NotAHookPool",
|
|
810
|
+
msg: "the account is not a DBC transfer-hook pool"
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
code: 6018,
|
|
814
|
+
name: "HookProgramMismatch",
|
|
815
|
+
msg: "the mint's transfer hook does not name this program"
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
code: 6019,
|
|
819
|
+
name: "MintAuthorityStillSet",
|
|
820
|
+
msg: "someone can still mint this token, which would go straight past the cap"
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
code: 6020,
|
|
824
|
+
name: "WrongLaunchTemplate",
|
|
825
|
+
msg: "the launch template is not the one this pool was opened on"
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
code: 6021,
|
|
829
|
+
name: "FeesNotInQuoteToken",
|
|
830
|
+
msg: "the launch template collects fees in the sale token instead of the paying token"
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
code: 6022,
|
|
834
|
+
name: "ZeroCap",
|
|
835
|
+
msg: "the cap must be above zero"
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
code: 6023,
|
|
839
|
+
name: "InvalidAccessMode",
|
|
840
|
+
msg: "that access mode is not available"
|
|
841
|
+
},
|
|
842
|
+
{
|
|
843
|
+
code: 6024,
|
|
844
|
+
name: "InvalidBand",
|
|
845
|
+
msg: "the price band settings are incomplete, out of range, or set on a sale that has no band"
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
code: 6025,
|
|
849
|
+
name: "SaleStillRunning",
|
|
850
|
+
msg: "the sale is still running, the mint still names this program as its hook"
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
code: 6026,
|
|
854
|
+
name: "NotIssuer",
|
|
855
|
+
msg: "only the issuer can do this"
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
code: 6027,
|
|
859
|
+
name: "MathOverflow",
|
|
860
|
+
msg: "the counter would overflow"
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
code: 6028,
|
|
864
|
+
name: "WrongLayoutVersion",
|
|
865
|
+
msg: "these sale rules were written by another layout of the program"
|
|
866
|
+
},
|
|
867
|
+
{
|
|
868
|
+
code: 6029,
|
|
869
|
+
name: "BandNeedsDollarQuote",
|
|
870
|
+
msg: "a price band needs buyers to pay in a dollar token on this network's list"
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
code: 6030,
|
|
874
|
+
name: "IssuerControlsPayingToken",
|
|
875
|
+
msg: "the issuer can freeze the paying token, which would let them stop sellers being paid"
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
code: 6031,
|
|
879
|
+
name: "CapCoversWholeSale",
|
|
880
|
+
msg: "the cap is at or above everything the curve sells, so it limits nobody"
|
|
881
|
+
},
|
|
882
|
+
{
|
|
883
|
+
code: 6032,
|
|
884
|
+
name: "EndInThePast",
|
|
885
|
+
msg: "the offering period would end at a time that has already passed"
|
|
886
|
+
}
|
|
887
|
+
],
|
|
888
|
+
types: [
|
|
889
|
+
{
|
|
890
|
+
name: "Bought",
|
|
891
|
+
type: {
|
|
892
|
+
kind: "struct",
|
|
893
|
+
fields: [
|
|
894
|
+
{
|
|
895
|
+
name: "mint",
|
|
896
|
+
type: "pubkey"
|
|
897
|
+
},
|
|
898
|
+
{
|
|
899
|
+
name: "wallet",
|
|
900
|
+
type: "pubkey"
|
|
901
|
+
},
|
|
902
|
+
{
|
|
903
|
+
name: "amount",
|
|
904
|
+
type: "u64"
|
|
905
|
+
},
|
|
906
|
+
{
|
|
907
|
+
name: "net_bought",
|
|
908
|
+
type: "u64"
|
|
909
|
+
}
|
|
910
|
+
]
|
|
911
|
+
}
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
name: "BuyerApproved",
|
|
915
|
+
type: {
|
|
916
|
+
kind: "struct",
|
|
917
|
+
fields: [
|
|
918
|
+
{
|
|
919
|
+
name: "mint",
|
|
920
|
+
type: "pubkey"
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
name: "wallet",
|
|
924
|
+
type: "pubkey"
|
|
925
|
+
}
|
|
926
|
+
]
|
|
927
|
+
}
|
|
928
|
+
},
|
|
929
|
+
{
|
|
930
|
+
name: "BuyerRecord",
|
|
931
|
+
docs: [
|
|
932
|
+
"One wallet's standing in one sale. Keyed on the wallet that owns the token",
|
|
933
|
+
"account, never on the token account, so extra token accounts share one cap."
|
|
934
|
+
],
|
|
935
|
+
type: {
|
|
936
|
+
kind: "struct",
|
|
937
|
+
fields: [
|
|
938
|
+
{
|
|
939
|
+
name: "mint",
|
|
940
|
+
type: "pubkey"
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
name: "wallet",
|
|
944
|
+
type: "pubkey"
|
|
945
|
+
},
|
|
946
|
+
{
|
|
947
|
+
name: "approved",
|
|
948
|
+
type: "bool"
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
name: "net_bought",
|
|
952
|
+
docs: [
|
|
953
|
+
"Tokens received from the pool minus tokens sold back to it."
|
|
954
|
+
],
|
|
955
|
+
type: "u64"
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
name: "bump",
|
|
959
|
+
type: "u8"
|
|
960
|
+
}
|
|
961
|
+
]
|
|
962
|
+
}
|
|
963
|
+
},
|
|
964
|
+
{
|
|
965
|
+
name: "BuyerRecordClosed",
|
|
966
|
+
type: {
|
|
967
|
+
kind: "struct",
|
|
968
|
+
fields: [
|
|
969
|
+
{
|
|
970
|
+
name: "mint",
|
|
971
|
+
type: "pubkey"
|
|
972
|
+
},
|
|
973
|
+
{
|
|
974
|
+
name: "wallet",
|
|
975
|
+
type: "pubkey"
|
|
976
|
+
}
|
|
977
|
+
]
|
|
978
|
+
}
|
|
979
|
+
},
|
|
980
|
+
{
|
|
981
|
+
name: "BuyerRecordOpened",
|
|
982
|
+
type: {
|
|
983
|
+
kind: "struct",
|
|
984
|
+
fields: [
|
|
985
|
+
{
|
|
986
|
+
name: "mint",
|
|
987
|
+
type: "pubkey"
|
|
988
|
+
},
|
|
989
|
+
{
|
|
990
|
+
name: "wallet",
|
|
991
|
+
type: "pubkey"
|
|
992
|
+
}
|
|
993
|
+
]
|
|
994
|
+
}
|
|
995
|
+
},
|
|
996
|
+
{
|
|
997
|
+
name: "BuyerRevoked",
|
|
998
|
+
type: {
|
|
999
|
+
kind: "struct",
|
|
1000
|
+
fields: [
|
|
1001
|
+
{
|
|
1002
|
+
name: "mint",
|
|
1003
|
+
type: "pubkey"
|
|
1004
|
+
},
|
|
1005
|
+
{
|
|
1006
|
+
name: "wallet",
|
|
1007
|
+
type: "pubkey"
|
|
1008
|
+
}
|
|
1009
|
+
]
|
|
1010
|
+
}
|
|
1011
|
+
},
|
|
1012
|
+
{
|
|
1013
|
+
name: "PriceBand",
|
|
1014
|
+
docs: [
|
|
1015
|
+
"The price band settings, passed to `create_sale` as one value.",
|
|
1016
|
+
"",
|
|
1017
|
+
"They travel together because they are only meaningful together: the price",
|
|
1018
|
+
"account's address is derived from the shard id and the feed id, so changing",
|
|
1019
|
+
"either one changes which account the hook must read."
|
|
1020
|
+
],
|
|
1021
|
+
type: {
|
|
1022
|
+
kind: "struct",
|
|
1023
|
+
fields: [
|
|
1024
|
+
{
|
|
1025
|
+
name: "band_bps",
|
|
1026
|
+
docs: [
|
|
1027
|
+
"How far above the live stock price a buy may leave the curve price, in",
|
|
1028
|
+
"basis points. Zero switches the whole band off."
|
|
1029
|
+
],
|
|
1030
|
+
type: "u16"
|
|
1031
|
+
},
|
|
1032
|
+
{
|
|
1033
|
+
name: "price_account",
|
|
1034
|
+
docs: [
|
|
1035
|
+
"The Pyth price feed account. Must be the address the shard id and the feed",
|
|
1036
|
+
"id below produce under Pyth's price feed program."
|
|
1037
|
+
],
|
|
1038
|
+
type: "pubkey"
|
|
1039
|
+
},
|
|
1040
|
+
{
|
|
1041
|
+
name: "price_feed_id",
|
|
1042
|
+
docs: [
|
|
1043
|
+
"The Pyth feed carrying the stock price in dollars."
|
|
1044
|
+
],
|
|
1045
|
+
type: {
|
|
1046
|
+
array: [
|
|
1047
|
+
"u8",
|
|
1048
|
+
32
|
|
1049
|
+
]
|
|
1050
|
+
}
|
|
1051
|
+
},
|
|
1052
|
+
{
|
|
1053
|
+
name: "price_shard",
|
|
1054
|
+
docs: [
|
|
1055
|
+
"Which of Pyth's shards this sale reads. A shard is just a second copy of",
|
|
1056
|
+
"the same feed at a second address, so a sale can depend on a price its own",
|
|
1057
|
+
"refresher keeps fresh rather than on Pyth's sponsored one."
|
|
1058
|
+
],
|
|
1059
|
+
type: "u16"
|
|
1060
|
+
},
|
|
1061
|
+
{
|
|
1062
|
+
name: "max_price_age_secs",
|
|
1063
|
+
docs: [
|
|
1064
|
+
"How old the published price may be on a buy, in seconds."
|
|
1065
|
+
],
|
|
1066
|
+
type: "u32"
|
|
1067
|
+
},
|
|
1068
|
+
{
|
|
1069
|
+
name: "max_conf_bps",
|
|
1070
|
+
docs: [
|
|
1071
|
+
"The widest confidence interval this sale will buy against, in basis points",
|
|
1072
|
+
"of the price itself."
|
|
1073
|
+
],
|
|
1074
|
+
type: "u16"
|
|
1075
|
+
}
|
|
1076
|
+
]
|
|
1077
|
+
}
|
|
1078
|
+
},
|
|
1079
|
+
{
|
|
1080
|
+
name: "SaleCreated",
|
|
1081
|
+
type: {
|
|
1082
|
+
kind: "struct",
|
|
1083
|
+
fields: [
|
|
1084
|
+
{
|
|
1085
|
+
name: "mint",
|
|
1086
|
+
type: "pubkey"
|
|
1087
|
+
},
|
|
1088
|
+
{
|
|
1089
|
+
name: "pool",
|
|
1090
|
+
type: "pubkey"
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
name: "issuer",
|
|
1094
|
+
type: "pubkey"
|
|
1095
|
+
},
|
|
1096
|
+
{
|
|
1097
|
+
name: "base_vault",
|
|
1098
|
+
type: "pubkey"
|
|
1099
|
+
},
|
|
1100
|
+
{
|
|
1101
|
+
name: "cap",
|
|
1102
|
+
type: "u64"
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
name: "access_mode",
|
|
1106
|
+
type: "u8"
|
|
1107
|
+
},
|
|
1108
|
+
{
|
|
1109
|
+
name: "band_bps",
|
|
1110
|
+
type: "u16"
|
|
1111
|
+
},
|
|
1112
|
+
{
|
|
1113
|
+
name: "quote_mint",
|
|
1114
|
+
type: "pubkey"
|
|
1115
|
+
},
|
|
1116
|
+
{
|
|
1117
|
+
name: "ends_at",
|
|
1118
|
+
docs: [
|
|
1119
|
+
"Unix seconds when the offering period ends and every rule lifts. Zero",
|
|
1120
|
+
"means the rules hold until graduation."
|
|
1121
|
+
],
|
|
1122
|
+
type: "i64"
|
|
1123
|
+
}
|
|
1124
|
+
]
|
|
1125
|
+
}
|
|
1126
|
+
},
|
|
1127
|
+
{
|
|
1128
|
+
name: "SaleRules",
|
|
1129
|
+
docs: [
|
|
1130
|
+
"The rules of one sale. Written once at creation and never changed: there is no",
|
|
1131
|
+
"update instruction, which is what makes the cap a promise instead of a setting."
|
|
1132
|
+
],
|
|
1133
|
+
type: {
|
|
1134
|
+
kind: "struct",
|
|
1135
|
+
fields: [
|
|
1136
|
+
{
|
|
1137
|
+
name: "mint",
|
|
1138
|
+
type: "pubkey"
|
|
1139
|
+
},
|
|
1140
|
+
{
|
|
1141
|
+
name: "pool",
|
|
1142
|
+
type: "pubkey"
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
name: "base_vault",
|
|
1146
|
+
docs: [
|
|
1147
|
+
"The pool's base token vault, read out of the pool account at creation. The",
|
|
1148
|
+
"hook tells a buy from a sell by comparing against this one address."
|
|
1149
|
+
],
|
|
1150
|
+
type: "pubkey"
|
|
1151
|
+
},
|
|
1152
|
+
{
|
|
1153
|
+
name: "issuer",
|
|
1154
|
+
docs: [
|
|
1155
|
+
"The pool creator. The only key that can approve or revoke buyers."
|
|
1156
|
+
],
|
|
1157
|
+
type: "pubkey"
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
name: "cap",
|
|
1161
|
+
docs: [
|
|
1162
|
+
"Most tokens one wallet may hold net of sells, in raw units."
|
|
1163
|
+
],
|
|
1164
|
+
type: "u64"
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
name: "access_mode",
|
|
1168
|
+
type: "u8"
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
name: "credential",
|
|
1172
|
+
docs: [
|
|
1173
|
+
"Mode 2 only: the attestation credential whose approvals count. Zero",
|
|
1174
|
+
"otherwise. Sits at byte 145 of the account, and the hook's extra accounts",
|
|
1175
|
+
"are derived by reading it there, so it can never move."
|
|
1176
|
+
],
|
|
1177
|
+
type: "pubkey"
|
|
1178
|
+
},
|
|
1179
|
+
{
|
|
1180
|
+
name: "schema",
|
|
1181
|
+
docs: [
|
|
1182
|
+
"Mode 2 only: the attestation schema that counts. Zero otherwise. Sits at",
|
|
1183
|
+
"byte 177 of the account, read the same way."
|
|
1184
|
+
],
|
|
1185
|
+
type: "pubkey"
|
|
1186
|
+
},
|
|
1187
|
+
{
|
|
1188
|
+
name: "price_account",
|
|
1189
|
+
docs: [
|
|
1190
|
+
"Band only: the Pyth price feed account, at byte 209. Zero otherwise."
|
|
1191
|
+
],
|
|
1192
|
+
type: "pubkey"
|
|
1193
|
+
},
|
|
1194
|
+
{
|
|
1195
|
+
name: "price_feed_id",
|
|
1196
|
+
docs: [
|
|
1197
|
+
"Band only: the Pyth feed the price account must carry, at byte 241."
|
|
1198
|
+
],
|
|
1199
|
+
type: {
|
|
1200
|
+
array: [
|
|
1201
|
+
"u8",
|
|
1202
|
+
32
|
|
1203
|
+
]
|
|
1204
|
+
}
|
|
1205
|
+
},
|
|
1206
|
+
{
|
|
1207
|
+
name: "price_shard",
|
|
1208
|
+
docs: [
|
|
1209
|
+
"Band only: the Pyth shard the price account was derived under."
|
|
1210
|
+
],
|
|
1211
|
+
type: "u16"
|
|
1212
|
+
},
|
|
1213
|
+
{
|
|
1214
|
+
name: "band_bps",
|
|
1215
|
+
docs: [
|
|
1216
|
+
"Zero means no band."
|
|
1217
|
+
],
|
|
1218
|
+
type: "u16"
|
|
1219
|
+
},
|
|
1220
|
+
{
|
|
1221
|
+
name: "max_price_age_secs",
|
|
1222
|
+
type: "u32"
|
|
1223
|
+
},
|
|
1224
|
+
{
|
|
1225
|
+
name: "max_conf_bps",
|
|
1226
|
+
type: "u16"
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
name: "base_decimals",
|
|
1230
|
+
docs: [
|
|
1231
|
+
"Read off the two mints at creation, so the curve price can be turned into",
|
|
1232
|
+
"dollars per whole token without trusting anything passed at buy time."
|
|
1233
|
+
],
|
|
1234
|
+
type: "u8"
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
name: "quote_decimals",
|
|
1238
|
+
type: "u8"
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
name: "buyers",
|
|
1242
|
+
docs: [
|
|
1243
|
+
"Wallets whose record is above zero right now."
|
|
1244
|
+
],
|
|
1245
|
+
type: "u32"
|
|
1246
|
+
},
|
|
1247
|
+
{
|
|
1248
|
+
name: "total_net_bought",
|
|
1249
|
+
docs: [
|
|
1250
|
+
"Sum of every record, so the app can show the largest holder's share."
|
|
1251
|
+
],
|
|
1252
|
+
type: "u64"
|
|
1253
|
+
},
|
|
1254
|
+
{
|
|
1255
|
+
name: "bump",
|
|
1256
|
+
type: "u8"
|
|
1257
|
+
},
|
|
1258
|
+
{
|
|
1259
|
+
name: "layout_version",
|
|
1260
|
+
docs: [
|
|
1261
|
+
"Which layout wrote this account, at byte 298. It takes the first of what",
|
|
1262
|
+
"used to be the spare bytes, so the account is the same size and every",
|
|
1263
|
+
"field in front of it sits exactly where it always did. A sale opened",
|
|
1264
|
+
"before this byte existed reads as version 0, which is how a reader tells",
|
|
1265
|
+
"the two apart instead of reading one layout's bytes as the other's."
|
|
1266
|
+
],
|
|
1267
|
+
type: "u8"
|
|
1268
|
+
},
|
|
1269
|
+
{
|
|
1270
|
+
name: "quote_mint",
|
|
1271
|
+
docs: [
|
|
1272
|
+
"The token buyers pay in, read from the launch template at creation, at",
|
|
1273
|
+
"byte 299. Layout 2 onwards; a version 1 account holds zeros here."
|
|
1274
|
+
],
|
|
1275
|
+
type: "pubkey"
|
|
1276
|
+
},
|
|
1277
|
+
{
|
|
1278
|
+
name: "ends_at",
|
|
1279
|
+
docs: [
|
|
1280
|
+
"Unix seconds at which the offering period ends, at byte 331. From then on",
|
|
1281
|
+
"every rule lifts and the token moves freely, so a curve that never fills",
|
|
1282
|
+
"cannot hold the token in place for good. Zero means no end: the rules hold",
|
|
1283
|
+
"until graduation. Fixed at creation like every other rule."
|
|
1284
|
+
],
|
|
1285
|
+
type: "i64"
|
|
1286
|
+
},
|
|
1287
|
+
{
|
|
1288
|
+
name: "reserved",
|
|
1289
|
+
type: {
|
|
1290
|
+
array: [
|
|
1291
|
+
"u8",
|
|
1292
|
+
23
|
|
1293
|
+
]
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
]
|
|
1297
|
+
}
|
|
1298
|
+
},
|
|
1299
|
+
{
|
|
1300
|
+
name: "SoldBack",
|
|
1301
|
+
type: {
|
|
1302
|
+
kind: "struct",
|
|
1303
|
+
fields: [
|
|
1304
|
+
{
|
|
1305
|
+
name: "mint",
|
|
1306
|
+
type: "pubkey"
|
|
1307
|
+
},
|
|
1308
|
+
{
|
|
1309
|
+
name: "wallet",
|
|
1310
|
+
type: "pubkey"
|
|
1311
|
+
},
|
|
1312
|
+
{
|
|
1313
|
+
name: "amount",
|
|
1314
|
+
type: "u64"
|
|
1315
|
+
},
|
|
1316
|
+
{
|
|
1317
|
+
name: "net_bought",
|
|
1318
|
+
type: "u64"
|
|
1319
|
+
}
|
|
1320
|
+
]
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
]
|
|
1324
|
+
};
|
|
1325
|
+
|
|
1326
|
+
// src/constants.ts
|
|
1327
|
+
var PANGU_IDL = pangu_default;
|
|
1328
|
+
var PANGU_PROGRAM_ID = new PublicKey(PANGU_IDL.address);
|
|
1329
|
+
var DBC_PROGRAM_ID = new PublicKey(
|
|
1330
|
+
"dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN"
|
|
1331
|
+
);
|
|
1332
|
+
var SAS_PROGRAM_ID = new PublicKey(
|
|
1333
|
+
"22zoJMtdu4tQc2PzL74ZUT7FrwgB1Udec8DdW4yw4BdG"
|
|
1334
|
+
);
|
|
1335
|
+
var PYTH_PRICE_FEED_PROGRAM_ID = new PublicKey(
|
|
1336
|
+
"pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT"
|
|
1337
|
+
);
|
|
1338
|
+
var PYTH_RECEIVER_PROGRAM_ID = new PublicKey(
|
|
1339
|
+
"rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ"
|
|
1340
|
+
);
|
|
1341
|
+
var PANGU_SHARD_ID = 7700;
|
|
1342
|
+
var LIMITS = {
|
|
1343
|
+
/** price.rs MAX_BAND_BPS: half again over the live stock price. */
|
|
1344
|
+
maxBandBps: 5e3,
|
|
1345
|
+
minBandBps: 1,
|
|
1346
|
+
/** price.rs MAX_PRICE_AGE_SECS, and create_sale.rs check_band takes 1..=3600. */
|
|
1347
|
+
maxPriceAgeSecs: 3600,
|
|
1348
|
+
minPriceAgeSecs: 1,
|
|
1349
|
+
/** price.rs MAX_CONF_BPS: ten percent, and check_band takes 1..=1000. */
|
|
1350
|
+
maxConfBps: 1e3,
|
|
1351
|
+
minConfBps: 1,
|
|
1352
|
+
/** price.rs MAX_DECIMALS. */
|
|
1353
|
+
maxDecimals: 18,
|
|
1354
|
+
/** Every Pyth feed id is 32 bytes. */
|
|
1355
|
+
feedIdLength: 32,
|
|
1356
|
+
/** A Pyth shard id is a u16, which is what the address seed holds. */
|
|
1357
|
+
maxShard: 65535,
|
|
1358
|
+
/** u64 raw token units, the widest cap the program can hold. */
|
|
1359
|
+
maxCap: (1n << 64n) - 1n
|
|
1360
|
+
};
|
|
1361
|
+
|
|
1362
|
+
// src/inputs.ts
|
|
1363
|
+
import { PublicKey as PublicKey2 } from "@solana/web3.js";
|
|
1364
|
+
var PanguInputError = class extends Error {
|
|
1365
|
+
constructor(message) {
|
|
1366
|
+
super(message);
|
|
1367
|
+
this.name = "PanguInputError";
|
|
1368
|
+
}
|
|
1369
|
+
};
|
|
1370
|
+
function requirePublicKey(value, field) {
|
|
1371
|
+
if (!(value instanceof PublicKey2)) {
|
|
1372
|
+
throw new PanguInputError(`${field} must be a PublicKey`);
|
|
1373
|
+
}
|
|
1374
|
+
return value;
|
|
1375
|
+
}
|
|
1376
|
+
function requireRealPublicKey(value, field) {
|
|
1377
|
+
const key = requirePublicKey(value, field);
|
|
1378
|
+
if (key.equals(PublicKey2.default)) {
|
|
1379
|
+
throw new PanguInputError(`${field} must not be the all zero address`);
|
|
1380
|
+
}
|
|
1381
|
+
return key;
|
|
1382
|
+
}
|
|
1383
|
+
function requireWholeNumber(value, field, low, high) {
|
|
1384
|
+
if (typeof value !== "number" || !Number.isInteger(value)) {
|
|
1385
|
+
throw new PanguInputError(`${field} must be a whole number`);
|
|
1386
|
+
}
|
|
1387
|
+
if (value < low || value > high) {
|
|
1388
|
+
throw new PanguInputError(`${field} must be between ${low} and ${high}, got ${value}`);
|
|
1389
|
+
}
|
|
1390
|
+
return value;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
// src/addresses.ts
|
|
1394
|
+
var HEX = /^[0-9a-fA-F]+$/;
|
|
1395
|
+
function feedIdBytes(id) {
|
|
1396
|
+
let bytes;
|
|
1397
|
+
if (typeof id === "string") {
|
|
1398
|
+
const text = id.startsWith("0x") || id.startsWith("0X") ? id.slice(2) : id;
|
|
1399
|
+
if (text.length !== LIMITS.feedIdLength * 2 || !HEX.test(text)) {
|
|
1400
|
+
throw new PanguInputError(
|
|
1401
|
+
`a feed id must be ${LIMITS.feedIdLength * 2} hex characters, got "${id}"`
|
|
1402
|
+
);
|
|
1403
|
+
}
|
|
1404
|
+
bytes = new Uint8Array(LIMITS.feedIdLength);
|
|
1405
|
+
for (let i = 0; i < LIMITS.feedIdLength; i += 1) {
|
|
1406
|
+
bytes[i] = Number.parseInt(text.slice(i * 2, i * 2 + 2), 16);
|
|
1407
|
+
}
|
|
1408
|
+
return bytes;
|
|
1409
|
+
}
|
|
1410
|
+
if (Array.isArray(id)) {
|
|
1411
|
+
if (id.some((byte) => !Number.isInteger(byte) || byte < 0 || byte > 255)) {
|
|
1412
|
+
throw new PanguInputError("a feed id array must hold whole bytes");
|
|
1413
|
+
}
|
|
1414
|
+
bytes = Uint8Array.from(id);
|
|
1415
|
+
} else if (id instanceof Uint8Array) {
|
|
1416
|
+
bytes = id;
|
|
1417
|
+
} else {
|
|
1418
|
+
throw new PanguInputError("a feed id must be hex or 32 bytes");
|
|
1419
|
+
}
|
|
1420
|
+
if (bytes.length !== LIMITS.feedIdLength) {
|
|
1421
|
+
throw new PanguInputError(
|
|
1422
|
+
`a feed id must be ${LIMITS.feedIdLength} bytes, got ${bytes.length}`
|
|
1423
|
+
);
|
|
1424
|
+
}
|
|
1425
|
+
return bytes;
|
|
1426
|
+
}
|
|
1427
|
+
function feedIdHex(id) {
|
|
1428
|
+
return Array.from(feedIdBytes(id)).map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
1429
|
+
}
|
|
1430
|
+
function priceFeedAddress(feedId, shard = PANGU_SHARD_ID) {
|
|
1431
|
+
const id = feedIdBytes(feedId);
|
|
1432
|
+
const shardId = requireWholeNumber(shard, "shard", 0, LIMITS.maxShard);
|
|
1433
|
+
const seedBytes = new Uint8Array(2);
|
|
1434
|
+
seedBytes[0] = shardId & 255;
|
|
1435
|
+
seedBytes[1] = shardId >> 8 & 255;
|
|
1436
|
+
return PublicKey3.findProgramAddressSync(
|
|
1437
|
+
[seedBytes, id],
|
|
1438
|
+
PYTH_PRICE_FEED_PROGRAM_ID
|
|
1439
|
+
)[0];
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
// src/price.ts
|
|
1443
|
+
var HERMES_URL = "https://hermes.pyth.network";
|
|
1444
|
+
var API_KEY_VARIABLE = "PYTH_API_KEY";
|
|
1445
|
+
var COMPUTE_UNIT_PRICE_MICRO_LAMPORTS = 2e4;
|
|
1446
|
+
var HERMES_TIMEOUT_MS = 15e3;
|
|
1447
|
+
function feedOf(input) {
|
|
1448
|
+
if (input.sale !== void 0 && input.sale !== null) {
|
|
1449
|
+
if (!input.sale.hasBand) {
|
|
1450
|
+
throw new PanguInputError(
|
|
1451
|
+
"this sale has no price band, so it has no price to refresh"
|
|
1452
|
+
);
|
|
1453
|
+
}
|
|
1454
|
+
return { feedId: input.sale.priceFeedId, shard: input.sale.priceShard };
|
|
1455
|
+
}
|
|
1456
|
+
if (input.feed === void 0 || input.feed === null) {
|
|
1457
|
+
throw new PanguInputError("a refresh needs either a sale or a feed id");
|
|
1458
|
+
}
|
|
1459
|
+
return {
|
|
1460
|
+
feedId: feedIdHex(input.feed.priceFeedId),
|
|
1461
|
+
shard: input.feed.shard === void 0 ? PANGU_SHARD_ID : requireWholeNumber(input.feed.shard, "feed.shard", 0, LIMITS.maxShard)
|
|
1462
|
+
};
|
|
1463
|
+
}
|
|
1464
|
+
function apiKey(given) {
|
|
1465
|
+
const key = given === void 0 || given === "" ? globalThis.process?.env?.[API_KEY_VARIABLE] : given;
|
|
1466
|
+
if (key === void 0 || key === "") {
|
|
1467
|
+
throw new PanguInputError(
|
|
1468
|
+
`${API_KEY_VARIABLE} is not set. Every Hermes read has needed a key since 26 August 2026, and it belongs in the server's environment, never in a browser.`
|
|
1469
|
+
);
|
|
1470
|
+
}
|
|
1471
|
+
return key;
|
|
1472
|
+
}
|
|
1473
|
+
async function latestUpdate(host, feedId, key) {
|
|
1474
|
+
const url = `${host}/v2/updates/price/latest?ids[]=${feedId}&encoding=base64`;
|
|
1475
|
+
const response = await fetch(url, {
|
|
1476
|
+
headers: { Authorization: `Bearer ${key}` },
|
|
1477
|
+
signal: AbortSignal.timeout(HERMES_TIMEOUT_MS)
|
|
1478
|
+
});
|
|
1479
|
+
if (!response.ok) {
|
|
1480
|
+
const body2 = (await response.text()).slice(0, 200).split(key).join("[key]");
|
|
1481
|
+
throw new PanguInputError(`Hermes answered ${response.status}: ${body2}`);
|
|
1482
|
+
}
|
|
1483
|
+
const body = await response.json();
|
|
1484
|
+
const data = body?.binary?.data;
|
|
1485
|
+
if (!Array.isArray(data) || data.length === 0 || typeof data[0] !== "string") {
|
|
1486
|
+
throw new PanguInputError("Hermes returned no price update for this feed");
|
|
1487
|
+
}
|
|
1488
|
+
return data;
|
|
1489
|
+
}
|
|
1490
|
+
async function refreshPriceTransaction(input) {
|
|
1491
|
+
const payer = requireRealPublicKey(input.payer, "payer");
|
|
1492
|
+
const { feedId, shard } = feedOf(input);
|
|
1493
|
+
const key = apiKey(input.apiKey);
|
|
1494
|
+
const updateData = await latestUpdate(
|
|
1495
|
+
input.hermesUrl ?? HERMES_URL,
|
|
1496
|
+
feedId,
|
|
1497
|
+
key
|
|
1498
|
+
);
|
|
1499
|
+
const wallet = {
|
|
1500
|
+
publicKey: payer,
|
|
1501
|
+
signTransaction: () => {
|
|
1502
|
+
throw new PanguInputError("pangu-sdk never signs, sign the transactions yourself");
|
|
1503
|
+
},
|
|
1504
|
+
signAllTransactions: () => {
|
|
1505
|
+
throw new PanguInputError("pangu-sdk never signs, sign the transactions yourself");
|
|
1506
|
+
}
|
|
1507
|
+
};
|
|
1508
|
+
const receiver = new PythSolanaReceiver({ connection: input.connection, wallet });
|
|
1509
|
+
const builder = receiver.newTransactionBuilder({ closeUpdateAccounts: true });
|
|
1510
|
+
await builder.addUpdatePriceFeed(updateData, shard);
|
|
1511
|
+
const built = await builder.buildVersionedTransactions({
|
|
1512
|
+
computeUnitPriceMicroLamports: COMPUTE_UNIT_PRICE_MICRO_LAMPORTS
|
|
1513
|
+
});
|
|
1514
|
+
const transactions = built.map((entry) => ({
|
|
1515
|
+
transaction: entry.tx,
|
|
1516
|
+
signers: entry.signers
|
|
1517
|
+
}));
|
|
1518
|
+
return {
|
|
1519
|
+
transactions,
|
|
1520
|
+
priceAccount: priceFeedAddress(feedId, shard),
|
|
1521
|
+
shard,
|
|
1522
|
+
feedId,
|
|
1523
|
+
bytes: transactions.reduce(
|
|
1524
|
+
(total, entry) => total + entry.transaction.serialize().length,
|
|
1525
|
+
0
|
|
1526
|
+
)
|
|
1527
|
+
};
|
|
1528
|
+
}
|
|
1529
|
+
export {
|
|
1530
|
+
API_KEY_VARIABLE,
|
|
1531
|
+
refreshPriceTransaction
|
|
1532
|
+
};
|
|
1533
|
+
//# sourceMappingURL=price.mjs.map
|