@medialane/sdk 0.28.0 → 0.30.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.
package/dist/index.cjs CHANGED
@@ -61,6 +61,12 @@ var COLLECTION_1155_CONTRACT_MAINNET = "0x067064adcaaed61e17bf50ea802ea648233612
61
61
  var COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET = "0x188321a7c9ca972cc63e352e3b3a4cdf33781852d957f4b4b62249310fe4c75";
62
62
  var COLLECTION_1155_CLASS_HASH_MAINNET = "0x281e13803c906f20bbe158efb44b7a0273c56fdebbeeb55b2ba59530ddb1c80";
63
63
  var COLLECTION_1155_START_BLOCK_MAINNET = 10045611;
64
+ var CREATOR_COIN_FACTORY_CONTRACT_MAINNET = "0x50fa807b5274079fb19374673d7bab6d2dc3af7e1032ea43eb6e44bcbde4c3c";
65
+ var CREATOR_COIN_EKUBO_LAUNCHER_MAINNET = "0x4f7fceb5ac10f12f9544a09580592e5bdf1b7f04f48765eecf12286d8ccb7b4";
66
+ var CREATOR_COIN_CLASS_HASH_MAINNET = "0x743e4c8a5b96bb83bbf4af04edbbb482d5ece89eed9b729a79fb7df0cd0b6b6";
67
+ var CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET = "0x51765926b1344c9a20b8cd4b5abe7b7d47375ae97cf6804db3ea5d4b05a9b55";
68
+ var CREATOR_COIN_START_BLOCK_MAINNET = 10474544;
69
+ var EKUBO_CORE_MAINNET = "0x00000005dd3d2f4429af886cd1a3b08289dbcea99a294197e9eb43b0e0325b4b";
64
70
  var FeeConfigSchema = zod.z.object({
65
71
  enabled: zod.z.boolean().default(true),
66
72
  fundAddress: zod.z.string().min(1).optional(),
@@ -4629,6 +4635,9 @@ var IPNftABI = [
4629
4635
  }
4630
4636
  ];
4631
4637
 
4638
+ // src/abis/creatorCoinFactory.ts
4639
+ var CreatorCoinFactoryABI = [{ "type": "impl", "name": "FactoryImpl", "interface_name": "creator_coin::factory::interface::IFactory" }, { "type": "struct", "name": "core::integer::u256", "members": [{ "name": "low", "type": "core::integer::u128" }, { "name": "high", "type": "core::integer::u128" }] }, { "type": "struct", "name": "core::array::Span::<core::starknet::contract_address::ContractAddress>", "members": [{ "name": "snapshot", "type": "@core::array::Array::<core::starknet::contract_address::ContractAddress>" }] }, { "type": "struct", "name": "core::array::Span::<core::integer::u256>", "members": [{ "name": "snapshot", "type": "@core::array::Array::<core::integer::u256>" }] }, { "type": "struct", "name": "creator_coin::factory::LaunchParameters", "members": [{ "name": "creator_coin_address", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "transfer_restriction_delay", "type": "core::integer::u64" }, { "name": "max_percentage_buy_launch", "type": "core::integer::u16" }, { "name": "quote_address", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "initial_holders", "type": "core::array::Span::<core::starknet::contract_address::ContractAddress>" }, { "name": "initial_holders_amounts", "type": "core::array::Span::<core::integer::u256>" }] }, { "type": "enum", "name": "core::bool", "variants": [{ "name": "False", "type": "()" }, { "name": "True", "type": "()" }] }, { "type": "struct", "name": "ekubo::types::i129::i129", "members": [{ "name": "mag", "type": "core::integer::u128" }, { "name": "sign", "type": "core::bool" }] }, { "type": "struct", "name": "creator_coin::exchanges::ekubo::ekubo_adapter::EkuboPoolParameters", "members": [{ "name": "fee", "type": "core::integer::u128" }, { "name": "tick_spacing", "type": "core::integer::u128" }, { "name": "starting_price", "type": "ekubo::types::i129::i129" }, { "name": "bound", "type": "core::integer::u128" }] }, { "type": "struct", "name": "ekubo::types::keys::PoolKey", "members": [{ "name": "token0", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "token1", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "fee", "type": "core::integer::u128" }, { "name": "tick_spacing", "type": "core::integer::u128" }, { "name": "extension", "type": "core::starknet::contract_address::ContractAddress" }] }, { "type": "struct", "name": "ekubo::types::bounds::Bounds", "members": [{ "name": "lower", "type": "ekubo::types::i129::i129" }, { "name": "upper", "type": "ekubo::types::i129::i129" }] }, { "type": "struct", "name": "creator_coin::exchanges::ekubo::launcher::EkuboLP", "members": [{ "name": "owner", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "quote_address", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "pool_key", "type": "ekubo::types::keys::PoolKey" }, { "name": "bounds", "type": "ekubo::types::bounds::Bounds" }] }, { "type": "enum", "name": "creator_coin::exchanges::SupportedExchanges", "variants": [{ "name": "Jediswap", "type": "()" }, { "name": "Ekubo", "type": "()" }, { "name": "Starkdefi", "type": "()" }] }, { "type": "enum", "name": "creator_coin::token::creator_coin::LiquidityType", "variants": [{ "name": "JediERC20", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "StarkDeFiERC20", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "EkuboNFT", "type": "core::integer::u64" }] }, { "type": "enum", "name": "core::option::Option::<(core::starknet::contract_address::ContractAddress, creator_coin::token::creator_coin::LiquidityType)>", "variants": [{ "name": "Some", "type": "(core::starknet::contract_address::ContractAddress, creator_coin::token::creator_coin::LiquidityType)" }, { "name": "None", "type": "()" }] }, { "type": "interface", "name": "creator_coin::factory::interface::IFactory", "items": [{ "type": "function", "name": "create_creator_coin", "inputs": [{ "name": "owner", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "name", "type": "core::felt252" }, { "name": "symbol", "type": "core::felt252" }, { "name": "initial_supply", "type": "core::integer::u256" }, { "name": "contract_address_salt", "type": "core::felt252" }], "outputs": [{ "type": "core::starknet::contract_address::ContractAddress" }], "state_mutability": "external" }, { "type": "function", "name": "launch_on_jediswap", "inputs": [{ "name": "launch_parameters", "type": "creator_coin::factory::LaunchParameters" }, { "name": "quote_amount", "type": "core::integer::u256" }, { "name": "unlock_time", "type": "core::integer::u64" }], "outputs": [{ "type": "core::starknet::contract_address::ContractAddress" }], "state_mutability": "external" }, { "type": "function", "name": "launch_on_ekubo", "inputs": [{ "name": "launch_parameters", "type": "creator_coin::factory::LaunchParameters" }, { "name": "ekubo_parameters", "type": "creator_coin::exchanges::ekubo::ekubo_adapter::EkuboPoolParameters" }], "outputs": [{ "type": "(core::integer::u64, creator_coin::exchanges::ekubo::launcher::EkuboLP)" }], "state_mutability": "external" }, { "type": "function", "name": "launch_on_starkdefi", "inputs": [{ "name": "launch_parameters", "type": "creator_coin::factory::LaunchParameters" }, { "name": "quote_amount", "type": "core::integer::u256" }, { "name": "unlock_time", "type": "core::integer::u64" }], "outputs": [{ "type": "core::starknet::contract_address::ContractAddress" }], "state_mutability": "external" }, { "type": "function", "name": "exchange_address", "inputs": [{ "name": "exchange", "type": "creator_coin::exchanges::SupportedExchanges" }], "outputs": [{ "type": "core::starknet::contract_address::ContractAddress" }], "state_mutability": "view" }, { "type": "function", "name": "lock_manager_address", "inputs": [], "outputs": [{ "type": "core::starknet::contract_address::ContractAddress" }], "state_mutability": "view" }, { "type": "function", "name": "locked_liquidity", "inputs": [{ "name": "token", "type": "core::starknet::contract_address::ContractAddress" }], "outputs": [{ "type": "core::option::Option::<(core::starknet::contract_address::ContractAddress, creator_coin::token::creator_coin::LiquidityType)>" }], "state_mutability": "view" }, { "type": "function", "name": "is_creator_coin", "inputs": [{ "name": "address", "type": "core::starknet::contract_address::ContractAddress" }], "outputs": [{ "type": "core::bool" }], "state_mutability": "view" }, { "type": "function", "name": "ekubo_core_address", "inputs": [], "outputs": [{ "type": "core::starknet::contract_address::ContractAddress" }], "state_mutability": "view" }] }, { "type": "struct", "name": "core::array::Span::<(creator_coin::exchanges::SupportedExchanges, core::starknet::contract_address::ContractAddress)>", "members": [{ "name": "snapshot", "type": "@core::array::Array::<(creator_coin::exchanges::SupportedExchanges, core::starknet::contract_address::ContractAddress)>" }] }, { "type": "struct", "name": "core::array::Span::<(core::starknet::contract_address::ContractAddress, core::starknet::contract_address::ContractAddress)>", "members": [{ "name": "snapshot", "type": "@core::array::Array::<(core::starknet::contract_address::ContractAddress, core::starknet::contract_address::ContractAddress)>" }] }, { "type": "constructor", "name": "constructor", "inputs": [{ "name": "creator_coin_class_hash", "type": "core::starknet::class_hash::ClassHash" }, { "name": "lock_manager_address", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "exchanges", "type": "core::array::Span::<(creator_coin::exchanges::SupportedExchanges, core::starknet::contract_address::ContractAddress)>" }, { "name": "migrated_tokens", "type": "core::array::Span::<(core::starknet::contract_address::ContractAddress, core::starknet::contract_address::ContractAddress)>" }] }, { "type": "event", "name": "creator_coin::factory::factory::Factory::CreatorCoinCreated", "kind": "struct", "members": [{ "name": "owner", "type": "core::starknet::contract_address::ContractAddress", "kind": "data" }, { "name": "name", "type": "core::felt252", "kind": "data" }, { "name": "symbol", "type": "core::felt252", "kind": "data" }, { "name": "initial_supply", "type": "core::integer::u256", "kind": "data" }, { "name": "creator_coin_address", "type": "core::starknet::contract_address::ContractAddress", "kind": "data" }] }, { "type": "event", "name": "creator_coin::factory::factory::Factory::CreatorCoinLaunched", "kind": "struct", "members": [{ "name": "creator_coin_address", "type": "core::starknet::contract_address::ContractAddress", "kind": "data" }, { "name": "quote_token", "type": "core::starknet::contract_address::ContractAddress", "kind": "data" }, { "name": "exchange_name", "type": "core::felt252", "kind": "data" }] }, { "type": "event", "name": "creator_coin::factory::factory::Factory::Event", "kind": "enum", "variants": [{ "name": "CreatorCoinCreated", "type": "creator_coin::factory::factory::Factory::CreatorCoinCreated", "kind": "nested" }, { "name": "CreatorCoinLaunched", "type": "creator_coin::factory::factory::Factory::CreatorCoinLaunched", "kind": "nested" }] }];
4640
+
4632
4641
  // src/utils/bigint.ts
4633
4642
  function stringifyBigInts(obj) {
4634
4643
  if (typeof obj === "bigint") {
@@ -6370,6 +6379,107 @@ var ERC1155CollectionService = class {
6370
6379
  return { txHash: res.transaction_hash };
6371
6380
  }
6372
6381
  };
6382
+ var VALIDATED_EKUBO_PARAMS = {
6383
+ fee: "0xc49ba5e353f7d00000000000000000",
6384
+ tickSpacing: 5982n,
6385
+ startingPrice: { mag: 4600158n, sign: true },
6386
+ bound: 88719042n
6387
+ };
6388
+ var COIN_DECIMALS = 18;
6389
+ async function getCreatorCoinPrice(coinAddress, provider) {
6390
+ const r = await provider.callContract({
6391
+ contractAddress: coinAddress,
6392
+ entrypoint: "launched_with_liquidity_parameters",
6393
+ calldata: []
6394
+ });
6395
+ if (BigInt(r[0]) !== 0n || BigInt(r[1]) !== 0n) return null;
6396
+ const fee = r[2];
6397
+ const tickSpacing = r[3];
6398
+ const quoteToken = normalizeAddress("0x" + BigInt(r[7]).toString(16));
6399
+ const token = getTokenByAddress(quoteToken);
6400
+ const quoteDecimals = token?.decimals ?? 18;
6401
+ const ci = BigInt(coinAddress);
6402
+ const qi = BigInt(quoteToken);
6403
+ const [t0, t1] = ci < qi ? [coinAddress, quoteToken] : [quoteToken, coinAddress];
6404
+ const quoteIsToken0 = qi === BigInt(t0);
6405
+ const pp = await provider.callContract({
6406
+ contractAddress: EKUBO_CORE_MAINNET,
6407
+ entrypoint: "get_pool_price",
6408
+ calldata: [t0, t1, fee, tickSpacing, "0x0"]
6409
+ });
6410
+ const sqrt = BigInt(pp[0]) + (BigInt(pp[1] ?? "0x0") << 128n);
6411
+ const priceT1perT0 = (Number(sqrt) / 2 ** 128) ** 2;
6412
+ const decAdj = 10 ** (COIN_DECIMALS - quoteDecimals);
6413
+ const quotePerCoin = (quoteIsToken0 ? 1 / priceT1perT0 : priceT1perT0) * decAdj;
6414
+ return { quotePerCoin, quoteToken, quoteSymbol: token?.symbol ?? null, quoteDecimals };
6415
+ }
6416
+ var CreatorCoinService = class {
6417
+ constructor(config) {
6418
+ this.factoryAddress = CREATOR_COIN_FACTORY_CONTRACT_MAINNET;
6419
+ this.config = config;
6420
+ }
6421
+ _factory(account) {
6422
+ return new starknet.Contract(CreatorCoinFactoryABI, this.factoryAddress, account);
6423
+ }
6424
+ /** Deploy a fixed-supply CreatorCoin (full supply minted to the Factory). */
6425
+ async createCreatorCoin(account, params) {
6426
+ const salt = params.salt ?? BigInt("0x" + Date.now().toString(16));
6427
+ const call = this._factory(account).populate("create_creator_coin", [
6428
+ params.owner,
6429
+ params.name,
6430
+ params.symbol,
6431
+ BigInt(params.initialSupply),
6432
+ BigInt(salt)
6433
+ ]);
6434
+ const res = await account.execute([call]);
6435
+ return { txHash: res.transaction_hash };
6436
+ }
6437
+ /**
6438
+ * Launch a coin on Ekubo (owner-only). Optionally pre-funds the Factory with
6439
+ * quote (for the buyback) in the same multicall. Liquidity is permanently
6440
+ * locked in the EkuboLauncher.
6441
+ */
6442
+ async launchOnEkubo(account, params) {
6443
+ const ek = params.ekubo ?? VALIDATED_EKUBO_PARAMS;
6444
+ const factory = this._factory(account);
6445
+ const launchParameters = {
6446
+ creator_coin_address: params.creatorCoin,
6447
+ transfer_restriction_delay: params.transferRestrictionDelay ?? 0,
6448
+ max_percentage_buy_launch: params.maxPercentageBuyLaunch ?? 200,
6449
+ quote_address: params.quoteToken,
6450
+ initial_holders: params.initialHolders,
6451
+ initial_holders_amounts: params.initialHoldersAmounts.map((a) => BigInt(a))
6452
+ };
6453
+ const ekuboParameters = {
6454
+ fee: BigInt(ek.fee),
6455
+ tick_spacing: BigInt(ek.tickSpacing),
6456
+ starting_price: { mag: BigInt(ek.startingPrice.mag), sign: ek.startingPrice.sign },
6457
+ bound: BigInt(ek.bound)
6458
+ };
6459
+ const calls = [];
6460
+ if (params.quoteFundAmount !== void 0) {
6461
+ const amt = starknet.uint256.bnToUint256(BigInt(params.quoteFundAmount));
6462
+ calls.push({
6463
+ contractAddress: params.quoteToken,
6464
+ entrypoint: "transfer",
6465
+ calldata: [this.factoryAddress, amt.low, amt.high]
6466
+ });
6467
+ }
6468
+ calls.push(factory.populate("launch_on_ekubo", [launchParameters, ekuboParameters]));
6469
+ const res = await account.execute(calls);
6470
+ return { txHash: res.transaction_hash };
6471
+ }
6472
+ /** View: is this address a Factory-deployed Creator Coin? */
6473
+ async isCreatorCoin(address, account) {
6474
+ const r = await this._factory(account).is_creator_coin(address);
6475
+ return BigInt(r) === 1n;
6476
+ }
6477
+ /** Read a coin's live Ekubo spot price (quote-per-coin) via the configured RPC.
6478
+ * Read-only; returns null if the coin isn't launched on Ekubo. */
6479
+ async getPrice(coinAddress) {
6480
+ return getCreatorCoinPrice(coinAddress, new starknet.RpcProvider({ nodeUrl: this.config.rpcUrl }));
6481
+ }
6482
+ };
6373
6483
 
6374
6484
  // src/client.ts
6375
6485
  var MedialaneClient = class {
@@ -6380,7 +6490,8 @@ var MedialaneClient = class {
6380
6490
  this.services = {
6381
6491
  pop: new PopService(this.config),
6382
6492
  drop: new DropService(this.config),
6383
- erc1155Collection: new ERC1155CollectionService(this.config)
6493
+ erc1155Collection: new ERC1155CollectionService(this.config),
6494
+ creatorCoin: new CreatorCoinService(this.config)
6384
6495
  };
6385
6496
  if (!this.config.backendUrl) {
6386
6497
  const sentinel = new ApiClient("https://medialane-sdk-no-backend.invalid", this.config.apiKey);
@@ -6508,6 +6619,28 @@ var SERVICES = {
6508
6619
  ],
6509
6620
  metadataSchema: { licenseDefault: "CC BY-SA" }
6510
6621
  },
6622
+ "creator-coin": {
6623
+ id: "creator-coin",
6624
+ displayName: "Creator Coin",
6625
+ description: "Launch a fixed-supply social token with permanently-locked Ekubo liquidity.",
6626
+ standard: "ERC20",
6627
+ provenance: "MEDIALANE",
6628
+ onchain: {
6629
+ factoryAddress: CREATOR_COIN_FACTORY_CONTRACT_MAINNET,
6630
+ classHash: CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET,
6631
+ startBlock: CREATOR_COIN_START_BLOCK_MAINNET
6632
+ },
6633
+ uiVariant: "coin",
6634
+ // `swap` is a UI affordance (05 §III): the marketplace renders an embedded
6635
+ // Ekubo swap (via StarkZapp) for the coin. Settlement is Ekubo — Medialane
6636
+ // operates NO trading venue and custodies nothing. No venue service exists
6637
+ // for coins (unlike NFTs, whose Medialane marketplace contract settles them).
6638
+ capabilities: ["launch", "swap", "transfer"],
6639
+ events: [
6640
+ { name: "CreatorCoinCreated", emittedBy: "factory" },
6641
+ { name: "CreatorCoinLaunched", emittedBy: "factory" }
6642
+ ]
6643
+ },
6511
6644
  "medialane-marketplace-erc721": {
6512
6645
  id: "medialane-marketplace-erc721",
6513
6646
  displayName: "Medialane Marketplace (ERC-721)",
@@ -6546,6 +6679,15 @@ var SERVICES = {
6546
6679
  { name: "OrderCancelled", emittedBy: "factory" }
6547
6680
  ]
6548
6681
  },
6682
+ "external-erc20": {
6683
+ id: "external-erc20",
6684
+ displayName: "External ERC-20",
6685
+ description: "An ERC-20 token (e.g. an unrug memecoin or a partner coin) not deployed via a Medialane service. Brought in by owner claim or admin/partnership \u2014 never bulk-indexed. Generalizes to future chains.",
6686
+ standard: "ERC20",
6687
+ provenance: "EXTERNAL",
6688
+ uiVariant: "coin",
6689
+ capabilities: ["swap", "transfer"]
6690
+ },
6549
6691
  "external-erc721": {
6550
6692
  id: "external-erc721",
6551
6693
  displayName: "External ERC-721",
@@ -6587,13 +6729,21 @@ exports.COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET = COLLECTION_1155_FACTORY_CLA
6587
6729
  exports.COLLECTION_1155_START_BLOCK_MAINNET = COLLECTION_1155_START_BLOCK_MAINNET;
6588
6730
  exports.COLLECTION_721_CONTRACT_MAINNET = COLLECTION_721_CONTRACT_MAINNET;
6589
6731
  exports.COLLECTION_721_START_BLOCK_MAINNET = COLLECTION_721_START_BLOCK_MAINNET;
6732
+ exports.CREATOR_COIN_CLASS_HASH_MAINNET = CREATOR_COIN_CLASS_HASH_MAINNET;
6733
+ exports.CREATOR_COIN_EKUBO_LAUNCHER_MAINNET = CREATOR_COIN_EKUBO_LAUNCHER_MAINNET;
6734
+ exports.CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET = CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET;
6735
+ exports.CREATOR_COIN_FACTORY_CONTRACT_MAINNET = CREATOR_COIN_FACTORY_CONTRACT_MAINNET;
6736
+ exports.CREATOR_COIN_START_BLOCK_MAINNET = CREATOR_COIN_START_BLOCK_MAINNET;
6590
6737
  exports.CollectionRegistryABI = CollectionRegistryABI;
6738
+ exports.CreatorCoinFactoryABI = CreatorCoinFactoryABI;
6739
+ exports.CreatorCoinService = CreatorCoinService;
6591
6740
  exports.DEFAULT_RPC_URL = DEFAULT_RPC_URL;
6592
6741
  exports.DROP_COLLECTION_CLASS_HASH_MAINNET = DROP_COLLECTION_CLASS_HASH_MAINNET;
6593
6742
  exports.DROP_FACTORY_CONTRACT_MAINNET = DROP_FACTORY_CONTRACT_MAINNET;
6594
6743
  exports.DropCollectionABI = DropCollectionABI;
6595
6744
  exports.DropFactoryABI = DropFactoryABI;
6596
6745
  exports.DropService = DropService;
6746
+ exports.EKUBO_CORE_MAINNET = EKUBO_CORE_MAINNET;
6597
6747
  exports.ERC1155CollectionService = ERC1155CollectionService;
6598
6748
  exports.FeeConfigSchema = FeeConfigSchema;
6599
6749
  exports.IPCOLLECTION_CLASS_HASH_MAINNET = IPCOLLECTION_CLASS_HASH_MAINNET;
@@ -6625,6 +6775,7 @@ exports.PUBLIC_RPC_FALLBACKS = PUBLIC_RPC_FALLBACKS;
6625
6775
  exports.PopService = PopService;
6626
6776
  exports.SUPPORTED_NETWORKS = SUPPORTED_NETWORKS;
6627
6777
  exports.SUPPORTED_TOKENS = SUPPORTED_TOKENS;
6778
+ exports.VALIDATED_EKUBO_PARAMS = VALIDATED_EKUBO_PARAMS;
6628
6779
  exports.build1155CancellationTypedData = build1155CancellationTypedData;
6629
6780
  exports.build1155OrderTypedData = build1155OrderTypedData;
6630
6781
  exports.buildCancellationTypedData = buildCancellationTypedData;
@@ -6633,6 +6784,7 @@ exports.buildOrderTypedData = buildOrderTypedData;
6633
6784
  exports.createFailoverFetch = createFailoverFetch;
6634
6785
  exports.encodeByteArray = encodeByteArray;
6635
6786
  exports.formatAmount = formatAmount;
6787
+ exports.getCreatorCoinPrice = getCreatorCoinPrice;
6636
6788
  exports.getListableTokens = getListableTokens;
6637
6789
  exports.getService = getService;
6638
6790
  exports.getServicesByCapability = getServicesByCapability;