@liquid-af/sdk 0.1.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.
Files changed (225) hide show
  1. package/README.md +776 -0
  2. package/dist/accounts/index.d.ts +5 -0
  3. package/dist/accounts/index.d.ts.map +1 -0
  4. package/dist/accounts/index.js +5 -0
  5. package/dist/accounts/index.js.map +1 -0
  6. package/dist/accounts/liquid-fees.d.ts +63 -0
  7. package/dist/accounts/liquid-fees.d.ts.map +1 -0
  8. package/dist/accounts/liquid-fees.js +27 -0
  9. package/dist/accounts/liquid-fees.js.map +1 -0
  10. package/dist/accounts/liquid-state.d.ts +112 -0
  11. package/dist/accounts/liquid-state.d.ts.map +1 -0
  12. package/dist/accounts/liquid-state.js +92 -0
  13. package/dist/accounts/liquid-state.js.map +1 -0
  14. package/dist/accounts/liquid-swap.d.ts +97 -0
  15. package/dist/accounts/liquid-swap.d.ts.map +1 -0
  16. package/dist/accounts/liquid-swap.js +54 -0
  17. package/dist/accounts/liquid-swap.js.map +1 -0
  18. package/dist/accounts/liquid.d.ts +175 -0
  19. package/dist/accounts/liquid.d.ts.map +1 -0
  20. package/dist/accounts/liquid.js +66 -0
  21. package/dist/accounts/liquid.js.map +1 -0
  22. package/dist/client.d.ts +621 -0
  23. package/dist/client.d.ts.map +1 -0
  24. package/dist/client.js +511 -0
  25. package/dist/client.js.map +1 -0
  26. package/dist/config.d.ts +56 -0
  27. package/dist/config.d.ts.map +1 -0
  28. package/dist/config.js +44 -0
  29. package/dist/config.js.map +1 -0
  30. package/dist/errors.d.ts +39 -0
  31. package/dist/errors.d.ts.map +1 -0
  32. package/dist/errors.js +63 -0
  33. package/dist/errors.js.map +1 -0
  34. package/dist/events/index.d.ts +4 -0
  35. package/dist/events/index.d.ts.map +1 -0
  36. package/dist/events/index.js +2 -0
  37. package/dist/events/index.js.map +1 -0
  38. package/dist/events/parser.d.ts +40 -0
  39. package/dist/events/parser.d.ts.map +1 -0
  40. package/dist/events/parser.js +67 -0
  41. package/dist/events/parser.js.map +1 -0
  42. package/dist/events/types.d.ts +286 -0
  43. package/dist/events/types.d.ts.map +1 -0
  44. package/dist/events/types.js +2 -0
  45. package/dist/events/types.js.map +1 -0
  46. package/dist/helpers/index.d.ts +4 -0
  47. package/dist/helpers/index.d.ts.map +1 -0
  48. package/dist/helpers/index.js +3 -0
  49. package/dist/helpers/index.js.map +1 -0
  50. package/dist/helpers/preview.d.ts +259 -0
  51. package/dist/helpers/preview.d.ts.map +1 -0
  52. package/dist/helpers/preview.js +458 -0
  53. package/dist/helpers/preview.js.map +1 -0
  54. package/dist/helpers/user.d.ts +11 -0
  55. package/dist/helpers/user.d.ts.map +1 -0
  56. package/dist/helpers/user.js +20 -0
  57. package/dist/helpers/user.js.map +1 -0
  58. package/dist/idl/index.d.ts +53 -0
  59. package/dist/idl/index.d.ts.map +1 -0
  60. package/dist/idl/index.js +64 -0
  61. package/dist/idl/index.js.map +1 -0
  62. package/dist/idl/liquid.d.ts +10523 -0
  63. package/dist/idl/liquid.d.ts.map +1 -0
  64. package/dist/idl/liquid.js +2 -0
  65. package/dist/idl/liquid.js.map +1 -0
  66. package/dist/idl/liquid.json +10516 -0
  67. package/dist/idl/liquid_fees.d.ts +1520 -0
  68. package/dist/idl/liquid_fees.d.ts.map +1 -0
  69. package/dist/idl/liquid_fees.js +2 -0
  70. package/dist/idl/liquid_fees.js.map +1 -0
  71. package/dist/idl/liquid_fees.json +1513 -0
  72. package/dist/idl/liquid_state.d.ts +2936 -0
  73. package/dist/idl/liquid_state.d.ts.map +1 -0
  74. package/dist/idl/liquid_state.js +2 -0
  75. package/dist/idl/liquid_state.js.map +1 -0
  76. package/dist/idl/liquid_state.json +2929 -0
  77. package/dist/idl/liquid_swap.d.ts +5849 -0
  78. package/dist/idl/liquid_swap.d.ts.map +1 -0
  79. package/dist/idl/liquid_swap.js +2 -0
  80. package/dist/idl/liquid_swap.js.map +1 -0
  81. package/dist/idl/liquid_swap.json +5842 -0
  82. package/dist/index.d.ts +19 -0
  83. package/dist/index.d.ts.map +1 -0
  84. package/dist/index.js +15 -0
  85. package/dist/index.js.map +1 -0
  86. package/dist/instructions/index.d.ts +9 -0
  87. package/dist/instructions/index.d.ts.map +1 -0
  88. package/dist/instructions/index.js +9 -0
  89. package/dist/instructions/index.js.map +1 -0
  90. package/dist/instructions/liquid-fees.d.ts +111 -0
  91. package/dist/instructions/liquid-fees.d.ts.map +1 -0
  92. package/dist/instructions/liquid-fees.js +169 -0
  93. package/dist/instructions/liquid-fees.js.map +1 -0
  94. package/dist/instructions/liquid-state.d.ts +173 -0
  95. package/dist/instructions/liquid-state.d.ts.map +1 -0
  96. package/dist/instructions/liquid-state.js +194 -0
  97. package/dist/instructions/liquid-state.js.map +1 -0
  98. package/dist/instructions/liquid-swap.d.ts +122 -0
  99. package/dist/instructions/liquid-swap.d.ts.map +1 -0
  100. package/dist/instructions/liquid-swap.js +167 -0
  101. package/dist/instructions/liquid-swap.js.map +1 -0
  102. package/dist/instructions/liquid.d.ts +297 -0
  103. package/dist/instructions/liquid.d.ts.map +1 -0
  104. package/dist/instructions/liquid.js +483 -0
  105. package/dist/instructions/liquid.js.map +1 -0
  106. package/dist/instructions/program-cache.d.ts +35 -0
  107. package/dist/instructions/program-cache.d.ts.map +1 -0
  108. package/dist/instructions/program-cache.js +68 -0
  109. package/dist/instructions/program-cache.js.map +1 -0
  110. package/dist/math/amm.d.ts +42 -0
  111. package/dist/math/amm.d.ts.map +1 -0
  112. package/dist/math/amm.js +109 -0
  113. package/dist/math/amm.js.map +1 -0
  114. package/dist/math/bonding-curve.d.ts +34 -0
  115. package/dist/math/bonding-curve.d.ts.map +1 -0
  116. package/dist/math/bonding-curve.js +80 -0
  117. package/dist/math/bonding-curve.js.map +1 -0
  118. package/dist/math/constants.d.ts +14 -0
  119. package/dist/math/constants.d.ts.map +1 -0
  120. package/dist/math/constants.js +14 -0
  121. package/dist/math/constants.js.map +1 -0
  122. package/dist/math/fees.d.ts +88 -0
  123. package/dist/math/fees.d.ts.map +1 -0
  124. package/dist/math/fees.js +135 -0
  125. package/dist/math/fees.js.map +1 -0
  126. package/dist/math/index.d.ts +8 -0
  127. package/dist/math/index.d.ts.map +1 -0
  128. package/dist/math/index.js +6 -0
  129. package/dist/math/index.js.map +1 -0
  130. package/dist/math/tiered-fees.d.ts +80 -0
  131. package/dist/math/tiered-fees.d.ts.map +1 -0
  132. package/dist/math/tiered-fees.js +129 -0
  133. package/dist/math/tiered-fees.js.map +1 -0
  134. package/dist/oracle.d.ts +53 -0
  135. package/dist/oracle.d.ts.map +1 -0
  136. package/dist/oracle.js +70 -0
  137. package/dist/oracle.js.map +1 -0
  138. package/dist/pda/index.d.ts +89 -0
  139. package/dist/pda/index.d.ts.map +1 -0
  140. package/dist/pda/index.js +127 -0
  141. package/dist/pda/index.js.map +1 -0
  142. package/dist/pda/liquid-fees.d.ts +27 -0
  143. package/dist/pda/liquid-fees.d.ts.map +1 -0
  144. package/dist/pda/liquid-fees.js +36 -0
  145. package/dist/pda/liquid-fees.js.map +1 -0
  146. package/dist/pda/liquid-state.d.ts +56 -0
  147. package/dist/pda/liquid-state.d.ts.map +1 -0
  148. package/dist/pda/liquid-state.js +79 -0
  149. package/dist/pda/liquid-state.js.map +1 -0
  150. package/dist/pda/liquid-swap.d.ts +76 -0
  151. package/dist/pda/liquid-swap.d.ts.map +1 -0
  152. package/dist/pda/liquid-swap.js +103 -0
  153. package/dist/pda/liquid-swap.js.map +1 -0
  154. package/dist/pda/liquid.d.ts +67 -0
  155. package/dist/pda/liquid.d.ts.map +1 -0
  156. package/dist/pda/liquid.js +91 -0
  157. package/dist/pda/liquid.js.map +1 -0
  158. package/dist/provider.d.ts +26 -0
  159. package/dist/provider.d.ts.map +1 -0
  160. package/dist/provider.js +47 -0
  161. package/dist/provider.js.map +1 -0
  162. package/dist/transaction/builder.d.ts +30 -0
  163. package/dist/transaction/builder.d.ts.map +1 -0
  164. package/dist/transaction/builder.js +48 -0
  165. package/dist/transaction/builder.js.map +1 -0
  166. package/dist/transaction/index.d.ts +3 -0
  167. package/dist/transaction/index.d.ts.map +1 -0
  168. package/dist/transaction/index.js +3 -0
  169. package/dist/transaction/index.js.map +1 -0
  170. package/dist/transaction/send.d.ts +25 -0
  171. package/dist/transaction/send.d.ts.map +1 -0
  172. package/dist/transaction/send.js +52 -0
  173. package/dist/transaction/send.js.map +1 -0
  174. package/dist/types.d.ts +311 -0
  175. package/dist/types.d.ts.map +1 -0
  176. package/dist/types.js +46 -0
  177. package/dist/types.js.map +1 -0
  178. package/package.json +112 -0
  179. package/src/accounts/index.ts +26 -0
  180. package/src/accounts/liquid-fees.ts +38 -0
  181. package/src/accounts/liquid-state.ts +134 -0
  182. package/src/accounts/liquid-swap.ts +79 -0
  183. package/src/accounts/liquid.ts +100 -0
  184. package/src/client.ts +1001 -0
  185. package/src/config.ts +91 -0
  186. package/src/errors.ts +94 -0
  187. package/src/events/index.ts +42 -0
  188. package/src/events/parser.ts +90 -0
  189. package/src/events/types.ts +310 -0
  190. package/src/helpers/index.ts +23 -0
  191. package/src/helpers/preview.ts +798 -0
  192. package/src/helpers/user.ts +24 -0
  193. package/src/idl/index.ts +94 -0
  194. package/src/idl/liquid.json +10516 -0
  195. package/src/idl/liquid.ts +10522 -0
  196. package/src/idl/liquid_fees.json +1513 -0
  197. package/src/idl/liquid_fees.ts +1519 -0
  198. package/src/idl/liquid_state.json +2929 -0
  199. package/src/idl/liquid_state.ts +2935 -0
  200. package/src/idl/liquid_swap.json +5842 -0
  201. package/src/idl/liquid_swap.ts +5848 -0
  202. package/src/index.ts +98 -0
  203. package/src/instructions/index.ts +109 -0
  204. package/src/instructions/liquid-fees.ts +289 -0
  205. package/src/instructions/liquid-state.ts +336 -0
  206. package/src/instructions/liquid-swap.ts +414 -0
  207. package/src/instructions/liquid.ts +884 -0
  208. package/src/instructions/program-cache.ts +106 -0
  209. package/src/math/amm.ts +146 -0
  210. package/src/math/bonding-curve.ts +122 -0
  211. package/src/math/constants.ts +19 -0
  212. package/src/math/fees.ts +191 -0
  213. package/src/math/index.ts +40 -0
  214. package/src/math/tiered-fees.ts +165 -0
  215. package/src/oracle.ts +97 -0
  216. package/src/pda/index.ts +331 -0
  217. package/src/pda/liquid-fees.ts +58 -0
  218. package/src/pda/liquid-state.ts +123 -0
  219. package/src/pda/liquid-swap.ts +162 -0
  220. package/src/pda/liquid.ts +152 -0
  221. package/src/provider.ts +60 -0
  222. package/src/transaction/builder.ts +80 -0
  223. package/src/transaction/index.ts +6 -0
  224. package/src/transaction/send.ts +72 -0
  225. package/src/types.ts +354 -0
