auctionflow-sdk 1.2.0 → 2.0.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.
package/README.md CHANGED
@@ -17,7 +17,7 @@ pnpm add auctionflow-sdk viem
17
17
  ## Quick start
18
18
 
19
19
  ```typescript
20
- import { AuctionFlowSDK } from "auctionflow-sdk";
20
+ import { AuctionFlowSDK, parseCurvePrice } from "auctionflow-sdk";
21
21
  import { createWalletClient, http, parseUnits } from "viem";
22
22
  import { privateKeyToAccount } from "viem/accounts";
23
23
  import { baseSepolia } from "viem/chains";
@@ -53,10 +53,31 @@ const sdk = new AuctionFlowSDK({
53
53
 
54
54
  Without it, constructing on a chain that has no built-in deployment throws.
55
55
 
56
- ## Create an auction
56
+ ## How a launch works
57
57
 
58
- The builder validates required fields and basic invariants (`startTime < endTime`,
59
- positive `basePrice` / `maxSupply` / `maxRaise`) before producing a config.
58
+ 1. **Launch.** A token is created and trading starts immediately on a bonding
59
+ curve: every buy raises the price, every sell lowers it.
60
+ 2. **Trade.** Anyone can buy, and sell back to the curve, until the auction has
61
+ raised its **graduation threshold** (`maxRaise`). Tokens can't be transferred
62
+ in the meantime; selling back is how you exit.
63
+ 3. **Graduate.** The purchase that reaches the threshold closes the curve, and
64
+ the token migrates to a Uniswap v3 pool where it trades freely.
65
+
66
+ ## Launch a token (one click)
67
+
68
+ ```typescript
69
+ const hash = await sdk.launch("My Token", "MTK", "ipfs://<metadata-json>");
70
+ ```
71
+
72
+ Everything except the name, symbol and metadata (such as the token image) comes
73
+ from the protocol's standard launch preset: the payment token, supply, curve,
74
+ graduation threshold and liquidity share.
75
+
76
+ ## Create an auction with custom parameters
77
+
78
+ The builder validates required fields and basic invariants (positive
79
+ `basePrice` / `maxSupply` / `maxRaise`, a liquidity share between 20% and 100%)
80
+ before producing a config.
60
81
 
61
82
  ```typescript
62
83
  const config = sdk
@@ -64,25 +85,74 @@ const config = sdk
64
85
  .withToken("MyToken", "MTK", parseUnits("1000000", 18))
65
86
  .withPaymentToken("0x036CbD53842c5426634e7929541eC2318f3dCF7e") // USDC Sepolia
66
87
  .withBondingCurve(
67
- parseUnits("0.01", 6), // base price: 0.01 USDC
68
- parseUnits("0.000001", 6) // slope
69
- )
70
- .withMaxRaise(parseUnits("50000", 6))
71
- .withSchedule(
72
- BigInt(Math.floor(Date.now() / 1000) + 3600),
73
- BigInt(Math.floor(Date.now() / 1000) + 3600 * 72)
88
+ parseCurvePrice("0.01", 6), // base price: 0.01 USDC per token
89
+ parseCurvePrice("0.000001", 6) // slope: +0.000001 USDC per token sold
74
90
  )
91
+ .withMaxRaise(parseUnits("50000", 6)) // graduation threshold
92
+ .withLiquidity(5_000) // 50% of the raise seeds the Uniswap pool (the default)
93
+ .withMetadata("ipfs://<metadata-json>")
75
94
  .build();
76
95
 
77
96
  const hash = await sdk.createAuction(config);
78
97
  ```
79
98
 
99
+ Prices are per whole token, stored with 18 extra decimals so a curve can rise
100
+ by far less than one USDC unit per token, as a billion-token memecoin needs.
101
+ `parseCurvePrice(price, paymentDecimals)` converts a human price into those
102
+ units, and `formatCurvePrice` converts back (for example, a `getSpotPrice`
103
+ result for display).
104
+
105
+ `withLiquidity` sets the share of the raise, in basis points, that is paired
106
+ with newly minted tokens to open a Uniswap pool when the auction ends; the
107
+ creator receives the rest. The token supply must leave room for those tokens on
108
+ top of a sold-out sale, so the contract rejects a `maxSupply` that is too small.
109
+
110
+ Auction tokens can't be transferred until the auction migrates. That stops any
111
+ holder from creating or pricing the Uniswap pool ahead of the auction. Holders
112
+ can always exit before then by selling back to the curve.
113
+
80
114
  ## Buy tokens
81
115
 
82
116
  ```typescript
