@liquid-af/sdk 0.8.1 → 0.9.0

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.
@@ -0,0 +1,28 @@
1
+ import type { PublicKey, TransactionInstruction } from "@solana/web3.js";
2
+ /**
3
+ * Builds an instruction that creates the ATA for `owner` idempotently.
4
+ * Safe to include even if the ATA already exists — it becomes a no-op on-chain.
5
+ *
6
+ * Use this to ensure the user's token account exists before calling a buy
7
+ * instruction, since the on-chain program no longer auto-creates it.
8
+ *
9
+ * @param payer - Rent payer for account creation
10
+ * @param owner - Token account owner (wallet)
11
+ * @param mint - Token mint
12
+ * @param tokenProgram - TOKEN_PROGRAM_ID or TOKEN_2022_PROGRAM_ID
13
+ * @returns `{ ata, instruction }` — the derived ATA address and the init instruction
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const { ata, instruction: ataIx } = buildEnsureAtaInstruction(
18
+ * payer, user, mint, TOKEN_2022_PROGRAM_ID,
19
+ * );
20
+ * const buyIx = await buildBuyExactInNative({ ..., userTokenAccount: ata });
21
+ * await sendTransaction([ataIx, buyIx], ...);
22
+ * ```
23
+ */
24
+ export declare function buildEnsureAtaInstruction(payer: PublicKey, owner: PublicKey, mint: PublicKey, tokenProgram: PublicKey): {
25
+ ata: PublicKey;
26
+ instruction: TransactionInstruction;
27
+ };
28
+ //# sourceMappingURL=ata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ata.d.ts","sourceRoot":"","sources":["../../src/helpers/ata.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,yBAAyB,CACxC,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,SAAS,EACf,YAAY,EAAE,SAAS,GACrB;IAAE,GAAG,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,sBAAsB,CAAA;CAAE,CAUzD"}
@@ -0,0 +1,29 @@
1
+ import { createAssociatedTokenAccountIdempotentInstruction, getAssociatedTokenAddressSync, } from "@solana/spl-token";
2
+ /**
3
+ * Builds an instruction that creates the ATA for `owner` idempotently.
4
+ * Safe to include even if the ATA already exists — it becomes a no-op on-chain.
5
+ *
6
+ * Use this to ensure the user's token account exists before calling a buy
7
+ * instruction, since the on-chain program no longer auto-creates it.
8
+ *
9
+ * @param payer - Rent payer for account creation
10
+ * @param owner - Token account owner (wallet)
11
+ * @param mint - Token mint
12
+ * @param tokenProgram - TOKEN_PROGRAM_ID or TOKEN_2022_PROGRAM_ID
13
+ * @returns `{ ata, instruction }` — the derived ATA address and the init instruction
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const { ata, instruction: ataIx } = buildEnsureAtaInstruction(
18
+ * payer, user, mint, TOKEN_2022_PROGRAM_ID,
19
+ * );
20
+ * const buyIx = await buildBuyExactInNative({ ..., userTokenAccount: ata });
21
+ * await sendTransaction([ataIx, buyIx], ...);
22
+ * ```
23
+ */
24
+ export function buildEnsureAtaInstruction(payer, owner, mint, tokenProgram) {
25
+ const ata = getAssociatedTokenAddressSync(mint, owner, false, tokenProgram);
26
+ const instruction = createAssociatedTokenAccountIdempotentInstruction(payer, ata, owner, mint, tokenProgram);
27
+ return { ata, instruction };
28
+ }
29
+ //# sourceMappingURL=ata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ata.js","sourceRoot":"","sources":["../../src/helpers/ata.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iDAAiD,EACjD,6BAA6B,GAC7B,MAAM,mBAAmB,CAAC;AAG3B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,yBAAyB,CACxC,KAAgB,EAChB,KAAgB,EAChB,IAAe,EACf,YAAuB;IAEvB,MAAM,GAAG,GAAG,6BAA6B,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IAC5E,MAAM,WAAW,GAAG,iDAAiD,CACpE,KAAK,EACL,GAAG,EACH,KAAK,EACL,IAAI,EACJ,YAAY,CACZ,CAAC;IACF,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC;AAC7B,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export { previewBuyOnCurve, previewSellOnCurve, previewSwapSell, previewSwapBuy, calculateBuyCurvePreview, calculateSellCurvePreview, calculateSwapSellPreview, calculateSwapBuyPreview, } from "./preview.js";
2
2
  export type { CurvePreviewState, SwapPreviewState, CurvePreviewOptions, CurvePrefetchedState, NativeCurveOptions, StableCurveOptions, CurveAsyncOptions, SwapPrefetchedState, } from "./preview.js";
3
3
  export { resolveTokenProgram } from "./user.js";
4
+ export { buildEnsureAtaInstruction } from "./ata.js";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,GACvB,MAAM,cAAc,CAAC;AAEtB,YAAY,EACX,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,GACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,GACvB,MAAM,cAAc,CAAC;AAEtB,YAAY,EACX,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,GACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { previewBuyOnCurve, previewSellOnCurve, previewSwapSell, previewSwapBuy, calculateBuyCurvePreview, calculateSellCurvePreview, calculateSwapSellPreview, calculateSwapBuyPreview, } from "./preview.js";
2
2
  export { resolveTokenProgram } from "./user.js";
3
+ export { buildEnsureAtaInstruction } from "./ata.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,GACvB,MAAM,cAAc,CAAC;AAatB,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,GACvB,MAAM,cAAc,CAAC;AAatB,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC"}