@pythnetwork/pyth-solana-receiver 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 +13 -0
- package/lib/PythSolanaReceiver.d.ts +49 -0
- package/lib/PythSolanaReceiver.d.ts.map +1 -0
- package/lib/PythSolanaReceiver.js +168 -0
- package/lib/address.d.ts +7 -0
- package/lib/address.d.ts.map +1 -0
- package/lib/address.js +20 -0
- package/lib/compute_budget.d.ts +4 -0
- package/lib/compute_budget.d.ts.map +1 -0
- package/lib/compute_budget.js +6 -0
- package/lib/idl/pyth_solana_receiver.d.ts +604 -0
- package/lib/idl/pyth_solana_receiver.d.ts.map +1 -0
- package/lib/idl/pyth_solana_receiver.js +605 -0
- package/lib/idl/wormhole_core_bridge_solana.d.ts +1607 -0
- package/lib/idl/wormhole_core_bridge_solana.d.ts.map +1 -0
- package/lib/idl/wormhole_core_bridge_solana.js +1608 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +7 -0
- package/lib/vaa.d.ts +17 -0
- package/lib/vaa.d.ts.map +1 -0
- package/lib/vaa.js +61 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Pyth Contributors.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AnchorProvider, Program } from "@coral-xyz/anchor";
|
|
3
|
+
import { Connection, Signer, VersionedTransaction } from "@solana/web3.js";
|
|
4
|
+
import { PythSolanaReceiver as PythSolanaReceiverProgram } from "./idl/pyth_solana_receiver";
|
|
5
|
+
import { WormholeCoreBridgeSolana } from "./idl/wormhole_core_bridge_solana";
|
|
6
|
+
import { PublicKey } from "@solana/web3.js";
|
|
7
|
+
import { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
|
|
8
|
+
import { InstructionWithEphemeralSigners } from "@pythnetwork/solana-utils";
|
|
9
|
+
import { PriorityFeeConfig } from "@pythnetwork/solana-utils/lib/transaction";
|
|
10
|
+
export declare const DEFAULT_TREASURY_ID = 0;
|
|
11
|
+
export declare class PythSolanaReceiver {
|
|
12
|
+
readonly connection: Connection;
|
|
13
|
+
readonly wallet: Wallet;
|
|
14
|
+
readonly provider: AnchorProvider;
|
|
15
|
+
readonly receiver: Program<PythSolanaReceiverProgram>;
|
|
16
|
+
readonly wormhole: Program<WormholeCoreBridgeSolana>;
|
|
17
|
+
constructor({ connection, wallet, wormholeProgramId, receiverProgramId, }: {
|
|
18
|
+
connection: Connection;
|
|
19
|
+
wallet: Wallet;
|
|
20
|
+
wormholeProgramId?: PublicKey;
|
|
21
|
+
receiverProgramId?: PublicKey;
|
|
22
|
+
});
|
|
23
|
+
withPriceUpdate(priceUpdateDataArray: string[], getInstructions: (priceFeedIdToPriceUpdateAccount: Record<string, PublicKey>) => Promise<InstructionWithEphemeralSigners[]>, priorityFeeConfig?: PriorityFeeConfig): Promise<{
|
|
24
|
+
tx: VersionedTransaction;
|
|
25
|
+
signers: Signer[];
|
|
26
|
+
}[]>;
|
|
27
|
+
withPartiallyVerifiedPriceUpdate(priceUpdateDataArray: string[], getInstructions: (priceFeedIdToPriceUpdateAccount: Record<string, PublicKey>) => Promise<InstructionWithEphemeralSigners[]>, priorityFeeConfig?: PriorityFeeConfig): Promise<{
|
|
28
|
+
tx: VersionedTransaction;
|
|
29
|
+
signers: Signer[];
|
|
30
|
+
}[]>;
|
|
31
|
+
buildPostPriceUpdateAtomicInstructions(priceUpdateDataArray: string[]): Promise<{
|
|
32
|
+
postInstructions: InstructionWithEphemeralSigners[];
|
|
33
|
+
priceFeedIdToPriceUpdateAccount: Record<string, PublicKey>;
|
|
34
|
+
cleanupInstructions: InstructionWithEphemeralSigners[];
|
|
35
|
+
}>;
|
|
36
|
+
buildPostEncodedVaaInstructions(vaa: Buffer): Promise<{
|
|
37
|
+
postInstructions: InstructionWithEphemeralSigners[];
|
|
38
|
+
encodedVaaAddress: PublicKey;
|
|
39
|
+
cleanupInstructions: InstructionWithEphemeralSigners[];
|
|
40
|
+
}>;
|
|
41
|
+
buildPostPriceUpdateInstructions(priceUpdateDataArray: string[]): Promise<{
|
|
42
|
+
postInstructions: InstructionWithEphemeralSigners[];
|
|
43
|
+
priceFeedIdToPriceUpdateAccount: Record<string, PublicKey>;
|
|
44
|
+
cleanupInstructions: InstructionWithEphemeralSigners[];
|
|
45
|
+
}>;
|
|
46
|
+
buildCloseEncodedVaaInstruction(encodedVaa: PublicKey): Promise<InstructionWithEphemeralSigners>;
|
|
47
|
+
buildClosePriceUpdateInstruction(priceUpdateAccount: PublicKey): Promise<InstructionWithEphemeralSigners>;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=PythSolanaReceiver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PythSolanaReceiver.d.ts","sourceRoot":"","sources":["../src/PythSolanaReceiver.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PythSolanaReceiver = exports.DEFAULT_TREASURY_ID = void 0;
|
|
4
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
|
+
const pyth_solana_receiver_1 = require("./idl/pyth_solana_receiver");
|
|
6
|
+
const wormhole_core_bridge_solana_1 = require("./idl/wormhole_core_bridge_solana");
|
|
7
|
+
const address_1 = require("./address");
|
|
8
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
9
|
+
const price_service_sdk_1 = require("@pythnetwork/price-service-sdk");
|
|
10
|
+
const compute_budget_1 = require("./compute_budget");
|
|
11
|
+
const vaa_1 = require("./vaa");
|
|
12
|
+
const solana_utils_1 = require("@pythnetwork/solana-utils");
|
|
13
|
+
exports.DEFAULT_TREASURY_ID = 0;
|
|
14
|
+
class PythSolanaReceiver {
|
|
15
|
+
connection;
|
|
16
|
+
wallet;
|
|
17
|
+
provider;
|
|
18
|
+
receiver;
|
|
19
|
+
wormhole;
|
|
20
|
+
constructor({ connection, wallet, wormholeProgramId = address_1.DEFAULT_WORMHOLE_PROGRAM_ID, receiverProgramId = address_1.DEFAULT_RECEIVER_PROGRAM_ID, }) {
|
|
21
|
+
this.connection = connection;
|
|
22
|
+
this.wallet = wallet;
|
|
23
|
+
this.provider = new anchor_1.AnchorProvider(this.connection, this.wallet, {
|
|
24
|
+
commitment: connection.commitment,
|
|
25
|
+
});
|
|
26
|
+
this.receiver = new anchor_1.Program(pyth_solana_receiver_1.IDL, receiverProgramId, this.provider);
|
|
27
|
+
this.wormhole = new anchor_1.Program(wormhole_core_bridge_solana_1.IDL, wormholeProgramId, this.provider);
|
|
28
|
+
}
|
|
29
|
+
async withPriceUpdate(priceUpdateDataArray, getInstructions, priorityFeeConfig) {
|
|
30
|
+
const { postInstructions, priceFeedIdToPriceUpdateAccount: priceFeedIdToPriceUpdateAccount, cleanupInstructions, } = await this.buildPostPriceUpdateInstructions(priceUpdateDataArray);
|
|
31
|
+
return solana_utils_1.TransactionBuilder.batchIntoVersionedTransactions(this.wallet.publicKey, this.connection, [
|
|
32
|
+
...postInstructions,
|
|
33
|
+
...(await getInstructions(priceFeedIdToPriceUpdateAccount)),
|
|
34
|
+
...cleanupInstructions,
|
|
35
|
+
], priorityFeeConfig ?? {});
|
|
36
|
+
}
|
|
37
|
+
async withPartiallyVerifiedPriceUpdate(priceUpdateDataArray, getInstructions, priorityFeeConfig) {
|
|
38
|
+
const { postInstructions, priceFeedIdToPriceUpdateAccount, cleanupInstructions, } = await this.buildPostPriceUpdateAtomicInstructions(priceUpdateDataArray);
|
|
39
|
+
return solana_utils_1.TransactionBuilder.batchIntoVersionedTransactions(this.wallet.publicKey, this.connection, [
|
|
40
|
+
...postInstructions,
|
|
41
|
+
...(await getInstructions(priceFeedIdToPriceUpdateAccount)),
|
|
42
|
+
...cleanupInstructions,
|
|
43
|
+
], priorityFeeConfig ?? {});
|
|
44
|
+
}
|
|
45
|
+
async buildPostPriceUpdateAtomicInstructions(priceUpdateDataArray) {
|
|
46
|
+
const postInstructions = [];
|
|
47
|
+
const priceFeedIdToPriceUpdateAccount = {};
|
|
48
|
+
const cleanupInstructions = [];
|
|
49
|
+
for (const priceUpdateData of priceUpdateDataArray) {
|
|
50
|
+
const accumulatorUpdateData = (0, price_service_sdk_1.parseAccumulatorUpdateData)(Buffer.from(priceUpdateData, "base64"));
|
|
51
|
+
const guardianSetIndex = (0, vaa_1.getGuardianSetIndex)(accumulatorUpdateData.vaa);
|
|
52
|
+
const trimmedVaa = (0, vaa_1.trimSignatures)(accumulatorUpdateData.vaa);
|
|
53
|
+
for (const update of accumulatorUpdateData.updates) {
|
|
54
|
+
const priceUpdateKeypair = new web3_js_1.Keypair();
|
|
55
|
+
postInstructions.push({
|
|
56
|
+
instruction: await this.receiver.methods
|
|
57
|
+
.postUpdateAtomic({
|
|
58
|
+
vaa: trimmedVaa,
|
|
59
|
+
merklePriceUpdate: update,
|
|
60
|
+
treasuryId: exports.DEFAULT_TREASURY_ID,
|
|
61
|
+
})
|
|
62
|
+
.accounts({
|
|
63
|
+
priceUpdateAccount: priceUpdateKeypair.publicKey,
|
|
64
|
+
treasury: (0, address_1.getTreasuryPda)(exports.DEFAULT_TREASURY_ID),
|
|
65
|
+
config: (0, address_1.getConfigPda)(),
|
|
66
|
+
guardianSet: (0, address_1.getGuardianSetPda)(guardianSetIndex),
|
|
67
|
+
})
|
|
68
|
+
.instruction(),
|
|
69
|
+
signers: [priceUpdateKeypair],
|
|
70
|
+
computeUnits: compute_budget_1.POST_UPDATE_ATOMIC_COMPUTE_BUDGET,
|
|
71
|
+
});
|
|
72
|
+
priceFeedIdToPriceUpdateAccount["0x" + (0, price_service_sdk_1.parsePriceFeedMessage)(update.message).feedId.toString("hex")] = priceUpdateKeypair.publicKey;
|
|
73
|
+
cleanupInstructions.push(await this.buildClosePriceUpdateInstruction(priceUpdateKeypair.publicKey));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
postInstructions,
|
|
78
|
+
priceFeedIdToPriceUpdateAccount,
|
|
79
|
+
cleanupInstructions,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
async buildPostEncodedVaaInstructions(vaa) {
|
|
83
|
+
const postInstructions = [];
|
|
84
|
+
const cleanupInstructions = [];
|
|
85
|
+
const encodedVaaKeypair = new web3_js_1.Keypair();
|
|
86
|
+
const guardianSetIndex = (0, vaa_1.getGuardianSetIndex)(vaa);
|
|
87
|
+
postInstructions.push(await (0, vaa_1.buildEncodedVaaCreateInstruction)(this.wormhole, vaa, encodedVaaKeypair));
|
|
88
|
+
postInstructions.push({
|
|
89
|
+
instruction: await this.wormhole.methods
|
|
90
|
+
.initEncodedVaa()
|
|
91
|
+
.accounts({
|
|
92
|
+
encodedVaa: encodedVaaKeypair.publicKey,
|
|
93
|
+
})
|
|
94
|
+
.instruction(),
|
|
95
|
+
signers: [],
|
|
96
|
+
});
|
|
97
|
+
postInstructions.push(...(await (0, vaa_1.buildWriteEncodedVaaWithSplit)(this.wormhole, vaa, encodedVaaKeypair.publicKey)));
|
|
98
|
+
postInstructions.push({
|
|
99
|
+
instruction: await this.wormhole.methods
|
|
100
|
+
.verifyEncodedVaaV1()
|
|
101
|
+
.accounts({
|
|
102
|
+
guardianSet: (0, address_1.getGuardianSetPda)(guardianSetIndex),
|
|
103
|
+
draftVaa: encodedVaaKeypair.publicKey,
|
|
104
|
+
})
|
|
105
|
+
.instruction(),
|
|
106
|
+
signers: [],
|
|
107
|
+
computeUnits: compute_budget_1.VERIFY_ENCODED_VAA_COMPUTE_BUDGET,
|
|
108
|
+
});
|
|
109
|
+
cleanupInstructions.push(await this.buildCloseEncodedVaaInstruction(encodedVaaKeypair.publicKey));
|
|
110
|
+
return {
|
|
111
|
+
postInstructions,
|
|
112
|
+
encodedVaaAddress: encodedVaaKeypair.publicKey,
|
|
113
|
+
cleanupInstructions,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
async buildPostPriceUpdateInstructions(priceUpdateDataArray) {
|
|
117
|
+
const postInstructions = [];
|
|
118
|
+
const priceFeedIdToPriceUpdateAccount = {};
|
|
119
|
+
const cleanupInstructions = [];
|
|
120
|
+
for (const priceUpdateData of priceUpdateDataArray) {
|
|
121
|
+
const accumulatorUpdateData = (0, price_service_sdk_1.parseAccumulatorUpdateData)(Buffer.from(priceUpdateData, "base64"));
|
|
122
|
+
const { postInstructions: postEncodedVaaInstructions, encodedVaaAddress: encodedVaa, cleanupInstructions: postEncodedVaaCleanupInstructions, } = await this.buildPostEncodedVaaInstructions(accumulatorUpdateData.vaa);
|
|
123
|
+
postInstructions.push(...postEncodedVaaInstructions);
|
|
124
|
+
cleanupInstructions.push(...postEncodedVaaCleanupInstructions);
|
|
125
|
+
for (const update of accumulatorUpdateData.updates) {
|
|
126
|
+
const priceUpdateKeypair = new web3_js_1.Keypair();
|
|
127
|
+
postInstructions.push({
|
|
128
|
+
instruction: await this.receiver.methods
|
|
129
|
+
.postUpdate({
|
|
130
|
+
merklePriceUpdate: update,
|
|
131
|
+
treasuryId: exports.DEFAULT_TREASURY_ID,
|
|
132
|
+
})
|
|
133
|
+
.accounts({
|
|
134
|
+
encodedVaa,
|
|
135
|
+
priceUpdateAccount: priceUpdateKeypair.publicKey,
|
|
136
|
+
treasury: (0, address_1.getTreasuryPda)(exports.DEFAULT_TREASURY_ID),
|
|
137
|
+
config: (0, address_1.getConfigPda)(),
|
|
138
|
+
})
|
|
139
|
+
.instruction(),
|
|
140
|
+
signers: [priceUpdateKeypair],
|
|
141
|
+
computeUnits: compute_budget_1.POST_UPDATE_COMPUTE_BUDGET,
|
|
142
|
+
});
|
|
143
|
+
priceFeedIdToPriceUpdateAccount["0x" + (0, price_service_sdk_1.parsePriceFeedMessage)(update.message).feedId.toString("hex")] = priceUpdateKeypair.publicKey;
|
|
144
|
+
cleanupInstructions.push(await this.buildClosePriceUpdateInstruction(priceUpdateKeypair.publicKey));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
postInstructions,
|
|
149
|
+
priceFeedIdToPriceUpdateAccount,
|
|
150
|
+
cleanupInstructions,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
async buildCloseEncodedVaaInstruction(encodedVaa) {
|
|
154
|
+
const instruction = await this.wormhole.methods
|
|
155
|
+
.closeEncodedVaa()
|
|
156
|
+
.accounts({ encodedVaa })
|
|
157
|
+
.instruction();
|
|
158
|
+
return { instruction, signers: [] };
|
|
159
|
+
}
|
|
160
|
+
async buildClosePriceUpdateInstruction(priceUpdateAccount) {
|
|
161
|
+
const instruction = await this.receiver.methods
|
|
162
|
+
.reclaimRent()
|
|
163
|
+
.accounts({ priceUpdateAccount })
|
|
164
|
+
.instruction();
|
|
165
|
+
return { instruction, signers: [] };
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.PythSolanaReceiver = PythSolanaReceiver;
|
package/lib/address.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
export declare const DEFAULT_RECEIVER_PROGRAM_ID: PublicKey;
|
|
3
|
+
export declare const DEFAULT_WORMHOLE_PROGRAM_ID: PublicKey;
|
|
4
|
+
export declare const getGuardianSetPda: (guardianSetIndex: number) => PublicKey;
|
|
5
|
+
export declare const getTreasuryPda: (treasuryId: number) => PublicKey;
|
|
6
|
+
export declare const getConfigPda: () => PublicKey;
|
|
7
|
+
//# sourceMappingURL=address.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,eAAO,MAAM,2BAA2B,WAEvC,CAAC;AACF,eAAO,MAAM,2BAA2B,WAEvC,CAAC;AAEF,eAAO,MAAM,iBAAiB,qBAAsB,MAAM,cAOzD,CAAC;AAEF,eAAO,MAAM,cAAc,eAAgB,MAAM,cAKhD,CAAC;AAEF,eAAO,MAAM,YAAY,iBAKxB,CAAC"}
|
package/lib/address.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getConfigPda = exports.getTreasuryPda = exports.getGuardianSetPda = exports.DEFAULT_WORMHOLE_PROGRAM_ID = exports.DEFAULT_RECEIVER_PROGRAM_ID = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
exports.DEFAULT_RECEIVER_PROGRAM_ID = new web3_js_1.PublicKey("rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ");
|
|
6
|
+
exports.DEFAULT_WORMHOLE_PROGRAM_ID = new web3_js_1.PublicKey("HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ");
|
|
7
|
+
const getGuardianSetPda = (guardianSetIndex) => {
|
|
8
|
+
const guardianSetIndexBuf = Buffer.alloc(4);
|
|
9
|
+
guardianSetIndexBuf.writeUInt32BE(guardianSetIndex, 0);
|
|
10
|
+
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("GuardianSet"), guardianSetIndexBuf], exports.DEFAULT_WORMHOLE_PROGRAM_ID)[0];
|
|
11
|
+
};
|
|
12
|
+
exports.getGuardianSetPda = getGuardianSetPda;
|
|
13
|
+
const getTreasuryPda = (treasuryId) => {
|
|
14
|
+
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("treasury"), Buffer.from([treasuryId])], exports.DEFAULT_RECEIVER_PROGRAM_ID)[0];
|
|
15
|
+
};
|
|
16
|
+
exports.getTreasuryPda = getTreasuryPda;
|
|
17
|
+
const getConfigPda = () => {
|
|
18
|
+
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("config")], exports.DEFAULT_RECEIVER_PROGRAM_ID)[0];
|
|
19
|
+
};
|
|
20
|
+
exports.getConfigPda = getConfigPda;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compute_budget.d.ts","sourceRoot":"","sources":["../src/compute_budget.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iCAAiC,SAAS,CAAC;AACxD,eAAO,MAAM,iCAAiC,SAAS,CAAC;AACxD,eAAO,MAAM,0BAA0B,SAAS,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.POST_UPDATE_COMPUTE_BUDGET = exports.POST_UPDATE_ATOMIC_COMPUTE_BUDGET = exports.VERIFY_ENCODED_VAA_COMPUTE_BUDGET = void 0;
|
|
4
|
+
exports.VERIFY_ENCODED_VAA_COMPUTE_BUDGET = 400000;
|
|
5
|
+
exports.POST_UPDATE_ATOMIC_COMPUTE_BUDGET = 400000;
|
|
6
|
+
exports.POST_UPDATE_COMPUTE_BUDGET = 200000;
|