@zoralabs/coins-sdk 0.0.2-sdkalpha.4 → 0.0.2-sdkalpha.6
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 +157 -115
- package/dist/actions/updatePayoutRecipient.d.ts +30 -0
- package/dist/actions/updatePayoutRecipient.d.ts.map +1 -0
- package/dist/api/explore.d.ts +6 -6
- package/dist/api/explore.d.ts.map +1 -1
- package/dist/api/queries.d.ts +2 -2
- package/dist/api/queries.d.ts.map +1 -1
- package/dist/client/sdk.gen.d.ts +2 -2
- package/dist/client/sdk.gen.d.ts.map +1 -1
- package/dist/client/types.gen.d.ts +5 -14
- package/dist/client/types.gen.d.ts.map +1 -1
- package/dist/index.cjs +68 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -19
- package/dist/index.js.map +1 -1
- package/dist/utils/validateClientNetwork.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/actions/updatePayoutRecipient.ts +47 -0
- package/src/api/explore.ts +6 -6
- package/src/api/queries.ts +6 -4
- package/src/client/sdk.gen.ts +6 -6
- package/src/client/types.gen.ts +5 -15
- package/src/index.ts +9 -0
package/dist/index.cjs
CHANGED
|
@@ -26,20 +26,23 @@ __export(src_exports, {
|
|
|
26
26
|
getCoinComments: () => getCoinComments2,
|
|
27
27
|
getCoinCreateFromLogs: () => getCoinCreateFromLogs,
|
|
28
28
|
getCoins: () => getCoins2,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
getCoinsLastTraded: () => getCoinsLastTraded,
|
|
30
|
+
getCoinsLastTradedUnique: () => getCoinsLastTradedUnique,
|
|
31
|
+
getCoinsMostValuable: () => getCoinsMostValuable,
|
|
32
|
+
getCoinsNew: () => getCoinsNew,
|
|
33
|
+
getCoinsTopGainers: () => getCoinsTopGainers,
|
|
34
|
+
getCoinsTopVolume24h: () => getCoinsTopVolume24h,
|
|
35
35
|
getOnchainCoinDetails: () => getOnchainCoinDetails,
|
|
36
36
|
getProfile: () => getProfile2,
|
|
37
|
-
|
|
37
|
+
getProfileBalances: () => getProfileBalances2,
|
|
38
38
|
getTradeFromLogs: () => getTradeFromLogs,
|
|
39
|
+
setApiKey: () => setApiKey,
|
|
39
40
|
tradeCoin: () => tradeCoin,
|
|
40
41
|
tradeCoinCall: () => tradeCoinCall,
|
|
41
42
|
updateCoinURI: () => updateCoinURI,
|
|
42
|
-
updateCoinURICall: () => updateCoinURICall
|
|
43
|
+
updateCoinURICall: () => updateCoinURICall,
|
|
44
|
+
updatePayoutRecipient: () => updatePayoutRecipient,
|
|
45
|
+
updatePayoutRecipientCall: () => updatePayoutRecipientCall
|
|
43
46
|
});
|
|
44
47
|
module.exports = __toCommonJS(src_exports);
|
|
45
48
|
|
|
@@ -66,7 +69,9 @@ var validateClientNetwork = (publicClient) => {
|
|
|
66
69
|
if (clientChainId === import_chains2.baseSepolia.id) {
|
|
67
70
|
return;
|
|
68
71
|
}
|
|
69
|
-
throw new Error(
|
|
72
|
+
throw new Error(
|
|
73
|
+
"Client network needs to be base or baseSepolia for current coin deployments."
|
|
74
|
+
);
|
|
70
75
|
};
|
|
71
76
|
|
|
72
77
|
// src/actions/createCoin.ts
|
|
@@ -357,6 +362,36 @@ async function updateCoinURI(args, walletClient, publicClient) {
|
|
|
357
362
|
return { hash, receipt, uriUpdated };
|
|
358
363
|
}
|
|
359
364
|
|
|
365
|
+
// src/actions/updatePayoutRecipient.ts
|
|
366
|
+
var import_coins6 = require("@zoralabs/coins");
|
|
367
|
+
var import_viem5 = require("viem");
|
|
368
|
+
function updatePayoutRecipientCall({
|
|
369
|
+
newPayoutRecipient,
|
|
370
|
+
coin
|
|
371
|
+
}) {
|
|
372
|
+
return {
|
|
373
|
+
abi: import_coins6.coinABI,
|
|
374
|
+
address: coin,
|
|
375
|
+
functionName: "setPayoutRecipient",
|
|
376
|
+
args: [newPayoutRecipient]
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
async function updatePayoutRecipient(args, walletClient, publicClient) {
|
|
380
|
+
validateClientNetwork(publicClient);
|
|
381
|
+
const call = updatePayoutRecipientCall(args);
|
|
382
|
+
const { request } = await publicClient.simulateContract({
|
|
383
|
+
...call,
|
|
384
|
+
account: walletClient.account
|
|
385
|
+
});
|
|
386
|
+
const hash = await walletClient.writeContract(request);
|
|
387
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
388
|
+
const eventLogs = (0, import_viem5.parseEventLogs)({ abi: import_coins6.coinABI, logs: receipt.logs });
|
|
389
|
+
const payoutRecipientUpdated = eventLogs.find(
|
|
390
|
+
(log) => log.eventName === "CoinPayoutRecipientUpdated"
|
|
391
|
+
);
|
|
392
|
+
return { hash, receipt, payoutRecipientUpdated };
|
|
393
|
+
}
|
|
394
|
+
|
|
360
395
|
// src/client/client.gen.ts
|
|
361
396
|
var import_client_fetch = require("@hey-api/client-fetch");
|
|
362
397
|
var client = (0, import_client_fetch.createClient)((0, import_client_fetch.createConfig)({
|
|
@@ -394,15 +429,18 @@ var getProfile = (options) => {
|
|
|
394
429
|
...options
|
|
395
430
|
});
|
|
396
431
|
};
|
|
397
|
-
var
|
|
432
|
+
var getProfileBalances = (options) => {
|
|
398
433
|
return (options.client ?? client).get({
|
|
399
|
-
url: "/
|
|
434
|
+
url: "/profileBalances",
|
|
400
435
|
...options
|
|
401
436
|
});
|
|
402
437
|
};
|
|
403
438
|
|
|
404
439
|
// src/api/api-key.ts
|
|
405
440
|
var apiKey;
|
|
441
|
+
function setApiKey(key) {
|
|
442
|
+
apiKey = key;
|
|
443
|
+
}
|
|
406
444
|
function getApiKeyMeta() {
|
|
407
445
|
if (!apiKey) {
|
|
408
446
|
return {};
|
|
@@ -447,8 +485,8 @@ var getProfile2 = async (query) => {
|
|
|
447
485
|
meta: getApiKeyMeta()
|
|
448
486
|
});
|
|
449
487
|
};
|
|
450
|
-
var
|
|
451
|
-
return await
|
|
488
|
+
var getProfileBalances2 = async (query) => {
|
|
489
|
+
return await getProfileBalances({
|
|
452
490
|
query,
|
|
453
491
|
meta: getApiKeyMeta()
|
|
454
492
|
});
|
|
@@ -460,12 +498,12 @@ var createExploreQuery = (listType, options) => getExplore({
|
|
|
460
498
|
query: { ...options?.query, listType },
|
|
461
499
|
meta: getApiKeyMeta()
|
|
462
500
|
});
|
|
463
|
-
var
|
|
464
|
-
var
|
|
465
|
-
var
|
|
466
|
-
var
|
|
467
|
-
var
|
|
468
|
-
var
|
|
501
|
+
var getCoinsTopGainers = (options) => createExploreQuery("TOP_GAINERS", options);
|
|
502
|
+
var getCoinsTopVolume24h = (options) => createExploreQuery("TOP_VOLUME_24H", options);
|
|
503
|
+
var getCoinsMostValuable = (options) => createExploreQuery("MOST_VALUABLE", options);
|
|
504
|
+
var getCoinsNew = (options) => createExploreQuery("NEW", options);
|
|
505
|
+
var getCoinsLastTraded = (options) => createExploreQuery("LAST_TRADED", options);
|
|
506
|
+
var getCoinsLastTradedUnique = (options) => createExploreQuery("LAST_TRADED_UNIQUE", options);
|
|
469
507
|
// Annotate the CommonJS export names for ESM import in node:
|
|
470
508
|
0 && (module.exports = {
|
|
471
509
|
createCoin,
|
|
@@ -474,19 +512,22 @@ var getExploreLastTradedUnique = (options) => createExploreQuery("LAST_TRADED_UN
|
|
|
474
512
|
getCoinComments,
|
|
475
513
|
getCoinCreateFromLogs,
|
|
476
514
|
getCoins,
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
515
|
+
getCoinsLastTraded,
|
|
516
|
+
getCoinsLastTradedUnique,
|
|
517
|
+
getCoinsMostValuable,
|
|
518
|
+
getCoinsNew,
|
|
519
|
+
getCoinsTopGainers,
|
|
520
|
+
getCoinsTopVolume24h,
|
|
483
521
|
getOnchainCoinDetails,
|
|
484
522
|
getProfile,
|
|
485
|
-
|
|
523
|
+
getProfileBalances,
|
|
486
524
|
getTradeFromLogs,
|
|
525
|
+
setApiKey,
|
|
487
526
|
tradeCoin,
|
|
488
527
|
tradeCoinCall,
|
|
489
528
|
updateCoinURI,
|
|
490
|
-
updateCoinURICall
|
|
529
|
+
updateCoinURICall,
|
|
530
|
+
updatePayoutRecipient,
|
|
531
|
+
updatePayoutRecipientCall
|
|
491
532
|
});
|
|
492
533
|
//# sourceMappingURL=index.cjs.map
|
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/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,uBAAuB,oCAAuB,MAAM;AAE1D,IAAM,0BAA0B;AAEhC,IAAM,2BAAoD;AAAA,EAC7D,CAAC,mBAAK,EAAE,GAAG;AACf;;;ACVA,IAAAC,iBAAkC;AAE3B,IAAM,wBAAwB,CAAC,iBAAmD;AACrF,QAAM,gBAAgB,cAAc,OAAO;AAC3C,MAAI,kBAAkB,oBAAK,IAAI;AAC3B;AAAA,EACJ;AACA,MAAI,kBAAkB,2BAAY,IAAI;AAClC;AAAA,EACJ;AAEA,QAAM,IAAI,MAAM,8EAA8E;AAClG;;;AFgBO,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,qBAAqB;AAAA,EACrB,YAAY;AAAA,EACZ,mBAAmB;AACrB,GAGE;AACA,MAAI,CAAC,QAAQ;AACX,aAAS,CAAC,eAAe;AAAA,EAC3B;AAEA,QAAM,WAAW;AACjB,SAAO;AAAA,IACL,KAAK;AAAA,IACL,cAAc;AAAA,IACd,SAAS;AAAA,IACT,MAAM;AAA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["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"]}
|
|
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/actions/updatePayoutRecipient.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\";\nexport { updatePayoutRecipient, updatePayoutRecipientCall } from \"./actions/updatePayoutRecipient\";\n\n// API Read Actions\nexport * from \"./api/queries\";\nexport * from \"./api/explore\";\n\nexport { setApiKey } from \"./api/api-key\";\n\n// API Types\nexport type * from \"src/client/types.gen\";\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 = (\n publicClient: PublicClient<any, any, any, any>,\n) => {\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(\n \"Client network needs to be base or baseSepolia for current coin deployments.\",\n );\n};\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","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 UpdatePayoutRecipientArgs = {\n coin: Address;\n newPayoutRecipient: string;\n};\n\nexport function updatePayoutRecipientCall({\n newPayoutRecipient,\n coin,\n}: UpdatePayoutRecipientArgs): SimulateContractParameters {\n return {\n abi: coinABI,\n address: coin,\n functionName: \"setPayoutRecipient\",\n args: [newPayoutRecipient],\n };\n}\n\nexport async function updatePayoutRecipient(\n args: UpdatePayoutRecipientArgs,\n walletClient: WalletClient,\n publicClient: PublicClient,\n) {\n validateClientNetwork(publicClient);\n const call = updatePayoutRecipientCall(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 payoutRecipientUpdated = eventLogs.find(\n (log) => log.eventName === \"CoinPayoutRecipientUpdated\",\n );\n\n return { hash, receipt, payoutRecipientUpdated };\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 GetProfileBalancesData,\n GetProfileBalancesResponse,\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 getProfileBalances = <ThrowOnError extends boolean = false>(\n options: Options<GetProfileBalancesData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetProfileBalancesResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/profileBalances\",\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 GetProfileBalancesData,\n GetProfileData,\n} from \"src/client\";\nimport {\n getCoin as getCoinSDK,\n getCoins as getCoinsSDK,\n getCoinComments as getCoinCommentsSDK,\n getProfile as getProfileSDK,\n getProfileBalances as getProfileBalancesSDK,\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 getProfileBalances = async (\n query: GetProfileBalancesData[\"query\"],\n) => {\n return await getProfileBalancesSDK({\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 getCoinsTopGainers = <T extends boolean = false>(\n options?: Options<QueryInnerType, T>,\n) => createExploreQuery(\"TOP_GAINERS\", options);\n\n/** Get coins with highest 24h volume */\nexport const getCoinsTopVolume24h = <T extends boolean = false>(\n options?: Options<QueryInnerType, T>,\n) => createExploreQuery(\"TOP_VOLUME_24H\", options);\n\n/** Get most valuable coins */\nexport const getCoinsMostValuable = <T extends boolean = false>(\n options?: Options<QueryInnerType, T>,\n) => createExploreQuery(\"MOST_VALUABLE\", options);\n\n/** Get newly created coins */\nexport const getCoinsNew = <T extends boolean = false>(\n options?: Options<QueryInnerType, T>,\n) => createExploreQuery(\"NEW\", options);\n\n/** Get recently traded coins */\nexport const getCoinsLastTraded = <T extends boolean = false>(\n options?: Options<QueryInnerType, T>,\n) => createExploreQuery(\"LAST_TRADED\", options);\n\n/** Get recently traded unique coins */\nexport const getCoinsLastTradedUnique = <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,0BAAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAC,gBAAmC;AACnC,kB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AAuB,CAClC,YACG,mBAAmB,iBAAiB,OAAO;AAGzC,IAAM,cAAc,CACzB,YACG,mBAAmB,OAAO,OAAO;AAG/B,IAAM,qBAAqB,CAChC,YACG,mBAAmB,eAAe,OAAO;AAGvC,IAAM,2BAA2B,CACtC,YACG,mBAAmB,sBAAsB,OAAO;","names":["getCoin","getCoinComments","getCoins","getProfile","getProfileBalances","import_coins","import_chains","import_coins","import_viem","import_chains","import_coins","import_viem","import_coins","import_viem","import_coins","import_viem","getCoin","getCoins","getCoinComments","getProfile","getProfileBalances"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ export { createCoin, createCoinCall, getCoinCreateFromLogs, } from "./actions/cr
|
|
|
2
2
|
export { tradeCoin, tradeCoinCall, getTradeFromLogs, } from "./actions/tradeCoin";
|
|
3
3
|
export { getOnchainCoinDetails, type OnchainCoinDetails, } from "./actions/getOnchainCoinDetails";
|
|
4
4
|
export { updateCoinURI, updateCoinURICall } from "./actions/updateCoinURI";
|
|
5
|
+
export { updatePayoutRecipient, updatePayoutRecipientCall } from "./actions/updatePayoutRecipient";
|
|
5
6
|
export * from "./api/queries";
|
|
6
7
|
export * from "./api/explore";
|
|
8
|
+
export { setApiKey } from "./api/api-key";
|
|
9
|
+
export type * from "src/client/types.gen";
|
|
7
10
|
//# 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":"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;
|
|
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;AAC3E,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAGnG,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,mBAAmB,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,9 @@ var validateClientNetwork = (publicClient) => {
|
|
|
23
23
|
if (clientChainId === baseSepolia.id) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
throw new Error(
|
|
26
|
+
throw new Error(
|
|
27
|
+
"Client network needs to be base or baseSepolia for current coin deployments."
|
|
28
|
+
);
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
// src/actions/createCoin.ts
|
|
@@ -325,6 +327,38 @@ async function updateCoinURI(args, walletClient, publicClient) {
|
|
|
325
327
|
return { hash, receipt, uriUpdated };
|
|
326
328
|
}
|
|
327
329
|
|
|
330
|
+
// src/actions/updatePayoutRecipient.ts
|
|
331
|
+
import { coinABI as coinABI4 } from "@zoralabs/coins";
|
|
332
|
+
import {
|
|
333
|
+
parseEventLogs as parseEventLogs4
|
|
334
|
+
} from "viem";
|
|
335
|
+
function updatePayoutRecipientCall({
|
|
336
|
+
newPayoutRecipient,
|
|
337
|
+
coin
|
|
338
|
+
}) {
|
|
339
|
+
return {
|
|
340
|
+
abi: coinABI4,
|
|
341
|
+
address: coin,
|
|
342
|
+
functionName: "setPayoutRecipient",
|
|
343
|
+
args: [newPayoutRecipient]
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
async function updatePayoutRecipient(args, walletClient, publicClient) {
|
|
347
|
+
validateClientNetwork(publicClient);
|
|
348
|
+
const call = updatePayoutRecipientCall(args);
|
|
349
|
+
const { request } = await publicClient.simulateContract({
|
|
350
|
+
...call,
|
|
351
|
+
account: walletClient.account
|
|
352
|
+
});
|
|
353
|
+
const hash = await walletClient.writeContract(request);
|
|
354
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
355
|
+
const eventLogs = parseEventLogs4({ abi: coinABI4, logs: receipt.logs });
|
|
356
|
+
const payoutRecipientUpdated = eventLogs.find(
|
|
357
|
+
(log) => log.eventName === "CoinPayoutRecipientUpdated"
|
|
358
|
+
);
|
|
359
|
+
return { hash, receipt, payoutRecipientUpdated };
|
|
360
|
+
}
|
|
361
|
+
|
|
328
362
|
// src/client/client.gen.ts
|
|
329
363
|
import { createClient, createConfig } from "@hey-api/client-fetch";
|
|
330
364
|
var client = createClient(createConfig({
|
|
@@ -362,15 +396,18 @@ var getProfile = (options) => {
|
|
|
362
396
|
...options
|
|
363
397
|
});
|
|
364
398
|
};
|
|
365
|
-
var
|
|
399
|
+
var getProfileBalances = (options) => {
|
|
366
400
|
return (options.client ?? client).get({
|
|
367
|
-
url: "/
|
|
401
|
+
url: "/profileBalances",
|
|
368
402
|
...options
|
|
369
403
|
});
|
|
370
404
|
};
|
|
371
405
|
|
|
372
406
|
// src/api/api-key.ts
|
|
373
407
|
var apiKey;
|
|
408
|
+
function setApiKey(key) {
|
|
409
|
+
apiKey = key;
|
|
410
|
+
}
|
|
374
411
|
function getApiKeyMeta() {
|
|
375
412
|
if (!apiKey) {
|
|
376
413
|
return {};
|
|
@@ -415,8 +452,8 @@ var getProfile2 = async (query) => {
|
|
|
415
452
|
meta: getApiKeyMeta()
|
|
416
453
|
});
|
|
417
454
|
};
|
|
418
|
-
var
|
|
419
|
-
return await
|
|
455
|
+
var getProfileBalances2 = async (query) => {
|
|
456
|
+
return await getProfileBalances({
|
|
420
457
|
query,
|
|
421
458
|
meta: getApiKeyMeta()
|
|
422
459
|
});
|
|
@@ -428,12 +465,12 @@ var createExploreQuery = (listType, options) => getExplore({
|
|
|
428
465
|
query: { ...options?.query, listType },
|
|
429
466
|
meta: getApiKeyMeta()
|
|
430
467
|
});
|
|
431
|
-
var
|
|
432
|
-
var
|
|
433
|
-
var
|
|
434
|
-
var
|
|
435
|
-
var
|
|
436
|
-
var
|
|
468
|
+
var getCoinsTopGainers = (options) => createExploreQuery("TOP_GAINERS", options);
|
|
469
|
+
var getCoinsTopVolume24h = (options) => createExploreQuery("TOP_VOLUME_24H", options);
|
|
470
|
+
var getCoinsMostValuable = (options) => createExploreQuery("MOST_VALUABLE", options);
|
|
471
|
+
var getCoinsNew = (options) => createExploreQuery("NEW", options);
|
|
472
|
+
var getCoinsLastTraded = (options) => createExploreQuery("LAST_TRADED", options);
|
|
473
|
+
var getCoinsLastTradedUnique = (options) => createExploreQuery("LAST_TRADED_UNIQUE", options);
|
|
437
474
|
export {
|
|
438
475
|
createCoin,
|
|
439
476
|
createCoinCall,
|
|
@@ -441,19 +478,22 @@ export {
|
|
|
441
478
|
getCoinComments2 as getCoinComments,
|
|
442
479
|
getCoinCreateFromLogs,
|
|
443
480
|
getCoins2 as getCoins,
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
481
|
+
getCoinsLastTraded,
|
|
482
|
+
getCoinsLastTradedUnique,
|
|
483
|
+
getCoinsMostValuable,
|
|
484
|
+
getCoinsNew,
|
|
485
|
+
getCoinsTopGainers,
|
|
486
|
+
getCoinsTopVolume24h,
|
|
450
487
|
getOnchainCoinDetails,
|
|
451
488
|
getProfile2 as getProfile,
|
|
452
|
-
|
|
489
|
+
getProfileBalances2 as getProfileBalances,
|
|
453
490
|
getTradeFromLogs,
|
|
491
|
+
setApiKey,
|
|
454
492
|
tradeCoin,
|
|
455
493
|
tradeCoinCall,
|
|
456
494
|
updateCoinURI,
|
|
457
|
-
updateCoinURICall
|
|
495
|
+
updateCoinURICall,
|
|
496
|
+
updatePayoutRecipient,
|
|
497
|
+
updatePayoutRecipientCall
|
|
458
498
|
};
|
|
459
499
|
//# sourceMappingURL=index.js.map
|