@lavarage/sdk 8.0.12 → 8.0.13

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/index.ts CHANGED
@@ -43,7 +43,7 @@ import {
43
43
  TOKEN_PROGRAM_ID,
44
44
  } from "@solana/spl-token";
45
45
  import { queuePubkey, USDC_MINT } from "./constants";
46
- import { getOracleQuoteForCollateralType, getOracleQuoteForFeedId } from "./switchboard";
46
+ import { getOracleQuoteForCollateralType, getOracleQuoteForFeedId, getSwitchboardQueue } from "./switchboard";
47
47
  import { u8ArrayToString } from "./utils";
48
48
  import { ApiKeys } from "./crossbar";
49
49
 
@@ -59,6 +59,8 @@ type OptionalRPCResults = {
59
59
  }
60
60
  const REFFERAL_VAULT_PROGRAM_ID = new PublicKey("FFe8xWs9iBdWB6vsxg8yBLirZHsbACFNbXqAM4K3fPPB");
61
61
 
62
+ const LAVARAGE_LOOKUP_TABLE = "CDPmKb5VggsHABwDCTaxiw5XXLjcgkqSJMNKRTzHWXwK";
63
+
62
64
  /**
63
65
  * Derives a Program Derived Address (PDA) for the given seed(s) and program ID
64
66
  *
@@ -1069,7 +1071,7 @@ export const openTradeV1 = async (
1069
1071
 
1070
1072
  addressLookupTableAccounts.push(
1071
1073
  ...(await getAddressLookupTableAccounts([
1072
- "5LEAB3owNUSKvECm7vkr58tDtQpzbngQ2NYpc7qmRFdi",
1074
+ LAVARAGE_LOOKUP_TABLE,
1073
1075
  ...addressLookupTableAddresses,
1074
1076
  ]))
1075
1077
  );
@@ -1453,12 +1455,18 @@ export const openTradeV2 = async (
1453
1455
 
1454
1456
  const addressLookupTableAccounts: AddressLookupTableAccount[] = [];
1455
1457
 
1458
+ // @ts-expect-error @coral-xyz/anchor versions mismatch
1459
+ const queue = await getSwitchboardQueue(program.provider);
1460
+
1461
+ const switchboardLookupTables = await queue.loadLookupTable();
1462
+
1456
1463
  addressLookupTableAccounts.push(
1457
1464
  ...(await getAddressLookupTableAccounts([
1458
1465
  ...addressLookupTableAddresses,
1459
1466
  getQuoteCurrencySpecificAddressLookupTable(quoteToken.toBase58()),
1460
- "5LEAB3owNUSKvECm7vkr58tDtQpzbngQ2NYpc7qmRFdi",
1461
- ]))
1467
+ LAVARAGE_LOOKUP_TABLE,
1468
+ ])),
1469
+ switchboardLookupTables
1462
1470
  );
1463
1471
 
1464
1472
  const { blockhash } =
@@ -2514,7 +2522,7 @@ export const closeTradeV1 = async (
2514
2522
  ].filter((i) => !!i);
2515
2523
  addressLookupTableAccounts.push(
2516
2524
  ...(await getAddressLookupTableAccounts([
2517
- "5LEAB3owNUSKvECm7vkr58tDtQpzbngQ2NYpc7qmRFdi",
2525
+ LAVARAGE_LOOKUP_TABLE,
2518
2526
  ...addressLookupTableAddresses,
2519
2527
  ]))
2520
2528
  );
@@ -2895,7 +2903,9 @@ export const closeTradeV2 = async (
2895
2903
  : await lavarageProgram.methods
2896
2904
  .tradingCloseRepaySol(
2897
2905
  new BN(jupInstruction.quoteResponse.outAmount),
2898
- new BN(9997)
2906
+ new BN(9997),
2907
+ null,
2908
+ null,
2899
2909
  )
2900
2910
  .accountsStrict({
2901
2911
  nodeWallet: pool.account.nodeWallet,
@@ -3006,7 +3016,9 @@ export const closeTradeV2 = async (
3006
3016
  : await lavarageProgram.methods
3007
3017
  .tradingCloseRepaySol(
3008
3018
  new BN(jupInstruction.quoteResponse.outAmount),
3009
- new BN(9998)
3019
+ new BN(9998),
3020
+ null,
3021
+ null,
3010
3022
  )
3011
3023
  .accountsStrict({
3012
3024
  nodeWallet: pool.account.nodeWallet,
@@ -3076,7 +3088,7 @@ export const closeTradeV2 = async (
3076
3088
  ...(await getAddressLookupTableAccounts([
3077
3089
  ...addressLookupTableAddresses,
3078
3090
  getQuoteCurrencySpecificAddressLookupTable(quoteToken.toBase58()),
3079
- "5LEAB3owNUSKvECm7vkr58tDtQpzbngQ2NYpc7qmRFdi",
3091
+ LAVARAGE_LOOKUP_TABLE,
3080
3092
  ]))
3081
3093
  );
3082
3094
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lavarage/sdk",
3
- "version": "8.0.12",
3
+ "version": "8.0.13",
4
4
  "description": "Lavarage SDK",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
package/switchboard.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { OracleQuote } from "@switchboard-xyz/on-demand";
1
+ import { ON_DEMAND_DEVNET_QUEUE, getQueue, isMainnetConnection, ON_DEMAND_MAINNET_QUEUE, OracleQuote, Queue, ON_DEMAND_MAINNET_PID, ON_DEMAND_DEVNET_PID } from "@switchboard-xyz/on-demand";
2
2
  import { queuePubkey } from "./constants";
3
3
  import { PublicKey } from "@solana/web3.js";
4
4
  import { SURGE_FEEDS } from "./crossbar";
5
+ import { AnchorProvider, Program } from "@coral-xyz/anchor";
5
6
 
6
7
  export function getOracleQuoteForFeedId(feedId: string) {
7
8
  const [oracleQuote] = OracleQuote.getCanonicalPubkey(
@@ -20,4 +21,20 @@ export function getOracleQuoteForCollateralType(collateralType: PublicKey) {
20
21
  }
21
22
 
22
23
  return getOracleQuoteForFeedId(feed.feedId);
24
+ }
25
+
26
+ async function getSwitchboardProgram(provider: AnchorProvider): Promise<Program> {
27
+ const programId = await isMainnetConnection(provider.connection) ? ON_DEMAND_MAINNET_PID : ON_DEMAND_DEVNET_PID;
28
+
29
+ return Program.at(programId, provider);
30
+ }
31
+
32
+ export async function getSwitchboardQueue(provider: AnchorProvider): Promise<Queue> {
33
+ const program = await getSwitchboardProgram(provider);
34
+
35
+ return await getQueue({
36
+ // @ts-expect-error @coral-xyz/anchor versions mismatch
37
+ program,
38
+ queueAddress: await isMainnetConnection(provider.connection) ? ON_DEMAND_MAINNET_QUEUE : ON_DEMAND_DEVNET_QUEUE,
39
+ });
23
40
  }