@liquid-af/sdk 0.8.2 → 0.9.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 (54) hide show
  1. package/dist/client.d.ts +0 -5
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +1 -5
  4. package/dist/client.js.map +1 -1
  5. package/dist/helpers/ata.d.ts +28 -0
  6. package/dist/helpers/ata.d.ts.map +1 -0
  7. package/dist/helpers/ata.js +29 -0
  8. package/dist/helpers/ata.js.map +1 -0
  9. package/dist/helpers/index.d.ts +1 -0
  10. package/dist/helpers/index.d.ts.map +1 -1
  11. package/dist/helpers/index.js +1 -0
  12. package/dist/helpers/index.js.map +1 -1
  13. package/dist/idl/liquid.d.ts +27 -663
  14. package/dist/idl/liquid.d.ts.map +1 -1
  15. package/dist/idl/liquid.json +37 -673
  16. package/dist/idl/liquid_fees.d.ts +0 -86
  17. package/dist/idl/liquid_fees.d.ts.map +1 -1
  18. package/dist/idl/liquid_fees.json +1 -87
  19. package/dist/idl/liquid_state.d.ts +18 -5
  20. package/dist/idl/liquid_state.d.ts.map +1 -1
  21. package/dist/idl/liquid_state.json +18 -5
  22. package/dist/instructions/index.d.ts +2 -2
  23. package/dist/instructions/index.d.ts.map +1 -1
  24. package/dist/instructions/index.js +1 -1
  25. package/dist/instructions/index.js.map +1 -1
  26. package/dist/instructions/liquid-fees.d.ts +1 -0
  27. package/dist/instructions/liquid-fees.d.ts.map +1 -1
  28. package/dist/instructions/liquid-fees.js +4 -1
  29. package/dist/instructions/liquid-fees.js.map +1 -1
  30. package/dist/instructions/liquid-state.d.ts +0 -13
  31. package/dist/instructions/liquid-state.d.ts.map +1 -1
  32. package/dist/instructions/liquid-state.js +0 -15
  33. package/dist/instructions/liquid-state.js.map +1 -1
  34. package/dist/instructions/liquid.d.ts +12 -0
  35. package/dist/instructions/liquid.d.ts.map +1 -1
  36. package/dist/instructions/liquid.js +45 -9
  37. package/dist/instructions/liquid.js.map +1 -1
  38. package/dist/types.d.ts +6 -3
  39. package/dist/types.d.ts.map +1 -1
  40. package/package.json +1 -1
  41. package/src/client.ts +0 -8
  42. package/src/helpers/ata.ts +44 -0
  43. package/src/helpers/index.ts +1 -0
  44. package/src/idl/liquid.json +37 -673
  45. package/src/idl/liquid.ts +37 -673
  46. package/src/idl/liquid_fees.json +1 -87
  47. package/src/idl/liquid_fees.ts +1 -87
  48. package/src/idl/liquid_state.json +18 -5
  49. package/src/idl/liquid_state.ts +18 -5
  50. package/src/instructions/index.ts +0 -2
  51. package/src/instructions/liquid-fees.ts +8 -1
  52. package/src/instructions/liquid-state.ts +0 -25
  53. package/src/instructions/liquid.ts +81 -0
  54. package/src/types.ts +6 -3
package/src/client.ts CHANGED
@@ -58,7 +58,6 @@ import {
58
58
  } from "./instructions/liquid-fees.js";
59
59
  import {
60
60
  buildInitializeUser,
61
- buildSetReferrer,
62
61
  buildSetCashbackMode,
63
62
  buildRedeemDeal,
64
63
  } from "./instructions/liquid-state.js";
@@ -727,13 +726,6 @@ export class LiquidClient {
727
726
  return buildInitializeUser({ ...params, config: this.config });
728
727
  }
729
728
 
730
- /** Builds a setReferrer instruction. One-time operation — referrer cannot be changed. */
731
- buildSetReferrer(params: {
732
- user: PublicKey;
733
- referrer: PublicKey;
734
- }): Promise<TransactionInstruction> {
735
- return buildSetReferrer({ ...params, config: this.config });
736
- }
737
729
 
738
730
  /** Builds a setCashbackMode instruction. Toggles between earning and spending mode. */
739
731
  buildSetCashbackMode(params: {
@@ -0,0 +1,44 @@
1
+ import {
2
+ createAssociatedTokenAccountIdempotentInstruction,
3
+ getAssociatedTokenAddressSync,
4
+ } from "@solana/spl-token";
5
+ import type { PublicKey, TransactionInstruction } from "@solana/web3.js";
6
+
7
+ /**
8
+ * Builds an instruction that creates the ATA for `owner` idempotently.
9
+ * Safe to include even if the ATA already exists — it becomes a no-op on-chain.
10
+ *
11
+ * Use this to ensure the user's token account exists before calling a buy
12
+ * instruction, since the on-chain program no longer auto-creates it.
13
+ *
14
+ * @param payer - Rent payer for account creation
15
+ * @param owner - Token account owner (wallet)
16
+ * @param mint - Token mint
17
+ * @param tokenProgram - TOKEN_PROGRAM_ID or TOKEN_2022_PROGRAM_ID
18
+ * @returns `{ ata, instruction }` — the derived ATA address and the init instruction
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const { ata, instruction: ataIx } = buildEnsureAtaInstruction(
23
+ * payer, user, mint, TOKEN_2022_PROGRAM_ID,
24
+ * );
25
+ * const buyIx = await buildBuyExactInNative({ ..., userTokenAccount: ata });
26
+ * await sendTransaction([ataIx, buyIx], ...);
27
+ * ```
28
+ */
29
+ export function buildEnsureAtaInstruction(
30
+ payer: PublicKey,
31
+ owner: PublicKey,
32
+ mint: PublicKey,
33
+ tokenProgram: PublicKey,
34
+ ): { ata: PublicKey; instruction: TransactionInstruction } {
35
+ const ata = getAssociatedTokenAddressSync(mint, owner, false, tokenProgram);
36
+ const instruction = createAssociatedTokenAccountIdempotentInstruction(
37
+ payer,
38
+ ata,
39
+ owner,
40
+ mint,
41
+ tokenProgram,
42
+ );
43
+ return { ata, instruction };
44
+ }
@@ -21,3 +21,4 @@ export type {
21
21
  } from "./preview.js";
22
22
 
23
23
  export { resolveTokenProgram } from "./user.js";
24
+ export { buildEnsureAtaInstruction } from "./ata.js";