@@ -0,0 +1,259 @@
1
+ import type { Connection, PublicKey } from "@solana/web3.js";
2
+ import BN from "bn.js";
3
+ import type { LiquidConfig } from "../config.js";
4
+ import type { BuyCurvePreview, SellCurvePreview, SwapPreview } from "../types.js";
5
+ /** State needed for bonding curve preview calculations (pure math, no I/O). */
6
+ export interface CurvePreviewState {
7
+ globalConfig: {
8
+ protocolFeeBasisPoints: number;
9
+ creatorFeeBasisPoints: number;
10
+ creatorReferralRewardBasisPoints: number;
11
+ traderReferralRewardBasisPoints: number;
12
+ };
13
+ bondingCurve: {
14
+ virtualQuoteReserves: BN;
15
+ virtualTokenReserves: BN;
16
+ realTokenReserves: BN;
17
+ };
18
+ }
19
+ /** State needed for AMM swap preview calculations (pure math, no I/O). */
20
+ export interface SwapPreviewState {
21
+ ammConfig: {
22
+ lpFeeRate: number;
23
+ creatorFeeRate: number;
24
+ protocolFeeRate: number;
25
+ };
26
+ baseVaultBalance: BN;
27
+ quoteVaultBalance: BN;
28
+ }
29
+ /** Referral options for curve previews. */
30
+ export interface CurvePreviewOptions {
31
+ hasCreatorRef?: boolean;
32
+ hasTraderRef?: boolean;
33
+ }
34
+ /**
35
+ * Optional pre-fetched state for {@link previewBuyOnCurve} / {@link previewSellOnCurve}.
36
+ *
37
+ * Provide any subset to skip the corresponding RPC calls. Omitted fields are
38
+ * fetched automatically from chain.
39
+ */
40
+ export interface CurvePrefetchedState {
41
+ /**
42
+ * Fee configuration from the global config account.
43
+ * Include `initialVirtualReserveUsd` when previewing native curves without
44
+ * a prefetched `bondingCurve` (needed to compute virtual SOL reserves).
45
+ */
46
+ globalConfig?: {
47
+ protocolFeeBasisPoints: number;
48
+ creatorFeeBasisPoints: number;
49
+ creatorReferralRewardBasisPoints: number;
50
+ traderReferralRewardBasisPoints: number;
51
+ initialVirtualReserveUsd?: BN;
52
+ };
53
+ /**
54
+ * Bonding curve reserves.
55
+ * For native curves, `virtualQuoteReserves` must already be oracle-adjusted
56
+ * (i.e. computed via `calculateVirtualSolReserves`).
57
+ */
58
+ bondingCurve?: {
59
+ virtualQuoteReserves: BN;
60
+ virtualTokenReserves: BN;
61
+ realTokenReserves: BN;
62
+ };
63
+ }
64
+ /** Shared options for async bonding curve preview functions. */
65
+ interface CurveOptionsBase {
66
+ /** Pre-fetched state to skip RPC calls. */
67
+ prefetched?: CurvePrefetchedState;
68
+ /** Whether the token creator has an active referral. */
69
+ hasCreatorRef?: boolean;
70
+ /** Whether the trader has an active referral. */
71
+ hasTraderRef?: boolean;
72
+ }
73
+ /**
74
+ * Options for native SOL bonding curve previews.
75
+ *
76
+ * Requires `solPriceUsd` to compute virtual SOL reserves from the on-chain
77
+ * USD-denominated initial reserve value.
78
+ */
79
+ export interface NativeCurveOptions extends CurveOptionsBase {
80
+ quoteMint?: never;
81
+ /** Current SOL price in USD (6 decimals, e.g. 150_000_000 = $150). */
82
+ solPriceUsd: BN;
83
+ }
84
+ /**
85
+ * Options for stable token (e.g. USDC) bonding curve previews.
86
+ *
87
+ * Virtual quote reserves are stored on-chain and fetched automatically.
88
+ */
89
+ export interface StableCurveOptions extends CurveOptionsBase {
90
+ /** Quote token mint address (e.g. USDC mint). */
91
+ quoteMint: PublicKey;
92
+ solPriceUsd?: never;
93
+ }
94
+ /**
95
+ * Options for async bonding curve previews. Discriminated union:
96
+ * - {@link NativeCurveOptions} — native SOL curves (requires `solPriceUsd`)
97
+ * - {@link StableCurveOptions} — stable curves (requires `quoteMint`)
98
+ */
99
+ export type CurveAsyncOptions = NativeCurveOptions | StableCurveOptions;
100
+ /** Pre-fetched state for AMM swap async previews. */
101
+ export interface SwapPrefetchedState {
102
+ /**
103
+ * Pre-computed fee rates.
104
+ * For tiered fee systems, use calculateFeesForPool() to determine the rates
105
+ * before passing them here.
106
+ */
107
+ feeRates?: {
108
+ lpFeeRate: number;
109
+ creatorFeeRate: number;
110
+ protocolFeeRate: number;
111
+ };
112
+ poolState?: {
113
+ baseVault: PublicKey;
114
+ quoteVault: PublicKey;
115
+ baseTokenProgram: PublicKey;
116
+ quoteTokenProgram: PublicKey;
117
+ baseMint: PublicKey;
118
+ quoteMint: PublicKey;
119
+ };
120
+ vaultBalances?: {
121
+ baseVaultBalance: BN;
122
+ quoteVaultBalance: BN;
123
+ };
124
+ baseTotalSupply?: BN;
125
+ }
126
+ /**
127
+ * Previews a buy on the bonding curve from pre-fetched state. The function executes offline using the state being passed in.
128
+ *
129
+ * @param amountInQuote - Quote token amount to spend (lamports for SOL, smallest unit for stables)
130
+ * @param state - Pre-fetched bonding curve and global config state
131
+ * @param options - Optional referral flags
132
+ * @returns Buy preview with tokens out, fees, price impact, and completion flag
133
+ */
134
+ export declare function calculateBuyCurvePreview(amountInQuote: BN, state: CurvePreviewState, options?: CurvePreviewOptions): BuyCurvePreview;
135
+ /**
136
+ * Previews a sell on the bonding curve from pre-fetched state. The function executes offline using the state being passed in.
137
+ *
138
+ * @param amountInTokens - Token amount to sell
139
+ * @param state - Pre-fetched bonding curve and global config state
140
+ * @param options - Optional referral flags
141
+ * @returns Sell preview with quote out, fees, and price impact
142
+ */
143
+ export declare function calculateSellCurvePreview(amountInTokens: BN, state: CurvePreviewState, options?: CurvePreviewOptions): SellCurvePreview;
144
+ /**
145
+ * Previews a buy swap on the AMM (quote -> base) from pre-fetched state. The function executes offline using the state being passed in.
146
+ *
147
+ * @param amountOut - Desired base token amount out
148
+ * @param state - Pre-fetched AMM config and vault balances
149
+ * @returns Swap preview with quote in, fees, and price impact
150
+ */
151
+ export declare function calculateSwapBuyPreview(amountOut: BN, state: SwapPreviewState): SwapPreview;
152
+ /**
153
+ * Previews a sell swap on the AMM (base -> quote) from pre-fetched state. The function executes offline using the state being passed in.
154
+ *
155
+ * @param amountIn - Base token amount to sell
156
+ * @param state - Pre-fetched AMM config and vault balances
157
+ * @returns Swap preview with quote out, fees, and price impact
158
+ */
159
+ export declare function calculateSwapSellPreview(amountIn: BN, state: SwapPreviewState): SwapPreview;
160
+ /**
161
+ * Previews a buy on the bonding curve.
162
+ *
163
+ * Auto-fetches the global config and bonding curve state from chain, then
164
+ * computes expected tokens out, fee breakdown, price impact, and whether the
165
+ * buy would complete the curve.
166
+ *
167
+ * @param connection - Solana RPC connection
168
+ * @param mint - Token mint address
169
+ * @param amountInQuote - Quote token amount to spend (lamports for SOL, smallest unit for stables)
170
+ * @param config - Liquid protocol configuration
171
+ * @param options - Native ({@link NativeCurveOptions}) or stable ({@link StableCurveOptions})
172
+ * @returns Buy preview with `tokensOut`, `fees`, `priceImpactBps`, `newReserves`, and `willComplete`
173
+ *
174
+ * @example Native SOL curve
175
+ * ```ts
176
+ * const preview = await previewBuyOnCurve(connection, mint, new BN(100_000_000), config, {
177
+ * solPriceUsd: new BN(150_000_000), // $150
178
+ * });
179
+ * ```
180
+ *
181
+ * @example Stable (USDC) curve
182
+ * ```ts
183
+ * const preview = await previewBuyOnCurve(connection, mint, new BN(10_000_000), config, {
184
+ * quoteMint: USDC_MINT,
185
+ * });
186
+ * ```
187
+ *
188
+ * @see {@link calculateBuyCurvePreview} for pure offline calculations with pre-built state
189
+ */
190
+ export declare function previewBuyOnCurve(connection: Connection, mint: PublicKey, amountInQuote: BN, config: LiquidConfig, options: CurveAsyncOptions): Promise<BuyCurvePreview>;
191
+ /**
192
+ * Previews a sell on the bonding curve.
193
+ *
194
+ * Auto-fetches the global config and bonding curve state from chain, then
195
+ * computes expected quote out, fee breakdown, and price impact.
196
+ *
197
+ * @param connection - Solana RPC connection
198
+ * @param mint - Token mint address
199
+ * @param amountInTokens - Token amount to sell (smallest unit, 6 decimals)
200
+ * @param config - Liquid protocol configuration
201
+ * @param options - Native ({@link NativeCurveOptions}) or stable ({@link StableCurveOptions})
202
+ * @returns Sell preview with `quoteOut`, `quoteOutNet`, `fees`, `priceImpactBps`, and `newReserves`
203
+ *
204
+ * @example Native SOL curve
205
+ * ```ts
206
+ * const preview = await previewSellOnCurve(connection, mint, new BN(5_000_000), config, {
207
+ * solPriceUsd: new BN(150_000_000),
208
+ * });
209
+ * ```
210
+ *
211
+ * @see {@link calculateSellCurvePreview} for pure offline calculations with pre-built state
212
+ */
213
+ export declare function previewSellOnCurve(connection: Connection, mint: PublicKey, amountInTokens: BN, config: LiquidConfig, options: CurveAsyncOptions): Promise<SellCurvePreview>;
214
+ /**
215
+ * Previews a sell swap on the AMM (base -> quote).
216
+ *
217
+ * Accepts optional pre-fetched state to avoid redundant RPC calls.
218
+ * For tiered fee systems, you must provide either:
219
+ * - `prefetched.feeRates` - pre-computed fee rates for the current market cap
220
+ * - `solPriceUsd` parameter - to calculate fee rates from on-chain tiered config
221
+ *
222
+ * @param connection - Solana RPC connection
223
+ * @param baseMint - Base token mint address
224
+ * @param quoteMint - Quote token mint address
225
+ * @param amountIn - Base token amount to sell
226
+ * @param config - Liquid protocol configuration
227
+ * @param options - Optional pre-fetched AMM state and solPriceUsd for tier calculation
228
+ * @returns Swap preview with quote out, fees, and price impact
229
+ *
230
+ * @throws Error if neither feeRates nor solPriceUsd is provided for tiered fee systems
231
+ */
232
+ export declare function previewSwapSell(connection: Connection, baseMint: PublicKey, quoteMint: PublicKey, amountIn: BN, config: LiquidConfig, options?: {
233
+ prefetched?: SwapPrefetchedState;
234
+ solPriceUsd?: BN;
235
+ }): Promise<SwapPreview>;
236
+ /**
237
+ * Previews a buy swap on the AMM (quote -> base).
238
+ *
239
+ * Accepts optional pre-fetched state to avoid redundant RPC calls.
240
+ * For tiered fee systems, you must provide either:
241
+ * - `prefetched.feeRates` - pre-computed fee rates for the current market cap
242
+ * - `solPriceUsd` parameter - to calculate fee rates from on-chain tiered config
243
+ *
244
+ * @param connection - Solana RPC connection
245
+ * @param baseMint - Base token mint address
246
+ * @param quoteMint - Quote token mint address
247
+ * @param amountOut - Desired base token amount out
248
+ * @param config - Liquid protocol configuration
249
+ * @param options - Optional pre-fetched AMM state and solPriceUsd for tier calculation
250
+ * @returns Swap preview with quote in, fees, and price impact
251
+ *
252
+ * @throws Error if neither feeRates nor solPriceUsd is provided for tiered fee systems
253
+ */
254
+ export declare function previewSwapBuy(connection: Connection, baseMint: PublicKey, quoteMint: PublicKey, amountOut: BN, config: LiquidConfig, options?: {
255
+ prefetched?: SwapPrefetchedState;
256
+ solPriceUsd?: BN;
257
+ }): Promise<SwapPreview>;
258
+ export {};
259
+ //# sourceMappingURL=preview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../src/helpers/preview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,MAAM,OAAO,CAAC;AACvB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAiBlF,+EAA+E;AAC/E,MAAM,WAAW,iBAAiB;IACjC,YAAY,EAAE;QACb,sBAAsB,EAAE,MAAM,CAAC;QAC/B,qBAAqB,EAAE,MAAM,CAAC;QAC9B,gCAAgC,EAAE,MAAM,CAAC;QACzC,+BAA+B,EAAE,MAAM,CAAC;KACxC,CAAC;IACF,YAAY,EAAE;QACb,oBAAoB,EAAE,EAAE,CAAC;QACzB,oBAAoB,EAAE,EAAE,CAAC;QACzB,iBAAiB,EAAE,EAAE,CAAC;KACtB,CAAC;CACF;AAED,0EAA0E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