@zoralabs/coins-sdk 0.2.9 → 0.2.11

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/dist/index.cjs CHANGED
@@ -12,7 +12,6 @@ var _chains = require('viem/chains');
12
12
 
13
13
 
14
14
  var COIN_FACTORY_ADDRESS = _protocoldeployments.coinFactoryAddress["8453"];
15
- var SUPERCHAIN_WETH_ADDRESS = "0x4200000000000000000000000000000000000006";
16
15
  var USDC_WETH_POOLS_BY_CHAIN = {
17
16
  [_chains.base.id]: "0xd0b53D9277642d899DF5C87A3966A349A798F224"
18
17
  };
@@ -334,147 +333,39 @@ async function createCoin(call, walletClient, publicClient, options) {
334
333
  // src/actions/getOnchainCoinDetails.ts
335
334
 
336
335
 
337
-
338
-
339
-
340
-
341
-
342
336
  async function getOnchainCoinDetails({
343
337
  coin,
344
338
  user = _viem.zeroAddress,
345
339
  publicClient
346
340
  }) {
347
341
  validateClientNetwork(publicClient);
348
- const [balance, pool, owners, payoutRecipient] = await publicClient.multicall(
349
- {
350
- contracts: [
351
- {
352
- address: coin,
353
- abi: _protocoldeployments.coinABI,
354
- functionName: "balanceOf",
355
- args: [user]
356
- },
357
- {
358
- address: coin,
359
- abi: _protocoldeployments.coinABI,
360
- functionName: "poolAddress"
361
- },
362
- {
363
- address: coin,
364
- abi: _protocoldeployments.coinABI,
365
- functionName: "owners"
366
- },
367
- {
368
- address: coin,
369
- abi: _protocoldeployments.coinABI,
370
- functionName: "payoutRecipient"
371
- }
372
- ],
373
- allowFailure: false
374
- }
375
- );
376
- const USDC_WETH_POOL = USDC_WETH_POOLS_BY_CHAIN[_optionalChain([publicClient, 'access', _9 => _9.chain, 'optionalAccess', _10 => _10.id]) || 0];
377
- const [
378
- coinWethPoolSlot0,
379
- coinWethPoolToken0,
380
- coinReservesRaw,
381
- coinTotalSupply,
382
- wethReservesRaw,
383
- usdcWethSlot0
384
- ] = await publicClient.multicall({
342
+ const [balance, owners, payoutRecipient] = await publicClient.multicall({
385
343
  contracts: [
386
- {
387
- address: pool,
388
- abi: _protocoldeployments.iUniswapV3PoolABI,
389
- functionName: "slot0"
390
- },
391
- {
392
- address: pool,
393
- abi: _protocoldeployments.iUniswapV3PoolABI,
394
- functionName: "token0"
395
- },
396
344
  {
397
345
  address: coin,
398
- abi: _viem.erc20Abi,
346
+ abi: _protocoldeployments.coinABI,
399
347
  functionName: "balanceOf",
400
- args: [pool]
348
+ args: [user]
401
349
  },
402
350
  {
403
351
  address: coin,
404
352
  abi: _protocoldeployments.coinABI,
405
- functionName: "totalSupply"
353
+ functionName: "owners"
406
354
  },
407
355
  {
408
- address: SUPERCHAIN_WETH_ADDRESS,
409
- abi: _viem.erc20Abi,
410
- functionName: "balanceOf",
411
- args: [pool]
412
- },
413
- {
414
- address: _nullishCoalesce(USDC_WETH_POOL, () => ( coin)),
415
- abi: _protocoldeployments.iUniswapV3PoolABI,
416
- functionName: "slot0"
356
+ address: coin,
357
+ abi: _protocoldeployments.coinABI,
358
+ functionName: "payoutRecipient"
417
359
  }
418
360
  ],
419
361
  allowFailure: false
420
362
  });
421
- const wethPriceInUsdc = USDC_WETH_POOL ? uniswapV3SqrtPriceToBigIntScaled(
422
- usdcWethSlot0.sqrtPriceX96,
423
- 18,
424
- 6,
425
- true,
426
- 18
427
- ) : null;
428
- const coinPriceInWeth = uniswapV3SqrtPriceToBigIntScaled(
429
- coinWethPoolSlot0.sqrtPriceX96,
430
- 18,
431
- 18,
432
- _viem.isAddressEqual.call(void 0, coinWethPoolToken0, coin),
433
- 18
434
- );
435
- const marketCap = coinPriceInWeth * coinTotalSupply / 10n ** 18n;
436
- const wethLiquidity = wethReservesRaw;
437
- const tokenLiquidity = coinReservesRaw * coinPriceInWeth / 10n ** 18n;
438
363
  return {
439
364
  balance,
440
- pool,
441
365
  owners,
442
- payoutRecipient,
443
- marketCap: convertEthOutput(marketCap, wethPriceInUsdc),
444
- liquidity: convertEthOutput(
445
- wethLiquidity + tokenLiquidity,
446
- wethPriceInUsdc
447
- ),
448
- poolState: coinWethPoolSlot0
449
- };
450
- }
451
- function convertEthOutput(amountETH, wethToUsdc) {
452
- return {
453
- eth: amountETH,
454
- ethDecimal: parseFloat(_viem.formatEther.call(void 0, amountETH)),
455
- usdc: wethToUsdc ? amountETH * wethToUsdc : null,
456
- usdcDecimal: wethToUsdc ? parseFloat(_viem.formatEther.call(void 0, amountETH * wethToUsdc / 10n ** 18n)) : null
366
+ payoutRecipient
457
367
  };
458
368
  }
459
- function uniswapV3SqrtPriceToBigIntScaled(sqrtPriceX96, token0Decimals, token1Decimals, isToken0Coin, scaleDecimals = 18) {
460
- const numerator = sqrtPriceX96 * sqrtPriceX96;
461
- const denominator = 2n ** 192n;
462
- const scaleFactor = 10n ** BigInt(scaleDecimals);
463
- let ratioScaled = numerator * scaleFactor / denominator;
464
- const decimalsDiff = BigInt(token0Decimals - token1Decimals);
465
- if (decimalsDiff > 0n) {
466
- ratioScaled *= 10n ** decimalsDiff;
467
- } else if (decimalsDiff < 0n) {
468
- ratioScaled /= 10n ** -decimalsDiff;
469
- }
470
- if (!isToken0Coin) {
471
- if (ratioScaled === 0n) {
472
- return 0n;
473
- }
474
- ratioScaled = scaleFactor * scaleFactor / ratioScaled;
475
- }
476
- return ratioScaled;
477
- }
478
369
 
479
370
  // src/actions/updateCoinURI.ts
480
371
 
@@ -589,6 +480,30 @@ var getCoinComments = (options) => {
589
480
  ...options
590
481
  });
591
482
  };
483
+ var getCoinHolders = (options) => {
484
+ return (_nullishCoalesce(options.client, () => ( client))).get({
485
+ security: [
486
+ {
487
+ name: "api-key",
488
+ type: "apiKey"
489
+ }
490
+ ],
491
+ url: "/coinHolders",
492
+ ...options
493
+ });
494
+ };
495
+ var getCoinSwaps = (options) => {
496
+ return (_nullishCoalesce(options.client, () => ( client))).get({
497
+ security: [
498
+ {
499
+ name: "api-key",
500
+ type: "apiKey"
501
+ }
502
+ ],
503
+ url: "/coinSwaps",
504
+ ...options
505
+ });
506
+ };
592
507
  var getCoins = (options) => {
593
508
  return (_nullishCoalesce(options.client, () => ( client))).get({
594
509
  security: [
@@ -602,7 +517,7 @@ var getCoins = (options) => {
602
517
  });
603
518
  };
604
519
  var setCreateUploadJwt = (options) => {
605
- return (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _11 => _11.client]), () => ( client))).post({
520
+ return (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _9 => _9.client]), () => ( client))).post({
606
521
  security: [
607
522
  {
608
523
  name: "api-key",
@@ -613,7 +528,7 @@ var setCreateUploadJwt = (options) => {
613
528
  ...options,
614
529
  headers: {
615
530
  "Content-Type": "application/json",
616
- ..._optionalChain([options, 'optionalAccess', _12 => _12.headers])
531
+ ..._optionalChain([options, 'optionalAccess', _10 => _10.headers])
617
532
  }
618
533
  });
619
534
  };
@@ -666,7 +581,7 @@ var getProfileCoins = (options) => {
666
581
  });
667
582
  };
