flash-sdk 1.0.128 → 1.0.129

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,6 +25,7 @@ export declare class PerpetualsClient {
25
25
  admin: PublicKey;
26
26
  programId: PublicKey;
27
27
  composabilityProgramId: PublicKey;
28
+ poolConfig: PoolConfig;
28
29
  multisig: {
29
30
  publicKey: PublicKey;
30
31
  bump: number;
@@ -45,7 +46,7 @@ export declare class PerpetualsClient {
45
46
  private postSendTxCallback?;
46
47
  private prioritizationFee;
47
48
  private txConfirmationCommitment;
48
- constructor(provider: AnchorProvider, programId: PublicKey, composabilityProgramId: PublicKey, opts: PerpClientOptions);
49
+ constructor(provider: AnchorProvider, poolConfig: PoolConfig, composabilityProgramId: PublicKey, opts: PerpClientOptions);
49
50
  setPrioritizationFee: (fee: number) => void;
50
51
  loadAddressLookupTable: (poolConfig: PoolConfig) => Promise<void>;
51
52
  findProgramAddress: (label: string, extraSeeds?: any) => {
@@ -2177,6 +2178,7 @@ export declare class PerpetualsClient {
2177
2178
  addCustody: (poolName: string, tokenMint: PublicKey, isStable: boolean, isVirtual: boolean, oracle: OracleParams, pricing: PricingParams, permissions: Permissions, fees: Fees, borrowRate: BorrowRateParams, ratios: TokenRatios[]) => Promise<void>;
2178
2179
  editCustody: (poolName: string, tokenMint: PublicKey, isStable: boolean, oracle: OracleParams, pricing: PricingParams, permissions: Permissions, fees: Fees, borrowRate: BorrowRateParams, ratios: TokenRatios[]) => Promise<void>;
2179
2180
  removeCustody: (poolName: string, tokenMint: PublicKey, ratios: TokenRatios[]) => Promise<void>;
2181
+ getPythnetOraclePrices: (poolConfig: PoolConfig, backupOracleSecretKey: string) => Promise<TransactionInstruction>;
2180
2182
  getLiquidationState: (wallet: PublicKey, poolName: string, tokenMint: PublicKey, collateralMint: PublicKey, side: PositionSide) => Promise<any>;
2181
2183
  validateCollectivePnl: (marketSymbol: string, collateralSymbol: string, poolConfig: PoolConfig, poolName: string, side: Side) => Promise<void>;
2182
2184
  liquidate: (wallet: PublicKey, poolName: string, tokenMint: PublicKey, collateralMint: PublicKey, side: PositionSide, receivingAccount: PublicKey, rewardsReceivingAccount: PublicKey) => Promise<string>;
@@ -10,6 +10,29 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
13
36
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
37
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
38
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -74,8 +97,11 @@ var rpc_1 = require("./utils/rpc");
74
97
  var utils_1 = require("./utils");
75
98
  var constants_1 = require("./constants");
76
99
  var bignumber_js_1 = __importDefault(require("bignumber.js"));
100
+ var backupOracle_1 = require("./backupOracle");
101
+ var bytes_1 = require("@coral-xyz/anchor/dist/cjs/utils/bytes");
102
+ var nacl = __importStar(require("tweetnacl"));
77
103
  var PerpetualsClient = (function () {
78
- function PerpetualsClient(provider, programId, composabilityProgramId, opts) {
104
+ function PerpetualsClient(provider, poolConfig, composabilityProgramId, opts) {
79
105
  var _this = this;
80
106
  var _a;
81
107
  this.addressLookupTables = [];
@@ -569,6 +595,44 @@ var PerpetualsClient = (function () {
569
595
  }
570
596
  });
571
597
  }); };
598
+ this.getPythnetOraclePrices = function (poolConfig, backupOracleSecretKey) { return __awaiter(_this, void 0, void 0, function () {
599
+ var pythPriceIds, currentPrices, backupOracleAccount, caches_1, permissionlessPythCache, message, signature, preInstruction;
600
+ return __generator(this, function (_a) {
601
+ switch (_a.label) {
602
+ case 0:
603
+ pythPriceIds = poolConfig.custodies.map(function (f) { return f.pythPriceId; });
604
+ return [4, backupOracle_1.pythPriceServiceConnection.getLatestPriceFeeds(pythPriceIds)];
605
+ case 1:
606
+ currentPrices = _a.sent();
607
+ backupOracleAccount = web3_js_1.Keypair.fromSecretKey(bytes_1.bs58.decode(backupOracleSecretKey));
608
+ if (pythPriceIds.length === currentPrices.length) {
609
+ caches_1 = currentPrices.map(function (price) {
610
+ var uncheckedPrice = price.getPriceUnchecked();
611
+ var uncheckedEmaPrice = price.getEmaPriceUnchecked();
612
+ return {
613
+ price: new anchor_1.BN(uncheckedPrice.price),
614
+ expo: uncheckedPrice.expo,
615
+ conf: new anchor_1.BN(uncheckedPrice.conf),
616
+ ema: new anchor_1.BN(uncheckedEmaPrice.price),
617
+ publishTime: new anchor_1.BN(uncheckedPrice.publishTime)
618
+ };
619
+ });
620
+ permissionlessPythCache = {
621
+ backupCache: caches_1
622
+ };
623
+ message = this.program._coder.types.encode('PermissionlessPythCache', permissionlessPythCache);
624
+ signature = nacl.sign.detached(message, backupOracleAccount.secretKey);
625
+ preInstruction = web3_js_1.Ed25519Program.createInstructionWithPublicKey({
626
+ publicKey: backupOracleAccount.publicKey.toBytes(),
627
+ message: message,
628
+ signature: signature,
629
+ });
630
+ return [2, preInstruction];
631
+ }
632
+ return [2];
633
+ }
634
+ });
635
+ }); };
572
636
  this.getLiquidationState = function (wallet, poolName, tokenMint, collateralMint, side) { return __awaiter(_this, void 0, void 0, function () {
573
637
  var _a, _b;
574
638
  var _c;
@@ -587,11 +651,12 @@ var PerpetualsClient = (function () {
587
651
  return [4, this.getCustodyOracleAccountKey(poolName, tokenMint)];
588
652
  case 1:
589
653
  _c.custodyOracleAccount = _d.sent(),
590
- _c.custodyCustomOracleAccount = web3_js_1.SystemProgram.programId,
654
+ _c.custodyCustomOracleAccount = this.poolConfig.backupOracle,
591
655
  _c.collateralCustody = this.getCustodyKey(poolName, collateralMint),
592
- _c.collateralCustodyCustomOracleAccount = web3_js_1.SystemProgram.programId;
656
+ _c.collateralCustodyCustomOracleAccount = this.poolConfig.backupOracle;
593
657
  return [4, this.getCustodyOracleAccountKey(poolName, collateralMint)];
594
658
  case 2: return [4, _b.apply(_a, [(_c.collateralCustodyOracleAccount = _d.sent(),
659
+ _c.ixSysvar = web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
595
660
  _c)])
596
661
  .view()
597
662
  .catch(function (err) {
@@ -616,10 +681,11 @@ var PerpetualsClient = (function () {
616
681
  pool: this.getPoolKey(poolName),
617
682
  custody: marketCustodyConfig.custodyAccount,
618
683
  custodyOracleAccount: marketCustodyConfig.oracleAddress,
619
- custodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
684
+ custodyCustomOracleAccount: this.poolConfig.backupOracle,
620
685
  collateralCustody: collateralCustodyConfig.custodyAccount,
621
686
  collateralCustodyOracleAccount: collateralCustodyConfig.oracleAddress,
622
- collateralCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
687
+ collateralCustodyCustomOracleAccount: this.poolConfig.backupOracle,
688
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
623
689
  })
624
690
  .remainingAccounts([])
625
691
  .rpc()
@@ -659,11 +725,12 @@ var PerpetualsClient = (function () {
659
725
  return [4, this.getCustodyOracleAccountKey(poolName, collateralMint)];
660
726
  case 2: return [4, _b.apply(_a, [(_c.collateralCustodyOracleAccount = _d.sent(),
661
727
  _c.collateralCustodyTokenAccount = this.getCustodyTokenAccountKey(poolName, collateralMint),
662
- _c.collateralCustodyCustomOracleAccount = web3_js_1.SystemProgram.programId,
663
- _c.custodyCustomOracleAccount = web3_js_1.SystemProgram.programId,
728
+ _c.collateralCustodyCustomOracleAccount = this.poolConfig.backupOracle,
729
+ _c.custodyCustomOracleAccount = this.poolConfig.backupOracle,
664
730
  _c.eventAuthority = this.eventAuthority.publicKey,
665
731
  _c.tokenProgram = spl_token_1.TOKEN_PROGRAM_ID,
666
732
  _c.program = this.program.programId,
733
+ _c.ixSysvar = web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
667
734
  _c)])
668
735
  .rpc()
669
736
  .catch(function (err) {
@@ -692,6 +759,7 @@ var PerpetualsClient = (function () {
692
759
  };
693
760
  return [4, this.getCustodyOracleAccountKey(poolName, tokenMint)];
694
761
  case 1: return [4, _b.apply(_a, [(_c.custodyOracleAccount = _d.sent(),
762
+ _c.ixSysvar = web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
695
763
  _c)])
696
764
  .view()
697
765
  .catch(function (err) {
@@ -722,6 +790,7 @@ var PerpetualsClient = (function () {
722
790
  case 1:
723
791
  _d = (_a = _c.apply(_b, [(_e.custodyOracleAccount = _f.sent(),
724
792
  _e.lpTokenMint = this.getPoolLpTokenKey(poolName),
793
+ _e.ixSysvar = web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
725
794
  _e)]))
726
795
  .remainingAccounts;
727
796
  return [4, this.getCustodyMetas(poolName)];
@@ -755,6 +824,7 @@ var PerpetualsClient = (function () {
755
824
  case 1:
756
825
  _d = (_a = _c.apply(_b, [(_e.custodyOracleAccount = _f.sent(),
757
826
  _e.lpTokenMint = this.getPoolLpTokenKey(poolName),
827
+ _e.ixSysvar = web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
758
828
  _e)]))
759
829
  .remainingAccounts;
760
830
  return [4, this.getCustodyMetas(poolName)];
@@ -788,6 +858,7 @@ var PerpetualsClient = (function () {
788
858
  };
789
859
  return [4, this.getCustodyOracleAccountKey(poolName, tokenMint)];
790
860
  case 1: return [4, _b.apply(_a, [(_c.custodyOracleAccount = _d.sent(),
861
+ _c.ixSysvar = web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
791
862
  _c)])
792
863
  .view()
793
864
  .catch(function (err) {
@@ -815,6 +886,7 @@ var PerpetualsClient = (function () {
815
886
  };
816
887
  return [4, this.getCustodyOracleAccountKey(poolName, tokenMint)];
817
888
  case 1: return [4, _b.apply(_a, [(_c.custodyOracleAccount = _d.sent(),
889
+ _c.ixSysvar = web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
818
890
  _c)])
819
891
  .view()
820
892
  .catch(function (err) {
@@ -848,6 +920,7 @@ var PerpetualsClient = (function () {
848
920
  };
849
921
  return [4, this.getCustodyOracleAccountKey(poolName, tokenMint)];
850
922
  case 1: return [4, _b.apply(_a, [(_c.custodyOracleAccount = _d.sent(),
923
+ _c.ixSysvar = web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
851
924
  _c)])
852
925
  .view()
853
926
  .catch(function (err) {
@@ -877,6 +950,7 @@ var PerpetualsClient = (function () {
877
950
  };
878
951
  return [4, this.getCustodyOracleAccountKey(poolName, tokenMint)];
879
952
  case 1: return [4, _b.apply(_a, [(_c.custodyOracleAccount = _d.sent(),
953
+ _c.ixSysvar = web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
880
954
  _c)])
881
955
  .view()
882
956
  .catch(function (err) {
@@ -909,6 +983,7 @@ var PerpetualsClient = (function () {
909
983
  _c.dispensingCustody = this.getCustodyKey(poolName, tokenMintOut);
910
984
  return [4, this.getCustodyOracleAccountKey(poolName, tokenMintOut)];
911
985
  case 2: return [4, _b.apply(_a, [(_c.dispensingCustodyOracleAccount = _d.sent(),
986
+ _c.ixSysvar = web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
912
987
  _c)])
913
988
  .view()
914
989
  .catch(function (err) {
@@ -929,6 +1004,7 @@ var PerpetualsClient = (function () {
929
1004
  .accounts({
930
1005
  perpetuals: this.perpetuals.publicKey,
931
1006
  pool: this.getPoolKey(poolName),
1007
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
932
1008
  }))
933
1009
  .remainingAccounts;
934
1010
  return [4, this.getCustodyMetas(poolName)];
@@ -1792,15 +1868,16 @@ var PerpetualsClient = (function () {
1792
1868
  position: positionAccount,
1793
1869
  custody: marketCustodyConfig.custodyAccount,
1794
1870
  custodyOracleAccount: marketCustodyConfig.oracleAddress,
1795
- custodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
1871
+ custodyCustomOracleAccount: this.poolConfig.backupOracle,
1796
1872
  collateralCustody: collateralCustodyConfig.custodyAccount,
1797
1873
  collateralCustodyOracleAccount: collateralCustodyConfig.oracleAddress,
1798
- collateralCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
1874
+ collateralCustodyCustomOracleAccount: this.poolConfig.backupOracle,
1799
1875
  collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
1800
1876
  eventAuthority: this.eventAuthority.publicKey,
1801
1877
  systemProgram: web3_js_1.SystemProgram.programId,
1802
1878
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1803
1879
  program: this.programId,
1880
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
1804
1881
  }).instruction()];
1805
1882
  case 8:
1806
1883
  instruction = _c.sent();
@@ -1907,7 +1984,7 @@ var PerpetualsClient = (function () {
1907
1984
  isWritable: false,
1908
1985
  });
1909
1986
  custodyCustomOracles.push({
1910
- pubkey: web3_js_1.SystemProgram.programId,
1987
+ pubkey: this.poolConfig.backupOracle,
1911
1988
  isSigner: false,
1912
1989
  isWritable: false,
1913
1990
  });
@@ -1917,7 +1994,8 @@ var PerpetualsClient = (function () {
1917
1994
  .accounts({
1918
1995
  payer: publicKey,
1919
1996
  perpetuals: poolConfig.perpetuals,
1920
- pool: poolConfig.poolAddress
1997
+ pool: poolConfig.poolAddress,
1998
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
1921
1999
  })
1922
2000
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), custodyCustomOracles, true))
1923
2001
  .instruction()];
@@ -1942,20 +2020,21 @@ var PerpetualsClient = (function () {
1942
2020
  pool: poolConfig.poolAddress,
1943
2021
  receivingCustody: inputCustodyConfig.custodyAccount,
1944
2022
  receivingCustodyOracleAccount: inputCustodyConfig.oracleAddress,
1945
- receivingCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2023
+ receivingCustodyCustomOracleAccount: this.poolConfig.backupOracle,
1946
2024
  receivingCustodyTokenAccount: inputCustodyConfig.tokenAccount,
1947
2025
  dispensingCustody: collateralCustodyConfig.custodyAccount,
1948
2026
  dispensingCustodyOracleAccount: collateralCustodyConfig.oracleAddress,
1949
- dispensingCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2027
+ dispensingCustodyCustomOracleAccount: this.poolConfig.backupOracle,
1950
2028
  dispensingCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
1951
2029
  position: positionAccount,
1952
2030
  custody: marketCustodyConfig.custodyAccount,
1953
2031
  custodyOracleAccount: marketCustodyConfig.oracleAddress,
1954
- custodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2032
+ custodyCustomOracleAccount: this.poolConfig.backupOracle,
1955
2033
  eventAuthority: this.eventAuthority.publicKey,
1956
2034
  systemProgram: web3_js_1.SystemProgram.programId,
1957
2035
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1958
2036
  perpProgram: this.programId,
2037
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
1959
2038
  })
1960
2039
  .instruction()];
1961
2040
  case 9:
@@ -2045,14 +2124,15 @@ var PerpetualsClient = (function () {
2045
2124
  position: positionAccount,
2046
2125
  custody: marketCustodyConfig.custodyAccount,
2047
2126
  custodyOracleAccount: marketCustodyConfig.oracleAddress,
2048
- custodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2127
+ custodyCustomOracleAccount: this.poolConfig.backupOracle,
2049
2128
  collateralCustody: collateralCustodyConfig.custodyAccount,
2050
2129
  collateralCustodyOracleAccount: collateralCustodyConfig.oracleAddress,
2051
- collateralCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2130
+ collateralCustodyCustomOracleAccount: this.poolConfig.backupOracle,
2052
2131
  collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
2053
2132
  eventAuthority: this.eventAuthority.publicKey,
2054
2133
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
2055
2134
  program: this.programId,
2135
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
2056
2136
  }).instruction()];
2057
2137
  case 8:
2058
2138
  instruction = _b.sent();
@@ -2150,7 +2230,7 @@ var PerpetualsClient = (function () {
2150
2230
  isWritable: false,
2151
2231
  });
2152
2232
  custodyCustomOracles.push({
2153
- pubkey: web3_js_1.SystemProgram.programId,
2233
+ pubkey: this.poolConfig.backupOracle,
2154
2234
  isSigner: false,
2155
2235
  isWritable: false,
2156
2236
  });
@@ -2160,7 +2240,8 @@ var PerpetualsClient = (function () {
2160
2240
  .accounts({
2161
2241
  payer: publicKey,
2162
2242
  perpetuals: poolConfig.perpetuals,
2163
- pool: poolConfig.poolAddress
2243
+ pool: poolConfig.poolAddress,
2244
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
2164
2245
  })
2165
2246
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), custodyCustomOracles, true))
2166
2247
  .instruction()];
@@ -2182,19 +2263,20 @@ var PerpetualsClient = (function () {
2182
2263
  pool: poolConfig.poolAddress,
2183
2264
  receivingCustody: collateralCustodyConfig.custodyAccount,
2184
2265
  receivingCustodyOracleAccount: collateralCustodyConfig.oracleAddress,
2185
- receivingCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2266
+ receivingCustodyCustomOracleAccount: this.poolConfig.backupOracle,
2186
2267
  receivingCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
2187
2268
  dispensingCustody: outputCustodyConfig.custodyAccount,
2188
2269
  dispensingCustodyOracleAccount: outputCustodyConfig.oracleAddress,
2189
- dispensingCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2270
+ dispensingCustodyCustomOracleAccount: this.poolConfig.backupOracle,
2190
2271
  dispensingCustodyTokenAccount: outputCustodyConfig.tokenAccount,
2191
2272
  position: positionAccount,
2192
2273
  custody: marketCustodyConfig.custodyAccount,
2193
2274
  custodyOracleAccount: marketCustodyConfig.oracleAddress,
2194
- custodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2275
+ custodyCustomOracleAccount: this.poolConfig.backupOracle,
2195
2276
  eventAuthority: this.eventAuthority.publicKey,
2196
2277
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
2197
2278
  perpProgram: this.programId,
2279
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
2198
2280
  })
2199
2281
  .instruction()];
2200
2282
  case 8:
@@ -2368,7 +2450,7 @@ var PerpetualsClient = (function () {
2368
2450
  isWritable: false,
2369
2451
  });
2370
2452
  custodyCustomOracles.push({
2371
- pubkey: web3_js_1.SystemProgram.programId,
2453
+ pubkey: this.poolConfig.backupOracle,
2372
2454
  isSigner: false,
2373
2455
  isWritable: false,
2374
2456
  });
@@ -2378,7 +2460,8 @@ var PerpetualsClient = (function () {
2378
2460
  .accounts({
2379
2461
  payer: publicKey,
2380
2462
  perpetuals: poolConfig.perpetuals,
2381
- pool: poolConfig.poolAddress
2463
+ pool: poolConfig.poolAddress,
2464
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
2382
2465
  })
2383
2466
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), custodyCustomOracles, true))
2384
2467
  .instruction()];
@@ -2401,15 +2484,16 @@ var PerpetualsClient = (function () {
2401
2484
  pool: poolConfig.poolAddress,
2402
2485
  receivingCustody: userInputCustodyConfig.custodyAccount,
2403
2486
  receivingCustodyOracleAccount: userInputCustodyConfig.oracleAddress,
2404
- receivingCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2487
+ receivingCustodyCustomOracleAccount: this.poolConfig.backupOracle,
2405
2488
  receivingCustodyTokenAccount: userInputCustodyConfig.tokenAccount,
2406
2489
  dispensingCustody: userOutputCustodyConfig.custodyAccount,
2407
2490
  dispensingCustodyOracleAccount: userOutputCustodyConfig.oracleAddress,
2408
- dispensingCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2491
+ dispensingCustodyCustomOracleAccount: this.poolConfig.backupOracle,
2409
2492
  dispensingCustodyTokenAccount: userOutputCustodyConfig.tokenAccount,
2410
2493
  eventAuthority: this.eventAuthority.publicKey,
2411
2494
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
2412
2495
  program: this.programId,
2496
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
2413
2497
  })
2414
2498
  .instruction()];
2415
2499
  case 21:
@@ -2511,14 +2595,15 @@ var PerpetualsClient = (function () {
2511
2595
  pool: poolConfig.poolAddress,
2512
2596
  custody: marketCustodyConfig.custodyAccount,
2513
2597
  custodyOracleAccount: marketCustodyConfig.oracleAddress,
2514
- custodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2598
+ custodyCustomOracleAccount: this.poolConfig.backupOracle,
2515
2599
  collateralCustody: collateralCustodyConfig.custodyAccount,
2516
2600
  collateralCustodyOracleAccount: collateralCustodyConfig.oracleAddress,
2517
- collateralCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2601
+ collateralCustodyCustomOracleAccount: this.poolConfig.backupOracle,
2518
2602
  collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
2519
2603
  eventAuthority: this.eventAuthority.publicKey,
2520
2604
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
2521
2605
  program: this.programId,
2606
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
2522
2607
  })
2523
2608
  .instruction()];
2524
2609
  case 8:
@@ -2623,7 +2708,7 @@ var PerpetualsClient = (function () {
2623
2708
  isWritable: false,
2624
2709
  });
2625
2710
  custodyCustomOracles.push({
2626
- pubkey: web3_js_1.SystemProgram.programId,
2711
+ pubkey: this.poolConfig.backupOracle,
2627
2712
  isSigner: false,
2628
2713
  isWritable: false,
2629
2714
  });
@@ -2633,7 +2718,8 @@ var PerpetualsClient = (function () {
2633
2718
  .accounts({
2634
2719
  payer: publicKey,
2635
2720
  perpetuals: poolConfig.perpetuals,
2636
- pool: poolConfig.poolAddress
2721
+ pool: poolConfig.poolAddress,
2722
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
2637
2723
  })
2638
2724
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), custodyCustomOracles, true))
2639
2725
  .instruction()];
@@ -2654,18 +2740,19 @@ var PerpetualsClient = (function () {
2654
2740
  pool: poolConfig.poolAddress,
2655
2741
  receivingCustody: inputCustodyConfig.custodyAccount,
2656
2742
  receivingCustodyOracleAccount: inputCustodyConfig.oracleAddress,
2657
- receivingCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2743
+ receivingCustodyCustomOracleAccount: this.poolConfig.backupOracle,
2658
2744
  receivingCustodyTokenAccount: inputCustodyConfig.tokenAccount,
2659
2745
  dispensingCustody: collateralCustodyConfig.custodyAccount,
2660
2746
  dispensingCustodyOracleAccount: collateralCustodyConfig.oracleAddress,
2661
- dispensingCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2747
+ dispensingCustodyCustomOracleAccount: this.poolConfig.backupOracle,
2662
2748
  dispensingCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
2663
2749
  custody: marketCustodyConfig.custodyAccount,
2664
2750
  custodyOracleAccount: marketCustodyConfig.oracleAddress,
2665
- custodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2751
+ custodyCustomOracleAccount: this.poolConfig.backupOracle,
2666
2752
  eventAuthority: this.eventAuthority.publicKey,
2667
2753
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
2668
2754
  perpProgram: this.programId,
2755
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
2669
2756
  })
2670
2757
  .instruction()];
2671
2758
  case 9:
@@ -2755,14 +2842,15 @@ var PerpetualsClient = (function () {
2755
2842
  position: positionPubKey,
2756
2843
  custody: marketCustodyConfig.custodyAccount,
2757
2844
  custodyOracleAccount: marketCustodyConfig.oracleAddress,
2758
- custodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2845
+ custodyCustomOracleAccount: this.poolConfig.backupOracle,
2759
2846
  collateralCustody: collateralCustodyConfig.custodyAccount,
2760
2847
  collateralCustodyOracleAccount: collateralCustodyConfig.oracleAddress,
2761
- collateralCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2848
+ collateralCustodyCustomOracleAccount: this.poolConfig.backupOracle,
2762
2849
  collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
2763
2850
  eventAuthority: this.eventAuthority.publicKey,
2764
2851
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
2765
2852
  program: this.programId,
2853
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
2766
2854
  })
2767
2855
  .instruction()];
2768
2856
  case 8:
@@ -2861,7 +2949,7 @@ var PerpetualsClient = (function () {
2861
2949
  isWritable: false,
2862
2950
  });
2863
2951
  custodyCustomOracles.push({
2864
- pubkey: web3_js_1.SystemProgram.programId,
2952
+ pubkey: this.poolConfig.backupOracle,
2865
2953
  isSigner: false,
2866
2954
  isWritable: false,
2867
2955
  });
@@ -2871,7 +2959,8 @@ var PerpetualsClient = (function () {
2871
2959
  .accounts({
2872
2960
  payer: publicKey,
2873
2961
  perpetuals: poolConfig.perpetuals,
2874
- pool: poolConfig.poolAddress
2962
+ pool: poolConfig.poolAddress,
2963
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
2875
2964
  })
2876
2965
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), custodyCustomOracles, true))
2877
2966
  .instruction()];
@@ -2893,19 +2982,20 @@ var PerpetualsClient = (function () {
2893
2982
  pool: poolConfig.poolAddress,
2894
2983
  receivingCustody: collateralCustodyConfig.custodyAccount,
2895
2984
  receivingCustodyOracleAccount: collateralCustodyConfig.oracleAddress,
2896
- receivingCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2985
+ receivingCustodyCustomOracleAccount: this.poolConfig.backupOracle,
2897
2986
  receivingCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
2898
2987
  dispensingCustody: outputCustodyConfig.custodyAccount,
2899
2988
  dispensingCustodyOracleAccount: outputCustodyConfig.oracleAddress,
2900
- dispensingCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2989
+ dispensingCustodyCustomOracleAccount: this.poolConfig.backupOracle,
2901
2990
  dispensingCustodyTokenAccount: outputCustodyConfig.tokenAccount,
2902
2991
  position: positionAccount,
2903
2992
  custody: marketCustodyConfig.custodyAccount,
2904
2993
  custodyOracleAccount: marketCustodyConfig.oracleAddress,
2905
- custodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
2994
+ custodyCustomOracleAccount: this.poolConfig.backupOracle,
2906
2995
  eventAuthority: this.eventAuthority.publicKey,
2907
2996
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
2908
2997
  perpProgram: this.programId,
2998
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
2909
2999
  })
2910
3000
  .instruction()];
2911
3001
  case 8:
@@ -2951,12 +3041,13 @@ var PerpetualsClient = (function () {
2951
3041
  position: positionPubKey,
2952
3042
  custody: marketCustodyConfig.custodyAccount,
2953
3043
  custodyOracleAccount: marketCustodyConfig.oracleAddress,
2954
- custodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
3044
+ custodyCustomOracleAccount: this.poolConfig.backupOracle,
2955
3045
  collateralCustody: collateralCustodyConfig.custodyAccount,
2956
3046
  collateralCustodyOracleAccount: collateralCustodyConfig.oracleAddress,
2957
- collateralCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
3047
+ collateralCustodyCustomOracleAccount: this.poolConfig.backupOracle,
2958
3048
  eventAuthority: this.eventAuthority.publicKey,
2959
3049
  program: this.programId,
3050
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
2960
3051
  })
2961
3052
  .instruction()];
2962
3053
  case 1:
@@ -3002,13 +3093,14 @@ var PerpetualsClient = (function () {
3002
3093
  position: positionPubKey,
3003
3094
  custody: marketCustodyConfig.custodyAccount,
3004
3095
  custodyOracleAccount: marketCustodyConfig.oracleAddress,
3005
- custodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
3096
+ custodyCustomOracleAccount: this.poolConfig.backupOracle,
3006
3097
  collateralCustody: collateralCustodyConfig.custodyAccount,
3007
3098
  collateralCustodyOracleAccount: collateralCustodyConfig.oracleAddress,
3008
- collateralCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
3099
+ collateralCustodyCustomOracleAccount: this.poolConfig.backupOracle,
3009
3100
  collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
3010
3101
  eventAuthority: this.eventAuthority.publicKey,
3011
3102
  program: this.programId,
3103
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
3012
3104
  })
3013
3105
  .instruction()];
3014
3106
  case 1:
@@ -3062,7 +3154,7 @@ var PerpetualsClient = (function () {
3062
3154
  isWritable: false,
3063
3155
  });
3064
3156
  custodyCustomOracles.push({
3065
- pubkey: web3_js_1.SystemProgram.programId,
3157
+ pubkey: this.poolConfig.backupOracle,
3066
3158
  isSigner: false,
3067
3159
  isWritable: false,
3068
3160
  });
@@ -3121,7 +3213,8 @@ var PerpetualsClient = (function () {
3121
3213
  .accounts({
3122
3214
  payer: publicKey,
3123
3215
  perpetuals: poolConfig.perpetuals,
3124
- pool: poolConfig.poolAddress
3216
+ pool: poolConfig.poolAddress,
3217
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
3125
3218
  })
3126
3219
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), custodyCustomOracles, true))
3127
3220
  .instruction()];
@@ -3143,12 +3236,13 @@ var PerpetualsClient = (function () {
3143
3236
  pool: poolConfig.poolAddress,
3144
3237
  custody: payTokenCustodyConfig.custodyAccount,
3145
3238
  custodyOracleAccount: payTokenCustodyConfig.oracleAddress,
3146
- custodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
3239
+ custodyCustomOracleAccount: this.poolConfig.backupOracle,
3147
3240
  custodyTokenAccount: payTokenCustodyConfig.tokenAccount,
3148
3241
  lpTokenMint: poolConfig.lpTokenMint,
3149
3242
  eventAuthority: this.eventAuthority.publicKey,
3150
3243
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
3151
3244
  program: this.programId,
3245
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
3152
3246
  })
3153
3247
  .instruction()];
3154
3248
  case 12:
@@ -3207,7 +3301,7 @@ var PerpetualsClient = (function () {
3207
3301
  isWritable: false,
3208
3302
  });
3209
3303
  custodyCustomOracles.push({
3210
- pubkey: web3_js_1.SystemProgram.programId,
3304
+ pubkey: this.poolConfig.backupOracle,
3211
3305
  isSigner: false,
3212
3306
  isWritable: false,
3213
3307
  });
@@ -3252,7 +3346,8 @@ var PerpetualsClient = (function () {
3252
3346
  .accounts({
3253
3347
  payer: publicKey,
3254
3348
  perpetuals: poolConfig.perpetuals,
3255
- pool: poolConfig.poolAddress
3349
+ pool: poolConfig.poolAddress,
3350
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
3256
3351
  })
3257
3352
  .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), custodyCustomOracles, true))
3258
3353
  .instruction()];
@@ -3275,12 +3370,13 @@ var PerpetualsClient = (function () {
3275
3370
  pool: poolConfig.poolAddress,
3276
3371
  custody: recieveTokenCustodyConfig.custodyAccount,
3277
3372
  custodyOracleAccount: recieveTokenCustodyConfig.oracleAddress,
3278
- custodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
3373
+ custodyCustomOracleAccount: this.poolConfig.backupOracle,
3279
3374
  custodyTokenAccount: recieveTokenCustodyConfig.tokenAccount,
3280
3375
  lpTokenMint: poolConfig.lpTokenMint,
3281
3376
  eventAuthority: this.eventAuthority.publicKey,
3282
3377
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
3283
3378
  program: this.programId,
3379
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
3284
3380
  })
3285
3381
  .instruction()];
3286
3382
  case 10:
@@ -3309,9 +3405,10 @@ var PerpetualsClient = (function () {
3309
3405
  };
3310
3406
  this.provider = provider;
3311
3407
  (0, anchor_1.setProvider)(provider);
3312
- this.program = new anchor_1.Program(perpetuals_1.IDL, programId);
3408
+ this.program = new anchor_1.Program(perpetuals_1.IDL, poolConfig.programId);
3313
3409
  this.programPerpComposability = new anchor_1.Program(perp_composability_1.IDL, composabilityProgramId);
3314
- this.programId = programId;
3410
+ this.poolConfig = poolConfig;
3411
+ this.programId = poolConfig.programId;
3315
3412
  this.composabilityProgramId = composabilityProgramId;
3316
3413
  this.admin = this.provider.wallet.publicKey;
3317
3414
  this.multisig = this.findProgramAddress("multisig");
@@ -10,6 +10,7 @@ export interface CustodyConfig {
10
10
  isStable: boolean;
11
11
  isVirtual: boolean;
12
12
  oracleAddress: PublicKey;
13
+ pythPriceId: string;
13
14
  }
14
15
  export type Token = {
15
16
  symbol: string;
@@ -30,9 +31,10 @@ export declare class PoolConfig {
30
31
  transferAuthority: PublicKey;
31
32
  multisig: PublicKey;
32
33
  addressLookupTableAddresses: PublicKey[];
34
+ backupOracle: PublicKey;
33
35
  tokens: Token[];
34
36
  custodies: CustodyConfig[];
35
- constructor(programId: PublicKey, cluster: Cluster, poolName: string, poolAddress: PublicKey, lpTokenMint: PublicKey, lpDecimals: number, perpetuals: PublicKey, transferAuthority: PublicKey, multisig: PublicKey, addressLookupTableAddresses: PublicKey[], tokens: Token[], custodies: CustodyConfig[]);
37
+ constructor(programId: PublicKey, cluster: Cluster, poolName: string, poolAddress: PublicKey, lpTokenMint: PublicKey, lpDecimals: number, perpetuals: PublicKey, transferAuthority: PublicKey, multisig: PublicKey, addressLookupTableAddresses: PublicKey[], backupOracle: PublicKey, tokens: Token[], custodies: CustodyConfig[]);
36
38
  getAllTokenMints(): PublicKey[];
37
39
  getNonStableTokens(): PublicKey[];
38
40
  getAllCustodies(): PublicKey[];