@@ -7,7 +7,10 @@ import {
7
7
AccountMeta ,
8
8
} from "@solana/web3.js" ;
9
9
import { program } from "commander" ;
10
- import { PythCluster } from "@pythnetwork/client/lib/cluster" ;
10
+ import {
11
+ getPythProgramKeyForCluster ,
12
+ PythCluster ,
13
+ } from "@pythnetwork/client/lib/cluster" ;
11
14
import { getPythClusterApiUrl } from "@pythnetwork/client/lib/cluster" ;
12
15
import { AnchorProvider , Program } from "@coral-xyz/anchor" ;
13
16
import fs from "fs" ;
@@ -24,6 +27,7 @@ import {
24
27
proposeInstructions ,
25
28
WORMHOLE_ADDRESS ,
26
29
} from "xc-admin-common" ;
30
+ import { pythOracleProgram } from "@pythnetwork/client" ;
27
31
28
32
const mutlisigCommand = ( name : string , description : string ) =>
29
33
program
@@ -165,6 +169,45 @@ mutlisigCommand("upgrade-program", "Upgrade a program from a buffer")
165
169
await proposeInstructions ( squad , vault , [ proposalInstruction ] , false ) ;
166
170
} ) ;
167
171
172
+ mutlisigCommand (
173
+ "init-price" ,
174
+ "Init price (useful for changing the exponent), only to be used on unused price feeds"
175
+ )
176
+ . requiredOption ( "-p, --price <pubkey>" , "Price account to modify" )
177
+ . requiredOption ( "-e, --exponent <number>" , "New exponent" )
178
+ . action ( async ( options : any ) => {
179
+ const wallet = new NodeWallet (
180
+ Keypair . fromSecretKey (
181
+ Uint8Array . from ( JSON . parse ( fs . readFileSync ( options . wallet , "ascii" ) ) )
182
+ )
183
+ ) ;
184
+ const cluster : PythCluster = options . cluster ;
185
+ const vault : PublicKey = new PublicKey ( options . vault ) ;
186
+ const priceAccount : PublicKey = new PublicKey ( options . price ) ;
187
+ const exponent = options . exponent ;
188
+ const squad = SquadsMesh . endpoint ( getPythClusterApiUrl ( cluster ) , wallet ) ;
189
+
190
+ const msAccount = await squad . getMultisig ( vault ) ;
191
+ const vaultAuthority = squad . getAuthorityPDA (
192
+ msAccount . publicKey ,
193
+ msAccount . authorityIndex
194
+ ) ;
195
+
196
+ const provider = new AnchorProvider (
197
+ squad . connection ,
198
+ wallet ,
199
+ AnchorProvider . defaultOptions ( )
200
+ ) ;
201
+ const proposalInstruction : TransactionInstruction = await pythOracleProgram (
202
+ getPythProgramKeyForCluster ( cluster ) ,
203
+ provider
204
+ )
205
+ . methods . initPrice ( exponent , 1 )
206
+ . accounts ( { fundingAccount : vaultAuthority , priceAccount } )
207
+ . instruction ( ) ;
208
+ await proposeInstructions ( squad , vault , [ proposalInstruction ] , false ) ;
209
+ } ) ;
210
+
168
211
program
169
212
. command ( "parse-transaction" )
170
213
. description ( "Parse a transaction sitting in the multisig" )
0 commit comments