83
117
  const hash = await sdk.buyTokens(0n, parseUnits("1000", 18));
84
118
  ```
85
119
 
120
+ Every purchase raises the price, so another buyer can move it between your
121
+ quote and your transaction. `buyTokens` sends a maximum total cost (cost plus
122
+ fee) and the contract reverts if the price moved past it. By default the SDK
123
+ quotes the purchase and allows 1% above that quote. To change the tolerance, or
124
+ set the bound yourself:
125
+
126
+ ```typescript
127
+ await sdk.buyTokens(0n, amount, { slippageBps: 50 }); // 0.5% tolerance
128
+ await sdk.buyTokens(0n, amount, { maxCost: 11_000_000n }); // exact bound, in USDC units
129
+ ```
130
+
131
+ A purchase that would take the auction past its `maxRaise` is filled with what
132
+ the remaining budget buys, and closes the auction. `getQuote` reports this up
133
+ front: `quote.amount` is what you'll actually receive and `quote.fillsAuction`
134
+ says whether your purchase completes the sale.
135
+
136
+ ## Sell tokens
137
+
138
+ Until graduation, anyone can sell tokens back to the curve at the curve price,
139
+ minus the protocol fee. The tokens are burned and the seller is paid from the
140
+ raise, so the price falls by exactly what the purchase raised it.
141
+
142
+ ```typescript
143
+ const quote = await sdk.getSellQuote(0n, parseUnits("400", 18));
144
+ console.log(quote.proceeds, quote.fee, quote.netProceeds);
145
+
146
+ await sdk.sellTokens(0n, parseUnits("400", 18)); // 1% below the quote
147
+ await sdk.sellTokens(0n, parseUnits("400", 18), { slippageBps: 50 }); // 0.5% tolerance
148
+ await sdk.sellTokens(0n, parseUnits("400", 18), { minProceeds: 4_000_000n });
149
+ ```
150
+
151
+ Like `buyTokens`, the contract reverts if the price moved past your bound before
152
+ the transaction landed. Purchases round up and sales round down, so a round
153
+ trip can never profit, and the contract always holds enough to buy back every
154
+ outstanding token.
155
+
86
156
  ## Read state & quotes
87
157
 
88
158
  ```typescript
@@ -98,23 +168,40 @@ console.log(quote.cost, quote.fee, quote.totalCost, quote.spotPriceAfter);
98
168
  The bonding-curve helpers are also exported directly for UI/preview use:
99
169
 
100
170
  ```typescript
101
- import { calculateBuyQuote, spotPrice } from "auctionflow-sdk";
171
+ import { calculateBuyQuote, calculateSellProceeds, spotPrice, formatCurvePrice } from "auctionflow-sdk";
102
172
  ```
103
173
 
104
- ## Withdraw proceeds
174
+ ## After graduation: migrate, withdraw, collect fees
105
175
 
106
- Once an auction reaches `COMPLETED` — either by hitting `maxRaise` or via
107
- `completeAuction` after `endTime` — its creator claims the raised payment
108
- tokens. Callable once, by the creator only.
176
+ Once an auction graduates, three things happen. Each can be called by anyone
177
+ except the withdrawal, which only the creator can make.
109
178
 
110
179
  ```typescript
180
+ // 1. Open the Uniswap v3 pool and unlock the token for trading.
181
+ await sdk.migrate(0n);
182
+ const { pool, positionId } = await sdk.getMigration(0n);
183
+
184
+ // 2. The creator claims their share of the raise.
111
185
  if (!(await sdk.hasWithdrawnProceeds(0n))) {
112
- const hash = await sdk.withdrawProceeds(0n);
186
+ await sdk.withdrawProceeds(0n);
113
187
  }
188
+
189
+ // 3. Later, collect the pool's trading fees.
190
+ await sdk.collectFees(0n);
114
191
  ```
115
192
 
116
- Protocol fees are routed to the fee recipient at buy time, so the amount paid
117
- out is exactly the auction's `totalRaised`.
193
+ **Migration** pairs the auction's liquidity share of the raise with newly
194
+ minted tokens and opens a 1% Uniswap v3 pool **at the auction's final price**,
195
+ so there is no price jump to arbitrage. If someone initialised the pool
196
+ beforehand at a different price, migration corrects it first. The position NFT
197
+ stays in the auction contract forever, so the liquidity can never be pulled.
198
+ Tokens Uniswap doesn't use are burned, and leftover funds go to the creator.
199
+
200
+ **Withdrawal** pays the creator everything not reserved for liquidity: with the
201
+ default 50% share, half the raise. It works before or after migration.
202
+
203
+ **Trading fees** from the pool go to the creator, minus the protocol's share
204
+ (`lpFeeShareBps`, at most 50%), fixed when the auction is created.
118
205
 
