auctionflow-sdk 2.0.1 → 3.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 +48 -11
- package/dist/index.d.mts +1288 -6
- package/dist/index.d.ts +1288 -6
- package/dist/index.js +505 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +502 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
|
@@ -186,8 +207,11 @@ if (!(await sdk.hasWithdrawnProceeds(0n))) {
|
|
|
186
207
|
await sdk.withdrawProceeds(0n);
|
|
187
208
|
}
|
|
188
209
|
|
|
189
|
-
// 3. Later, collect the pool's trading fees.
|
|
210
|
+
// 3. Later, collect the pool's trading fees. The creator's share is
|
|
211
|
+
// credited to them, and they withdraw it (in both tokens) with claim.
|
|
190
212
|
await sdk.collectFees(0n);
|
|
213
|
+
await sdk.claim(usdcAddress);
|
|
214
|
+
await sdk.claim(tokenAddress);
|
|
191
215
|
```
|
|
192
216
|
|
|
193
217
|
**Migration** pairs the auction's liquidity share of the raise with newly
|
|
@@ -195,13 +219,16 @@ minted tokens and opens a 1% Uniswap v3 pool **at the auction's final price**,
|
|
|
195
219
|
so there is no price jump to arbitrage. If someone initialised the pool
|
|
196
220
|
beforehand at a different price, migration corrects it first. The position NFT
|
|
197
221
|
stays in the auction contract forever, so the liquidity can never be pulled.
|
|
198
|
-
Tokens Uniswap doesn't use are burned, and leftover funds
|
|
222
|
+
Tokens Uniswap doesn't use are burned, and leftover funds are credited to the
|
|
223
|
+
creator to `claim`.
|
|
199
224
|
|
|
200
225
|
**Withdrawal** pays the creator everything not reserved for liquidity: with the
|
|
201
226
|
default 50% share, half the raise. It works before or after migration.
|
|
202
227
|
|
|
203
|
-
**Trading fees** from the pool
|
|
204
|
-
(`lpFeeShareBps`, at most 50%), fixed when the auction is
|
|
228
|
+
**Trading fees** from the pool are credited to the creator, minus the
|
|
229
|
+
protocol's share (`lpFeeShareBps`, at most 50%), fixed when the auction is
|
|
230
|
+
created. Payouts are claimed rather than sent, so no recipient (for example an
|
|
231
|
+
address USDC has blacklisted) can block a trade or a migration.
|
|
205
232
|
|
|
206
233
|
## How the bonding curve works
|
|
207
234
|
|
|
@@ -231,10 +258,14 @@ Early buyers pay less; later buyers pay more.
|
|
|
231
258
|
| Member | Description |
|
|
232
259
|
| --- | --- |
|
|
233
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. |
|
|
234
|
-
| `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. |
|
|
235
263
|
| `buildAuction()` | Returns an `AuctionBuilder` (fluent config builder). |
|
|
236
264
|
| `createAuction(config)` | Launch with custom parameters. Requires a wallet client. |
|
|
237
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. |
|
|
238
269
|
| `getAuction(auctionId)` | Read the full auction struct. |
|
|
239
270
|
| `getSpotPrice(auctionId)` | Read the current on-chain spot price. |
|
|
240
271
|
| `getQuote(auctionId, amount)` | Tokens actually filled, cost, fee, post-trade spot price, and whether the purchase completes the auction. |
|
|
@@ -245,8 +276,14 @@ Early buyers pay less; later buyers pay more.
|
|
|
245
276
|
| `migrate(auctionId)` | Open the Uniswap v3 pool at the final price, lock the liquidity, unlock the token. Anyone may call. |
|
|
246
277
|
| `getMigration(auctionId)` | The pool address and position NFT id, or `null` before migration. |
|
|
247
278
|
| `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
|
|
279
|
+
| `collectFees(auctionId)` | Collect the pool's trading fees: the protocol's share accrues to the protocol and the rest is credited to the creator. Anyone may call. |
|
|
280
|
+
| `claim(token)` | Withdraw everything credited to the connected account in `token`: a creator's share of pool fees, and any reserve migration couldn't place. |
|
|
281
|
+
| `getClaimable(token, account)` | How much of `token` is credited to `account`. |
|
|
282
|
+
| `claimProtocolFees(token)` | Send the protocol's unclaimed fees in `token` to the fee recipient. Anyone may call. |
|
|
283
|
+
| `getProtocolFees(token)` | The protocol's unclaimed fees in `token`. |
|
|
284
|
+
| `isPaymentTokenAllowed(token)` | Whether new auctions may be priced in `token`. Only owner-approved tokens (USDC and WETH) can be used. |
|
|
249
285
|
| `hasWithdrawnProceeds(auctionId)` | Whether the creator has already claimed the proceeds. |
|
|
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. |
|
|
250
287
|
|
|
251
288
|
## License
|
|
252
289
|
|