@medialane/sdk 0.29.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 +47 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -3
- package/dist/index.d.ts +37 -3
- package/dist/index.js +47 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -66,6 +66,7 @@ var CREATOR_COIN_EKUBO_LAUNCHER_MAINNET = "0x4f7fceb5ac10f12f9544a09580592e5bdf1
|
|
|
66
66
|
var CREATOR_COIN_CLASS_HASH_MAINNET = "0x743e4c8a5b96bb83bbf4af04edbbb482d5ece89eed9b729a79fb7df0cd0b6b6";
|
|
67
67
|
var CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET = "0x51765926b1344c9a20b8cd4b5abe7b7d47375ae97cf6804db3ea5d4b05a9b55";
|
|
68
68
|
var CREATOR_COIN_START_BLOCK_MAINNET = 10474544;
|
|
69
|
+
var EKUBO_CORE_MAINNET = "0x00000005dd3d2f4429af886cd1a3b08289dbcea99a294197e9eb43b0e0325b4b";
|
|
69
70
|
var FeeConfigSchema = zod.z.object({
|
|
70
71
|
enabled: zod.z.boolean().default(true),
|
|
71
72
|
fundAddress: zod.z.string().min(1).optional(),
|
|
@@ -6384,11 +6385,38 @@ var VALIDATED_EKUBO_PARAMS = {
|
|
|
6384
6385
|
startingPrice: { mag: 4600158n, sign: true },
|
|
6385
6386
|
bound: 88719042n
|
|
6386
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
|
+
}
|
|
6387
6416
|
var CreatorCoinService = class {
|
|
6388
|
-
|
|
6389
|
-
// today — launch is zero-fee and views take an account).
|
|
6390
|
-
constructor(_config) {
|
|
6417
|
+
constructor(config) {
|
|
6391
6418
|
this.factoryAddress = CREATOR_COIN_FACTORY_CONTRACT_MAINNET;
|
|
6419
|
+
this.config = config;
|
|
6392
6420
|
}
|
|
6393
6421
|
_factory(account) {
|
|
6394
6422
|
return new starknet.Contract(CreatorCoinFactoryABI, this.factoryAddress, account);
|
|
@@ -6446,6 +6474,11 @@ var CreatorCoinService = class {
|
|
|
6446
6474
|
const r = await this._factory(account).is_creator_coin(address);
|
|
6447
6475
|
return BigInt(r) === 1n;
|
|
6448
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
|
+
}
|
|
6449
6482
|
};
|
|
6450
6483
|
|
|
6451
6484
|
// src/client.ts
|
|
@@ -6646,6 +6679,15 @@ var SERVICES = {
|
|
|
6646
6679
|
{ name: "OrderCancelled", emittedBy: "factory" }
|
|
6647
6680
|
]
|
|
6648
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
|
+
},
|
|
6649
6691
|
"external-erc721": {
|
|
6650
6692
|
id: "external-erc721",
|
|
6651
6693
|
displayName: "External ERC-721",
|
|
@@ -6701,6 +6743,7 @@ exports.DROP_FACTORY_CONTRACT_MAINNET = DROP_FACTORY_CONTRACT_MAINNET;
|
|
|
6701
6743
|
exports.DropCollectionABI = DropCollectionABI;
|
|
6702
6744
|
exports.DropFactoryABI = DropFactoryABI;
|
|
6703
6745
|
exports.DropService = DropService;
|
|
6746
|
+
exports.EKUBO_CORE_MAINNET = EKUBO_CORE_MAINNET;
|
|
6704
6747
|
exports.ERC1155CollectionService = ERC1155CollectionService;
|
|
6705
6748
|
exports.FeeConfigSchema = FeeConfigSchema;
|
|
6706
6749
|
exports.IPCOLLECTION_CLASS_HASH_MAINNET = IPCOLLECTION_CLASS_HASH_MAINNET;
|
|
@@ -6741,6 +6784,7 @@ exports.buildOrderTypedData = buildOrderTypedData;
|
|
|
6741
6784
|
exports.createFailoverFetch = createFailoverFetch;
|
|
6742
6785
|
exports.encodeByteArray = encodeByteArray;
|
|
6743
6786
|
exports.formatAmount = formatAmount;
|
|
6787
|
+
exports.getCreatorCoinPrice = getCreatorCoinPrice;
|
|
6744
6788
|
exports.getListableTokens = getListableTokens;
|
|
6745
6789
|
exports.getService = getService;
|
|
6746
6790
|
exports.getServicesByCapability = getServicesByCapability;
|