@hadron-fi/sdk 0.3.1 → 0.3.2

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/dist/index.mjs CHANGED
@@ -593,10 +593,11 @@ function buildWithdraw(user, configPda, mintX, mintY, tokenProgramX, tokenProgra
593
593
  // src/instructions/swap.ts
594
594
  import {
595
595
  SYSVAR_CLOCK_PUBKEY,
596
+ SYSVAR_INSTRUCTIONS_PUBKEY,
596
597
  TransactionInstruction as TransactionInstruction4
597
598
  } from "@solana/web3.js";
598
599
  import { getAssociatedTokenAddressSync as getAssociatedTokenAddressSync4 } from "@solana/spl-token";
599
- function buildSwapExactIn(user, poolAddresses, mintX, mintY, tokenProgramX, tokenProgramY, params, programId = HADRON_PROGRAM_ID) {
600
+ function buildSwapExactIn(user, poolAddresses, mintX, mintY, tokenProgramX, tokenProgramY, params, programId = HADRON_PROGRAM_ID, spreadConfigInitialized = false) {
600
601
  const data = Buffer.alloc(1 + 1 + 8 + 8 + 8);
601
602
  let offset = 0;
602
603
  data.writeUInt8(Discriminator.SwapExactIn, offset);
@@ -621,39 +622,50 @@ function buildSwapExactIn(user, poolAddresses, mintX, mintY, tokenProgramX, toke
621
622
  false,
622
623
  inputMintProgram
623
624
  );
625
+ const keys = [
626
+ { pubkey: tokenProgramX, isSigner: false, isWritable: false },
627
+ { pubkey: tokenProgramY, isSigner: false, isWritable: false },
628
+ { pubkey: poolAddresses.config, isSigner: false, isWritable: false },
629
+ {
630
+ pubkey: poolAddresses.midpriceOracle,
631
+ isSigner: false,
632
+ isWritable: false
633
+ },
634
+ { pubkey: poolAddresses.curveMeta, isSigner: false, isWritable: false },
635
+ {
636
+ pubkey: poolAddresses.curvePrefabs,
637
+ isSigner: false,
638
+ isWritable: true
639
+ },
640
+ { pubkey: poolAddresses.config, isSigner: false, isWritable: false },
641
+ // authority = pool address PDA
642
+ { pubkey: user, isSigner: true, isWritable: false },
643
+ { pubkey: userSource, isSigner: false, isWritable: true },
644
+ { pubkey: vaultSource, isSigner: false, isWritable: true },
645
+ { pubkey: vaultDest, isSigner: false, isWritable: true },
646
+ { pubkey: userDest, isSigner: false, isWritable: true },
647
+ { pubkey: feeConfigPda, isSigner: false, isWritable: false },
648
+ { pubkey: feeRecipientAta, isSigner: false, isWritable: true },
649
+ { pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false },
650
+ {
651
+ pubkey: poolAddresses.curveUpdates,
652
+ isSigner: false,
653
+ isWritable: true
654
+ }
655
+ ];
656
+ if (spreadConfigInitialized) {
657
+ const [spreadConfigPda] = getSpreadConfigAddress(
658
+ poolAddresses.config,
659
+ programId
660
+ );
661
+ keys.push(
662
+ { pubkey: spreadConfigPda, isSigner: false, isWritable: false },
663
+ { pubkey: SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false }
664
+ );
665
+ }
624
666
  return new TransactionInstruction4({
625
667
  programId,
626
- keys: [
627
- { pubkey: tokenProgramX, isSigner: false, isWritable: false },
628
- { pubkey: tokenProgramY, isSigner: false, isWritable: false },
629
- { pubkey: poolAddresses.config, isSigner: false, isWritable: false },
630
- {
631
- pubkey: poolAddresses.midpriceOracle,
632
- isSigner: false,
633
- isWritable: false
634
- },
635
- { pubkey: poolAddresses.curveMeta, isSigner: false, isWritable: false },
636
- {
637
- pubkey: poolAddresses.curvePrefabs,
638
- isSigner: false,
639
- isWritable: true
640
- },
641
- { pubkey: poolAddresses.config, isSigner: false, isWritable: false },
642
- // authority = pool address PDA
643
- { pubkey: user, isSigner: true, isWritable: false },
644
- { pubkey: userSource, isSigner: false, isWritable: true },
645
- { pubkey: vaultSource, isSigner: false, isWritable: true },
646
- { pubkey: vaultDest, isSigner: false, isWritable: true },
647
- { pubkey: userDest, isSigner: false, isWritable: true },
648
- { pubkey: feeConfigPda, isSigner: false, isWritable: false },
649
- { pubkey: feeRecipientAta, isSigner: false, isWritable: true },
650
- { pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false },
651
- {
652
- pubkey: poolAddresses.curveUpdates,
653
- isSigner: false,
654
- isWritable: true
655
- }
656
- ],
668
+ keys,
657
669
  data
658
670
  });
659
671
  }
@@ -1375,7 +1387,8 @@ var Hadron = class _Hadron {
1375
1387
  this.config.tokenProgramX,
1376
1388
  this.config.tokenProgramY,
1377
1389
  params,
1378
- this.programId
1390
+ this.programId,
1391
+ this.config.spreadConfigInitialized
1379
1392
  );
1380
1393
  }
1381
1394
  /** Build set curve instruction. */