@liquid-af/sdk 0.2.0 → 0.3.1

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.
Files changed (72) hide show
  1. package/dist/accounts/liquid-swap.d.ts +2 -0
  2. package/dist/accounts/liquid-swap.d.ts.map +1 -1
  3. package/dist/client.d.ts +2 -0
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/helpers/preview.js.map +1 -1
  6. package/dist/idl/index.d.ts +1 -0
  7. package/dist/idl/index.d.ts.map +1 -1
  8. package/dist/idl/index.js +15 -4
  9. package/dist/idl/index.js.map +1 -1
  10. package/dist/idl/liquid.d.ts +1359 -1359
  11. package/dist/idl/liquid.d.ts.map +1 -1
  12. package/dist/idl/liquid.json +1359 -1359
  13. package/dist/idl/liquid_fees.d.ts +1 -1
  14. package/dist/idl/liquid_fees.json +1 -1
  15. package/dist/idl/liquid_state.d.ts +62 -62
  16. package/dist/idl/liquid_state.d.ts.map +1 -1
  17. package/dist/idl/liquid_state.json +62 -62
  18. package/dist/idl/liquid_swap.d.ts +597 -494
  19. package/dist/idl/liquid_swap.d.ts.map +1 -1
  20. package/dist/idl/liquid_swap.json +597 -494
  21. package/dist/idl/patch-idl.d.ts +10 -0
  22. package/dist/idl/patch-idl.d.ts.map +1 -0
  23. package/dist/idl/patch-idl.js +62 -0
  24. package/dist/idl/patch-idl.js.map +1 -0
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/instructions/program-cache.d.ts.map +1 -1
  30. package/dist/instructions/program-cache.js +10 -6
  31. package/dist/instructions/program-cache.js.map +1 -1
  32. package/package.json +4 -4
  33. package/src/accounts/liquid-fees.ts +2 -2
  34. package/src/accounts/liquid-state.ts +7 -7
  35. package/src/accounts/liquid-swap.ts +4 -4
  36. package/src/accounts/liquid.ts +6 -6
  37. package/src/client.ts +31 -31
  38. package/src/config.ts +10 -10
  39. package/src/errors.ts +6 -6
  40. package/src/events/parser.ts +5 -5
  41. package/src/helpers/preview.ts +31 -31
  42. package/src/helpers/user.ts +1 -1
  43. package/src/idl/index.ts +31 -8
  44. package/src/idl/liquid.json +1359 -1359
  45. package/src/idl/liquid.ts +1359 -1359
  46. package/src/idl/liquid_fees.json +1 -1
  47. package/src/idl/liquid_fees.ts +1 -1
  48. package/src/idl/liquid_state.json +62 -62
  49. package/src/idl/liquid_state.ts +62 -62
  50. package/src/idl/liquid_swap.json +597 -494
  51. package/src/idl/liquid_swap.ts +597 -494
  52. package/src/idl/patch-idl.ts +80 -0
  53. package/src/index.ts +1 -0
  54. package/src/instructions/liquid-fees.ts +14 -14
  55. package/src/instructions/liquid-state.ts +4 -4
  56. package/src/instructions/liquid-swap.ts +18 -18
  57. package/src/instructions/liquid.ts +47 -47
  58. package/src/instructions/program-cache.ts +18 -9
  59. package/src/math/amm.ts +3 -3
  60. package/src/math/bonding-curve.ts +6 -6
  61. package/src/math/fees.ts +9 -9
  62. package/src/math/tiered-fees.ts +5 -5
  63. package/src/oracle.ts +3 -3
  64. package/src/pda/index.ts +27 -27
  65. package/src/pda/liquid-fees.ts +6 -6
  66. package/src/pda/liquid-state.ts +13 -13
  67. package/src/pda/liquid-swap.ts +16 -16
  68. package/src/pda/liquid.ts +15 -15
  69. package/src/provider.ts +2 -2
  70. package/src/transaction/builder.ts +4 -4
  71. package/src/transaction/send.ts +4 -4
  72. package/src/types.ts +2 -2
