@medialane/sdk 0.74.0 → 0.75.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10342,6 +10342,46 @@ function getTokenByAddress(address) {
10342
10342
  });
10343
10343
  }
10344
10344
 
10345
+ // src/starknet/services/coinLaunchMath.ts
10346
+ var COIN_DECIMALS = 18;
10347
+ var LAUNCH_PRICE_QUOTE_PER_COIN = 0.01;
10348
+ var MIN_SUPPLY = 1000n;
10349
+ var MAX_SUPPLY = 1000000000000n;
10350
+ var MAX_FELT_BYTES = 31;
10351
+ function byteLen(s) {
10352
+ return new TextEncoder().encode(s).length;
10353
+ }
10354
+ function validateName(s) {
10355
+ if (!s.trim()) return "Name is required";
10356
+ if (byteLen(s) > MAX_FELT_BYTES) return `Name must be at most ${MAX_FELT_BYTES} bytes`;
10357
+ return null;
10358
+ }
10359
+ function validateSymbol(s) {
10360
+ if (!s.trim()) return "Symbol is required";
10361
+ if (byteLen(s) > MAX_FELT_BYTES) return `Symbol must be at most ${MAX_FELT_BYTES} bytes`;
10362
+ return null;
10363
+ }
10364
+ function validateSupply(human) {
10365
+ if (!/^\d+$/.test(human.trim())) return "Supply must be a whole number";
10366
+ const v = BigInt(human.trim());
10367
+ if (v < MIN_SUPPLY) return `Supply must be at least ${MIN_SUPPLY.toString()}`;
10368
+ if (v > MAX_SUPPLY) return `Supply must be at most ${MAX_SUPPLY.toString()}`;
10369
+ return null;
10370
+ }
10371
+ function toRaw(human, decimals = COIN_DECIMALS) {
10372
+ return human * 10n ** BigInt(decimals);
10373
+ }
10374
+ function teamCoinsRaw(supplyRaw, pct) {
10375
+ const bps = BigInt(Math.round(pct * 100));
10376
+ return supplyRaw * bps / 10000n;
10377
+ }
10378
+ function buybackQuoteRaw(teamCoinsRawValue, quoteDecimals) {
10379
+ return teamCoinsRawValue * 10n ** BigInt(quoteDecimals) / (100n * 10n ** BigInt(COIN_DECIMALS));
10380
+ }
10381
+ function fdvHuman(supplyHuman) {
10382
+ return supplyHuman * LAUNCH_PRICE_QUOTE_PER_COIN;
10383
+ }
10384
+
10345
10385
  // src/starknet/services/creatorCoin.ts
