@zoralabs/coins-sdk 0.0.2-sdkalpha.2 → 0.0.2-sdkalpha.4
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/CHANGELOG.md +12 -0
- package/README.md +448 -18
- package/dist/actions/createCoin.d.ts.map +1 -1
- package/dist/actions/{getCoinDetails.d.ts → getOnchainCoinDetails.d.ts} +9 -8
- package/dist/actions/getOnchainCoinDetails.d.ts.map +1 -0
- package/dist/api/api-key.d.ts +9 -0
- package/dist/api/api-key.d.ts.map +1 -0
- package/dist/api/explore.d.ts +347 -0
- package/dist/api/explore.d.ts.map +1 -0
- package/dist/api/index.d.ts +4 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/queries.d.ts +345 -0
- package/dist/api/queries.d.ts.map +1 -0
- package/dist/client/client.gen.d.ts +13 -0
- package/dist/client/client.gen.d.ts.map +1 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/sdk.gen.d.ts +366 -0
- package/dist/client/sdk.gen.d.ts.map +1 -0
- package/dist/client/types.gen.d.ts +549 -0
- package/dist/client/types.gen.d.ts.map +1 -0
- package/dist/index.cjs +185 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +179 -33
- package/dist/index.js.map +1 -1
- package/dist/utils/genericPublicClient.d.ts +3 -0
- package/dist/utils/genericPublicClient.d.ts.map +1 -0
- package/dist/utils/validateClientNetwork.d.ts +1 -1
- package/dist/utils/validateClientNetwork.d.ts.map +1 -1
- package/package.json +7 -4
- package/src/actions/createCoin.ts +5 -0
- package/src/actions/{getCoinDetails.ts → getOnchainCoinDetails.ts} +111 -76
- package/src/api/api-key.ts +15 -0
- package/src/api/explore.ts +55 -0
- package/src/api/index.ts +8 -0
- package/src/api/queries.ts +60 -0
- package/src/client/client.gen.ts +18 -0
- package/src/client/index.ts +3 -0
- package/src/client/sdk.gen.ts +117 -0
- package/src/client/types.gen.ts +580 -0
- package/src/index.ts +18 -4
- package/src/utils/genericPublicClient.ts +5 -0
- package/src/utils/validateClientNetwork.ts +16 -12
- package/dist/actions/getCoinDetails.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -22,8 +22,19 @@ var src_exports = {};
|
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
createCoin: () => createCoin,
|
|
24
24
|
createCoinCall: () => createCoinCall,
|
|
25
|
+
getCoin: () => getCoin2,
|
|
26
|
+
getCoinComments: () => getCoinComments2,
|
|
25
27
|
getCoinCreateFromLogs: () => getCoinCreateFromLogs,
|
|
26
|
-
|
|
28
|
+
getCoins: () => getCoins2,
|
|
29
|
+
getExploreLastTraded: () => getExploreLastTraded,
|
|
30
|
+
getExploreLastTradedUnique: () => getExploreLastTradedUnique,
|
|
31
|
+
getExploreMostValuable: () => getExploreMostValuable,
|
|
32
|
+
getExploreNew: () => getExploreNew,
|
|
33
|
+
getExploreTopGainers: () => getExploreTopGainers,
|
|
34
|
+
getExploreTopVolume24h: () => getExploreTopVolume24h,
|
|
35
|
+
getOnchainCoinDetails: () => getOnchainCoinDetails,
|
|
36
|
+
getProfile: () => getProfile2,
|
|
37
|
+
getProfileOwned: () => getProfileOwned2,
|
|
27
38
|
getTradeFromLogs: () => getTradeFromLogs,
|
|
28
39
|
tradeCoin: () => tradeCoin,
|
|
29
40
|
tradeCoinCall: () => tradeCoinCall,
|
|
@@ -104,6 +115,9 @@ async function createCoin(call, walletClient, publicClient) {
|
|
|
104
115
|
...createCoinCall(call),
|
|
105
116
|
account: walletClient.account
|
|
106
117
|
});
|
|
118
|
+
if (request.gas) {
|
|
119
|
+
request.gas = request.gas * 6n / 5n;
|
|
120
|
+
}
|
|
107
121
|
const hash = await walletClient.writeContract(request);
|
|
108
122
|
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
109
123
|
const deployment = getCoinCreateFromLogs(receipt);
|
|
@@ -170,43 +184,52 @@ async function tradeCoin(params, walletClient, publicClient) {
|
|
|
170
184
|
};
|
|
171
185
|
}
|
|
172
186
|
|
|
173
|
-
// src/actions/
|
|
187
|
+
// src/actions/getOnchainCoinDetails.ts
|
|
174
188
|
var import_coins4 = require("@zoralabs/coins");
|
|
175
189
|
var import_viem3 = require("viem");
|
|
176
|
-
async function
|
|
190
|
+
async function getOnchainCoinDetails({
|
|
177
191
|
coin,
|
|
178
192
|
user = import_viem3.zeroAddress,
|
|
179
193
|
publicClient
|
|
180
194
|
}) {
|
|
181
195
|
validateClientNetwork(publicClient);
|
|
182
|
-
const [balance, pool, owners, payoutRecipient] = await publicClient.multicall(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
196
|
+
const [balance, pool, owners, payoutRecipient] = await publicClient.multicall(
|
|
197
|
+
{
|
|
198
|
+
contracts: [
|
|
199
|
+
{
|
|
200
|
+
address: coin,
|
|
201
|
+
abi: import_coins4.coinABI,
|
|
202
|
+
functionName: "balanceOf",
|
|
203
|
+
args: [user]
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
address: coin,
|
|
207
|
+
abi: import_coins4.coinABI,
|
|
208
|
+
functionName: "poolAddress"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
address: coin,
|
|
212
|
+
abi: import_coins4.coinABI,
|
|
213
|
+
functionName: "owners"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
address: coin,
|
|
217
|
+
abi: import_coins4.coinABI,
|
|
218
|
+
functionName: "payoutRecipient"
|
|
219
|
+
}
|
|
220
|
+
],
|
|
221
|
+
allowFailure: false
|
|
222
|
+
}
|
|
223
|
+
);
|
|
208
224
|
const USDC_WETH_POOL = USDC_WETH_POOLS_BY_CHAIN[publicClient.chain?.id || 0];
|
|
209
|
-
const [
|
|
225
|
+
const [
|
|
226
|
+
coinWethPoolSlot0,
|
|
227
|
+
coinWethPoolToken0,
|
|
228
|
+
coinReservesRaw,
|
|
229
|
+
coinTotalSupply,
|
|
230
|
+
wethReservesRaw,
|
|
231
|
+
usdcWethSlot0
|
|
232
|
+
] = await publicClient.multicall({
|
|
210
233
|
contracts: [
|
|
211
234
|
{
|
|
212
235
|
address: pool,
|
|
@@ -266,12 +289,20 @@ async function getCoinDetails({
|
|
|
266
289
|
owners,
|
|
267
290
|
payoutRecipient,
|
|
268
291
|
marketCap: convertEthOutput(marketCap, wethPriceInUsdc),
|
|
269
|
-
liquidity: convertEthOutput(
|
|
292
|
+
liquidity: convertEthOutput(
|
|
293
|
+
wethLiquidity + tokenLiquidity,
|
|
294
|
+
wethPriceInUsdc
|
|
295
|
+
),
|
|
270
296
|
poolState: coinWethPoolSlot0
|
|
271
297
|
};
|
|
272
298
|
}
|
|
273
299
|
function convertEthOutput(amountETH, wethToUsdc) {
|
|
274
|
-
return {
|
|
300
|
+
return {
|
|
301
|
+
eth: amountETH,
|
|
302
|
+
ethDecimal: parseFloat((0, import_viem3.formatEther)(amountETH)),
|
|
303
|
+
usdc: wethToUsdc ? amountETH * wethToUsdc : null,
|
|
304
|
+
usdcDecimal: wethToUsdc ? parseFloat((0, import_viem3.formatEther)(amountETH * wethToUsdc / 10n ** 18n)) : null
|
|
305
|
+
};
|
|
275
306
|
}
|
|
276
307
|
function uniswapV3SqrtPriceToBigIntScaled(sqrtPriceX96, token0Decimals, token1Decimals, isToken0Coin, scaleDecimals = 18) {
|
|
277
308
|
const numerator = sqrtPriceX96 * sqrtPriceX96;
|
|
@@ -325,12 +356,133 @@ async function updateCoinURI(args, walletClient, publicClient) {
|
|
|
325
356
|
);
|
|
326
357
|
return { hash, receipt, uriUpdated };
|
|
327
358
|
}
|
|
359
|
+
|
|
360
|
+
// src/client/client.gen.ts
|
|
361
|
+
var import_client_fetch = require("@hey-api/client-fetch");
|
|
362
|
+
var client = (0, import_client_fetch.createClient)((0, import_client_fetch.createConfig)({
|
|
363
|
+
baseUrl: "https://api-sdk.zora.engineering/"
|
|
364
|
+
}));
|
|
365
|
+
|
|
366
|
+
// src/client/sdk.gen.ts
|
|
367
|
+
var getCoin = (options) => {
|
|
368
|
+
return (options.client ?? client).get({
|
|
369
|
+
url: "/coin",
|
|
370
|
+
...options
|
|
371
|
+
});
|
|
372
|
+
};
|
|
373
|
+
var getCoinComments = (options) => {
|
|
374
|
+
return (options.client ?? client).get({
|
|
375
|
+
url: "/coinComments",
|
|
376
|
+
...options
|
|
377
|
+
});
|
|
378
|
+
};
|
|
379
|
+
var getCoins = (options) => {
|
|
380
|
+
return (options.client ?? client).get({
|
|
381
|
+
url: "/coins",
|
|
382
|
+
...options
|
|
383
|
+
});
|
|
384
|
+
};
|
|
385
|
+
var getExplore = (options) => {
|
|
386
|
+
return (options.client ?? client).get({
|
|
387
|
+
url: "/explore",
|
|
388
|
+
...options
|
|
389
|
+
});
|
|
390
|
+
};
|
|
391
|
+
var getProfile = (options) => {
|
|
392
|
+
return (options.client ?? client).get({
|
|
393
|
+
url: "/profile",
|
|
394
|
+
...options
|
|
395
|
+
});
|
|
396
|
+
};
|
|
397
|
+
var getProfileOwned = (options) => {
|
|
398
|
+
return (options.client ?? client).get({
|
|
399
|
+
url: "/profileOwned",
|
|
400
|
+
...options
|
|
401
|
+
});
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
// src/api/api-key.ts
|
|
405
|
+
var apiKey;
|
|
406
|
+
function getApiKeyMeta() {
|
|
407
|
+
if (!apiKey) {
|
|
408
|
+
return {};
|
|
409
|
+
}
|
|
410
|
+
return {
|
|
411
|
+
headers: {
|
|
412
|
+
"api-key": apiKey
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// src/api/queries.ts
|
|
418
|
+
var getCoin2 = async (query) => {
|
|
419
|
+
return await getCoin({
|
|
420
|
+
query,
|
|
421
|
+
meta: getApiKeyMeta()
|
|
422
|
+
});
|
|
423
|
+
};
|
|
424
|
+
var getCoins2 = async ({
|
|
425
|
+
coinAddresses,
|
|
426
|
+
chainId
|
|
427
|
+
}) => {
|
|
428
|
+
return await getCoins({
|
|
429
|
+
query: {
|
|
430
|
+
coins: coinAddresses.map((collectionAddress) => ({
|
|
431
|
+
chainId,
|
|
432
|
+
collectionAddress
|
|
433
|
+
}))
|
|
434
|
+
},
|
|
435
|
+
meta: getApiKeyMeta()
|
|
436
|
+
});
|
|
437
|
+
};
|
|
438
|
+
var getCoinComments2 = async (query) => {
|
|
439
|
+
return await getCoinComments({
|
|
440
|
+
query,
|
|
441
|
+
meta: getApiKeyMeta()
|
|
442
|
+
});
|
|
443
|
+
};
|
|
444
|
+
var getProfile2 = async (query) => {
|
|
445
|
+
return await getProfile({
|
|
446
|
+
query,
|
|
447
|
+
meta: getApiKeyMeta()
|
|
448
|
+
});
|
|
449
|
+
};
|
|
450
|
+
var getProfileOwned2 = async (query) => {
|
|
451
|
+
return await getProfileOwned({
|
|
452
|
+
query,
|
|
453
|
+
meta: getApiKeyMeta()
|
|
454
|
+
});
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
// src/api/explore.ts
|
|
458
|
+
var createExploreQuery = (listType, options) => getExplore({
|
|
459
|
+
...options,
|
|
460
|
+
query: { ...options?.query, listType },
|
|
461
|
+
meta: getApiKeyMeta()
|
|
462
|
+
});
|
|
463
|
+
var getExploreTopGainers = (options) => createExploreQuery("TOP_GAINERS", options);
|
|
464
|
+
var getExploreTopVolume24h = (options) => createExploreQuery("TOP_VOLUME_24H", options);
|
|
465
|
+
var getExploreMostValuable = (options) => createExploreQuery("MOST_VALUABLE", options);
|
|
466
|
+
var getExploreNew = (options) => createExploreQuery("NEW", options);
|
|
467
|
+
var getExploreLastTraded = (options) => createExploreQuery("LAST_TRADED", options);
|
|
468
|
+
var getExploreLastTradedUnique = (options) => createExploreQuery("LAST_TRADED_UNIQUE", options);
|
|
328
469
|
// Annotate the CommonJS export names for ESM import in node:
|
|
329
470
|
0 && (module.exports = {
|
|
330
471
|
createCoin,
|
|
331
472
|
createCoinCall,
|
|
473
|
+
getCoin,
|
|
474
|
+
getCoinComments,
|
|
332
475
|
getCoinCreateFromLogs,
|
|
333
|
-
|
|
476
|
+
getCoins,
|
|
477
|
+
getExploreLastTraded,
|
|
478
|
+
getExploreLastTradedUnique,
|
|
479
|
+
getExploreMostValuable,
|
|
480
|
+
getExploreNew,
|
|
481
|
+
getExploreTopGainers,
|
|
482
|
+
getExploreTopVolume24h,
|
|
483
|
+
getOnchainCoinDetails,
|
|
484
|
+
getProfile,
|
|
485
|
+
getProfileOwned,
|
|
334
486
|
getTradeFromLogs,
|
|
335
487
|
tradeCoin,
|
|
336
488
|
tradeCoinCall,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/actions/createCoin.ts","../src/constants.ts","../src/utils/validateClientNetwork.ts","../src/actions/tradeCoin.ts","../src/actions/getCoinDetails.ts","../src/actions/updateCoinURI.ts"],"sourcesContent":["\nexport { createCoin, createCoinCall, getCoinCreateFromLogs } from \"./actions/createCoin\";\nexport { tradeCoin, tradeCoinCall, getTradeFromLogs } from \"./actions/tradeCoin\";\nexport { getCoinDetails, type CoinDetails } from \"./actions/getCoinDetails\";\nexport { updateCoinURI, updateCoinURICall } from \"./actions/updateCoinURI\";\n","import { zoraFactoryImplABI } from \"@zoralabs/coins\";\nimport {\n Address,\n PublicClient,\n TransactionReceipt,\n WalletClient,\n SimulateContractParameters,\n ContractEventArgsFromTopics,\n parseEventLogs,\n} from \"viem\";\nimport { COIN_FACTORY_ADDRESS } from \"../constants\";\nimport { validateClientNetwork } from \"src/utils/validateClientNetwork\";\n\nexport type CoinDeploymentLogArgs = ContractEventArgsFromTopics<\n typeof zoraFactoryImplABI,\n \"CoinCreated\"\n>;\n\ntype CreateCoinArgs = {\n name: string;\n symbol: string;\n uri: string;\n owners?: Address[];\n tickLower?: number;\n payoutRecipient: Address;\n platformReferrer?: Address;\n initialPurchaseWei?: bigint;\n};\n\nexport function createCoinCall({\n name,\n symbol,\n uri,\n owners,\n payoutRecipient,\n initialPurchaseWei = 0n,\n tickLower = -199200,\n platformReferrer = \"0x0000000000000000000000000000000000000000\",\n}: CreateCoinArgs): SimulateContractParameters<\n typeof zoraFactoryImplABI,\n \"deploy\"\n> {\n if (!owners) {\n owners = [payoutRecipient];\n }\n\n const currency = \"0x4200000000000000000000000000000000000006\";\n return {\n abi: zoraFactoryImplABI,\n functionName: \"deploy\",\n address: COIN_FACTORY_ADDRESS,\n args: [\n payoutRecipient,\n owners,\n uri,\n name,\n symbol,\n platformReferrer,\n currency,\n tickLower,\n initialPurchaseWei,\n ],\n value: initialPurchaseWei,\n } as const;\n}\n\n/**\n * Gets the deployed coin address from transaction receipt logs\n * @param receipt Transaction receipt containing the CoinCreated event\n * @returns The deployment information if found\n */\nexport function getCoinCreateFromLogs(\n receipt: TransactionReceipt,\n): CoinDeploymentLogArgs | undefined {\n const eventLogs = parseEventLogs({\n abi: zoraFactoryImplABI,\n logs: receipt.logs,\n });\n return eventLogs.find((log) => log.eventName === \"CoinCreated\")?.args;\n}\n\n// Update createCoin to return both receipt and coin address\nexport async function createCoin(\n call: CreateCoinArgs,\n walletClient: WalletClient,\n publicClient: PublicClient,\n) {\n validateClientNetwork(publicClient);\n const { request } = await publicClient.simulateContract({\n ...createCoinCall(call),\n account: walletClient.account,\n });\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const deployment = getCoinCreateFromLogs(receipt);\n\n return {\n hash,\n receipt,\n address: deployment?.coin,\n deployment,\n };\n}\n","import { zoraFactoryImplAddress } from \"@zoralabs/coins\";\nimport { Address } from \"viem\";\nimport { base } from \"viem/chains\";\n\n// this is the same across all chains due to deterministic deploys.\nexport const COIN_FACTORY_ADDRESS = zoraFactoryImplAddress[\"8453\"] as Address;\n\nexport const SUPERCHAIN_WETH_ADDRESS = '0x4200000000000000000000000000000000000006';\n\nexport const USDC_WETH_POOLS_BY_CHAIN: Record<number, Address> = {\n [base.id]: '0xd0b53D9277642d899DF5C87A3966A349A798F224',\n}\n","import { PublicClient } from \"viem\"\nimport { base, baseSepolia } from \"viem/chains\"\n\nexport const validateClientNetwork = (publicClient: PublicClient) => {\n const clientChainId = publicClient?.chain?.id;\n if (clientChainId === base.id) {\n return;\n }\n if (clientChainId === baseSepolia.id) {\n return;\n }\n\n throw new Error('Client network needs to be base or baseSepolia for current coin deployments.');\n}","import { coinABI } from \"@zoralabs/coins\";\nimport { validateClientNetwork } from \"src/utils/validateClientNetwork\";\nimport {\n Address,\n PublicClient,\n TransactionReceipt,\n WalletClient,\n SimulateContractParameters,\n parseEther,\n zeroAddress,\n ContractEventArgsFromTopics,\n parseEventLogs,\n} from \"viem\";\nimport { baseSepolia } from \"viem/chains\";\n\n// Define trade event args type\n\nexport type SellEventArgs = ContractEventArgsFromTopics<\n typeof coinABI,\n \"CoinSell\"\n>;\nexport type BuyEventArgs = ContractEventArgsFromTopics<\n typeof coinABI,\n \"CoinBuy\"\n>;\n\nexport type TradeEventArgs = SellEventArgs | BuyEventArgs;\n\n/**\n * Simulates a buy order to get the expected output amount\n * @param {Object} params - The simulation parameters\n * @param {Address} params.target - The target coin contract address\n * @param {bigint} params.requestedOrderSize - The desired input amount for the buy\n * @param {PublicClient} params.publicClient - The viem public client instance\n * @returns {Promise<{orderSize: bigint, amountOut: bigint}>} The simulated order size and output amount\n */\nexport async function simulateBuy({\n target,\n requestedOrderSize,\n publicClient,\n}: {\n target: Address;\n requestedOrderSize: bigint;\n publicClient: PublicClient;\n}): Promise<{ orderSize: bigint; amountOut: bigint }> {\n const numberResult = await publicClient.simulateContract({\n address: target,\n abi: coinABI,\n functionName: \"buy\",\n args: [\n zeroAddress,\n requestedOrderSize,\n 0n, // minAmountOut\n 0n, // sqrtPriceLimitX96\n zeroAddress, // tradeReferrer\n ],\n stateOverride: [\n {\n address: baseSepolia.contracts.multicall3.address,\n balance: parseEther(\"100000\"),\n },\n ],\n });\n const orderSize = numberResult.result[0];\n const amountOut = numberResult.result[1];\n return { orderSize, amountOut };\n}\n\n/**\n * Parameters for creating a trade call\n * @typedef {Object} TradeParams\n * @property {'sell' | 'buy'} direction - The trade direction\n * @property {Address} target - The target coin contract address\n * @property {Object} args - The trade arguments\n * @property {Address} args.recipient - The recipient of the trade output\n * @property {bigint} args.orderSize - The size of the order\n * @property {bigint} [args.minAmountOut] - The minimum amount to receive\n * @property {bigint} [args.sqrtPriceLimitX96] - The price limit for the trade\n * @property {Address} [args.tradeReferrer] - The referrer address for the trade\n */\ntype TradeParams = {\n direction: \"sell\" | \"buy\";\n target: Address;\n args: {\n recipient: Address;\n orderSize: bigint;\n minAmountOut?: bigint;\n sqrtPriceLimitX96?: bigint;\n tradeReferrer?: Address;\n };\n};\n\n/**\n * Creates a trade call parameters object for buy or sell\n * @param {TradeParams} params - The trade parameters\n * @returns {SimulateContractParameters} The contract call parameters\n */\nexport function tradeCoinCall({\n target,\n direction,\n args: {\n recipient,\n orderSize,\n minAmountOut = 0n,\n sqrtPriceLimitX96 = 0n,\n tradeReferrer = zeroAddress,\n },\n}: TradeParams): SimulateContractParameters {\n return {\n abi: coinABI,\n functionName: direction,\n address: target,\n args: [\n recipient,\n orderSize,\n minAmountOut,\n sqrtPriceLimitX96,\n tradeReferrer,\n ],\n value: direction === \"buy\" ? orderSize : 0n,\n } as const;\n}\n\n/**\n * Gets the trade event from transaction receipt logs\n * @param {TransactionReceipt} receipt - The transaction receipt containing the logs\n * @param {'buy' | 'sell'} direction - The direction of the trade\n * @returns {TradeEventArgs | undefined} The decoded trade event args if found\n */\nexport function getTradeFromLogs(\n receipt: TransactionReceipt,\n direction: \"buy\" | \"sell\",\n): TradeEventArgs | undefined {\n const eventLogs = parseEventLogs({\n abi: coinABI,\n logs: receipt.logs,\n });\n\n if (direction === \"buy\") {\n return eventLogs.find((log) => log.eventName === \"CoinBuy\")?.args;\n }\n return eventLogs.find((log) => log.eventName === \"CoinSell\")?.args;\n}\n\n/**\n * Executes a trade transaction\n * @param {TradeParams} params - The trade parameters\n * @param {PublicClient} publicClient - The viem public client instance\n * @param {WalletClient} walletClient - The viem wallet client instance\n * @returns {Promise<{\n * hash: `0x${string}`,\n * receipt: TransactionReceipt,\n * trade: TradeEventArgs | undefined\n * }>} The transaction result with trade details\n */\nexport async function tradeCoin(\n params: TradeParams,\n walletClient: WalletClient,\n publicClient: PublicClient,\n) {\n validateClientNetwork(publicClient);\n const { request } = await publicClient.simulateContract({\n ...tradeCoinCall(params),\n account: walletClient.account,\n });\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const trade = getTradeFromLogs(receipt, params.direction);\n\n return {\n hash,\n receipt,\n trade,\n };\n}\n","import { coinABI, iUniswapV3PoolABI } from \"@zoralabs/coins\";\nimport { SUPERCHAIN_WETH_ADDRESS, USDC_WETH_POOLS_BY_CHAIN } from \"src/constants\";\nimport { validateClientNetwork } from \"src/utils/validateClientNetwork\";\nimport { Address, erc20Abi, formatEther, isAddressEqual, PublicClient, zeroAddress } from \"viem\";\n\n\ntype Slot0Result = {\n sqrtPriceX96: bigint;\n tick: number;\n observationIndex: number;\n observationCardinality: number;\n observationCardinalityNext: number;\n feeProtocol: number;\n unlocked: boolean;\n};\n\ntype PricingResult = {\n eth: bigint,\n usdc: bigint | null,\n usdcDecimal: number | null,\n ethDecimal: number,\n}\n\n/**\n * Represents the current state of a coin\n * @typedef {Object} CoinDetails\n * @property {bigint} balance - The user's balance of the coin\n * @property {PricingResult} marketCap - The market cap of the coin\n * @property {PricingResult} liquidity - The liquidity of the coin\n * @property {Address} pool - Pool address\n * @property {Slot0Result} poolState - Current state of the UniswapV3 pool\n * @property {Address[]} owners - List of owners for the coin\n * @property {Address} payoutRecipient - The payout recipient address\n */\nexport type CoinDetails = {\n balance: bigint;\n marketCap: PricingResult;\n liquidity: PricingResult;\n pool: Address;\n poolState: Slot0Result;\n owners: readonly Address[],\n payoutRecipient: Address,\n};\n\n/**\n * Gets the current state of a coin for a user\n * @param {Object} params - The query parameters\n * @param {Address} params.coin - The coin contract address\n * @param {Address} params.user - The user address to check balance for\n * @param {PublicClient} params.publicClient - The viem public client instance\n * @returns {Promise<CoinDetails>} The coin's current state\n */\nexport async function getCoinDetails({\n coin,\n user = zeroAddress,\n publicClient,\n}: {\n coin: Address;\n user?: Address;\n publicClient: PublicClient;\n}): Promise<CoinDetails> {\n validateClientNetwork(publicClient);\n const [balance, pool, owners, payoutRecipient] = await publicClient.multicall({\n contracts: [\n {\n address: coin,\n abi: coinABI,\n functionName: \"balanceOf\",\n args: [user],\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"poolAddress\",\n },\n {\n address: coin,\n abi: coinABI,\n functionName: 'owners',\n },\n {\n address: coin,\n abi: coinABI,\n functionName: 'payoutRecipient',\n }\n ],\n allowFailure: false,\n });\n\n const USDC_WETH_POOL = USDC_WETH_POOLS_BY_CHAIN[publicClient.chain?.id || 0];\n\n const [coinWethPoolSlot0, coinWethPoolToken0, coinReservesRaw, coinTotalSupply, wethReservesRaw, usdcWethSlot0] = await publicClient.multicall({\n contracts: [{\n address: pool,\n abi: iUniswapV3PoolABI,\n functionName: \"slot0\",\n },\n {\n address: pool,\n abi: iUniswapV3PoolABI,\n functionName: 'token0'\n }, {\n address: coin,\n abi: erc20Abi,\n functionName: 'balanceOf',\n args: [pool],\n },\n {\n address: coin,\n abi: coinABI,\n functionName: 'totalSupply',\n }, {\n address: SUPERCHAIN_WETH_ADDRESS,\n abi: erc20Abi,\n functionName: 'balanceOf',\n args: [pool],\n }, {\n address: USDC_WETH_POOL ?? coin,\n abi: iUniswapV3PoolABI,\n functionName: 'slot0',\n }], allowFailure: false\n });\n\n const wethPriceInUsdc = USDC_WETH_POOL ? uniswapV3SqrtPriceToBigIntScaled(\n usdcWethSlot0.sqrtPriceX96,\n 18,\n 6,\n true,\n 18\n ) : null;\n\n const coinPriceInWeth = uniswapV3SqrtPriceToBigIntScaled(\n coinWethPoolSlot0.sqrtPriceX96,\n 18,\n 18,\n isAddressEqual(coinWethPoolToken0, coin),\n 18\n );\n\n // Divide by 10^18 to remove percision from `coinPriceInWeth` after math since bigint is decimal.\n const marketCap = coinPriceInWeth * coinTotalSupply / 10n ** 18n;\n\n const wethLiquidity = wethReservesRaw;\n // Divide by 10^18 to remove percision from `coinPriceInWeth` after math since bigint is decimal.\n const tokenLiquidity = coinReservesRaw * coinPriceInWeth / 10n ** 18n;\n\n return {\n balance,\n pool,\n owners,\n payoutRecipient,\n marketCap: convertEthOutput(marketCap, wethPriceInUsdc),\n liquidity: convertEthOutput(wethLiquidity + tokenLiquidity, wethPriceInUsdc),\n poolState: coinWethPoolSlot0,\n };\n}\n\n\nfunction convertEthOutput(amountETH: bigint, wethToUsdc: bigint | null) {\n return { eth: amountETH, ethDecimal: parseFloat(formatEther(amountETH)), usdc: wethToUsdc ? amountETH * wethToUsdc : null, usdcDecimal: wethToUsdc ? parseFloat(formatEther(amountETH * wethToUsdc / 10n ** 18n)) : null }\n}\n\nfunction uniswapV3SqrtPriceToBigIntScaled(\n sqrtPriceX96: bigint,\n token0Decimals: number,\n token1Decimals: number,\n isToken0Coin: boolean,\n scaleDecimals: number = 18\n): bigint {\n // (sqrtPrice^2 / 2^192) => ratio\n // We'll do: ratioScaled = (sqrtPrice^2 * 10^scaleDecimals) / 2^192\n const numerator = sqrtPriceX96 * sqrtPriceX96;\n const denominator = 2n ** 192n;\n const scaleFactor = 10n ** BigInt(scaleDecimals);\n\n // raw ratioScaled\n let ratioScaled = (numerator * scaleFactor) / denominator; // BigInt\n\n // Adjust for difference in decimals:\n // ratioScaled *= 10^(dec0 - dec1)\n const decimalsDiff = BigInt(token0Decimals - token1Decimals);\n if (decimalsDiff > 0n) {\n ratioScaled *= 10n ** decimalsDiff;\n } else if (decimalsDiff < 0n) {\n ratioScaled /= 10n ** (-decimalsDiff);\n }\n\n if (!isToken0Coin) {\n // We want the reciprocal: coin is token1 => coinPriceInToken0 = 1 / ratio\n // But we also want it scaled by 10^scaleDecimals\n // reciprocalScaled = (10^scaleDecimals * 10^(decimalsDiff)) / ratioScaled\n // (assuming ratioScaled != 0)\n if (ratioScaled === 0n) {\n return 0n; // or some huge number representing infinity\n }\n ratioScaled = (scaleFactor * scaleFactor) / ratioScaled;\n // or if we already included decimalsDiff above, handle carefully.\n }\n\n return ratioScaled;\n}\n","import { coinABI } from \"@zoralabs/coins\";\nimport { validateClientNetwork } from \"src/utils/validateClientNetwork\";\nimport {\n Address,\n parseEventLogs,\n PublicClient,\n SimulateContractParameters,\n WalletClient,\n} from \"viem\";\n\ntype UpdateCoinURIArgs = {\n coin: Address;\n newURI: string;\n};\n\nexport function updateCoinURICall({\n newURI,\n coin,\n}: UpdateCoinURIArgs): SimulateContractParameters {\n if (!newURI.startsWith(\"ipfs://\")) {\n throw new Error(\"URI needs to be an ipfs:// prefix uri\");\n }\n\n return {\n abi: coinABI,\n address: coin,\n functionName: \"setContractURI\",\n args: [newURI],\n };\n}\n\nexport async function updateCoinURI(\n args: UpdateCoinURIArgs,\n walletClient: WalletClient,\n publicClient: PublicClient,\n) {\n validateClientNetwork(publicClient);\n const call = updateCoinURICall(args);\n const { request } = await publicClient.simulateContract({\n ...call,\n account: walletClient.account!,\n });\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const eventLogs = parseEventLogs({ abi: coinABI, logs: receipt.logs });\n const uriUpdated = eventLogs.find(\n (log) => log.eventName === \"ContractURIUpdated\",\n );\n\n return { hash, receipt, uriUpdated };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAA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OAAQ,CAAC;AAAA,EAC1B;AAEA,MAAI,CAAC,cAAc;AAKjB,QAAI,gBAAgB,IAAI;AACtB,aAAO;AAAA,IACT;AACA,kBAAe,cAAc,cAAe;AAAA,EAE9C;AAEA,SAAO;AACT;;;ACxMA,IAAAC,gBAAwB;AAExB,IAAAC,eAMO;AAOA,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AACF,GAAkD;AAChD,MAAI,CAAC,OAAO,WAAW,SAAS,GAAG;AACjC,UAAM,IAAI,MAAM,uCAAuC;AAAA,EACzD;AAEA,SAAO;AAAA,IACL,KAAK;AAAA,IACL,SAAS;AAAA,IACT,cAAc;AAAA,IACd,MAAM,CAAC,MAAM;AAAA,EACf;AACF;AAEA,eAAsB,cACpB,MACA,cACA,cACA;AACA,wBAAsB,YAAY;AAClC,QAAM,OAAO,kBAAkB,IAAI;AACnC,QAAM,EAAE,QAAQ,IAAI,MAAM,aAAa,iBAAiB;AAAA,IACtD,GAAG;AAAA,IACH,SAAS,aAAa;AAAA,EACxB,CAAC;AACD,QAAM,OAAO,MAAM,aAAa,cAAc,OAAO;AACrD,QAAM,UAAU,MAAM,aAAa,0BAA0B,EAAE,KAAK,CAAC;AACrE,QAAM,gBAAY,6BAAe,EAAE,KAAK,uBAAS,MAAM,QAAQ,KAAK,CAAC;AACrE,QAAM,aAAa,UAAU;AAAA,IAC3B,CAAC,QAAQ,IAAI,cAAc;AAAA,EAC7B;AAEA,SAAO,EAAE,MAAM,SAAS,WAAW;AACrC;","names":["import_coins","import_chains","import_coins","import_viem","import_chains","import_coins","import_viem","import_coins","import_viem"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/actions/createCoin.ts","../src/constants.ts","../src/utils/validateClientNetwork.ts","../src/actions/tradeCoin.ts","../src/actions/getOnchainCoinDetails.ts","../src/actions/updateCoinURI.ts","../src/client/client.gen.ts","../src/client/sdk.gen.ts","../src/api/api-key.ts","../src/api/queries.ts","../src/api/explore.ts"],"sourcesContent":["export {\n createCoin,\n createCoinCall,\n getCoinCreateFromLogs,\n} from \"./actions/createCoin\";\nexport {\n tradeCoin,\n tradeCoinCall,\n getTradeFromLogs,\n} from \"./actions/tradeCoin\";\nexport {\n getOnchainCoinDetails,\n type OnchainCoinDetails,\n} from \"./actions/getOnchainCoinDetails\";\nexport { updateCoinURI, updateCoinURICall } from \"./actions/updateCoinURI\";\n\n// API Read Actions\nexport * from \"./api/queries\";\nexport * from \"./api/explore\";\n","import { zoraFactoryImplABI } from \"@zoralabs/coins\";\nimport {\n Address,\n PublicClient,\n TransactionReceipt,\n WalletClient,\n SimulateContractParameters,\n ContractEventArgsFromTopics,\n parseEventLogs,\n} from \"viem\";\nimport { COIN_FACTORY_ADDRESS } from \"../constants\";\nimport { validateClientNetwork } from \"src/utils/validateClientNetwork\";\n\nexport type CoinDeploymentLogArgs = ContractEventArgsFromTopics<\n typeof zoraFactoryImplABI,\n \"CoinCreated\"\n>;\n\ntype CreateCoinArgs = {\n name: string;\n symbol: string;\n uri: string;\n owners?: Address[];\n tickLower?: number;\n payoutRecipient: Address;\n platformReferrer?: Address;\n initialPurchaseWei?: bigint;\n};\n\nexport function createCoinCall({\n name,\n symbol,\n uri,\n owners,\n payoutRecipient,\n initialPurchaseWei = 0n,\n tickLower = -199200,\n platformReferrer = \"0x0000000000000000000000000000000000000000\",\n}: CreateCoinArgs): SimulateContractParameters<\n typeof zoraFactoryImplABI,\n \"deploy\"\n> {\n if (!owners) {\n owners = [payoutRecipient];\n }\n\n const currency = \"0x4200000000000000000000000000000000000006\";\n return {\n abi: zoraFactoryImplABI,\n functionName: \"deploy\",\n address: COIN_FACTORY_ADDRESS,\n args: [\n payoutRecipient,\n owners,\n uri,\n name,\n symbol,\n platformReferrer,\n currency,\n tickLower,\n initialPurchaseWei,\n ],\n value: initialPurchaseWei,\n } as const;\n}\n\n/**\n * Gets the deployed coin address from transaction receipt logs\n * @param receipt Transaction receipt containing the CoinCreated event\n * @returns The deployment information if found\n */\nexport function getCoinCreateFromLogs(\n receipt: TransactionReceipt,\n): CoinDeploymentLogArgs | undefined {\n const eventLogs = parseEventLogs({\n abi: zoraFactoryImplABI,\n logs: receipt.logs,\n });\n return eventLogs.find((log) => log.eventName === \"CoinCreated\")?.args;\n}\n\n// Update createCoin to return both receipt and coin address\nexport async function createCoin(\n call: CreateCoinArgs,\n walletClient: WalletClient,\n publicClient: PublicClient,\n) {\n validateClientNetwork(publicClient);\n const { request } = await publicClient.simulateContract({\n ...createCoinCall(call),\n account: walletClient.account,\n });\n\n // Add a 1/5th buffer on gas.\n if (request.gas) {\n request.gas = request.gas * 6n / 5n;\n }\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const deployment = getCoinCreateFromLogs(receipt);\n\n return {\n hash,\n receipt,\n address: deployment?.coin,\n deployment,\n };\n}\n","import { zoraFactoryImplAddress } from \"@zoralabs/coins\";\nimport { Address } from \"viem\";\nimport { base } from \"viem/chains\";\n\n// this is the same across all chains due to deterministic deploys.\nexport const COIN_FACTORY_ADDRESS = zoraFactoryImplAddress[\"8453\"] as Address;\n\nexport const SUPERCHAIN_WETH_ADDRESS = '0x4200000000000000000000000000000000000006';\n\nexport const USDC_WETH_POOLS_BY_CHAIN: Record<number, Address> = {\n [base.id]: '0xd0b53D9277642d899DF5C87A3966A349A798F224',\n}\n","import { PublicClient } from \"viem\"\nimport { base, baseSepolia } from \"viem/chains\"\n\nexport const validateClientNetwork = (publicClient: PublicClient<any, any, any, any>) => {\n const clientChainId = publicClient?.chain?.id;\n if (clientChainId === base.id) {\n return;\n }\n if (clientChainId === baseSepolia.id) {\n return;\n }\n\n throw new Error('Client network needs to be base or baseSepolia for current coin deployments.');\n}","import { coinABI } from \"@zoralabs/coins\";\nimport { validateClientNetwork } from \"src/utils/validateClientNetwork\";\nimport {\n Address,\n PublicClient,\n TransactionReceipt,\n WalletClient,\n SimulateContractParameters,\n parseEther,\n zeroAddress,\n ContractEventArgsFromTopics,\n parseEventLogs,\n} from \"viem\";\nimport { baseSepolia } from \"viem/chains\";\n\n// Define trade event args type\n\nexport type SellEventArgs = ContractEventArgsFromTopics<\n typeof coinABI,\n \"CoinSell\"\n>;\nexport type BuyEventArgs = ContractEventArgsFromTopics<\n typeof coinABI,\n \"CoinBuy\"\n>;\n\nexport type TradeEventArgs = SellEventArgs | BuyEventArgs;\n\n/**\n * Simulates a buy order to get the expected output amount\n * @param {Object} params - The simulation parameters\n * @param {Address} params.target - The target coin contract address\n * @param {bigint} params.requestedOrderSize - The desired input amount for the buy\n * @param {PublicClient} params.publicClient - The viem public client instance\n * @returns {Promise<{orderSize: bigint, amountOut: bigint}>} The simulated order size and output amount\n */\nexport async function simulateBuy({\n target,\n requestedOrderSize,\n publicClient,\n}: {\n target: Address;\n requestedOrderSize: bigint;\n publicClient: PublicClient;\n}): Promise<{ orderSize: bigint; amountOut: bigint }> {\n const numberResult = await publicClient.simulateContract({\n address: target,\n abi: coinABI,\n functionName: \"buy\",\n args: [\n zeroAddress,\n requestedOrderSize,\n 0n, // minAmountOut\n 0n, // sqrtPriceLimitX96\n zeroAddress, // tradeReferrer\n ],\n stateOverride: [\n {\n address: baseSepolia.contracts.multicall3.address,\n balance: parseEther(\"100000\"),\n },\n ],\n });\n const orderSize = numberResult.result[0];\n const amountOut = numberResult.result[1];\n return { orderSize, amountOut };\n}\n\n/**\n * Parameters for creating a trade call\n * @typedef {Object} TradeParams\n * @property {'sell' | 'buy'} direction - The trade direction\n * @property {Address} target - The target coin contract address\n * @property {Object} args - The trade arguments\n * @property {Address} args.recipient - The recipient of the trade output\n * @property {bigint} args.orderSize - The size of the order\n * @property {bigint} [args.minAmountOut] - The minimum amount to receive\n * @property {bigint} [args.sqrtPriceLimitX96] - The price limit for the trade\n * @property {Address} [args.tradeReferrer] - The referrer address for the trade\n */\ntype TradeParams = {\n direction: \"sell\" | \"buy\";\n target: Address;\n args: {\n recipient: Address;\n orderSize: bigint;\n minAmountOut?: bigint;\n sqrtPriceLimitX96?: bigint;\n tradeReferrer?: Address;\n };\n};\n\n/**\n * Creates a trade call parameters object for buy or sell\n * @param {TradeParams} params - The trade parameters\n * @returns {SimulateContractParameters} The contract call parameters\n */\nexport function tradeCoinCall({\n target,\n direction,\n args: {\n recipient,\n orderSize,\n minAmountOut = 0n,\n sqrtPriceLimitX96 = 0n,\n tradeReferrer = zeroAddress,\n },\n}: TradeParams): SimulateContractParameters {\n return {\n abi: coinABI,\n functionName: direction,\n address: target,\n args: [\n recipient,\n orderSize,\n minAmountOut,\n sqrtPriceLimitX96,\n tradeReferrer,\n ],\n value: direction === \"buy\" ? orderSize : 0n,\n } as const;\n}\n\n/**\n * Gets the trade event from transaction receipt logs\n * @param {TransactionReceipt} receipt - The transaction receipt containing the logs\n * @param {'buy' | 'sell'} direction - The direction of the trade\n * @returns {TradeEventArgs | undefined} The decoded trade event args if found\n */\nexport function getTradeFromLogs(\n receipt: TransactionReceipt,\n direction: \"buy\" | \"sell\",\n): TradeEventArgs | undefined {\n const eventLogs = parseEventLogs({\n abi: coinABI,\n logs: receipt.logs,\n });\n\n if (direction === \"buy\") {\n return eventLogs.find((log) => log.eventName === \"CoinBuy\")?.args;\n }\n return eventLogs.find((log) => log.eventName === \"CoinSell\")?.args;\n}\n\n/**\n * Executes a trade transaction\n * @param {TradeParams} params - The trade parameters\n * @param {PublicClient} publicClient - The viem public client instance\n * @param {WalletClient} walletClient - The viem wallet client instance\n * @returns {Promise<{\n * hash: `0x${string}`,\n * receipt: TransactionReceipt,\n * trade: TradeEventArgs | undefined\n * }>} The transaction result with trade details\n */\nexport async function tradeCoin(\n params: TradeParams,\n walletClient: WalletClient,\n publicClient: PublicClient,\n) {\n validateClientNetwork(publicClient);\n const { request } = await publicClient.simulateContract({\n ...tradeCoinCall(params),\n account: walletClient.account,\n });\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const trade = getTradeFromLogs(receipt, params.direction);\n\n return {\n hash,\n receipt,\n trade,\n };\n}\n","import { coinABI, iUniswapV3PoolABI } from \"@zoralabs/coins\";\nimport {\n SUPERCHAIN_WETH_ADDRESS,\n USDC_WETH_POOLS_BY_CHAIN,\n} from \"src/constants\";\nimport { GenericPublicClient } from \"src/utils/genericPublicClient\";\nimport { validateClientNetwork } from \"src/utils/validateClientNetwork\";\nimport {\n Address,\n erc20Abi,\n formatEther,\n isAddressEqual,\n zeroAddress,\n} from \"viem\";\n\ntype Slot0Result = {\n sqrtPriceX96: bigint;\n tick: number;\n observationIndex: number;\n observationCardinality: number;\n observationCardinalityNext: number;\n feeProtocol: number;\n unlocked: boolean;\n};\n\ntype PricingResult = {\n eth: bigint;\n usdc: bigint | null;\n usdcDecimal: number | null;\n ethDecimal: number;\n};\n\n/**\n * Represents the current state of a coin\n * @typedef {Object} OnchainCoinDetails\n * @property {bigint} balance - The user's balance of the coin\n * @property {PricingResult} marketCap - The market cap of the coin\n * @property {PricingResult} liquidity - The liquidity of the coin\n * @property {Address} pool - Pool address\n * @property {Slot0Result} poolState - Current state of the UniswapV3 pool\n * @property {Address[]} owners - List of owners for the coin\n * @property {Address} payoutRecipient - The payout recipient address\n */\nexport type OnchainCoinDetails = {\n balance: bigint;\n marketCap: PricingResult;\n liquidity: PricingResult;\n pool: Address;\n poolState: Slot0Result;\n owners: readonly Address[];\n payoutRecipient: Address;\n};\n\n/**\n * Gets the current state of a coin for a user\n * @param {Object} params - The query parameters\n * @param {Address} params.coin - The coin contract address\n * @param {Address} params.user - The user address to check balance for\n * @param {PublicClient} params.publicClient - The viem public client instance\n * @returns {Promise<OnchainCoinDetails>} The coin's current state\n */\nexport async function getOnchainCoinDetails({\n coin,\n user = zeroAddress,\n publicClient,\n}: {\n coin: Address;\n user?: Address;\n publicClient: GenericPublicClient;\n}): Promise<OnchainCoinDetails> {\n validateClientNetwork(publicClient);\n const [balance, pool, owners, payoutRecipient] = await publicClient.multicall(\n {\n contracts: [\n {\n address: coin,\n abi: coinABI,\n functionName: \"balanceOf\",\n args: [user],\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"poolAddress\",\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"owners\",\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"payoutRecipient\",\n },\n ],\n allowFailure: false,\n },\n );\n\n const USDC_WETH_POOL = USDC_WETH_POOLS_BY_CHAIN[publicClient.chain?.id || 0];\n\n const [\n coinWethPoolSlot0,\n coinWethPoolToken0,\n coinReservesRaw,\n coinTotalSupply,\n wethReservesRaw,\n usdcWethSlot0,\n ] = await publicClient.multicall({\n contracts: [\n {\n address: pool,\n abi: iUniswapV3PoolABI,\n functionName: \"slot0\",\n },\n {\n address: pool,\n abi: iUniswapV3PoolABI,\n functionName: \"token0\",\n },\n {\n address: coin,\n abi: erc20Abi,\n functionName: \"balanceOf\",\n args: [pool],\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"totalSupply\",\n },\n {\n address: SUPERCHAIN_WETH_ADDRESS,\n abi: erc20Abi,\n functionName: \"balanceOf\",\n args: [pool],\n },\n {\n address: USDC_WETH_POOL ?? coin,\n abi: iUniswapV3PoolABI,\n functionName: \"slot0\",\n },\n ],\n allowFailure: false,\n });\n\n const wethPriceInUsdc = USDC_WETH_POOL\n ? uniswapV3SqrtPriceToBigIntScaled(\n usdcWethSlot0.sqrtPriceX96,\n 18,\n 6,\n true,\n 18,\n )\n : null;\n\n const coinPriceInWeth = uniswapV3SqrtPriceToBigIntScaled(\n coinWethPoolSlot0.sqrtPriceX96,\n 18,\n 18,\n isAddressEqual(coinWethPoolToken0, coin),\n 18,\n );\n\n // Divide by 10^18 to remove percision from `coinPriceInWeth` after math since bigint is decimal.\n const marketCap = (coinPriceInWeth * coinTotalSupply) / 10n ** 18n;\n\n const wethLiquidity = wethReservesRaw;\n // Divide by 10^18 to remove percision from `coinPriceInWeth` after math since bigint is decimal.\n const tokenLiquidity = (coinReservesRaw * coinPriceInWeth) / 10n ** 18n;\n\n return {\n balance,\n pool,\n owners,\n payoutRecipient,\n marketCap: convertEthOutput(marketCap, wethPriceInUsdc),\n liquidity: convertEthOutput(\n wethLiquidity + tokenLiquidity,\n wethPriceInUsdc,\n ),\n poolState: coinWethPoolSlot0,\n };\n}\n\nfunction convertEthOutput(amountETH: bigint, wethToUsdc: bigint | null) {\n return {\n eth: amountETH,\n ethDecimal: parseFloat(formatEther(amountETH)),\n usdc: wethToUsdc ? amountETH * wethToUsdc : null,\n usdcDecimal: wethToUsdc\n ? parseFloat(formatEther((amountETH * wethToUsdc) / 10n ** 18n))\n : null,\n };\n}\n\nfunction uniswapV3SqrtPriceToBigIntScaled(\n sqrtPriceX96: bigint,\n token0Decimals: number,\n token1Decimals: number,\n isToken0Coin: boolean,\n scaleDecimals: number = 18,\n): bigint {\n // (sqrtPrice^2 / 2^192) => ratio\n // We'll do: ratioScaled = (sqrtPrice^2 * 10^scaleDecimals) / 2^192\n const numerator = sqrtPriceX96 * sqrtPriceX96;\n const denominator = 2n ** 192n;\n const scaleFactor = 10n ** BigInt(scaleDecimals);\n\n // raw ratioScaled\n let ratioScaled = (numerator * scaleFactor) / denominator; // BigInt\n\n // Adjust for difference in decimals:\n // ratioScaled *= 10^(dec0 - dec1)\n const decimalsDiff = BigInt(token0Decimals - token1Decimals);\n if (decimalsDiff > 0n) {\n ratioScaled *= 10n ** decimalsDiff;\n } else if (decimalsDiff < 0n) {\n ratioScaled /= 10n ** -decimalsDiff;\n }\n\n if (!isToken0Coin) {\n // We want the reciprocal: coin is token1 => coinPriceInToken0 = 1 / ratio\n // But we also want it scaled by 10^scaleDecimals\n // reciprocalScaled = (10^scaleDecimals * 10^(decimalsDiff)) / ratioScaled\n // (assuming ratioScaled != 0)\n if (ratioScaled === 0n) {\n return 0n; // or some huge number representing infinity\n }\n ratioScaled = (scaleFactor * scaleFactor) / ratioScaled;\n // or if we already included decimalsDiff above, handle carefully.\n }\n\n return ratioScaled;\n}\n","import { coinABI } from \"@zoralabs/coins\";\nimport { validateClientNetwork } from \"src/utils/validateClientNetwork\";\nimport {\n Address,\n parseEventLogs,\n PublicClient,\n SimulateContractParameters,\n WalletClient,\n} from \"viem\";\n\ntype UpdateCoinURIArgs = {\n coin: Address;\n newURI: string;\n};\n\nexport function updateCoinURICall({\n newURI,\n coin,\n}: UpdateCoinURIArgs): SimulateContractParameters {\n if (!newURI.startsWith(\"ipfs://\")) {\n throw new Error(\"URI needs to be an ipfs:// prefix uri\");\n }\n\n return {\n abi: coinABI,\n address: coin,\n functionName: \"setContractURI\",\n args: [newURI],\n };\n}\n\nexport async function updateCoinURI(\n args: UpdateCoinURIArgs,\n walletClient: WalletClient,\n publicClient: PublicClient,\n) {\n validateClientNetwork(publicClient);\n const call = updateCoinURICall(args);\n const { request } = await publicClient.simulateContract({\n ...call,\n account: walletClient.account!,\n });\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const eventLogs = parseEventLogs({ abi: coinABI, logs: receipt.logs });\n const uriUpdated = eventLogs.find(\n (log) => log.eventName === \"ContractURIUpdated\",\n );\n\n return { hash, receipt, uriUpdated };\n}\n","// This file is auto-generated by @hey-api/openapi-ts\n\nimport type { ClientOptions } from './types.gen';\nimport { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;\n\nexport const client = createClient(createConfig<ClientOptions>({\n baseUrl: 'https://api-sdk.zora.engineering/'\n}));","// This file is auto-generated by @hey-api/openapi-ts\n\nimport type {\n Options as ClientOptions,\n TDataShape,\n Client,\n} from \"@hey-api/client-fetch\";\nimport type {\n GetCoinData,\n GetCoinResponse,\n GetCoinCommentsData,\n GetCoinCommentsResponse,\n GetCoinsData,\n GetCoinsResponse,\n GetExploreData,\n GetExploreResponse,\n GetProfileData,\n GetProfileResponse,\n GetProfileOwnedData,\n GetProfileOwnedResponse,\n} from \"./types.gen\";\nimport { client as _heyApiClient } from \"./client.gen\";\n\nexport type Options<\n TData extends TDataShape = TDataShape,\n ThrowOnError extends boolean = boolean,\n> = ClientOptions<TData, ThrowOnError> & {\n /**\n * You can provide a client instance returned by `createClient()` instead of\n * individual options. This might be also useful if you want to implement a\n * custom client.\n */\n client?: Client;\n /**\n * You can pass arbitrary values through the `meta` object. This can be\n * used to access values that aren't defined as part of the SDK function.\n */\n meta?: Record<string, unknown>;\n};\n\nexport const getCoin = <ThrowOnError extends boolean = false>(\n options: Options<GetCoinData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetCoinResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/coin\",\n ...options,\n });\n};\n\nexport const getCoinComments = <ThrowOnError extends boolean = false>(\n options: Options<GetCoinCommentsData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetCoinCommentsResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/coinComments\",\n ...options,\n });\n};\n\nexport const getCoins = <ThrowOnError extends boolean = false>(\n options: Options<GetCoinsData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetCoinsResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/coins\",\n ...options,\n });\n};\n\nexport const getExplore = <ThrowOnError extends boolean = false>(\n options: Options<GetExploreData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetExploreResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/explore\",\n ...options,\n });\n};\n\nexport const getProfile = <ThrowOnError extends boolean = false>(\n options: Options<GetProfileData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetProfileResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/profile\",\n ...options,\n });\n};\n\nexport const getProfileOwned = <ThrowOnError extends boolean = false>(\n options: Options<GetProfileOwnedData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetProfileOwnedResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/profileOwned\",\n ...options,\n });\n};\n","let apiKey: string | undefined;\nexport function setApiKey(key: string) {\n apiKey = key;\n}\n\nexport function getApiKeyMeta() {\n if (!apiKey) {\n return {};\n }\n return {\n headers: {\n \"api-key\": apiKey,\n },\n };\n}\n","import {\n GetCoinCommentsData,\n GetCoinData,\n GetProfileData,\n GetProfileOwnedData,\n} from \"src/client\";\nimport {\n getCoin as getCoinSDK,\n getCoins as getCoinsSDK,\n getCoinComments as getCoinCommentsSDK,\n getProfile as getProfileSDK,\n getProfileOwned as getProfileOwnedSDK,\n} from \"../client/sdk.gen\";\nimport { getApiKeyMeta } from \"./api-key\";\n\nexport const getCoin = async (query: GetCoinData[\"query\"]) => {\n return await getCoinSDK({\n query,\n meta: getApiKeyMeta(),\n });\n};\n\nexport const getCoins = async ({\n coinAddresses,\n chainId,\n}: {\n coinAddresses: string[];\n chainId?: number;\n}) => {\n return await getCoinsSDK({\n query: {\n coins: coinAddresses.map((collectionAddress) => ({\n chainId,\n collectionAddress,\n })),\n },\n meta: getApiKeyMeta(),\n });\n};\n\nexport const getCoinComments = async (query: GetCoinCommentsData[\"query\"]) => {\n return await getCoinCommentsSDK({\n query,\n meta: getApiKeyMeta(),\n });\n};\n\nexport const getProfile = async (query: GetProfileData[\"query\"]) => {\n return await getProfileSDK({\n query,\n meta: getApiKeyMeta(),\n });\n};\n\nexport const getProfileOwned = async (query: GetProfileOwnedData[\"query\"]) => {\n return await getProfileOwnedSDK({\n query,\n meta: getApiKeyMeta(),\n });\n};\n","import { getExplore as getExploreSDK } from \"../client/sdk.gen\";\nimport type { GetExploreData } from \"../client/types.gen\";\nimport { Options } from \"@hey-api/client-fetch\";\nimport { getApiKeyMeta } from \"./api-key\";\n\n/**\n * The inner type for the explore queries that omits listType.\n * This is used to create the query object for the explore queries.\n */\ntype QueryInnerType = {\n query: Omit<GetExploreData[\"query\"], \"listType\">;\n} & Omit<GetExploreData, \"query\">;\n\n/**\n * Creates an explore query with the specified list type\n */\nconst createExploreQuery = <T extends boolean = false>(\n listType: GetExploreData[\"query\"][\"listType\"],\n options?: Options<QueryInnerType, T>,\n) =>\n getExploreSDK({\n ...options,\n query: { ...options?.query, listType },\n meta: getApiKeyMeta(),\n });\n\n/** Get top gaining coins */\nexport const getExploreTopGainers = <T extends boolean = false>(\n options?: Options<QueryInnerType, T>,\n) => createExploreQuery(\"TOP_GAINERS\", options);\n\n/** Get coins with highest 24h volume */\nexport const getExploreTopVolume24h = <T extends boolean = false>(\n options?: Options<QueryInnerType, T>,\n) => createExploreQuery(\"TOP_VOLUME_24H\", options);\n\n/** Get most valuable coins */\nexport const getExploreMostValuable = <T extends boolean = false>(\n options?: Options<QueryInnerType, T>,\n) => createExploreQuery(\"MOST_VALUABLE\", options);\n\n/** Get newly created coins */\nexport const getExploreNew = <T extends boolean = false>(\n options?: Options<QueryInnerType, T>,\n) => createExploreQuery(\"NEW\", options);\n\n/** Get recently traded coins */\nexport const getExploreLastTraded = <T extends boolean = false>(\n options?: Options<QueryInnerType, T>,\n) => createExploreQuery(\"LAST_TRADED\", options);\n\n/** Get recently traded unique coins */\nexport const getExploreLastTradedUnique = <T extends boolean = false>(\n options?: Options<QueryInnerType, T>,\n) => createExploreQuery(\"LAST_TRADED_UNIQUE\", options);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAAA;AAAA,EAAA,uBAAAC;AAAA,EAAA;AAAA,kBAAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAAC;AAAA,EAAA,uBAAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAC,gBAAmC;AACnC,kBAQO;;;ACTP,mBAAuC;AAEvC,oBAAqB;AAGd,IAAM,uBAAu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ACzB;AAAA,IACA,MAAM,cAAc;AAAA,EACtB,CAAC;AACH;AAEO,IAAMC,mBAAkB,OAAO,UAAwC;AAC5E,SAAO,MAAM,gBAAmB;AAAA,IAC9B;AAAA,IACA,MAAM,cAAc;AAAA,EACtB,CAAC;AACH;;;AC3CA,IAAM,qBAAqB,CACzB,UACA,YAEA,WAAc;AAAA,EACZ,GAAG;AAAA,EACH,OAAO,EAAE,GAAG,SAAS,OAAO,SAAS;AAAA,EACrC,MAAM,cAAc;AACtB,CAAC;AAGI,IAAM,uBAAuB,CAClC,YACG,mBAAmB,eAAe,OAAO;AAGvC,IAAM,yBAAyB,CACpC,YACG,mBAAmB,kBAAkB,OAAO;AAG1C,IAAM,yBAAyB,CACpC,YACG,mBAAmB,iBAAiB,OAAO;AAGzC,IAAM,gBAAgB,CAC3B,YACG,mBAAmB,OAAO,OAAO;AAG/B,IAAM,uBAAuB,CAClC,YACG,mBAAmB,eAAe,OAAO;AAGvC,IAAM,6BAA6B,CACxC,YACG,mBAAmB,sBAAsB,OAAO;","names":["getCoin","getCoinComments","getCoins","getProfile","getProfileOwned","import_coins","import_chains","import_coins","import_viem","import_chains","import_coins","import_viem","import_coins","import_viem","getCoin","getCoins","getCoinComments","getProfile","getProfileOwned"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export { createCoin, createCoinCall, getCoinCreateFromLogs } from "./actions/createCoin";
|
|
2
|
-
export { tradeCoin, tradeCoinCall, getTradeFromLogs } from "./actions/tradeCoin";
|
|
3
|
-
export {
|
|
1
|
+
export { createCoin, createCoinCall, getCoinCreateFromLogs, } from "./actions/createCoin";
|
|
2
|
+
export { tradeCoin, tradeCoinCall, getTradeFromLogs, } from "./actions/tradeCoin";
|
|
3
|
+
export { getOnchainCoinDetails, type OnchainCoinDetails, } from "./actions/getOnchainCoinDetails";
|
|
4
4
|
export { updateCoinURI, updateCoinURICall } from "./actions/updateCoinURI";
|
|
5
|
+
export * from "./api/queries";
|
|
6
|
+
export * from "./api/explore";
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,cAAc,EACd,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,SAAS,EACT,aAAa,EACb,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,qBAAqB,EACrB,KAAK,kBAAkB,GACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG3E,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
|