@zoralabs/coins-sdk 0.2.9 → 0.2.10

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # @zoralabs/coins-sdk
2
2
 
3
+ ## 0.2.10
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [262d1539]
8
+ - @zoralabs/protocol-deployments@0.6.2
9
+
3
10
  ## 0.2.9
4
11
 
5
12
  ### Patch Changes
@@ -1,20 +1,5 @@
1
1
  import { GenericPublicClient } from "../utils/genericPublicClient";
2
2
  import { Address } from "viem";
3
- type Slot0Result = {
4
- sqrtPriceX96: bigint;
5
- tick: number;
6
- observationIndex: number;
7
- observationCardinality: number;
8
- observationCardinalityNext: number;
9
- feeProtocol: number;
10
- unlocked: boolean;
11
- };
12
- type PricingResult = {
13
- eth: bigint;
14
- usdc: bigint | null;
15
- usdcDecimal: number | null;
16
- ethDecimal: number;
17
- };
18
3
  /**
19
4
  * Represents the current state of a coin
20
5
  * @typedef {Object} OnchainCoinDetails
@@ -28,10 +13,6 @@ type PricingResult = {
28
13
  */
29
14
  export type OnchainCoinDetails = {
30
15
  balance: bigint;
31
- marketCap: PricingResult;
32
- liquidity: PricingResult;
33
- pool: Address;
34
- poolState: Slot0Result;
35
16
  owners: readonly Address[];
36
17
  payoutRecipient: Address;
37
18
  };
@@ -48,5 +29,4 @@ export declare function getOnchainCoinDetails({ coin, user, publicClient, }: {
48
29
  user?: Address;
49
30
  publicClient: GenericPublicClient;
50
31
  }): Promise<OnchainCoinDetails>;
51
- export {};
52
32
  //# sourceMappingURL=getOnchainCoinDetails.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getOnchainCoinDetails.d.ts","sourceRoot":"","sources":["../../src/actions/getOnchainCoinDetails.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EACL,OA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kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,IAAI,EACJ,IAAkB,EAClB,YAAY,GACb,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,mBAAmB,CAAC;CACnC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA6B9B"}
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"
406
- },
407
- {
408
- address: SUPERCHAIN_WETH_ADDRESS,
409
- abi: _viem.erc20Abi,
410
- functionName: "balanceOf",
411
- args: [pool]
353
+ functionName: "owners"
412
354
  },
413
355
  {
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
 
@@ -602,7 +493,7 @@ var getCoins = (options) => {
602
493
  });
603
494
  };
604
495
  var setCreateUploadJwt = (options) => {
605
- return (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _11 => _11.client]), () => ( client))).post({
496
+ return (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _9 => _9.client]), () => ( client))).post({
606
497
  security: [
607
498
  {
608
499
  name: "api-key",
@@ -613,7 +504,7 @@ var setCreateUploadJwt = (options) => {
613
504
  ...options,
614
505
  headers: {
615
506
  "Content-Type": "application/json",
616
- ..._optionalChain([options, 'optionalAccess', _12 => _12.headers])
507
+ ..._optionalChain([options, 'optionalAccess', _10 => _10.headers])
617
508
  }
618
509
  });
619
510
  };
@@ -666,7 +557,7 @@ var getProfileCoins = (options) => {
666
557
  });
667
558
  };
668
559
  var postQuote = (options) => {
669
- return (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _13 => _13.client]), () => ( client))).post({
560
+ return (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _11 => _11.client]), () => ( client))).post({
670
561
  security: [
671
562
  {
672
563
  name: "api-key",
@@ -677,7 +568,7 @@ var postQuote = (options) => {
677
568
  ...options,
678
569
  headers: {
679
570
  "Content-Type": "application/json",
680
- ..._optionalChain([options, 'optionalAccess', _14 => _14.headers])
571
+ ..._optionalChain([options, 'optionalAccess', _12 => _12.headers])
681
572
  }
682
573
  });
683
574
  };
@@ -1033,9 +924,9 @@ var CoinMetadataBuilder = class {
1033
924
  symbol: this.symbol,
1034
925
  description: this.description,
1035
926
  image: this.imageURL.toString(),
1036
- animation_url: _optionalChain([this, 'access', _15 => _15.mediaURL, 'optionalAccess', _16 => _16.toString, 'call', _17 => _17()]),
927
+ animation_url: _optionalChain([this, 'access', _13 => _13.mediaURL, 'optionalAccess', _14 => _14.toString, 'call', _15 => _15()]),
1037
928
  content: this.mediaURL ? {
1038
- uri: _optionalChain([this, 'access', _18 => _18.mediaURL, 'optionalAccess', _19 => _19.toString, 'call', _20 => _20()]),
929
+ uri: _optionalChain([this, 'access', _16 => _16.mediaURL, 'optionalAccess', _17 => _17.toString, 'call', _18 => _18()]),
1039
930
  mime: this.mediaMimeType
1040
931
  } : void 0,
1041
932
  properties: this.properties
@@ -1097,7 +988,7 @@ var ZoraUploader = class {
1097
988
  const response = await setCreateUploadJwt2({
1098
989
  creatorAddress: this.creatorAddress
1099
990
  });
1100
- this.jwtApiKey = _optionalChain([response, 'access', _21 => _21.data, 'optionalAccess', _22 => _22.createUploadJwtFromApiKey]);
991
+ this.jwtApiKey = _optionalChain([response, 'access', _19 => _19.data, 'optionalAccess', _20 => _20.createUploadJwtFromApiKey]);
1101
992
  if (!this.jwtApiKey) {
1102
993
  throw new Error("Failed to create upload JWT");
1103
994
  }