auctionflow-sdk 2.1.0 → 3.0.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/README.md CHANGED
@@ -17,7 +17,7 @@ pnpm add auctionflow-sdk viem
17
17
  ## Quick start
18
18
 
19
19
  ```typescript
20
- import { AuctionFlowSDK, parseCurvePrice } from "auctionflow-sdk";
20
+ import { AuctionFlowSDK, parseCurvePrice, USDC_ADDRESSES } 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";
@@ -66,12 +66,15 @@ Without it, constructing on a chain that has no built-in deployment throws.
66
66
  ## Launch a token (one click)
67
67
 
68
68
  ```typescript
69
- const hash = await sdk.launch("My Token", "MTK", "ipfs://<metadata-json>");
69
+ const hash = await sdk.launch("My Token", "MTK", "ipfs://<metadata-json>"); // priced in ETH
70
+ const usdc = await sdk.launch("My Token", "MTK", "ipfs://<metadata-json>", USDC_ADDRESSES[84532]); // priced in USDC
70
71
  ```
71
72
 
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.
73
+ The creator picks the name, symbol, metadata (such as the token image) and the
74
+ payment token: WETH by default, so the token trades in plain ETH, or USDC.
75
+ Everything else comes from the protocol's standard launch preset for that
76
+ token: supply, curve, graduation threshold and liquidity share. Read it with
77
+ `getLaunchPreset(paymentToken)`, which returns `null` for a token with no preset.
75
78
 
76
79
  ## Create an auction with custom parameters
77
80
 
@@ -153,6 +156,24 @@ the transaction landed. Purchases round up and sales round down, so a round
153
156
  trip can never profit, and the contract always holds enough to buy back every
154
157
  outstanding token.
155
158
 
159
+ ## Pay in ETH
160
+
161
+ A token priced in WETH can be bought and sold with plain ETH, in one
162
+ transaction and with no token approval. The contract wraps and unwraps it.
163
+
164
+ ```typescript
165
+ if (await sdk.isPricedInETH(0n)) {
166
+ await sdk.buyTokensWithETH(0n, parseUnits("1000000", 18)); // sends the quote plus 1% as ETH
167
+ await sdk.sellTokensForETH(0n, parseUnits("400000", 18)); // paid out in ETH
168
+ }
169
+ ```
170
+
171
+ `buyTokensWithETH` sends the most the purchase may cost as the transaction's
172
+ value (the same `maxCost` / `slippageBps` options as `buyTokens`), and the
173
+ contract refunds whatever the purchase doesn't use. `sellTokensForETH` takes
174
+ the same options as `sellTokens`. A creator's proceeds, pool fees and claims
175
+ for such a token are paid in WETH.
176
+
156
177
  ## Read state & quotes
157
178
 
158
179
  ```typescript
@@ -237,10 +258,14 @@ Early buyers pay less; later buyers pay more.
237
258
  | Member | Description |
238
259
  | --- | --- |
239
260
  | `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. |
240
- | `launch(name, symbol, metadataURI?)` | One-click launch with the protocol's standard preset. Requires a wallet client. |
261
+ | `launch(name, symbol, metadataURI?, paymentToken?)` | One-click launch with the protocol's standard preset for `paymentToken` (default WETH). Requires a wallet client. |
262
+ | `getLaunchPreset(paymentToken)` | The standard launch for `paymentToken`, or `null` if none is configured. |
241
263
  | `buildAuction()` | Returns an `AuctionBuilder` (fluent config builder). |
242
264
  | `createAuction(config)` | Launch with custom parameters. Requires a wallet client. |
243
265
  | `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. |
266
+ | `buyTokensWithETH(auctionId, amount, { maxCost?, slippageBps? })` | `buyTokens` for a WETH-priced token, paid in plain ETH; the unused part of the value is refunded. Requires a wallet client. |
267
+ | `sellTokensForETH(auctionId, amount, { minProceeds?, slippageBps? })` | `sellTokens` for a WETH-priced token, paid out in plain ETH. Requires a wallet client. |
268
+ | `isPricedInETH(auctionId)` | Whether the auction is priced in WETH, so it trades in plain ETH. |
244
269
  | `getAuction(auctionId)` | Read the full auction struct. |
245
270
  | `getSpotPrice(auctionId)` | Read the current on-chain spot price. |
246
271
  | `getQuote(auctionId, amount)` | Tokens actually filled, cost, fee, post-trade spot price, and whether the purchase completes the auction. |
@@ -256,9 +281,9 @@ Early buyers pay less; later buyers pay more.
256
281
  | `getClaimable(token, account)` | How much of `token` is credited to `account`. |
257
282
  | `claimProtocolFees(token)` | Send the protocol's unclaimed fees in `token` to the fee recipient. Anyone may call. |
258
283
  | `getProtocolFees(token)` | The protocol's unclaimed fees in `token`. |
259
- | `isPaymentTokenAllowed(token)` | Whether new auctions may be priced in `token`. Only owner-approved tokens (USDC) can be used. |
284
+ | `isPaymentTokenAllowed(token)` | Whether new auctions may be priced in `token`. Only owner-approved tokens (USDC and WETH) can be used. |
260
285
  | `hasWithdrawnProceeds(auctionId)` | Whether the creator has already claimed the proceeds. |
261
- | `isPaused()` | Whether the protocol is paused. While paused, `launch`, `createAuction` and `buyTokens` revert; selling back, migration, withdrawals, fee collection and claims still work. |
286
+ | `isPaused()` | Whether the protocol is paused. While paused, `launch`, `createAuction`, `buyTokens` and `buyTokensWithETH` revert; selling back, migration, withdrawals, fee collection and claims still work. |
262
287
 
263
288
  ## License
264
289