@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.d.mts CHANGED
@@ -731,9 +731,9 @@ declare function buildWithdraw(user: PublicKey, configPda: PublicKey, mintX: Pub
731
731
  * user_source, vault_source, vault_dest, user_dest, fee_config,
732
732
  * fee_recipient_ata, clock, curve_updates.
733
733
  *
734
- * Optional (for introspection): spread_config, instructions_sysvar.
734
+ * When spread config is initialized: spread_config (#16) + instructions_sysvar (#17).
735
735
  */
736
- declare function buildSwapExactIn(user: PublicKey, poolAddresses: PoolAddresses, mintX: PublicKey, mintY: PublicKey, tokenProgramX: PublicKey, tokenProgramY: PublicKey, params: SwapParams, programId?: PublicKey): TransactionInstruction;
736
+ declare function buildSwapExactIn(user: PublicKey, poolAddresses: PoolAddresses, mintX: PublicKey, mintY: PublicKey, tokenProgramX: PublicKey, tokenProgramY: PublicKey, params: SwapParams, programId?: PublicKey, spreadConfigInitialized?: boolean): TransactionInstruction;
737
737
 
738
738
  /**
739
739
  * Build a SetCurve instruction (price curve).
package/dist/index.d.ts CHANGED
@@ -731,9 +731,9 @@ declare function buildWithdraw(user: PublicKey, configPda: PublicKey, mintX: Pub
731
731
  * user_source, vault_source, vault_dest, user_dest, fee_config,
732
732
  * fee_recipient_ata, clock, curve_updates.
733
733
  *
734
- * Optional (for introspection): spread_config, instructions_sysvar.
734
+ * When spread config is initialized: spread_config (#16) + instructions_sysvar (#17).
735
735
  */
736
- declare function buildSwapExactIn(user: PublicKey, poolAddresses: PoolAddresses, mintX: PublicKey, mintY: PublicKey, tokenProgramX: PublicKey, tokenProgramY: PublicKey, params: SwapParams, programId?: PublicKey): TransactionInstruction;
736
+ declare function buildSwapExactIn(user: PublicKey, poolAddresses: PoolAddresses, mintX: PublicKey, mintY: PublicKey, tokenProgramX: PublicKey, tokenProgramY: PublicKey, params: SwapParams, programId?: PublicKey, spreadConfigInitialized?: boolean): TransactionInstruction;
737
737
 
738
738
  /**
739
739
  * Build a SetCurve instruction (price curve).
package/dist/index.js CHANGED
@@ -596,7 +596,8 @@ function buildWithdraw(user, configPda, mintX, mintY, tokenProgramX, tokenProgra
596
596
 
597
597
 
598
598
 
599
- function buildSwapExactIn(user, poolAddresses, mintX, mintY, tokenProgramX, tokenProgramY, params, programId = HADRON_PROGRAM_ID) {
599
+
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: _web3js.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: _web3js.SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false }
664
+ );
665
+ }
624
666
  return new (0, _web3js.TransactionInstruction)({
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: _web3js.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. */