Skip to content

Commit cfdfb9d

Browse files
authored
Price account v2 for remote clusters (#1040)
1 parent 0559b45 commit cfdfb9d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

governance/xc_admin/packages/xc_admin_common/src/deterministic_oracle_accounts.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
TransactionInstruction,
1111
} from "@solana/web3.js";
1212
import { PRICE_FEED_OPS_KEY } from "./multisig";
13+
import { isRemoteCluster } from "./cluster";
1314

1415
/**
1516
* Get seed for deterministic creation of a price/product account
@@ -33,10 +34,17 @@ function getSeed(accountType: AccountType, symbol: string): string {
3334
* @param accountType Type of the account
3435
* @returns
3536
*/
36-
function getAccountTypeSize(accountType: AccountType): number {
37+
function getAccountTypeSize(
38+
accountType: AccountType,
39+
cluster: PythCluster
40+
): number {
3741
switch (accountType) {
3842
case AccountType.Price:
39-
return 3312;
43+
if (isRemoteCluster(cluster)) {
44+
return 12576;
45+
} else {
46+
return 3312;
47+
}
4048
case AccountType.Product:
4149
return 512;
4250
default:
@@ -88,9 +96,9 @@ export async function getCreateAccountWithSeedInstruction(
8896
basePubkey: base,
8997
newAccountPubkey: address,
9098
seed: seed,
91-
space: getAccountTypeSize(accountType),
99+
space: getAccountTypeSize(accountType, cluster),
92100
lamports: await connection.getMinimumBalanceForRentExemption(
93-
getAccountTypeSize(accountType)
101+
getAccountTypeSize(accountType, cluster)
94102
),
95103
programId: getPythProgramKeyForCluster(cluster),
96104
});

0 commit comments

Comments
 (0)