119
206
  ## How the bonding curve works
120
207
 
@@ -144,13 +231,21 @@ Early buyers pay less; later buyers pay more.
144
231
  | Member | Description |
145
232
  | --- | --- |
146
233
  | `new AuctionFlowSDK({ chainId, rpcUrl, walletClient?, auctionAddress? })` | Construct against a supported chain. `auctionAddress` overrides the built-in deployment; without it, a chain with no canonical deployment throws. |
234
+ | `launch(name, symbol, metadataURI?)` | One-click launch with the protocol's standard preset. Requires a wallet client. |
147
235
  | `buildAuction()` | Returns an `AuctionBuilder` (fluent config builder). |
148
- | `createAuction(config)` | Send the `createAuction` transaction. Requires a wallet client. |
149
- | `buyTokens(auctionId, amount)` | Send the `buyTokens` transaction. Requires a wallet client. |
236
+ | `createAuction(config)` | Launch with custom parameters. Requires a wallet client. |
237
+ | `buyTokens(auctionId, amount, { maxCost?, slippageBps? })` | Send the `buyTokens` transaction with a maximum total cost; reverts if the price moved past it. Defaults to the quote plus 1%. Requires a wallet client. |
150
238
  | `getAuction(auctionId)` | Read the full auction struct. |
151
239
  | `getSpotPrice(auctionId)` | Read the current on-chain spot price. |