668
583
  var postQuote = (options) => {
669
- return (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _13 => _13.client]), () => ( client))).post({
584
+ return (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _11 => _11.client]), () => ( client))).post({
670
585
  security: [
671
586
  {
672
587
  name: "api-key",
@@ -677,7 +592,7 @@ var postQuote = (options) => {
677
592
  ...options,
678
593
  headers: {
679
594
  "Content-Type": "application/json",
680
- ..._optionalChain([options, 'optionalAccess', _14 => _14.headers])
595
+ ..._optionalChain([options, 'optionalAccess', _12 => _12.headers])
681
596
  }
682
597
  });
683
598
  };
@@ -874,6 +789,20 @@ var getCoins2 = async (query, options) => {
874
789
  ...options
875
790
  });
876
791
  };
792
+ var getCoinHolders2 = async (query, options) => {
793
+ return await getCoinHolders({
794
+ query,
795
+ ...getApiKeyMeta(),
796
+ ...options
797
+ });
798
+ };
799
+ var getCoinSwaps2 = async (query, options) => {
800
+ return await getCoinSwaps({
801
+ query,
802
+ ...getApiKeyMeta(),
803
+ ...options
804
+ });
805
+ };
877
806
  var getCoinComments2 = async (query, options) => {
878
807
  return await getCoinComments({
879
808
  query,
@@ -1033,9 +962,9 @@ var CoinMetadataBuilder = class {
1033
962
  symbol: this.symbol,
1034
963
  description: this.description,
1035
964
  image: this.imageURL.toString(),
1036
- animation_url: _optionalChain([this, 'access', _15 => _15.mediaURL, 'optionalAccess', _16 => _16.toString, 'call', _17 => _17()]),
965
+ animation_url: _optionalChain([this, 'access', _13 => _13.mediaURL, 'optionalAccess', _14 => _14.toString, 'call', _15 => _15()]),
1037
966
  content: this.mediaURL ? {
1038
- uri: _optionalChain([this, 'access', _18 => _18.mediaURL, 'optionalAccess', _19 => _19.toString, 'call', _20 => _20()]),
967
+ uri: _optionalChain([this, 'access', _16 => _16.mediaURL, 'optionalAccess', _17 => _17.toString, 'call', _18 => _18()]),
1039
968
  mime: this.mediaMimeType
1040
969
  } : void 0,
1041
970
  properties: this.properties
@@ -1097,7 +1026,7 @@ var ZoraUploader = class {
1097
1026
  const response = await setCreateUploadJwt2({
1098
1027
  creatorAddress: this.creatorAddress
1099
1028
  });
1100
- this.jwtApiKey = _optionalChain([response, 'access', _21 => _21.data, 'optionalAccess', _22 => _22.createUploadJwtFromApiKey]);
1029
+ this.jwtApiKey = _optionalChain([response, 'access', _19 => _19.data, 'optionalAccess', _20 => _20.createUploadJwtFromApiKey]);
1101
1030
  if (!this.jwtApiKey) {
1102
1031
  throw new Error("Failed to create upload JWT");
1103
1032
  }
@@ -1170,5 +1099,7 @@ function createZoraUploaderForCreator(creatorAddress) {
1170
1099
 
1171
1100
 
1172
1101
 
1173
- exports.CoinMetadataBuilder = CoinMetadataBuilder; exports.DeployCurrency = DeployCurrency; exports.InitialPurchaseCurrency = InitialPurchaseCurrency; exports.ZoraUploader = ZoraUploader; exports.cleanAndValidateMetadataURI = cleanAndValidateMetadataURI; exports.createCoin = createCoin; exports.createCoinCall = createCoinCall; exports.createMetadataBuilder = createMetadataBuilder; exports.createTradeCall = createTradeCall; exports.createZoraUploaderForCreator = createZoraUploaderForCreator; exports.getCoin = getCoin2; exports.getCoinComments = getCoinComments2; exports.getCoinCreateFromLogs = getCoinCreateFromLogs; exports.getCoins = getCoins2; exports.getCoinsLastTraded = getCoinsLastTraded; exports.getCoinsLastTradedUnique = getCoinsLastTradedUnique; exports.getCoinsMostValuable = getCoinsMostValuable; exports.getCoinsNew = getCoinsNew; exports.getCoinsTopGainers = getCoinsTopGainers; exports.getCoinsTopVolume24h = getCoinsTopVolume24h; exports.getCreatorCoins = getCreatorCoins; exports.getMostValuableCreatorCoins = getMostValuableCreatorCoins; exports.getOnchainCoinDetails = getOnchainCoinDetails; exports.getProfile = getProfile2; exports.getProfileBalances = getProfileBalances2; exports.getProfileCoins = getProfileCoins2; exports.getURLFromUploadResult = getURLFromUploadResult; exports.setApiKey = setApiKey; exports.tradeCoin = tradeCoin; exports.updateCoinURI = updateCoinURI; exports.updateCoinURICall = updateCoinURICall; exports.updatePayoutRecipient = updatePayoutRecipient; exports.updatePayoutRecipientCall = updatePayoutRecipientCall; exports.validateImageMimeType = validateImageMimeType; exports.validateMetadataJSON = validateMetadataJSON; exports.validateMetadataURIContent = validateMetadataURIContent;
1102
+
1103
+
1104
+ exports.CoinMetadataBuilder = CoinMetadataBuilder; exports.DeployCurrency = DeployCurrency; exports.InitialPurchaseCurrency = InitialPurchaseCurrency; exports.ZoraUploader = ZoraUploader; exports.cleanAndValidateMetadataURI = cleanAndValidateMetadataURI; exports.createCoin = createCoin; exports.createCoinCall = createCoinCall; exports.createMetadataBuilder = createMetadataBuilder; exports.createTradeCall = createTradeCall; exports.createZoraUploaderForCreator = createZoraUploaderForCreator; exports.getCoin = getCoin2; exports.getCoinComments = getCoinComments2; exports.getCoinCreateFromLogs = getCoinCreateFromLogs; exports.getCoinHolders = getCoinHolders2; exports.getCoinSwaps = getCoinSwaps2; exports.getCoins = getCoins2; exports.getCoinsLastTraded = getCoinsLastTraded; exports.getCoinsLastTradedUnique = getCoinsLastTradedUnique; exports.getCoinsMostValuable = getCoinsMostValuable; exports.getCoinsNew = getCoinsNew; exports.getCoinsTopGainers = getCoinsTopGainers; exports.getCoinsTopVolume24h = getCoinsTopVolume24h; exports.getCreatorCoins = getCreatorCoins; exports.getMostValuableCreatorCoins = getMostValuableCreatorCoins; exports.getOnchainCoinDetails = getOnchainCoinDetails; exports.getProfile = getProfile2; exports.getProfileBalances = getProfileBalances2; exports.getProfileCoins = getProfileCoins2; exports.getURLFromUploadResult = getURLFromUploadResult; exports.setApiKey = setApiKey; exports.tradeCoin = tradeCoin; exports.updateCoinURI = updateCoinURI; exports.updateCoinURICall = updateCoinURICall; exports.updatePayoutRecipient = updatePayoutRecipient; exports.updatePayoutRecipientCall = updatePayoutRecipientCall; exports.validateImageMimeType = validateImageMimeType; exports.validateMetadataJSON = validateMetadataJSON; exports.validateMetadataURIContent = validateMetadataURIContent;
1174
1105
  //# sourceMappingURL=index.cjs.map