package/src/config.ts CHANGED
@@ -17,32 +17,32 @@ export interface LiquidConfig {
17
17
  /** Mainnet program IDs */
18
18
  export const MAINNET_CONFIG: LiquidConfig = {
19
19
  liquidProgramId: new PublicKey(
20
- "LiquidsqH2a9gsPRf1M2QFhFqfLXWYTDZGzbsNQCDux"
20
+ "LiquidsqH2a9gsPRf1M2QFhFqfLXWYTDZGzbsNQCDux",
21
21
  ),
22
22
  liquidSwapProgramId: new PublicKey(
23
- "SwapMXcpJdXgnFG9BZak2fBZUiNeR2qYxzexF2ZxdW8"
23
+ "SwapMXcpJdXgnFG9BZak2fBZUiNeR2qYxzexF2ZxdW8",
24
24
  ),
25
25
  liquidFeesProgramId: new PublicKey(
26
- "FeesZQLb1xTeZbvaFRGnqzrZYzzmQtwhTYKQphbNGQru"
26
+ "FeesZQLb1xTeZbvaFRGnqzrZYzzmQtwhTYKQphbNGQru",
27
27
  ),
28
28
  liquidStateProgramId: new PublicKey(
29
- "State3HtEfi7cXdsTpAtRoBvrij8zSFCiGTAVWmYH2d"
29
+ "State3HtEfi7cXdsTpAtRoBvrij8zSFCiGTAVWmYH2d",
30
30
  ),
31
31
  } as const;
32
32
 
33
33
  /** Devnet program IDs (liquid differs, others same as mainnet) */
34
34
  export const DEVNET_CONFIG: LiquidConfig = {
35
35
  liquidProgramId: new PublicKey(
36
- "76sZav3FHaGLQmo2wHpyboeEk3Bc7wbL6bPibaSyhxnt"
36
+ "76sZav3FHaGLQmo2wHpyboeEk3Bc7wbL6bPibaSyhxnt",
37
37
  ),
38
38
  liquidSwapProgramId: new PublicKey(
39
- "DoBPPSQETr2xK5fKeTDR8wJ2Y4aTjtDbNwd9K72whhQB"
39
+ "DoBPPSQETr2xK5fKeTDR8wJ2Y4aTjtDbNwd9K72whhQB",
40
40
  ),
41
41
  liquidFeesProgramId: new PublicKey(
42
- "3iFrDQxt6ZQT5eTyoHSpdq9hpyj9QmXDjTNEopGYpvTh"
42
+ "3iFrDQxt6ZQT5eTyoHSpdq9hpyj9QmXDjTNEopGYpvTh",
43
43
  ),
44
44
  liquidStateProgramId: new PublicKey(
45
- "9ZcKPa3HAEVEKxwFX8fYD56ZJCKPEQgqjgr9rfUvtwKJ"
45
+ "9ZcKPa3HAEVEKxwFX8fYD56ZJCKPEQgqjgr9rfUvtwKJ",
46
46
  ),
47
47
  } as const;
48
48
 
@@ -51,12 +51,12 @@ export const LOCALNET_CONFIG: LiquidConfig = { ...MAINNET_CONFIG } as const;
51
51
 
52
52
  /** WSOL mint address */
53
53
  export const WSOL_MINT = new PublicKey(
54
- "So11111111111111111111111111111111111111112"
54
+ "So11111111111111111111111111111111111111112",
55
55
  );
56
56
 
57
57
  /** Pyth Solana Receiver program ID (same across all networks and mock) */
58
58
  export const PYTH_RECEIVER_PROGRAM_ID = new PublicKey(
59
- "rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ"
59
+ "rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ",
60
60
  );
61
61
 
62
62
  /** Basis points denominator (10,000 = 100%) */
package/src/errors.ts CHANGED
@@ -30,7 +30,7 @@ export class LiquidError extends Error {
30
30
  constructor(
31
31
  readonly code: LiquidErrorCode,
32
32
  message: string,
33
- readonly cause?: unknown
33
+ readonly cause?: unknown,
34
34
  ) {
35
35
  super(message);
36
36
  }
@@ -58,7 +58,7 @@ export class LiquidError extends Error {
58
58
  return new LiquidError(
59
59
  LiquidErrorCode.AccountNotFound,
60
60
  msg,
61
- err
61
+ err,
62
62
  );
63
63
  }
64
64
 
@@ -66,7 +66,7 @@ export class LiquidError extends Error {
66
66
  return new LiquidError(
67
67
  LiquidErrorCode.TransactionTimeout,
68
68
  msg,
69
- err
69
+ err,
70
70
  );
71
71
  }
72
72
 
@@ -74,21 +74,21 @@ export class LiquidError extends Error {
74
74
  return new LiquidError(
75
75
  LiquidErrorCode.SimulationFailed,
76
76
  msg,
77
- err
77
+ err,
78
78
  );
79
79
  }
80
80
 
81
81
  return new LiquidError(
82
82
  LiquidErrorCode.TransactionBuildFailed,
83
83
  msg,
84
- err
84
+ err,
85
85
  );
86
86
  }
87
87
 
88
88
  return new LiquidError(
89
89
  LiquidErrorCode.TransactionBuildFailed,
90
90
  String(err),
91
- err
91
+ err,
92
92
  );
93
93
  }