10346
10386
  var VALIDATED_EKUBO_PARAMS = {
10347
10387
  fee: "0xc49ba5e353f7d00000000000000000",
@@ -10349,7 +10389,21 @@ var VALIDATED_EKUBO_PARAMS = {
10349
10389
  startingPrice: { mag: 4600158n, sign: true },
10350
10390
  bound: 88719042n
10351
10391
  };
10352
- var COIN_DECIMALS = 18;
10392
+ var TICK_BASE = 1.000001;
10393
+ function priceToEkuboParams(quoteDecimals, price = LAUNCH_PRICE_QUOTE_PER_COIN) {
10394
+ const decAdj = 10 ** (COIN_DECIMALS2 - quoteDecimals);
10395
+ const rawRatio = price / decAdj;
10396
+ const tickSpacing = Number(VALIDATED_EKUBO_PARAMS.tickSpacing);
10397
+ const rawTick = Math.log(rawRatio) / Math.log(TICK_BASE);
10398
+ const roundedTick = Math.trunc(rawTick / tickSpacing) * tickSpacing;
10399
+ return {
10400
+ fee: VALIDATED_EKUBO_PARAMS.fee,
10401
+ tickSpacing: VALIDATED_EKUBO_PARAMS.tickSpacing,
10402
+ startingPrice: { mag: BigInt(Math.abs(roundedTick)), sign: roundedTick < 0 },
10403
+ bound: VALIDATED_EKUBO_PARAMS.bound
10404
+ };
10405
+ }
10406
+ var COIN_DECIMALS2 = 18;
10353
10407
  async function getCreatorCoinPrice(coinAddress, provider) {
10354
10408
  const r = await provider.callContract({
10355
10409
  contractAddress: coinAddress,
@@ -10373,7 +10427,7 @@ async function getCreatorCoinPrice(coinAddress, provider) {
10373
10427
  });
10374
10428
  const sqrt = BigInt(pp[0]) + (BigInt(pp[1] ?? "0x0") << 128n);
10375
10429
  const priceT1perT0 = (Number(sqrt) / 2 ** 128) ** 2;
10376
- const decAdj = 10 ** (COIN_DECIMALS - quoteDecimals);
10430
+ const decAdj = 10 ** (COIN_DECIMALS2 - quoteDecimals);
10377
10431
  const quotePerCoin = (quoteIsToken0 ? 1 / priceT1perT0 : priceT1perT0) * decAdj;
10378
10432
  return { quotePerCoin, quoteToken, quoteSymbol: token?.symbol ?? null, quoteDecimals };
10379
10433
  }
@@ -11611,46 +11665,6 @@ async function requestSiwsToken({
11611
11665
  storeSiwsToken(walletAddress, token);
11612
11666
  return token;
11613
11667
  }
11614
-
11615
- // src/starknet/services/coinLaunchMath.ts
11616
- var COIN_DECIMALS2 = 18;
11617
- var LAUNCH_PRICE_QUOTE_PER_COIN = 0.01;
11618
- var MIN_SUPPLY = 1000n;
11619
- var MAX_SUPPLY = 1000000000000n;
11620
- var MAX_FELT_BYTES = 31;
11621
- function byteLen(s) {
11622
- return new TextEncoder().encode(s).length;
11623
- }
11624
- function validateName(s) {
11625
- if (!s.trim()) return "Name is required";
11626
- if (byteLen(s) > MAX_FELT_BYTES) return `Name must be at most ${MAX_FELT_BYTES} bytes`;
11627
- return null;
11628
- }
11629
- function validateSymbol(s) {
11630
- if (!s.trim()) return "Symbol is required";
11631
- if (byteLen(s) > MAX_FELT_BYTES) return `Symbol must be at most ${MAX_FELT_BYTES} bytes`;
11632
- return null;
11633
- }
11634
- function validateSupply(human) {
11635
- if (!/^\d+$/.test(human.trim())) return "Supply must be a whole number";
11636
- const v = BigInt(human.trim());
11637
- if (v < MIN_SUPPLY) return `Supply must be at least ${MIN_SUPPLY.toString()}`;
11638
- if (v > MAX_SUPPLY) return `Supply must be at most ${MAX_SUPPLY.toString()}`;
11639
- return null;
11640
- }
11641
- function toRaw(human, decimals = COIN_DECIMALS2) {
11642
- return human * 10n ** BigInt(decimals);
11643
- }
11644
- function teamCoinsRaw(supplyRaw, pct) {
11645
- const bps = BigInt(Math.round(pct * 100));
11646
- return supplyRaw * bps / 10000n;
11647
- }
11648
- function buybackQuoteRaw(teamCoinsRawValue, quoteDecimals) {
11649
- return teamCoinsRawValue * 10n ** BigInt(quoteDecimals) / (100n * 10n ** BigInt(COIN_DECIMALS2));
11650
- }
11651
- function fdvHuman(supplyHuman) {
11652
- return supplyHuman * LAUNCH_PRICE_QUOTE_PER_COIN;
11653
- }
11654
11668
  function encodeByteArray(str) {
11655
11669
  const bytes = new TextEncoder().encode(str);
11656
11670
  const fullChunks = [];
@@ -11735,6 +11749,7 @@ exports.isSiwsTokenValid = isSiwsTokenValid;
11735
11749
  exports.normalizeSiwsSignature = normalizeSiwsSignature;
11736
11750
  exports.parseAdminHeaders = parseAdminHeaders;
11737
11751
  exports.parseCreatorCoinCreated = parseCreatorCoinCreated;
11752
+ exports.priceToEkuboParams = priceToEkuboParams;
11738
11753
  exports.randomNonce = randomNonce;
11739
11754
  exports.requestSiwsToken = requestSiwsToken;
11740
11755
  exports.sessionKeyHashOf = sessionKeyHashOf;