152
- | `getQuote(auctionId, amount)` | Off-chain cost + fee + post-trade spot price. |
153
- | `withdrawProceeds(auctionId)` | Pay a completed auction's `totalRaised` to its creator. Creator-only, once. Requires a wallet client. |
240
+ | `getQuote(auctionId, amount)` | Tokens actually filled, cost, fee, post-trade spot price, and whether the purchase completes the auction. |
241
+ | `applySlippage(total, slippageBps)` | The maximum cost `buyTokens` would send for a quoted total. |
242
+ | `sellTokens(auctionId, amount, { minProceeds?, slippageBps? })` | Sell back to the curve before graduation, with a minimum payout; defaults to the quote minus 1%. Requires a wallet client. |
243
+ | `getSellQuote(auctionId, amount)` | Proceeds, fee, net payout, and post-trade spot price for a sale. |
244
+ | `applySellSlippage(netProceeds, slippageBps)` | The minimum payout `sellTokens` would send for a quoted sale. |
245
+ | `migrate(auctionId)` | Open the Uniswap v3 pool at the final price, lock the liquidity, unlock the token. Anyone may call. |
246
+ | `getMigration(auctionId)` | The pool address and position NFT id, or `null` before migration. |
247
+ | `withdrawProceeds(auctionId)` | Pay the creator their share of the raise (what isn't reserved for liquidity). Creator-only, once. |
248
+ | `collectFees(auctionId)` | Collect the pool's trading fees: protocol share to the protocol, the rest to the creator. Anyone may call. |
154
249
  | `hasWithdrawnProceeds(auctionId)` | Whether the creator has already claimed the proceeds. |
155
250
 
156
251
  ## License
package/dist/index.d.mts CHANGED
@@ -13,9 +13,15 @@ interface AuctionConfig {
13
13
  paymentToken: Address;
14
14
  basePrice: bigint;
15
15
  slope: bigint;
16
+ /** Graduation threshold: once this much is raised, trading moves to Uniswap. */
16
17
  maxRaise: bigint;
17
- startTime: bigint;
18
- endTime: bigint;
18
+ /** Off-chain metadata for the token, such as its image (e.g. an IPFS URI). */
19
+ metadataURI?: string;
20
+ /**
21
+ * Share of the raise seeded into Uniswap at migration, in basis points
22
+ * (2000..10000). Defaults to 5000 (50%).
23
+ */
24
+ liquidityBps?: bigint;
19
25
  }
20
26
  interface AuctionData {
21
27
  id: bigint;
@@ -25,18 +31,37 @@ interface AuctionData {
25
31
  basePrice: bigint;
26
32
  slope: bigint;
27
33
  maxRaise: bigint;
28
- startTime: bigint;
29
- endTime: bigint;
30
34
  state: AuctionState;
31
35
  totalRaised: bigint;
32
36
  totalSold: bigint;
33
37
  protocolFeeBps: bigint;
38
+ liquidityBps: bigint;
39
+ /** Protocol's share of the Uniswap pool's trading fees, in basis points. */
40
+ lpFeeShareBps: bigint;
41
+ }
42
+ interface SellQuote {
43
+ /** Curve value of the tokens being sold, before the protocol fee. */
44
+ proceeds: bigint;
45
+ fee: bigint;
46
+ /** What the seller receives: proceeds minus fee. */
47
+ netProceeds: bigint;
48
+ spotPriceAfter: bigint;
49
+ }
50
+ interface MigrationInfo {
51
+ /** The Uniswap v3 pool, or null if the auction unlocked without one. */
52
+ pool: Address | null;
53
+ /** The Uniswap position NFT, held by the auction contract forever. */
54
+ positionId: bigint | null;
34
55
  }
35
56
  interface BuyQuote {
57
+ /** Tokens the purchase would actually deliver: less than requested if it fills the auction. */
58
+ amount: bigint;
36
59
  cost: bigint;
37
60
  fee: bigint;
38
61
  totalCost: bigint;
39
62
  spotPriceAfter: bigint;
63
+ /** True if this purchase reaches the cap and closes the auction. */
64
+ fillsAuction: boolean;
40
65
  }
41
66
  interface TransactionResult {
42
67
  hash: Hash;
@@ -48,8 +73,16 @@ declare class AuctionBuilder {
48
73
  withToken(name: string, symbol: string, maxSupply: bigint): this;
49
74
  withPaymentToken(address: Address): this;
50
75
  withBondingCurve(basePrice: bigint, slope: bigint): this;
76
+ /** Graduation threshold: once this much is raised, trading moves to Uniswap. */
51
77
  withMaxRaise(maxRaise: bigint): this;
52
- withSchedule(startTime: bigint, endTime: bigint): this;
78
+ /**
79
+ * Share of the raise, in basis points, seeded into a Uniswap pool when the
80
+ * auction migrates (5000 = 50%). The rest goes to the creator. Defaults to
81
+ * 50%; must be between 20% and 100%.
82
+ */
83
+ withLiquidity(liquidityBps: number): this;
84
+ /** Off-chain metadata for the token, such as its image (e.g. an IPFS URI). */
85
+ withMetadata(metadataURI: string): this;
53
86
  build(): AuctionConfig;
54
87
  }
55
88
 
@@ -67,12 +100,55 @@ declare class AuctionFlowSDK {
67
100
  });
68
101
  buildAuction(): AuctionBuilder;
69
102
  createAuction(config: AuctionConfig): Promise<Hash>;
70
- buyTokens(auctionId: bigint, amount: bigint): Promise<Hash>;
71
103
  /**
72
- * Withdraw a completed auction's raised payment tokens to its creator.
73
- * Only the auction's creator can call this, and only once.
104
+ * One-click launch: a token with the protocol's standard curve, threshold
105
+ * and liquidity share. Trading starts immediately.
106
+ */
107
+ launch(name: string, symbol: string, metadataURI?: string): Promise<Hash>;
108
+ /**
109
+ * Sell `amount` tokens (in token wei) back to the curve before graduation.
110
+ * The contract reverts if the price fell below the bound before the
111
+ * transaction landed: pass `minProceeds` to set it exactly, or `slippageBps`
112
+ * to derive it from a fresh quote (default 100 = 1% below it).
113
+ */
114
+ sellTokens(auctionId: bigint, amount: bigint, options?: {
115
+ minProceeds?: bigint;
116
+ slippageBps?: number;
117
+ }): Promise<Hash>;
118
+ /** What selling `amount` tokens back to the curve would pay right now. */
119
+ getSellQuote(auctionId: bigint, amount: bigint): Promise<SellQuote>;
120
+ /**
121
+ * Buy `amount` tokens (in token wei). The price rises with every purchase, so
122
+ * the contract takes a maximum total cost and reverts if the price moved past
123
+ * it before the transaction landed.
124
+ *
125
+ * Pass `maxCost` to set that bound exactly, or `slippageBps` to derive it
126
+ * from a fresh quote (default 100 = 1% above the quoted total).
127
+ */
128
+ buyTokens(auctionId: bigint, amount: bigint, options?: {
129
+ maxCost?: bigint;
130
+ slippageBps?: number;
131
+ }): Promise<Hash>;
132
+ /**
133
+ * Pay a completed auction's creator their share of the raise: everything
134
+ * not reserved for Uniswap liquidity. Creator only, once, before or after
135
+ * migration.
74
136
  */
75
137
  withdrawProceeds(auctionId: bigint): Promise<Hash>;
138
+ /**
139
+ * Move a completed auction's liquidity into a Uniswap v3 pool at the
140
+ * auction's final price, lock it, and unlock the token for trading. Anyone
141
+ * may call it.
142
+ */
143
+ migrate(auctionId: bigint): Promise<Hash>;
144
+ /**
145
+ * Collect the migrated pool's trading fees. The protocol takes its share and
146
+ * the creator receives the rest. Anyone may call it.
147
+ */
148
+ collectFees(auctionId: bigint): Promise<Hash>;
149
+ /** The Uniswap pool and position for a migrated auction. */
150
+ getMigration(auctionId: bigint): Promise<MigrationInfo>;
151
+ private write;
76
152
  hasWithdrawnProceeds(auctionId: bigint): Promise<boolean>;
77
153
  getAuction(auctionId: bigint): Promise<AuctionData>;
78
154
  getQuote(auctionId: bigint, amount: bigint): Promise<BuyQuote>;
@@ -83,7 +159,28 @@ declare class AuctionFlowSDK {
83
159
  declare const AUCTION_ADDRESSES: Record<SupportedChainId, Address>;
84
160
  declare const USDC_ADDRESSES: Record<SupportedChainId, Address>;
85
161
 
162
+ /** Smallest share of the raise an auction may commit to Uniswap liquidity (20%). Mirrors TokenAuction.MIN_LIQUIDITY_BPS. */
163
+ declare const MIN_LIQUIDITY_BPS = 2000;
164
+ /** Liquidity share the builder uses when none is given (50%). */
165
+ declare const DEFAULT_LIQUIDITY_BPS = 5000;
166
+
167
+ /** Fixed-point scale of `basePrice`, `slope` and spot prices. */
168
+ declare const PRICE_SCALE: bigint;
169
+ /**
170
+ * A human-readable price per whole token, in curve units.
171
+ * `parseCurvePrice("0.01", 6)` is 0.01 USDC per token.
172
+ */
173
+ declare function parseCurvePrice(price: string, paymentDecimals: number): bigint;
174
+ /** A curve price (e.g. from `getSpotPrice`) as a human-readable price per whole token. */
175
+ declare function formatCurvePrice(price: bigint, paymentDecimals: number): string;
86
176
  declare function calculateBuyCost(currentSupply: bigint, amount: bigint, basePrice: bigint, slope: bigint): bigint;
177
+ /**
178
+ * Proceeds from selling `amount` tokens back to the curve when `currentSupply`
179
+ * are outstanding. Mirrors BondingCurve.calculateSellProceeds: the same
180
+ * integral as a purchase, but rounded down, so a round trip never profits.
181
+ */
182
+ declare function calculateSellProceeds(currentSupply: bigint, amount: bigint, basePrice: bigint, slope: bigint): bigint;
183
+ /** Price of the next whole token, in curve units (payment units × 1e18). */
87
184
  declare function spotPrice(currentSupply: bigint, basePrice: bigint, slope: bigint): bigint;
88
185
  declare function calculateBuyQuote(currentSupply: bigint, amount: bigint, basePrice: bigint, slope: bigint, feeBps: bigint): {
89
186
  cost: bigint;
@@ -91,5 +188,33 @@ declare function calculateBuyQuote(currentSupply: bigint, amount: bigint, basePr
91
188
  total: bigint;
92
189
  spotPriceAfter: bigint;
93
190
  };
191
+ /** Default slippage tolerance for `buyTokens` and `sellTokens`, in basis points (100 = 1%). */
192
+ declare const DEFAULT_SLIPPAGE_BPS = 100;
193
+ /**
194
+ * Upper bound a buyer will accept for a quoted total, given a tolerance in
195
+ * basis points. Rounds up so a tolerance never comes out tighter than asked.
196
+ */
197
+ declare function applySlippage(total: bigint, slippageBps: number): bigint;
198
+ /**
199
+ * Largest amount (token wei) buyable from `currentSupply` for at most `budget`,
200
+ * capped at `upperBound`. Mirrors BondingCurve.maxBuyable (binary search).
201
+ */
202
+ declare function maxBuyable(currentSupply: bigint, budget: bigint, basePrice: bigint, slope: bigint, upperBound: bigint): bigint;
203
+ /**
204
+ * What a purchase of `requested` tokens actually fills, given how much the
205
+ * auction has left to raise. Mirrors TokenAuction._fill: a purchase that would
206
+ * overshoot the cap delivers what the remaining budget buys and closes the
207
+ * auction.
208
+ */
209
+ declare function fillPurchase(currentSupply: bigint, requested: bigint, basePrice: bigint, slope: bigint, totalRaised: bigint, maxRaise: bigint): {
210
+ amount: bigint;
211
+ cost: bigint;
212
+ fillsAuction: boolean;
213
+ };
214
+ /**
215
+ * Least a seller will accept for a quoted amount, given a tolerance in basis
216
+ * points. Rounds down so a tolerance never comes out tighter than asked.
217
+ */
218
+ declare function applySellSlippage(netProceeds: bigint, slippageBps: number): bigint;
94
219
 
95
- export { AUCTION_ADDRESSES, AuctionBuilder, type AuctionConfig, type AuctionData, AuctionFlowSDK, AuctionState, type BuyQuote, type SupportedChainId, type TransactionResult, USDC_ADDRESSES, calculateBuyCost, calculateBuyQuote, spotPrice };
220
+ export { AUCTION_ADDRESSES, AuctionBuilder, type AuctionConfig, type AuctionData, AuctionFlowSDK, AuctionState, type BuyQuote, DEFAULT_LIQUIDITY_BPS, DEFAULT_SLIPPAGE_BPS, MIN_LIQUIDITY_BPS, type MigrationInfo, PRICE_SCALE, type SellQuote, type SupportedChainId, type TransactionResult, USDC_ADDRESSES, applySellSlippage, applySlippage, calculateBuyCost, calculateBuyQuote, calculateSellProceeds, fillPurchase, formatCurvePrice, maxBuyable, parseCurvePrice, spotPrice };
package/dist/index.d.ts CHANGED
@@ -13,9 +13,15 @@ interface AuctionConfig {
13
13
  paymentToken: Address;
14
14
  basePrice: bigint;
15
15
  slope: bigint;
16
+ /** Graduation threshold: once this much is raised, trading moves to Uniswap. */
16
17
  maxRaise: bigint;
17
- startTime: bigint;
18
- endTime: bigint;
18
+ /** Off-chain metadata for the token, such as its image (e.g. an IPFS URI). */
19
+ metadataURI?: string;
20
+ /**
21
+ * Share of the raise seeded into Uniswap at migration, in basis points
22
+ * (2000..10000). Defaults to 5000 (50%).
23
+ */
24
+ liquidityBps?: bigint;
19
25
  }
20
26
  interface AuctionData {
21
27
  id: bigint;
@@ -25,18 +31,37 @@ interface AuctionData {
25
31
  basePrice: bigint;
26
32
  slope: bigint;
27
33
  maxRaise: bigint;
28
- startTime: bigint;
29
- endTime: bigint;
30
34
  state: AuctionState;
31
35
  totalRaised: bigint;
32
36
  totalSold: bigint;
33
37
  protocolFeeBps: bigint;
38
+ liquidityBps: bigint;
39
+ /** Protocol's share of the Uniswap pool's trading fees, in basis points. */
40
+ lpFeeShareBps: bigint;
41
+ }
42
+ interface SellQuote {
43
+ /** Curve value of the tokens being sold, before the protocol fee. */
44
+ proceeds: bigint;
45
+ fee: bigint;
46
+ /** What the seller receives: proceeds minus fee. */
47
+ netProceeds: bigint;
48
+ spotPriceAfter: bigint;
49
+ }
50
+ interface MigrationInfo {
51
+ /** The Uniswap v3 pool, or null if the auction unlocked without one. */
52
+ pool: Address | null;
53
+ /** The Uniswap position NFT, held by the auction contract forever. */
54
+ positionId: bigint | null;
34
55
  }
35
56
  interface BuyQuote {
57
+ /** Tokens the purchase would actually deliver: less than requested if it fills the auction. */
58
+ amount: bigint;
36
59
  cost: bigint;
37
60
  fee: bigint;
38
61
  totalCost: bigint;
39
62
  spotPriceAfter: bigint;
63
+ /** True if this purchase reaches the cap and closes the auction. */
64
+ fillsAuction: boolean;
40
65
  }
41
66
  interface TransactionResult {
42
67
  hash: Hash;
@@ -48,8 +73,16 @@ declare class AuctionBuilder {
48
73
  withToken(name: string, symbol: string, maxSupply: bigint): this;
49
74
  withPaymentToken(address: Address): this;
50
75
  withBondingCurve(basePrice: bigint, slope: bigint): this;
76
+ /** Graduation threshold: once this much is raised, trading moves to Uniswap. */
51
77
  withMaxRaise(maxRaise: bigint): this;
52
- withSchedule(startTime: bigint, endTime: bigint): this;
78
+ /**
79
+ * Share of the raise, in basis points, seeded into a Uniswap pool when the
80
+ * auction migrates (5000 = 50%). The rest goes to the creator. Defaults to
81
+ * 50%; must be between 20% and 100%.
82
+ */
83
+ withLiquidity(liquidityBps: number): this;
84
+ /** Off-chain metadata for the token, such as its image (e.g. an IPFS URI). */
85
+ withMetadata(metadataURI: string): this;
53
86
  build(): AuctionConfig;
54
87
  }
55
88
 
@@ -67,12 +100,55 @@ declare class AuctionFlowSDK {
67
100
  });
68
101
  buildAuction(): AuctionBuilder;
69
102
  createAuction(config: AuctionConfig): Promise<Hash>;
70
- buyTokens(auctionId: bigint, amount: bigint): Promise<Hash>;
71
103
  /**
72
- * Withdraw a completed auction's raised payment tokens to its creator.
73
- * Only the auction's creator can call this, and only once.
104
+ * One-click launch: a token with the protocol's standard curve, threshold
105
+ * and liquidity share. Trading starts immediately.
106
+ */
107
+ launch(name: string, symbol: string, metadataURI?: string): Promise<Hash>;
108
+ /**
109
+ * Sell `amount` tokens (in token wei) back to the curve before graduation.
110
+ * The contract reverts if the price fell below the bound before the
111
+ * transaction landed: pass `minProceeds` to set it exactly, or `slippageBps`
112
+ * to derive it from a fresh quote (default 100 = 1% below it).
113
+ */
114
+ sellTokens(auctionId: bigint, amount: bigint, options?: {
115
+ minProceeds?: bigint;
116
+ slippageBps?: number;
117
+ }): Promise<Hash>;
118
+ /** What selling `amount` tokens back to the curve would pay right now. */
119
+ getSellQuote(auctionId: bigint, amount: bigint): Promise<SellQuote>;
120
+ /**
121
+ * Buy `amount` tokens (in token wei). The price rises with every purchase, so
122
+ * the contract takes a maximum total cost and reverts if the price moved past
123
+ * it before the transaction landed.
124
+ *
125
+ * Pass `maxCost` to set that bound exactly, or `slippageBps` to derive it
126
+ * from a fresh quote (default 100 = 1% above the quoted total).
127
+ */
128
+ buyTokens(auctionId: bigint, amount: bigint, options?: {
129
+ maxCost?: bigint;
130
+ slippageBps?: number;
131
+ }): Promise<Hash>;
132
+ /**
133
+ * Pay a completed auction's creator their share of the raise: everything
134
+ * not reserved for Uniswap liquidity. Creator only, once, before or after
135
+ * migration.
74
136
  */
75
137
  withdrawProceeds(auctionId: bigint): Promise<Hash>;
138
+ /**
139
+ * Move a completed auction's liquidity into a Uniswap v3 pool at the
140
+ * auction's final price, lock it, and unlock the token for trading. Anyone
141
+ * may call it.
142
+ */
143
+ migrate(auctionId: bigint): Promise<Hash>;
144
+ /**
145
+ * Collect the migrated pool's trading fees. The protocol takes its share and
146
+ * the creator receives the rest. Anyone may call it.
147
+ */
148
+ collectFees(auctionId: bigint): Promise<Hash>;
149
+ /** The Uniswap pool and position for a migrated auction. */
150
+ getMigration(auctionId: bigint): Promise<MigrationInfo>;
151
+ private write;
76
152
  hasWithdrawnProceeds(auctionId: bigint): Promise<boolean>;
77
153
  getAuction(auctionId: bigint): Promise<AuctionData>;
78
154
  getQuote(auctionId: bigint, amount: bigint): Promise<BuyQuote>;
@@ -83,7 +159,28 @@ declare class AuctionFlowSDK {
83
159
  declare const AUCTION_ADDRESSES: Record<SupportedChainId, Address>;
84
160
  declare const USDC_ADDRESSES: Record<SupportedChainId, Address>;
85
161
 
162
+ /** Smallest share of the raise an auction may commit to Uniswap liquidity (20%). Mirrors TokenAuction.MIN_LIQUIDITY_BPS. */
163
+ declare const MIN_LIQUIDITY_BPS = 2000;
164
+ /** Liquidity share the builder uses when none is given (50%). */
165
+ declare const DEFAULT_LIQUIDITY_BPS = 5000;
166
+
167
+ /** Fixed-point scale of `basePrice`, `slope` and spot prices. */
168
+ declare const PRICE_SCALE: bigint;
169
+ /**
170
+ * A human-readable price per whole token, in curve units.
171
+ * `parseCurvePrice("0.01", 6)` is 0.01 USDC per token.
172
+ */
173
+ declare function parseCurvePrice(price: string, paymentDecimals: number): bigint;
174
+ /** A curve price (e.g. from `getSpotPrice`) as a human-readable price per whole token. */
175
+ declare function formatCurvePrice(price: bigint, paymentDecimals: number): string;
86
176
  declare function calculateBuyCost(currentSupply: bigint, amount: bigint, basePrice: bigint, slope: bigint): bigint;
177
+ /**
178
+ * Proceeds from selling `amount` tokens back to the curve when `currentSupply`
179
+ * are outstanding. Mirrors BondingCurve.calculateSellProceeds: the same
180
+ * integral as a purchase, but rounded down, so a round trip never profits.
181
+ */
182
+ declare function calculateSellProceeds(currentSupply: bigint, amount: bigint, basePrice: bigint, slope: bigint): bigint;
183
+ /** Price of the next whole token, in curve units (payment units × 1e18). */
87
184
  declare function spotPrice(currentSupply: bigint, basePrice: bigint, slope: bigint): bigint;
88
185
  declare function calculateBuyQuote(currentSupply: bigint, amount: bigint, basePrice: bigint, slope: bigint, feeBps: bigint): {
89
186
  cost: bigint;
@@ -91,5 +188,33 @@ declare function calculateBuyQuote(currentSupply: bigint, amount: bigint, basePr
91
188
  total: bigint;
92
189
  spotPriceAfter: bigint;
93
190
  };
191
+ /** Default slippage tolerance for `buyTokens` and `sellTokens`, in basis points (100 = 1%). */
192
+ declare const DEFAULT_SLIPPAGE_BPS = 100;
193
+ /**
194
+ * Upper bound a buyer will accept for a quoted total, given a tolerance in
195
+ * basis points. Rounds up so a tolerance never comes out tighter than asked.
196
+ */
197
+ declare function applySlippage(total: bigint, slippageBps: number): bigint;
198
+ /**
199
+ * Largest amount (token wei) buyable from `currentSupply` for at most `budget`,
200
+ * capped at `upperBound`. Mirrors BondingCurve.maxBuyable (binary search).
201
+ */
202
+ declare function maxBuyable(currentSupply: bigint, budget: bigint, basePrice: bigint, slope: bigint, upperBound: bigint): bigint;
203
+ /**
204
+ * What a purchase of `requested` tokens actually fills, given how much the
205
+ * auction has left to raise. Mirrors TokenAuction._fill: a purchase that would
206
+ * overshoot the cap delivers what the remaining budget buys and closes the
207
+ * auction.
208
+ */
209
+ declare function fillPurchase(currentSupply: bigint, requested: bigint, basePrice: bigint, slope: bigint, totalRaised: bigint, maxRaise: bigint): {
210
+ amount: bigint;
211
+ cost: bigint;
212
+ fillsAuction: boolean;
213
+ };
214
+ /**
215
+ * Least a seller will accept for a quoted amount, given a tolerance in basis
216
+ * points. Rounds down so a tolerance never comes out tighter than asked.
217
+ */
218
+ declare function applySellSlippage(netProceeds: bigint, slippageBps: number): bigint;
94
219
 
95
- export { AUCTION_ADDRESSES, AuctionBuilder, type AuctionConfig, type AuctionData, AuctionFlowSDK, AuctionState, type BuyQuote, type SupportedChainId, type TransactionResult, USDC_ADDRESSES, calculateBuyCost, calculateBuyQuote, spotPrice };
220
+ export { AUCTION_ADDRESSES, AuctionBuilder, type AuctionConfig, type AuctionData, AuctionFlowSDK, AuctionState, type BuyQuote, DEFAULT_LIQUIDITY_BPS, DEFAULT_SLIPPAGE_BPS, MIN_LIQUIDITY_BPS, type MigrationInfo, PRICE_SCALE, type SellQuote, type SupportedChainId, type TransactionResult, USDC_ADDRESSES, applySellSlippage, applySlippage, calculateBuyCost, calculateBuyQuote, calculateSellProceeds, fillPurchase, formatCurvePrice, maxBuyable, parseCurvePrice, spotPrice };