@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.
- package/dist/client.d.ts +0 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -5
- package/dist/client.js.map +1 -1
- package/dist/helpers/ata.d.ts +28 -0
- package/dist/helpers/ata.d.ts.map +1 -0
- package/dist/helpers/ata.js +29 -0
- package/dist/helpers/ata.js.map +1 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/index.js.map +1 -1
- package/dist/idl/liquid.d.ts +27 -663
- package/dist/idl/liquid.d.ts.map +1 -1
- package/dist/idl/liquid.json +37 -673
- package/dist/idl/liquid_fees.d.ts +0 -86
- package/dist/idl/liquid_fees.d.ts.map +1 -1
- package/dist/idl/liquid_fees.json +1 -87
- package/dist/idl/liquid_state.d.ts +18 -5
- package/dist/idl/liquid_state.d.ts.map +1 -1
- package/dist/idl/liquid_state.json +18 -5
- package/dist/instructions/index.d.ts +2 -2
- package/dist/instructions/index.d.ts.map +1 -1
- package/dist/instructions/index.js +1 -1
- package/dist/instructions/index.js.map +1 -1
- package/dist/instructions/liquid-fees.d.ts +1 -0
- package/dist/instructions/liquid-fees.d.ts.map +1 -1
- package/dist/instructions/liquid-fees.js +4 -1
- package/dist/instructions/liquid-fees.js.map +1 -1
- package/dist/instructions/liquid-state.d.ts +0 -13
- package/dist/instructions/liquid-state.d.ts.map +1 -1
- package/dist/instructions/liquid-state.js +0 -15
- package/dist/instructions/liquid-state.js.map +1 -1
- package/dist/instructions/liquid.d.ts +12 -0
- package/dist/instructions/liquid.d.ts.map +1 -1
- package/dist/instructions/liquid.js +45 -9
- package/dist/instructions/liquid.js.map +1 -1
- package/dist/types.d.ts +6 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +0 -8
- package/src/helpers/ata.ts +44 -0
- package/src/helpers/index.ts +1 -0
- package/src/idl/liquid.json +37 -673
- package/src/idl/liquid.ts +37 -673
- package/src/idl/liquid_fees.json +1 -87
- package/src/idl/liquid_fees.ts +1 -87
- package/src/idl/liquid_state.json +18 -5
- package/src/idl/liquid_state.ts +18 -5
- package/src/instructions/index.ts +0 -2
- package/src/instructions/liquid-fees.ts +8 -1
- package/src/instructions/liquid-state.ts +0 -25
- package/src/instructions/liquid.ts +81 -0
- 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
|
+
}
|
package/src/helpers/index.ts
CHANGED