94
94
  }
@@ -15,11 +15,11 @@ export interface ParsedEvent<T = unknown> {
15
15
  */
16
16
  export const parseTransactionEvents = (
17
17
  logs: string[],
18
- program: Program
18
+ program: Program,
19
19
  ): ParsedEvent[] => {
20
20
  const parser = new EventParser(
21
21
  program.programId,
22
- new BorshCoder(program.idl)
22
+ new BorshCoder(program.idl),
23
23
  );
24
24
  const events: ParsedEvent[] = [];
25
25
  const generator = parser.parseLogs(logs);
@@ -41,7 +41,7 @@ export const parseTransactionEvents = (
41
41
  export const addEventListener = <T>(
42
42
  program: Program,
43
43
  eventName: string,
44
- callback: (event: T) => void
44
+ callback: (event: T) => void,
45
45
  ): number => {
46
46
  return program.addEventListener(eventName, (data: T) => {
47
47
  callback(data);
@@ -64,7 +64,7 @@ export async function waitForEvent<TEvent, TResult = string>(
64
64
  program: Program<any>,
65
65
  eventName: string,
66
66
  trigger: () => Promise<TResult>,
67
- timeoutMs = 5000
67
+ timeoutMs = 5000,
68
68
  ): Promise<{ result: TResult; event: TEvent }> {
69
69
  let eventData: TEvent | null = null;
70
70
  const listenerId = program.addEventListener(eventName, (data: TEvent) => {
@@ -79,7 +79,7 @@ export async function waitForEvent<TEvent, TResult = string>(
79
79
  await program.removeEventListener(listenerId);
80
80
  if (!eventData) {
81
81
  throw new Error(
82
- `Event '${eventName}' not received within ${timeoutMs}ms`
82
+ `Event '${eventName}' not received within ${timeoutMs}ms`,
83
83
  );
84
84
  }
85
85
  return { result, event: eventData };
@@ -160,7 +160,7 @@ export interface SwapPrefetchedState {
160
160
  export function calculateBuyCurvePreview(
161
161
  amountInQuote: BN,
162
162
  state: CurvePreviewState,
163
- options?: CurvePreviewOptions
163
+ options?: CurvePreviewOptions,
164
164
  ): BuyCurvePreview {
165
165
  const { globalConfig, bondingCurve } = state;
166
166
 
@@ -176,7 +176,7 @@ export function calculateBuyCurvePreview(
176
176
  bondingCurve,
177
177
  feeConfig,
178
178
  options?.hasCreatorRef ?? false,
179
- options?.hasTraderRef ?? false
179
+ options?.hasTraderRef ?? false,
180
180
  );
181
181
 
182
182
  const priceBefore = bondingCurve.virtualQuoteReserves
@@ -222,7 +222,7 @@ export function calculateBuyCurvePreview(
222
222
  export function calculateSellCurvePreview(
223
223
  amountInTokens: BN,
224
224
  state: CurvePreviewState,
225
- options?: CurvePreviewOptions
225
+ options?: CurvePreviewOptions,
226
226
  ): SellCurvePreview {
227
227
  const { globalConfig, bondingCurve } = state;
228
228
 
@@ -238,7 +238,7 @@ export function calculateSellCurvePreview(
238
238
  bondingCurve,
239
239
  feeConfig,
240
240
  options?.hasCreatorRef ?? false,
241
- options?.hasTraderRef ?? false
241
+ options?.hasTraderRef ?? false,
242
242
  );
243
243
 
244
244
  const priceBefore = bondingCurve.virtualQuoteReserves
@@ -280,7 +280,7 @@ export function calculateSellCurvePreview(
280
280
  */
281
281
  export function calculateSwapBuyPreview(
282
282
  amountOut: BN,
283
- state: SwapPreviewState
283
+ state: SwapPreviewState,
284
284
  ): SwapPreview {
285
285
  const { ammConfig, baseVaultBalance, quoteVaultBalance } = state;
286
286
 
@@ -292,7 +292,7 @@ export function calculateSwapBuyPreview(
292
292
  lpFeeRate: ammConfig.lpFeeRate,
293
293
  creatorFeeRate: ammConfig.creatorFeeRate,
294
294
  protocolFeeRate: ammConfig.protocolFeeRate,
295
- }
295
+ },
296
296
  );
297
297
 
298
298
  const priceBefore = quoteVaultBalance
@@ -331,7 +331,7 @@ export function calculateSwapBuyPreview(
331
331
  */
332
332
  export function calculateSwapSellPreview(
333
333
  amountIn: BN,
334
- state: SwapPreviewState
334
+ state: SwapPreviewState,
335
335
  ): SwapPreview {
336
336
  const { ammConfig, baseVaultBalance, quoteVaultBalance } = state;
337
337
 
@@ -343,7 +343,7 @@ export function calculateSwapSellPreview(
343
343
  lpFeeRate: ammConfig.lpFeeRate,
344
344
  creatorFeeRate: ammConfig.creatorFeeRate,
345
345
  protocolFeeRate: ammConfig.protocolFeeRate,
346
- }
346
+ },
347
347
  );
348
348
 
349
349
  const priceBefore = quoteVaultBalance
@@ -383,7 +383,7 @@ export function calculateSwapSellPreview(
383
383
  */
384
384
  async function fetchCurveGlobalConfig(
385
385
  connection: Connection,
386
- config: LiquidConfig
386
+ config: LiquidConfig,
387
387
  ): Promise<
388
388
  CurvePreviewState["globalConfig"] & { initialVirtualReserveUsd: BN }
389
389
  > {
@@ -414,7 +414,7 @@ async function resolveNativeCurve(
414
414
  connection: Connection,
415
415
  mint: PublicKey,
416
416
  options: NativeCurveOptions,
417
- config: LiquidConfig
417
+ config: LiquidConfig,
418
418
  ): Promise<CurvePreviewState> {
419
419
  const pre = options.prefetched;
420
420
 
@@ -427,7 +427,7 @@ async function resolveNativeCurve(
427
427
 
428
428
  const virtualSolReserves = calculateVirtualSolReserves(
429
429
  BigInt(globalConfig.initialVirtualReserveUsd!.toString()),
430
- BigInt(options.solPriceUsd.toString())
430
+ BigInt(options.solPriceUsd.toString()),
431
431
  );
432
432
 
433
433
  const bondingCurve = pre?.bondingCurve ?? {
@@ -456,7 +456,7 @@ async function resolveStableCurve(
456
456
  connection: Connection,
457
457
  mint: PublicKey,
458
458
  options: StableCurveOptions,
459
- config: LiquidConfig
459
+ config: LiquidConfig,
460
460
  ): Promise<CurvePreviewState> {
461
461
  const pre = options.prefetched;
462
462
 
@@ -468,8 +468,8 @@ async function resolveStableCurve(
468
468
  connection,
469
469
  mint,
470
470
  options.quoteMint,
471
- config
472
- ),
471
+ config,
472
+ ),
473
473
  ]);
474
474
 
475
475
  const bondingCurve = pre?.bondingCurve ?? {
@@ -495,21 +495,21 @@ function resolveCurveState(
495
495
  connection: Connection,
496
496
  mint: PublicKey,
497
497
  config: LiquidConfig,
498
- options: CurveAsyncOptions
498
+ options: CurveAsyncOptions,
499
499
  ): Promise<CurvePreviewState> {
500
500
  if (options.quoteMint) {
501
501
  return resolveStableCurve(
502
502
  connection,
503
503
  mint,
504
504
  options as StableCurveOptions,
505
- config
505
+ config,
506
506
  );
507
507
  }
508
508
  return resolveNativeCurve(
509
509
  connection,
510
510
  mint,
511
511
  options as NativeCurveOptions,
512
- config
512
+ config,
513
513
  );
514
514
  }
515
515
 
@@ -548,7 +548,7 @@ export async function previewBuyOnCurve(
548
548
  mint: PublicKey,
549
549
  amountInQuote: BN,
550
550
  config: LiquidConfig,
551
- options: CurveAsyncOptions
551
+ options: CurveAsyncOptions,
552
552
  ): Promise<BuyCurvePreview> {
553
553
  const state = await resolveCurveState(connection, mint, config, options);
554
554
  return calculateBuyCurvePreview(amountInQuote, state, {
@@ -584,7 +584,7 @@ export async function previewSellOnCurve(
584
584
  mint: PublicKey,
585
585
  amountInTokens: BN,
586
586
  config: LiquidConfig,
587
- options: CurveAsyncOptions
587
+ options: CurveAsyncOptions,
588
588
  ): Promise<SellCurvePreview> {
589
589
  const state = await resolveCurveState(connection, mint, config, options);
590
590
  return calculateSellCurvePreview(amountInTokens, state, {
@@ -617,7 +617,7 @@ export async function previewSwapSell(
617
617
  quoteMint: PublicKey,
618
618
  amountIn: BN,
619
619
  config: LiquidConfig,
620
- options?: { prefetched?: SwapPrefetchedState; solPriceUsd?: BN }
620
+ options?: { prefetched?: SwapPrefetchedState; solPriceUsd?: BN },
621
621
  ): Promise<SwapPreview> {
622
622
  const pre = options?.prefetched;
623
623
 
@@ -638,13 +638,13 @@ export async function previewSwapSell(
638
638
  connection,
639
639
  poolState.baseVault,
640
640
  "confirmed",
641
- poolState.baseTokenProgram
641
+ poolState.baseTokenProgram,
642
642
  ),
643
643
  getAccount(
644
644
  connection,
645
645
  poolState.quoteVault,
646
646
  "confirmed",
647
- poolState.quoteTokenProgram
647
+ poolState.quoteTokenProgram,
648
648
  ),
649
649
  ]);
650
650
  baseVaultBalance = new BN(baseVaultAccount.amount.toString());
@@ -668,7 +668,7 @@ export async function previewSwapSell(
668
668
  connection,
669
669
  poolState.baseMint,
670
670
  "confirmed",
671
- poolState.baseTokenProgram
671
+ poolState.baseTokenProgram,
672
672
  );
673
673
  const baseTotalSupply = new BN(baseMintAccount.supply.toString());
674
674
 
@@ -680,13 +680,13 @@ export async function previewSwapSell(
680
680
  baseTotalSupply,
681
681
  options.solPriceUsd,
682
682
  poolState.quoteMint,
683
- tiers
683
+ tiers,
684
684
  );
685
685
 
686
686
  feeRates = { lpFeeRate, protocolFeeRate, creatorFeeRate };
687
687
  } else {
688
688
  throw new Error(
689
- "Either prefetched.feeRates or solPriceUsd must be provided for tiered fee calculations"
689
+ "Either prefetched.feeRates or solPriceUsd must be provided for tiered fee calculations",
690
690
  );
691
691
  }
692
692
 
@@ -721,7 +721,7 @@ export async function previewSwapBuy(
721
721
  quoteMint: PublicKey,
722
722
  amountOut: BN,
723
723
  config: LiquidConfig,
724
- options?: { prefetched?: SwapPrefetchedState; solPriceUsd?: BN }
724
+ options?: { prefetched?: SwapPrefetchedState; solPriceUsd?: BN },
725
725
  ): Promise<SwapPreview> {
726
726
  const pre = options?.prefetched;
727
727
 
@@ -742,13 +742,13 @@ export async function previewSwapBuy(
742
742
  connection,
743
743
  poolState.baseVault,
744
744
  "confirmed",
745
- poolState.baseTokenProgram
745
+ poolState.baseTokenProgram,
746
746
  ),
747
747
  getAccount(
748
748
  connection,
749
749
  poolState.quoteVault,
750
750
  "confirmed",
751
- poolState.quoteTokenProgram
751
+ poolState.quoteTokenProgram,
752
752
  ),
753
753
  ]);
754
754
  baseVaultBalance = new BN(baseVaultAccount.amount.toString());
@@ -772,7 +772,7 @@ export async function previewSwapBuy(
772
772
  connection,
773
773
  poolState.baseMint,
774
774
  "confirmed",
775
- poolState.baseTokenProgram
775
+ poolState.baseTokenProgram,
776
776
  );
777
777
  const baseTotalSupply = new BN(baseMintAccount.supply.toString());
778
778
 
@@ -784,13 +784,13 @@ export async function previewSwapBuy(
784
784
  baseTotalSupply,
785
785
  options.solPriceUsd,
786
786
  poolState.quoteMint,
787
- tiers
787
+ tiers,
788
788
  );
789
789
 
790
790
  feeRates = { lpFeeRate, protocolFeeRate, creatorFeeRate };
791
791
  } else {
792
792
  throw new Error(
793
- "Either prefetched.feeRates or solPriceUsd must be provided for tiered fee calculations"
793
+ "Either prefetched.feeRates or solPriceUsd must be provided for tiered fee calculations",
794
794
  );
795
795
  }
796
796
 
@@ -11,7 +11,7 @@ import { TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID } from "@solana/spl-token";
11
11
  */
12
12
  export const resolveTokenProgram = async (
13
13
  connection: Connection,
14
- mint: PublicKey
14
+ mint: PublicKey,
15
15
  ): Promise<PublicKey> => {
16
16
  const account = await connection.getAccountInfo(mint);
17
17
  if (!account) {
package/src/idl/index.ts CHANGED
@@ -2,6 +2,7 @@ import { Program } from "@coral-xyz/anchor";
2
2
  import { Connection } from "@solana/web3.js";
3
3
  import type { LiquidConfig } from "../config.js";
4
4
  import { createReadonlyProvider } from "../provider.js";
5
+ import { patchIdl } from "./patch-idl.js";
5
6
 
6
7
  import liquidIdl from "./liquid.json" with { type: "json" };
7
8
  import liquidSwapIdl from "./liquid_swap.json" with { type: "json" };
@@ -9,6 +10,7 @@ import liquidFeesIdl from "./liquid_fees.json" with { type: "json" };
9
10
  import liquidStateIdl from "./liquid_state.json" with { type: "json" };
10
11
 
11
12
  export { liquidIdl, liquidSwapIdl, liquidFeesIdl, liquidStateIdl };
13
+ export { patchIdl } from "./patch-idl.js";
12
14
 
13
15
  // Re-export Anchor-generated IDL types
14
16
  export type { Liquid } from "./liquid.js";
@@ -31,10 +33,13 @@ import type { LiquidState } from "./liquid_state.js";
31
33
  */
32
34
  export function getLiquidProgram(
33
35
  connection: Connection,
34
- config?: LiquidConfig
36
+ config?: LiquidConfig,
35
37
  ): Program<Liquid> {
36
38
  const idl = config
37
- ? { ...liquidIdl, address: config.liquidProgramId.toBase58() }
39
+ ? patchIdl(
40
+ { ...liquidIdl, address: config.liquidProgramId.toBase58() },
41
+ config,
42
+ )
38
43
  : liquidIdl;
39
44
  return new Program(idl as Liquid, createReadonlyProvider(connection));
40
45
  }
@@ -49,10 +54,16 @@ export function getLiquidProgram(
49
54
  */
50
55
  export function getLiquidSwapProgram(
51
56
  connection: Connection,
52
- config?: LiquidConfig
57
+ config?: LiquidConfig,
53
58
  ): Program<LiquidSwap> {
54
59
  const idl = config
55
- ? { ...liquidSwapIdl, address: config.liquidSwapProgramId.toBase58() }
60
+ ? patchIdl(
61
+ {
62
+ ...liquidSwapIdl,
63
+ address: config.liquidSwapProgramId.toBase58(),
64
+ },
65
+ config,
66
+ )
56
67
  : liquidSwapIdl;
57
68
  return new Program(idl as LiquidSwap, createReadonlyProvider(connection));
58
69
  }
@@ -67,10 +78,16 @@ export function getLiquidSwapProgram(
67
78
  */
68
79
  export function getLiquidFeesProgram(
69
80
  connection: Connection,
70
- config?: LiquidConfig
81
+ config?: LiquidConfig,
71
82
  ): Program<LiquidFees> {
72
83
  const idl = config
73
- ? { ...liquidFeesIdl, address: config.liquidFeesProgramId.toBase58() }
84
+ ? patchIdl(
85
+ {
86
+ ...liquidFeesIdl,
87
+ address: config.liquidFeesProgramId.toBase58(),
88
+ },
89
+ config,
90
+ )
74
91
  : liquidFeesIdl;
75
92
  return new Program(idl as LiquidFees, createReadonlyProvider(connection));
76
93
  }
@@ -85,10 +102,16 @@ export function getLiquidFeesProgram(
85
102
  */
86
103
  export function getLiquidStateProgram(
87
104
  connection: Connection,
88
- config?: LiquidConfig
105
+ config?: LiquidConfig,
89
106
  ): Program<LiquidState> {
90
107
  const idl = config
91
- ? { ...liquidStateIdl, address: config.liquidStateProgramId.toBase58() }
108
+ ? patchIdl(
109
+ {
110
+ ...liquidStateIdl,
111
+ address: config.liquidStateProgramId.toBase58(),
112
+ },
113
+ config,
114
+ )
92
115
  : liquidStateIdl;
93
116
  return new Program(idl as LiquidState, createReadonlyProvider(connection));
94
117
  }