@zoralabs/coins-sdk 0.1.3 → 0.2.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/CHANGELOG.md +6 -0
- package/dist/actions/createCoin.d.ts +18 -5
- package/dist/actions/createCoin.d.ts.map +1 -1
- package/dist/index.cjs +89 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +91 -17
- package/dist/index.js.map +1 -1
- package/dist/metadata/cleanAndValidateMetadataURI.d.ts.map +1 -1
- package/dist/utils/poolConfigUtils.d.ts +14 -0
- package/dist/utils/poolConfigUtils.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/actions/createCoin.ts +49 -13
- package/src/index.ts +1 -0
- package/src/metadata/cleanAndValidateMetadataURI.ts +2 -1
- package/src/utils/poolConfigUtils.ts +53 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { coinFactoryABI as zoraFactoryImplABI } from "@zoralabs/protocol-deployments";
|
|
2
|
-
import { Address, TransactionReceipt, WalletClient, SimulateContractParameters, ContractEventArgsFromTopics } from "viem";
|
|
2
|
+
import { Address, TransactionReceipt, WalletClient, SimulateContractParameters, ContractEventArgsFromTopics, Account } from "viem";
|
|
3
3
|
import { GenericPublicClient } from "src/utils/genericPublicClient";
|
|
4
4
|
import { ValidMetadataURI } from "src/metadata";
|
|
5
|
-
export type CoinDeploymentLogArgs = ContractEventArgsFromTopics<typeof zoraFactoryImplABI, "
|
|
5
|
+
export type CoinDeploymentLogArgs = ContractEventArgsFromTopics<typeof zoraFactoryImplABI, "CoinCreatedV4">;
|
|
6
|
+
export declare enum DeployCurrency {
|
|
7
|
+
ZORA = 1,
|
|
8
|
+
ETH = 2
|
|
9
|
+
}
|
|
6
10
|
export type CreateCoinArgs = {
|
|
7
11
|
name: string;
|
|
8
12
|
symbol: string;
|
|
9
13
|
uri: ValidMetadataURI;
|
|
14
|
+
chainId: number;
|
|
10
15
|
owners?: Address[];
|
|
11
16
|
payoutRecipient: Address;
|
|
12
17
|
platformReferrer?: Address;
|
|
13
|
-
|
|
18
|
+
currency?: DeployCurrency;
|
|
14
19
|
};
|
|
15
|
-
export declare function createCoinCall({ name, symbol, uri, owners, payoutRecipient,
|
|
20
|
+
export declare function createCoinCall({ name, symbol, uri, owners, payoutRecipient, currency, chainId, platformReferrer, }: CreateCoinArgs): Promise<SimulateContractParameters<typeof zoraFactoryImplABI, "deploy">>;
|
|
16
21
|
/**
|
|
17
22
|
* Gets the deployed coin address from transaction receipt logs
|
|
18
23
|
* @param receipt Transaction receipt containing the CoinCreated event
|
|
@@ -21,6 +26,7 @@ export declare function createCoinCall({ name, symbol, uri, owners, payoutRecipi
|
|
|
21
26
|
export declare function getCoinCreateFromLogs(receipt: TransactionReceipt): CoinDeploymentLogArgs | undefined;
|
|
22
27
|
export declare function createCoin(call: CreateCoinArgs, walletClient: WalletClient, publicClient: GenericPublicClient, options?: {
|
|
23
28
|
gasMultiplier?: number;
|
|
29
|
+
account?: Account | Address;
|
|
24
30
|
}): Promise<{
|
|
25
31
|
hash: `0x${string}`;
|
|
26
32
|
receipt: any;
|
|
@@ -34,7 +40,14 @@ export declare function createCoin(call: CreateCoinArgs, walletClient: WalletCli
|
|
|
34
40
|
name: string;
|
|
35
41
|
symbol: string;
|
|
36
42
|
coin: `0x${string}`;
|
|
37
|
-
|
|
43
|
+
poolKey: {
|
|
44
|
+
currency0: `0x${string}`;
|
|
45
|
+
currency1: `0x${string}`;
|
|
46
|
+
fee: number;
|
|
47
|
+
tickSpacing: number;
|
|
48
|
+
hooks: `0x${string}`;
|
|
49
|
+
};
|
|
50
|
+
poolKeyHash: `0x${string}`;
|
|
38
51
|
version: string;
|
|
39
52
|
} | undefined;
|
|
40
53
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCoin.d.ts","sourceRoot":"","sources":["../../src/actions/createCoin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACtF,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,YAAY,EACZ,0BAA0B,EAC1B,2BAA2B,
|
|
1
|
+
{"version":3,"file":"createCoin.d.ts","sourceRoot":"","sources":["../../src/actions/createCoin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACtF,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,YAAY,EACZ,0BAA0B,EAC1B,2BAA2B,EAM3B,OAAO,EACR,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAA8B,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAQ5E,MAAM,MAAM,qBAAqB,GAAG,2BAA2B,CAC7D,OAAO,kBAAkB,EACzB,eAAe,CAChB,CAAC;AAEF,oBAAY,cAAc;IACxB,IAAI,IAAI;IACR,GAAG,IAAI;CACR;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,gBAAgB,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;IACnB,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,CAAC;AAqBF,wBAAsB,cAAc,CAAC,EACnC,IAAI,EACJ,MAAM,EACN,GAAG,EACH,MAAM,EACN,eAAe,EACf,QAAQ,EACR,OAAiB,EACjB,gBAA+D,GAChE,EAAE,cAAc,GAAG,OAAO,CACzB,0BAA0B,CAAC,OAAO,kBAAkB,EAAE,QAAQ,CAAC,CAChE,CAgCA;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,kBAAkB,GAC1B,qBAAqB,GAAG,SAAS,CAOnC;AAGD,wBAAsB,UAAU,CAC9B,IAAI,EAAE,cAAc,EACpB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,mBAAmB,EACjC,OAAO,CAAC,EAAE;IACR,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CAC7B;;;;;;;;;;;;;;;;;;;;;;;GAyBF"}
|
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
var _protocoldeployments = require('@zoralabs/protocol-deployments');
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
5
8
|
var _viem = require('viem');
|
|
6
9
|
|
|
7
10
|
// src/constants.ts
|
|
@@ -40,7 +43,7 @@ function cleanAndValidateMetadataURI(uri) {
|
|
|
40
43
|
return uri.replace("ar://", "http://arweave.net/");
|
|
41
44
|
}
|
|
42
45
|
if (uri.startsWith("data:")) {
|
|
43
|
-
|
|
46
|
+
return uri;
|
|
44
47
|
}
|
|
45
48
|
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
46
49
|
return uri;
|
|
@@ -131,21 +134,87 @@ function getAttribution() {
|
|
|
131
134
|
}
|
|
132
135
|
|
|
133
136
|
// src/actions/createCoin.ts
|
|
134
|
-
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
// src/utils/poolConfigUtils.ts
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
var ZORA_DECIMALS = 18;
|
|
144
|
+
var ZORA_ADDRESS = "0x1111111111166b7fe7bd91427724b487980afc69";
|
|
145
|
+
var COIN_ETH_PAIR_LOWER_TICK = -25e4;
|
|
146
|
+
var COIN_ETH_PAIR_UPPER_TICK = -195e3;
|
|
147
|
+
var COIN_ETH_PAIR_NUM_DISCOVERY_POSITIONS = 11;
|
|
148
|
+
var COIN_ETH_PAIR_MAX_DISCOVERY_SUPPLY_SHARE = _viem.parseUnits.call(void 0, "0.05", 18);
|
|
149
|
+
var COIN_ETH_PAIR_POOL_CONFIG = {
|
|
150
|
+
[_chains.base.id]: _protocoldeployments.encodeMultiCurvePoolConfig.call(void 0, {
|
|
151
|
+
currency: _viem.zeroAddress,
|
|
152
|
+
tickLower: [COIN_ETH_PAIR_LOWER_TICK],
|
|
153
|
+
tickUpper: [COIN_ETH_PAIR_UPPER_TICK],
|
|
154
|
+
numDiscoveryPositions: [COIN_ETH_PAIR_NUM_DISCOVERY_POSITIONS],
|
|
155
|
+
maxDiscoverySupplyShare: [COIN_ETH_PAIR_MAX_DISCOVERY_SUPPLY_SHARE]
|
|
156
|
+
}),
|
|
157
|
+
[_chains.baseSepolia.id]: _protocoldeployments.encodeMultiCurvePoolConfig.call(void 0, {
|
|
158
|
+
currency: _viem.zeroAddress,
|
|
159
|
+
tickLower: [COIN_ETH_PAIR_LOWER_TICK],
|
|
160
|
+
tickUpper: [COIN_ETH_PAIR_UPPER_TICK],
|
|
161
|
+
numDiscoveryPositions: [COIN_ETH_PAIR_NUM_DISCOVERY_POSITIONS],
|
|
162
|
+
maxDiscoverySupplyShare: [COIN_ETH_PAIR_MAX_DISCOVERY_SUPPLY_SHARE]
|
|
163
|
+
})
|
|
164
|
+
};
|
|
165
|
+
var COIN_ZORA_PAIR_LOWER_TICK = -138e3;
|
|
166
|
+
var COIN_ZORA_PAIR_UPPER_TICK = -81e3;
|
|
167
|
+
var COIN_ZORA_PAIR_NUM_DISCOVERY_POSITIONS = 11;
|
|
168
|
+
var COIN_ZORA_PAIR_MAX_DISCOVERY_SUPPLY_SHARE = _viem.parseUnits.call(void 0,
|
|
169
|
+
"0.05",
|
|
170
|
+
ZORA_DECIMALS
|
|
171
|
+
);
|
|
172
|
+
var COIN_ZORA_PAIR_POOL_CONFIG = {
|
|
173
|
+
[_chains.base.id]: _protocoldeployments.encodeMultiCurvePoolConfig.call(void 0, {
|
|
174
|
+
currency: ZORA_ADDRESS,
|
|
175
|
+
tickLower: [COIN_ZORA_PAIR_LOWER_TICK],
|
|
176
|
+
tickUpper: [COIN_ZORA_PAIR_UPPER_TICK],
|
|
177
|
+
numDiscoveryPositions: [COIN_ZORA_PAIR_NUM_DISCOVERY_POSITIONS],
|
|
178
|
+
maxDiscoverySupplyShare: [COIN_ZORA_PAIR_MAX_DISCOVERY_SUPPLY_SHARE]
|
|
179
|
+
})
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// src/actions/createCoin.ts
|
|
183
|
+
var DeployCurrency = /* @__PURE__ */ ((DeployCurrency2) => {
|
|
184
|
+
DeployCurrency2[DeployCurrency2["ZORA"] = 1] = "ZORA";
|
|
185
|
+
DeployCurrency2[DeployCurrency2["ETH"] = 2] = "ETH";
|
|
186
|
+
return DeployCurrency2;
|
|
187
|
+
})(DeployCurrency || {});
|
|
188
|
+
function getPoolConfig(currency, chainId) {
|
|
189
|
+
if (currency === 1 /* ZORA */ && chainId == _chains.baseSepolia.id) {
|
|
190
|
+
throw new Error("ZORA is not supported on Base Sepolia");
|
|
191
|
+
}
|
|
192
|
+
switch (currency) {
|
|
193
|
+
case 1 /* ZORA */:
|
|
194
|
+
return COIN_ZORA_PAIR_POOL_CONFIG[chainId];
|
|
195
|
+
case 2 /* ETH */:
|
|
196
|
+
return COIN_ETH_PAIR_POOL_CONFIG[chainId];
|
|
197
|
+
default:
|
|
198
|
+
throw new Error("Invalid currency");
|
|
199
|
+
}
|
|
200
|
+
}
|
|
135
201
|
async function createCoinCall({
|
|
136
202
|
name,
|
|
137
203
|
symbol,
|
|
138
204
|
uri,
|
|
139
205
|
owners,
|
|
140
206
|
payoutRecipient,
|
|
141
|
-
|
|
207
|
+
currency,
|
|
208
|
+
chainId = _chains.base.id,
|
|
142
209
|
platformReferrer = "0x0000000000000000000000000000000000000000"
|
|
143
210
|
}) {
|
|
144
211
|
if (!owners) {
|
|
145
212
|
owners = [payoutRecipient];
|
|
146
213
|
}
|
|
147
|
-
|
|
148
|
-
|
|
214
|
+
if (!currency) {
|
|
215
|
+
currency = chainId !== _chains.base.id ? 2 /* ETH */ : 1 /* ZORA */;
|
|
216
|
+
}
|
|
217
|
+
const poolConfig = getPoolConfig(currency, chainId);
|
|
149
218
|
await validateMetadataURIContent(uri);
|
|
150
219
|
return {
|
|
151
220
|
abi: _protocoldeployments.coinFactoryABI,
|
|
@@ -159,9 +228,13 @@ async function createCoinCall({
|
|
|
159
228
|
symbol,
|
|
160
229
|
poolConfig,
|
|
161
230
|
platformReferrer,
|
|
162
|
-
|
|
231
|
+
_viem.zeroAddress,
|
|
232
|
+
// hookAddress
|
|
233
|
+
"0x",
|
|
234
|
+
// hookData
|
|
235
|
+
_viem.keccak256.call(void 0, _viem.toBytes.call(void 0, Math.random().toString()))
|
|
236
|
+
// coinSalt
|
|
163
237
|
],
|
|
164
|
-
value: initialPurchaseWei,
|
|
165
238
|
dataSuffix: getAttribution()
|
|
166
239
|
};
|
|
167
240
|
}
|
|
@@ -170,17 +243,17 @@ function getCoinCreateFromLogs(receipt) {
|
|
|
170
243
|
abi: _protocoldeployments.coinFactoryABI,
|
|
171
244
|
logs: receipt.logs
|
|
172
245
|
});
|
|
173
|
-
return _optionalChain([eventLogs, 'access', _3 => _3.find, 'call', _4 => _4((log) => log.eventName === "
|
|
246
|
+
return _optionalChain([eventLogs, 'access', _3 => _3.find, 'call', _4 => _4((log) => log.eventName === "CoinCreatedV4"), 'optionalAccess', _5 => _5.args]);
|
|
174
247
|
}
|
|
175
248
|
async function createCoin(call, walletClient, publicClient, options) {
|
|
176
249
|
validateClientNetwork(publicClient);
|
|
177
250
|
const createCoinRequest = await createCoinCall(call);
|
|
178
251
|
const { request } = await publicClient.simulateContract({
|
|
179
252
|
...createCoinRequest,
|
|
180
|
-
account: walletClient.account
|
|
253
|
+
account: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _6 => _6.account]), () => ( walletClient.account))
|
|
181
254
|
});
|
|
182
255
|
if (request.gas) {
|
|
183
|
-
request.gas = request.gas * BigInt(_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
256
|
+
request.gas = request.gas * BigInt(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _7 => _7.gasMultiplier]), () => ( 100))) / 100n;
|
|
184
257
|
}
|
|
185
258
|
const hash = await walletClient.writeContract(request);
|
|
186
259
|
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
@@ -188,7 +261,7 @@ async function createCoin(call, walletClient, publicClient, options) {
|
|
|
188
261
|
return {
|
|
189
262
|
hash,
|
|
190
263
|
receipt,
|
|
191
|
-
address: _optionalChain([deployment, 'optionalAccess',
|
|
264
|
+
address: _optionalChain([deployment, 'optionalAccess', _8 => _8.coin]),
|
|
192
265
|
deployment
|
|
193
266
|
};
|
|
194
267
|
}
|
|
@@ -265,9 +338,9 @@ function getTradeFromLogs(receipt, direction) {
|
|
|
265
338
|
logs: receipt.logs
|
|
266
339
|
});
|
|
267
340
|
if (direction === "buy") {
|
|
268
|
-
return _optionalChain([eventLogs, 'access',
|
|
341
|
+
return _optionalChain([eventLogs, 'access', _9 => _9.find, 'call', _10 => _10((log) => log.eventName === "CoinBuy"), 'optionalAccess', _11 => _11.args]);
|
|
269
342
|
}
|
|
270
|
-
return _optionalChain([eventLogs, 'access',
|
|
343
|
+
return _optionalChain([eventLogs, 'access', _12 => _12.find, 'call', _13 => _13((log) => log.eventName === "CoinSell"), 'optionalAccess', _14 => _14.args]);
|
|
271
344
|
}
|
|
272
345
|
async function tradeCoin(params, walletClient, publicClient) {
|
|
273
346
|
validateClientNetwork(publicClient);
|
|
@@ -327,7 +400,7 @@ async function getOnchainCoinDetails({
|
|
|
327
400
|
allowFailure: false
|
|
328
401
|
}
|
|
329
402
|
);
|
|
330
|
-
const USDC_WETH_POOL = USDC_WETH_POOLS_BY_CHAIN[_optionalChain([publicClient, 'access',
|
|
403
|
+
const USDC_WETH_POOL = USDC_WETH_POOLS_BY_CHAIN[_optionalChain([publicClient, 'access', _15 => _15.chain, 'optionalAccess', _16 => _16.id]) || 0];
|
|
331
404
|
const [
|
|
332
405
|
coinWethPoolSlot0,
|
|
333
406
|
coinWethPoolToken0,
|
|
@@ -643,5 +716,6 @@ var getCoinsLastTradedUnique = (query = {}, options) => createExploreQuery(query
|
|
|
643
716
|
|
|
644
717
|
|
|
645
718
|
|
|
646
|
-
|
|
719
|
+
|
|
720
|
+
exports.DeployCurrency = DeployCurrency; exports.cleanAndValidateMetadataURI = cleanAndValidateMetadataURI; exports.createCoin = createCoin; exports.createCoinCall = createCoinCall; 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.getOnchainCoinDetails = getOnchainCoinDetails; exports.getProfile = getProfile2; exports.getProfileBalances = getProfileBalances2; exports.getTradeFromLogs = getTradeFromLogs; exports.setApiKey = setApiKey; exports.simulateBuy = simulateBuy; exports.tradeCoin = tradeCoin; exports.tradeCoinCall = tradeCoinCall; exports.updateCoinURI = updateCoinURI; exports.updateCoinURICall = updateCoinURICall; exports.updatePayoutRecipient = updatePayoutRecipient; exports.updatePayoutRecipientCall = updatePayoutRecipientCall; exports.validateMetadataJSON = validateMetadataJSON; exports.validateMetadataURIContent = validateMetadataURIContent;
|
|
647
721
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/zora-protocol-private/zora-protocol-private/packages/coins-sdk/dist/index.cjs","../src/actions/createCoin.ts","../src/constants.ts","../src/utils/validateClientNetwork.ts","../src/metadata/cleanAndValidateMetadataURI.ts","../src/metadata/validateMetadataJSON.ts","../src/metadata/validateMetadataURIContent.ts","../src/utils/attribution.ts","../src/actions/tradeCoin.ts","../src/actions/getOnchainCoinDetails.ts","../src/actions/updateCoinURI.ts","../src/actions/updatePayoutRecipient.ts","../src/client/client.gen.ts","../src/client/sdk.gen.ts","../src/api/api-key.ts","../src/api/queries.ts","../src/api/explore.ts"],"names":["base","baseSepolia","parseEventLogs","zeroAddress","coinABI","getCoin","getCoins","getCoinComments","getProfile","getProfileBalances"],"mappings":"AAAA;ACAA,qEAAqD;AACrD;AAME;AAAA,4BAEK;ADJP;AACA;AENA;AAEA,qCAAqB;AAGd,IAAM,qBAAA,EAAuB,uCAAA,CAAuB,MAAM,CAAA;AAE1D,IAAM,wBAAA,EACX,4CAAA;AAEK,IAAM,yBAAA,EAAoD;AAAA,EAC/D,CAAC,YAAA,CAAK,EAAE,CAAA,EAAG;AACb,CAAA;AFEA;AACA;AGdA;AAEO,IAAM,sBAAA,EAAwB,CACnC,YAAA,EAAA,GACG;AACH,EAAA,MAAM,cAAA,kBAAgB,YAAA,2BAAc,KAAA,6BAAO,IAAA;AAC3C,EAAA,GAAA,CAAI,cAAA,IAAkBA,YAAAA,CAAK,EAAA,EAAI;AAC7B,IAAA,MAAA;AAAA,EACF;AACA,EAAA,GAAA,CAAI,cAAA,IAAkB,mBAAA,CAAY,EAAA,EAAI;AACpC,IAAA,MAAA;AAAA,EACF;AAEA,EAAA,MAAM,IAAI,KAAA;AAAA,IACR;AAAA,EACF,CAAA;AACF,CAAA;AHYA;AACA;AIlBO,SAAS,2BAAA,CAA4B,GAAA,EAAuB;AACjE,EAAA,GAAA,CAAI,GAAA,CAAI,UAAA,CAAW,SAAS,CAAA,EAAG;AAC7B,IAAA,OAAO,GAAA,CAAI,OAAA;AAAA,MACT,SAAA;AAAA,MACA;AAAA,IACF,CAAA;AAAA,EACF;AACA,EAAA,GAAA,CAAI,GAAA,CAAI,UAAA,CAAW,OAAO,CAAA,EAAG;AA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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,utCAAC","file":"/home/runner/work/zora-protocol-private/zora-protocol-private/packages/coins-sdk/dist/index.cjs","sourcesContent":[null,"import { coinFactoryABI as zoraFactoryImplABI } from \"@zoralabs/protocol-deployments\";\nimport {\n Address,\n TransactionReceipt,\n WalletClient,\n SimulateContractParameters,\n ContractEventArgsFromTopics,\n parseEventLogs,\n Hex,\n} from \"viem\";\nimport { COIN_FACTORY_ADDRESS } from \"../constants\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport { GenericPublicClient } from \"src/utils/genericPublicClient\";\nimport { validateMetadataURIContent, ValidMetadataURI } from \"src/metadata\";\nimport { getAttribution } from \"../utils/attribution\";\n\nexport type CoinDeploymentLogArgs = ContractEventArgsFromTopics<\n typeof zoraFactoryImplABI,\n \"CoinCreated\"\n>;\n\n// This is the default pool config matching zora.co front-end. TODO: Allow users to customize further parameters within safe contract limits.\nconst POOL_CONFIG =\n \"0x00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc2f70fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcf2c0000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000b1a2bc2ec50000\" as Hex;\n\nexport type CreateCoinArgs = {\n name: string;\n symbol: string;\n uri: ValidMetadataURI;\n owners?: Address[];\n payoutRecipient: Address;\n platformReferrer?: Address;\n initialPurchaseWei?: bigint;\n};\n\nexport async function createCoinCall({\n name,\n symbol,\n uri,\n owners,\n payoutRecipient,\n initialPurchaseWei = 0n,\n platformReferrer = \"0x0000000000000000000000000000000000000000\",\n}: CreateCoinArgs): Promise<\n SimulateContractParameters<typeof zoraFactoryImplABI, \"deploy\">\n> {\n if (!owners) {\n owners = [payoutRecipient];\n }\n\n const orderSize: bigint = initialPurchaseWei;\n // The default pool config for\n const poolConfig = POOL_CONFIG;\n\n // This will throw an error if the metadata is not valid\n await validateMetadataURIContent(uri);\n\n return {\n abi: zoraFactoryImplABI,\n functionName: \"deploy\",\n address: COIN_FACTORY_ADDRESS,\n args: [\n payoutRecipient,\n owners,\n uri,\n name,\n symbol,\n poolConfig,\n platformReferrer,\n orderSize,\n ],\n value: initialPurchaseWei,\n dataSuffix: getAttribution(),\n } as const;\n}\n\n/**\n * Gets the deployed coin address from transaction receipt logs\n * @param receipt Transaction receipt containing the CoinCreated event\n * @returns The deployment information if found\n */\nexport function getCoinCreateFromLogs(\n receipt: TransactionReceipt,\n): CoinDeploymentLogArgs | undefined {\n const eventLogs = parseEventLogs({\n abi: zoraFactoryImplABI,\n logs: receipt.logs,\n });\n return eventLogs.find((log) => log.eventName === \"CoinCreated\")?.args;\n}\n\n// Update createCoin to return both receipt and coin address\nexport async function createCoin(\n call: CreateCoinArgs,\n walletClient: WalletClient,\n publicClient: GenericPublicClient,\n options?: {\n gasMultiplier?: number;\n },\n) {\n validateClientNetwork(publicClient);\n\n const createCoinRequest = await createCoinCall(call);\n const { request } = await publicClient.simulateContract({\n ...createCoinRequest,\n account: walletClient.account,\n });\n\n // Add a 2/5th buffer on gas.\n if (request.gas) {\n // Gas limit multiplier is a percentage argument.\n request.gas = (request.gas * BigInt(options?.gasMultiplier ?? 100)) / 100n;\n }\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const deployment = getCoinCreateFromLogs(receipt);\n\n return {\n hash,\n receipt,\n address: deployment?.coin,\n deployment,\n };\n}\n","import { coinFactoryAddress as zoraFactoryImplAddress } from \"@zoralabs/protocol-deployments\";\nimport { Address } from \"viem\";\nimport { base } from \"viem/chains\";\n\n// this is the same across all chains due to deterministic deploys.\nexport const COIN_FACTORY_ADDRESS = zoraFactoryImplAddress[\"8453\"] as Address;\n\nexport const SUPERCHAIN_WETH_ADDRESS =\n \"0x4200000000000000000000000000000000000006\";\n\nexport const USDC_WETH_POOLS_BY_CHAIN: Record<number, Address> = {\n [base.id]: \"0xd0b53D9277642d899DF5C87A3966A349A798F224\",\n};\n","import { PublicClient } from \"viem\";\nimport { base, baseSepolia } from \"viem/chains\";\n\nexport const validateClientNetwork = (\n publicClient: PublicClient<any, any, any, any>,\n) => {\n const clientChainId = publicClient?.chain?.id;\n if (clientChainId === base.id) {\n return;\n }\n if (clientChainId === baseSepolia.id) {\n return;\n }\n\n throw new Error(\n \"Client network needs to be base or baseSepolia for current coin deployments.\",\n );\n};\n","export type ValidMetadataURI =\n | `ipfs://${string}`\n | `ar://${string}`\n | `data:${string}`\n | `https://${string}`;\n\n/**\n * Clean the metadata URI to HTTPS format\n * @param metadataURI - The metadata URI to clean from IPFS or Arweave\n * @returns The cleaned metadata URI\n * @throws If the metadata URI is a data URI\n */\nexport function cleanAndValidateMetadataURI(uri: ValidMetadataURI) {\n if (uri.startsWith(\"ipfs://\")) {\n return uri.replace(\n \"ipfs://\",\n \"https://magic.decentralized-content.com/ipfs/\",\n );\n }\n if (uri.startsWith(\"ar://\")) {\n return uri.replace(\"ar://\", \"http://arweave.net/\");\n }\n if (uri.startsWith(\"data:\")) {\n throw new Error(\"Data URIs are not supported\");\n }\n if (uri.startsWith(\"http://\") || uri.startsWith(\"https://\")) {\n return uri;\n }\n\n throw new Error(\"Invalid metadata URI\");\n}\n","export type ValidMetadataJSON = {\n name: string;\n description: string;\n image: string;\n animation_url?: string;\n content?: { uri: string; mime?: string };\n};\n\nfunction validateURIString(uri: unknown) {\n if (typeof uri !== \"string\") {\n throw new Error(\"URI must be a string\");\n }\n if (uri.startsWith(\"ipfs://\")) {\n return true;\n }\n if (uri.startsWith(\"ar://\")) {\n return true;\n }\n if (uri.startsWith(\"https://\")) {\n return true;\n }\n if (uri.startsWith(\"data:\")) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Validate the metadata JSON object\n * @param metadata - The metadata object to validate\n */\nexport function validateMetadataJSON(metadata: ValidMetadataJSON | unknown) {\n if (typeof metadata !== \"object\" || !metadata) {\n throw new Error(\"Metadata must be an object and exist\");\n }\n if (typeof (metadata as { name: unknown }).name !== \"string\") {\n throw new Error(\"Metadata name is required and must be a string\");\n }\n if (typeof (metadata as { description: unknown }).description !== \"string\") {\n throw new Error(\"Metadata description is required and must be a string\");\n }\n if (typeof (metadata as { image: unknown }).image === \"string\") {\n if (!validateURIString((metadata as { image: string }).image)) {\n throw new Error(\"Metadata image is not a valid URI\");\n }\n } else {\n throw new Error(\"Metadata image is required and must be a string\");\n }\n if (\"animation_url\" in metadata) {\n if (\n typeof (metadata as { animation_url?: unknown }).animation_url !==\n \"string\"\n ) {\n throw new Error(\"Metadata animation_url, if provided, must be a string\");\n }\n if (!validateURIString(metadata.animation_url)) {\n throw new Error(\"Metadata animation_url is not a valid URI\");\n }\n }\n const content =\n \"content\" in metadata && (metadata as { content?: unknown }).content;\n if (content) {\n if (typeof (content as { uri?: unknown }).uri !== \"string\") {\n throw new Error(\"If provided, content.uri must be a string\");\n }\n if (!validateURIString((content as { uri: string }).uri)) {\n throw new Error(\"If provided, content.uri must be a valid URI string\");\n }\n if (typeof (content as { mime?: unknown }).mime !== \"string\") {\n throw new Error(\"If provided, content.mime must be a string\");\n }\n }\n\n return true;\n}\n","import {\n cleanAndValidateMetadataURI,\n ValidMetadataURI,\n} from \"./cleanAndValidateMetadataURI\";\nimport { validateMetadataJSON } from \"./validateMetadataJSON\";\n\n/**\n * Validate the metadata URI Content\n * @param metadataURI - The metadata URI to validate\n * @returns true if the metadata is valid, throws an error otherwise\n */\nexport async function validateMetadataURIContent(\n metadataURI: ValidMetadataURI,\n) {\n const cleanedURI = cleanAndValidateMetadataURI(metadataURI);\n const response = await fetch(cleanedURI);\n if (!response.ok) {\n throw new Error(\"Metadata fetch failed\");\n }\n if (\n ![\"application/json\", \"text/plain\"].includes(\n response.headers.get(\"content-type\") ?? \"\",\n )\n ) {\n throw new Error(\"Metadata is not a valid JSON or plain text response type\");\n }\n const metadataJson = await response.json();\n return validateMetadataJSON(metadataJson);\n}\n","import { Hex, keccak256, slice, toHex } from \"viem\";\n\nexport function getAttribution(): Hex {\n const hash = keccak256(toHex(\"api-sdk.zora.engineering\"));\n return slice(hash, 0, 4) as Hex;\n}\n","import { coinABI } from \"@zoralabs/protocol-deployments\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport {\n Address,\n TransactionReceipt,\n WalletClient,\n SimulateContractParameters,\n parseEther,\n zeroAddress,\n ContractEventArgsFromTopics,\n parseEventLogs,\n} from \"viem\";\nimport { baseSepolia } from \"viem/chains\";\nimport { GenericPublicClient } from \"src/utils/genericPublicClient\";\nimport { getAttribution } from \"../utils/attribution\";\n// Define trade event args type\n\nexport type SellEventArgs = ContractEventArgsFromTopics<\n typeof coinABI,\n \"CoinSell\"\n>;\nexport type BuyEventArgs = ContractEventArgsFromTopics<\n typeof coinABI,\n \"CoinBuy\"\n>;\n\nexport type TradeEventArgs = SellEventArgs | BuyEventArgs;\n\n// We'll use this address to ensure it will have funds to simulate an eth trade.\n// @dev: This only works on OP chains and is a fix for a bug. Another approach should be taken long term.\nconst OP_BRIDGE_ADDRESS =\n \"0x4200000000000000000000000000000000000016\" as Address;\n\n/**\n * Simulates a buy order to get the expected output amount\n * @param {Object} params - The simulation parameters\n * @param {Address} params.target - The target coin contract address\n * @param {bigint} params.requestedOrderSize - The desired input amount for the buy\n * @param {PublicClient} params.publicClient - The viem public client instance\n * @returns {Promise<{orderSize: bigint, amountOut: bigint}>} The simulated order size and output amount\n */\nexport async function simulateBuy({\n target,\n requestedOrderSize,\n publicClient,\n}: {\n target: Address;\n requestedOrderSize: bigint;\n publicClient: GenericPublicClient;\n}): Promise<{ orderSize: bigint; amountOut: bigint }> {\n const numberResult = await publicClient.simulateContract({\n address: target,\n abi: coinABI,\n functionName: \"buy\",\n dataSuffix: getAttribution(),\n args: [\n OP_BRIDGE_ADDRESS,\n requestedOrderSize,\n 0n, // minAmountOut\n 0n, // sqrtPriceLimitX96\n zeroAddress, // tradeReferrer\n ],\n // We want to ensure that the multicall3 contract has enough ETH to buy in the simulation\n stateOverride: [\n {\n address: baseSepolia.contracts.multicall3.address,\n balance: parseEther(\"10000000\"),\n },\n ],\n });\n const orderSize = numberResult.result[0];\n const amountOut = numberResult.result[1];\n return { orderSize, amountOut };\n}\n\n/**\n * Parameters for creating a trade call\n * @typedef {Object} TradeParams\n * @property {'sell' | 'buy'} direction - The trade direction\n * @property {Address} target - The target coin contract address\n * @property {Object} args - The trade arguments\n * @property {Address} args.recipient - The recipient of the trade output\n * @property {bigint} args.orderSize - The size of the order\n * @property {bigint} [args.minAmountOut] - The minimum amount to receive\n * @property {bigint} [args.sqrtPriceLimitX96] - The price limit for the trade\n * @property {Address} [args.tradeReferrer] - The referrer address for the trade\n */\nexport type TradeParams = {\n direction: \"sell\" | \"buy\";\n target: Address;\n args: {\n recipient: Address;\n orderSize: bigint;\n minAmountOut?: bigint;\n sqrtPriceLimitX96?: bigint;\n tradeReferrer?: Address;\n };\n};\n\n/**\n * Creates a trade call parameters object for buy or sell\n * @param {TradeParams} params - The trade parameters\n * @returns {SimulateContractParameters} The contract call parameters\n */\nexport function tradeCoinCall({\n target,\n direction,\n args: {\n recipient,\n orderSize,\n minAmountOut = 0n,\n sqrtPriceLimitX96 = 0n,\n tradeReferrer = zeroAddress,\n },\n}: TradeParams): SimulateContractParameters {\n return {\n abi: coinABI,\n functionName: direction,\n address: target,\n args: [\n recipient,\n orderSize,\n minAmountOut,\n sqrtPriceLimitX96,\n tradeReferrer,\n ],\n value: direction === \"buy\" ? orderSize : 0n,\n } as const;\n}\n\n/**\n * Gets the trade event from transaction receipt logs\n * @param {TransactionReceipt} receipt - The transaction receipt containing the logs\n * @param {'buy' | 'sell'} direction - The direction of the trade\n * @returns {TradeEventArgs | undefined} The decoded trade event args if found\n */\nexport function getTradeFromLogs(\n receipt: TransactionReceipt,\n direction: \"buy\" | \"sell\",\n): TradeEventArgs | undefined {\n const eventLogs = parseEventLogs({\n abi: coinABI,\n logs: receipt.logs,\n });\n\n if (direction === \"buy\") {\n return eventLogs.find((log) => log.eventName === \"CoinBuy\")?.args;\n }\n return eventLogs.find((log) => log.eventName === \"CoinSell\")?.args;\n}\n\n/**\n * Executes a trade transaction\n * @param {TradeParams} params - The trade parameters\n * @param {PublicClient} publicClient - The viem public client instance\n * @param {WalletClient} walletClient - The viem wallet client instance\n * @returns {Promise<{\n * hash: `0x${string}`,\n * receipt: TransactionReceipt,\n * trade: TradeEventArgs | undefined\n * }>} The transaction result with trade details\n */\nexport async function tradeCoin(\n params: TradeParams,\n walletClient: WalletClient,\n publicClient: GenericPublicClient,\n) {\n validateClientNetwork(publicClient);\n const { request } = await publicClient.simulateContract({\n ...tradeCoinCall(params),\n account: walletClient.account,\n });\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const trade = getTradeFromLogs(receipt, params.direction);\n\n return {\n hash,\n receipt,\n trade,\n };\n}\n","import { coinABI, iUniswapV3PoolABI } from \"@zoralabs/protocol-deployments\";\nimport {\n SUPERCHAIN_WETH_ADDRESS,\n USDC_WETH_POOLS_BY_CHAIN,\n} from \"../constants\";\nimport { GenericPublicClient } from \"../utils/genericPublicClient\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport {\n Address,\n erc20Abi,\n formatEther,\n isAddressEqual,\n zeroAddress,\n} from \"viem\";\n\ntype Slot0Result = {\n sqrtPriceX96: bigint;\n tick: number;\n observationIndex: number;\n observationCardinality: number;\n observationCardinalityNext: number;\n feeProtocol: number;\n unlocked: boolean;\n};\n\ntype PricingResult = {\n eth: bigint;\n usdc: bigint | null;\n usdcDecimal: number | null;\n ethDecimal: number;\n};\n\n/**\n * Represents the current state of a coin\n * @typedef {Object} OnchainCoinDetails\n * @property {bigint} balance - The user's balance of the coin\n * @property {PricingResult} marketCap - The market cap of the coin\n * @property {PricingResult} liquidity - The liquidity of the coin\n * @property {Address} pool - Pool address\n * @property {Slot0Result} poolState - Current state of the UniswapV3 pool\n * @property {Address[]} owners - List of owners for the coin\n * @property {Address} payoutRecipient - The payout recipient address\n */\nexport type OnchainCoinDetails = {\n balance: bigint;\n marketCap: PricingResult;\n liquidity: PricingResult;\n pool: Address;\n poolState: Slot0Result;\n owners: readonly Address[];\n payoutRecipient: Address;\n};\n\n/**\n * Gets the current state of a coin for a user\n * @param {Object} params - The query parameters\n * @param {Address} params.coin - The coin contract address\n * @param {Address} params.user - The user address to check balance for\n * @param {PublicClient} params.publicClient - The viem public client instance\n * @returns {Promise<OnchainCoinDetails>} The coin's current state\n */\nexport async function getOnchainCoinDetails({\n coin,\n user = zeroAddress,\n publicClient,\n}: {\n coin: Address;\n user?: Address;\n publicClient: GenericPublicClient;\n}): Promise<OnchainCoinDetails> {\n validateClientNetwork(publicClient);\n const [balance, pool, owners, payoutRecipient] = await publicClient.multicall(\n {\n contracts: [\n {\n address: coin,\n abi: coinABI,\n functionName: \"balanceOf\",\n args: [user],\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"poolAddress\",\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"owners\",\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"payoutRecipient\",\n },\n ],\n allowFailure: false,\n },\n );\n\n const USDC_WETH_POOL = USDC_WETH_POOLS_BY_CHAIN[publicClient.chain?.id || 0];\n\n const [\n coinWethPoolSlot0,\n coinWethPoolToken0,\n coinReservesRaw,\n coinTotalSupply,\n wethReservesRaw,\n usdcWethSlot0,\n ] = await publicClient.multicall({\n contracts: [\n {\n address: pool,\n abi: iUniswapV3PoolABI,\n functionName: \"slot0\",\n },\n {\n address: pool,\n abi: iUniswapV3PoolABI,\n functionName: \"token0\",\n },\n {\n address: coin,\n abi: erc20Abi,\n functionName: \"balanceOf\",\n args: [pool],\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"totalSupply\",\n },\n {\n address: SUPERCHAIN_WETH_ADDRESS,\n abi: erc20Abi,\n functionName: \"balanceOf\",\n args: [pool],\n },\n {\n address: USDC_WETH_POOL ?? coin,\n abi: iUniswapV3PoolABI,\n functionName: \"slot0\",\n },\n ],\n allowFailure: false,\n });\n\n const wethPriceInUsdc = USDC_WETH_POOL\n ? uniswapV3SqrtPriceToBigIntScaled(\n usdcWethSlot0.sqrtPriceX96,\n 18,\n 6,\n true,\n 18,\n )\n : null;\n\n const coinPriceInWeth = uniswapV3SqrtPriceToBigIntScaled(\n coinWethPoolSlot0.sqrtPriceX96,\n 18,\n 18,\n isAddressEqual(coinWethPoolToken0, coin),\n 18,\n );\n\n // Divide by 10^18 to remove percision from `coinPriceInWeth` after math since bigint is decimal.\n const marketCap = (coinPriceInWeth * coinTotalSupply) / 10n ** 18n;\n\n const wethLiquidity = wethReservesRaw;\n // Divide by 10^18 to remove percision from `coinPriceInWeth` after math since bigint is decimal.\n const tokenLiquidity = (coinReservesRaw * coinPriceInWeth) / 10n ** 18n;\n\n return {\n balance,\n pool,\n owners,\n payoutRecipient,\n marketCap: convertEthOutput(marketCap, wethPriceInUsdc),\n liquidity: convertEthOutput(\n wethLiquidity + tokenLiquidity,\n wethPriceInUsdc,\n ),\n poolState: coinWethPoolSlot0,\n };\n}\n\nfunction convertEthOutput(amountETH: bigint, wethToUsdc: bigint | null) {\n return {\n eth: amountETH,\n ethDecimal: parseFloat(formatEther(amountETH)),\n usdc: wethToUsdc ? amountETH * wethToUsdc : null,\n usdcDecimal: wethToUsdc\n ? parseFloat(formatEther((amountETH * wethToUsdc) / 10n ** 18n))\n : null,\n };\n}\n\nfunction uniswapV3SqrtPriceToBigIntScaled(\n sqrtPriceX96: bigint,\n token0Decimals: number,\n token1Decimals: number,\n isToken0Coin: boolean,\n scaleDecimals: number = 18,\n): bigint {\n // (sqrtPrice^2 / 2^192) => ratio\n // We'll do: ratioScaled = (sqrtPrice^2 * 10^scaleDecimals) / 2^192\n const numerator = sqrtPriceX96 * sqrtPriceX96;\n const denominator = 2n ** 192n;\n const scaleFactor = 10n ** BigInt(scaleDecimals);\n\n // raw ratioScaled\n let ratioScaled = (numerator * scaleFactor) / denominator; // BigInt\n\n // Adjust for difference in decimals:\n // ratioScaled *= 10^(dec0 - dec1)\n const decimalsDiff = BigInt(token0Decimals - token1Decimals);\n if (decimalsDiff > 0n) {\n ratioScaled *= 10n ** decimalsDiff;\n } else if (decimalsDiff < 0n) {\n ratioScaled /= 10n ** -decimalsDiff;\n }\n\n if (!isToken0Coin) {\n // We want the reciprocal: coin is token1 => coinPriceInToken0 = 1 / ratio\n // But we also want it scaled by 10^scaleDecimals\n // reciprocalScaled = (10^scaleDecimals * 10^(decimalsDiff)) / ratioScaled\n // (assuming ratioScaled != 0)\n if (ratioScaled === 0n) {\n return 0n; // or some huge number representing infinity\n }\n ratioScaled = (scaleFactor * scaleFactor) / ratioScaled;\n // or if we already included decimalsDiff above, handle carefully.\n }\n\n return ratioScaled;\n}\n","import { coinABI } from \"@zoralabs/protocol-deployments\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport {\n Address,\n parseEventLogs,\n SimulateContractParameters,\n WalletClient,\n} from \"viem\";\nimport { GenericPublicClient } from \"src/utils/genericPublicClient\";\nimport { getAttribution } from \"../utils/attribution\";\n\nexport type UpdateCoinURIArgs = {\n coin: Address;\n newURI: string;\n};\n\nexport function updateCoinURICall({\n newURI,\n coin,\n}: UpdateCoinURIArgs): SimulateContractParameters {\n if (!newURI.startsWith(\"ipfs://\")) {\n throw new Error(\"URI needs to be an ipfs:// prefix uri\");\n }\n\n return {\n abi: coinABI,\n address: coin,\n functionName: \"setContractURI\",\n args: [newURI],\n dataSuffix: getAttribution(),\n };\n}\n\nexport async function updateCoinURI(\n args: UpdateCoinURIArgs,\n walletClient: WalletClient,\n publicClient: GenericPublicClient,\n) {\n validateClientNetwork(publicClient);\n const call = updateCoinURICall(args);\n const { request } = await publicClient.simulateContract({\n ...call,\n account: walletClient.account!,\n });\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const eventLogs = parseEventLogs({ abi: coinABI, logs: receipt.logs });\n const uriUpdated = eventLogs.find(\n (log) => log.eventName === \"ContractURIUpdated\",\n );\n\n return { hash, receipt, uriUpdated };\n}\n","import { coinABI } from \"@zoralabs/protocol-deployments\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport {\n Address,\n parseEventLogs,\n SimulateContractParameters,\n WalletClient,\n} from \"viem\";\nimport { GenericPublicClient } from \"src/utils/genericPublicClient\";\nimport { getAttribution } from \"../utils/attribution\";\n\nexport type UpdatePayoutRecipientArgs = {\n coin: Address;\n newPayoutRecipient: string;\n};\n\nexport function updatePayoutRecipientCall({\n newPayoutRecipient,\n coin,\n}: UpdatePayoutRecipientArgs): SimulateContractParameters {\n return {\n abi: coinABI,\n address: coin,\n functionName: \"setPayoutRecipient\",\n args: [newPayoutRecipient],\n dataSuffix: getAttribution(),\n };\n}\n\nexport async function updatePayoutRecipient(\n args: UpdatePayoutRecipientArgs,\n walletClient: WalletClient,\n publicClient: GenericPublicClient,\n) {\n validateClientNetwork(publicClient);\n const call = updatePayoutRecipientCall(args);\n const { request } = await publicClient.simulateContract({\n ...call,\n account: walletClient.account!,\n });\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const eventLogs = parseEventLogs({ abi: coinABI, logs: receipt.logs });\n const payoutRecipientUpdated = eventLogs.find(\n (log) => log.eventName === \"CoinPayoutRecipientUpdated\",\n );\n\n return { hash, receipt, payoutRecipientUpdated };\n}\n","// This file is auto-generated by @hey-api/openapi-ts\n\nimport type { ClientOptions } from \"./types.gen\";\nimport {\n type Config,\n type ClientOptions as DefaultClientOptions,\n createClient,\n createConfig,\n} from \"@hey-api/client-fetch\";\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> =\n (\n override?: Config<DefaultClientOptions & T>,\n ) => Config<Required<DefaultClientOptions> & T>;\n\nexport const client = createClient(\n createConfig<ClientOptions>({\n baseUrl: \"https://api-sdk.zora.engineering/\",\n }),\n);\n","// This file is auto-generated by @hey-api/openapi-ts\n\nimport type {\n Options as ClientOptions,\n TDataShape,\n Client,\n} from \"@hey-api/client-fetch\";\nimport type {\n GetCoinData,\n GetCoinResponse,\n GetCoinCommentsData,\n GetCoinCommentsResponse,\n GetCoinsData,\n GetCoinsResponse,\n GetExploreData,\n GetExploreResponse,\n GetProfileData,\n GetProfileResponse,\n GetProfileBalancesData,\n GetProfileBalancesResponse,\n} from \"./types.gen\";\nimport { client as _heyApiClient } from \"./client.gen\";\n\nexport type Options<\n TData extends TDataShape = TDataShape,\n ThrowOnError extends boolean = boolean,\n> = ClientOptions<TData, ThrowOnError> & {\n /**\n * You can provide a client instance returned by `createClient()` instead of\n * individual options. This might be also useful if you want to implement a\n * custom client.\n */\n client?: Client;\n /**\n * You can pass arbitrary values through the `meta` object. This can be\n * used to access values that aren't defined as part of the SDK function.\n */\n meta?: Record<string, unknown>;\n};\n\n/**\n * zoraSDK_coin query\n */\nexport const getCoin = <ThrowOnError extends boolean = false>(\n options: Options<GetCoinData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetCoinResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/coin\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_coinComments query\n */\nexport const getCoinComments = <ThrowOnError extends boolean = false>(\n options: Options<GetCoinCommentsData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetCoinCommentsResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/coinComments\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_coins query\n */\nexport const getCoins = <ThrowOnError extends boolean = false>(\n options: Options<GetCoinsData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetCoinsResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/coins\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_explore query\n */\nexport const getExplore = <ThrowOnError extends boolean = false>(\n options: Options<GetExploreData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetExploreResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/explore\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_profile query\n */\nexport const getProfile = <ThrowOnError extends boolean = false>(\n options: Options<GetProfileData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetProfileResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/profile\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_profileBalances query\n */\nexport const getProfileBalances = <ThrowOnError extends boolean = false>(\n options: Options<GetProfileBalancesData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetProfileBalancesResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/profileBalances\",\n ...options,\n });\n};\n","let apiKey: string | undefined;\nexport function setApiKey(key: string) {\n apiKey = key;\n}\n\nexport function getApiKeyMeta() {\n if (!apiKey) {\n return {};\n }\n return {\n headers: {\n \"api-key\": apiKey,\n },\n };\n}\n","import {\n GetCoinCommentsData,\n GetCoinCommentsResponse,\n GetCoinData,\n GetCoinResponse,\n GetCoinsData,\n GetCoinsResponse,\n GetProfileBalancesData,\n GetProfileBalancesResponse,\n GetProfileData,\n GetProfileResponse,\n} from \"../client/types.gen\";\nimport {\n getCoin as getCoinSDK,\n getCoins as getCoinsSDK,\n getCoinComments as getCoinCommentsSDK,\n getProfile as getProfileSDK,\n getProfileBalances as getProfileBalancesSDK,\n} from \"../client/sdk.gen\";\nimport { getApiKeyMeta } from \"./api-key\";\nimport { RequestOptionsType } from \"./query-types\";\nimport { RequestResult } from \"@hey-api/client-fetch\";\n\nexport type { RequestResult };\n\ntype GetCoinQuery = GetCoinData[\"query\"];\nexport type { GetCoinQuery, GetCoinData };\nexport type { GetCoinResponse } from \"../client/types.gen\";\n\nexport type CoinData = NonNullable<GetCoinResponse[\"zora20Token\"]>;\n\nexport const getCoin = async (\n query: GetCoinQuery,\n options?: RequestOptionsType<GetCoinData>,\n): Promise<RequestResult<GetCoinResponse>> => {\n return await getCoinSDK({\n ...options,\n query,\n meta: getApiKeyMeta(),\n });\n};\n\ntype GetCoinsQuery = GetCoinsData[\"query\"];\nexport type { GetCoinsQuery, GetCoinsData };\nexport type { GetCoinsResponse } from \"../client/types.gen\";\n\nexport const getCoins = async (\n query: GetCoinsQuery,\n options?: RequestOptionsType<GetCoinsData>,\n): Promise<RequestResult<GetCoinsResponse>> => {\n return await getCoinsSDK({\n query: {\n coins: query.coins.map((coinData) => JSON.stringify(coinData)) as any,\n },\n meta: getApiKeyMeta(),\n ...options,\n });\n};\n\ntype GetCoinCommentsQuery = GetCoinCommentsData[\"query\"];\nexport type { GetCoinCommentsQuery, GetCoinCommentsData };\nexport type { GetCoinCommentsResponse } from \"../client/types.gen\";\n\nexport const getCoinComments = async (\n query: GetCoinCommentsQuery,\n options?: RequestOptionsType<GetCoinCommentsData>,\n): Promise<RequestResult<GetCoinCommentsResponse>> => {\n return await getCoinCommentsSDK({\n query,\n meta: getApiKeyMeta(),\n ...options,\n });\n};\n\ntype GetProfileQuery = GetProfileData[\"query\"];\nexport type { GetProfileQuery, GetProfileData };\nexport type { GetProfileResponse } from \"../client/types.gen\";\n\nexport const getProfile = async (\n query: GetProfileQuery,\n options?: RequestOptionsType<GetProfileData>,\n): Promise<RequestResult<GetProfileResponse>> => {\n return await getProfileSDK({\n query,\n meta: getApiKeyMeta(),\n ...options,\n });\n};\n\ntype GetProfileBalancesQuery = GetProfileBalancesData[\"query\"];\nexport type { GetProfileBalancesQuery, GetProfileBalancesData };\nexport type { GetProfileBalancesResponse } from \"../client/types.gen\";\n\nexport const getProfileBalances = async (\n query: GetProfileBalancesQuery,\n options?: RequestOptionsType<GetProfileBalancesData>,\n): Promise<RequestResult<GetProfileBalancesResponse>> => {\n return await getProfileBalancesSDK({\n query,\n meta: getApiKeyMeta(),\n ...options,\n });\n};\n","import { getExplore as getExploreSDK } from \"../client/sdk.gen\";\nimport type { GetExploreData, GetExploreResponse } from \"../client/types.gen\";\nimport { getApiKeyMeta } from \"./api-key\";\nimport { RequestOptionsType } from \"./query-types\";\n\n/**\n * The inner type for the explore queries that omits listType.\n * This is used to create the query object for the explore queries.\n */\nexport type QueryRequestType = Omit<GetExploreData[\"query\"], \"listType\">;\n\ntype ExploreResponse = { data?: GetExploreResponse };\n\nexport type ListType = GetExploreData[\"query\"][\"listType\"];\n\nexport type { ExploreResponse };\n\nexport type { GetExploreData };\n\n/**\n * Creates an explore query with the specified list type\n */\nconst createExploreQuery = (\n query: QueryRequestType,\n listType: ListType,\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n getExploreSDK({\n ...options,\n query: { ...query, listType },\n meta: getApiKeyMeta(),\n });\n\n/** Get top gaining coins */\nexport const getCoinsTopGainers = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"TOP_GAINERS\", options);\n\n/** Get coins with highest 24h volume */\nexport const getCoinsTopVolume24h = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"TOP_VOLUME_24H\", options);\n\n/** Get most valuable coins */\nexport const getCoinsMostValuable = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"MOST_VALUABLE\", options);\n\n/** Get newly created coins */\nexport const getCoinsNew = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> => createExploreQuery(query, \"NEW\", options);\n\n/** Get recently traded coins */\nexport const getCoinsLastTraded = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"LAST_TRADED\", options);\n\n/** Get recently traded unique coins */\nexport const getCoinsLastTradedUnique = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"LAST_TRADED_UNIQUE\", options);\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/zora-protocol-private/zora-protocol-private/packages/coins-sdk/dist/index.cjs","../src/actions/createCoin.ts","../src/constants.ts","../src/utils/validateClientNetwork.ts","../src/metadata/cleanAndValidateMetadataURI.ts","../src/metadata/validateMetadataJSON.ts","../src/metadata/validateMetadataURIContent.ts","../src/utils/attribution.ts","../src/utils/poolConfigUtils.ts","../src/actions/tradeCoin.ts","../src/actions/getOnchainCoinDetails.ts","../src/actions/updateCoinURI.ts","../src/actions/updatePayoutRecipient.ts","../src/client/client.gen.ts","../src/client/sdk.gen.ts","../src/api/api-key.ts","../src/api/queries.ts","../src/api/explore.ts"],"names":["base","baseSepolia","DeployCurrency","zeroAddress","keccak256","parseEventLogs","coinABI","getCoin","getCoins","getCoinComments","getProfile","getProfileBalances"],"mappings":"AAAA;ACAA,qEAAqD;AACrD;AAME;AACA;AACA;AACA;AAAA,4BAGK;ADLP;AACA;AETA;AAEA,qCAAqB;AAGd,IAAM,qBAAA,EAAuB,uCAAA,CAAuB,MAAM,CAAA;AAE1D,IAAM,wBAAA,EACX,4CAAA;AAEK,IAAM,yBAAA,EAAoD;AAAA,EAC/D,CAAC,YAAA,CAAK,EAAE,CAAA,EAAG;AACb,CAAA;AFKA;AACA;AGjBA;AAEO,IAAM,sBAAA,EAAwB,CACnC,YAAA,EAAA,GACG;AACH,EAAA,MAAM,cAAA,kBAAgB,YAAA,2BAAc,KAAA,6BAAO,IAAA;AAC3C,EAAA,GAAA,CAAI,cAAA,IAAkBA,YAAAA,CAAK,EAAA,EAAI;AAC7B,IAAA,MAAA;AAAA,EACF;AACA,EAAA,GAAA,CAAI,cAAA,IAAkB,mBAAA,CAAY,EAAA,EAAI;AACpC,IAAA,MAAA;AAAA,EACF;AAEA,EAAA,MAAM,IAAI,KAAA;AAAA,IACR;AAA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C,IAAM,yBAAA,EAA2B,CACtC,MAAA,EAA0B,CAAC,CAAA,EAC3B,OAAA,EAAA,GAEA,kBAAA,CAAmB,KAAA,EAAO,oBAAA,EAAsB,OAAO,CAAA;AjB0mBzD;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,gwCAAC","file":"/home/runner/work/zora-protocol-private/zora-protocol-private/packages/coins-sdk/dist/index.cjs","sourcesContent":[null,"import { coinFactoryABI as zoraFactoryImplABI } from \"@zoralabs/protocol-deployments\";\nimport {\n Address,\n TransactionReceipt,\n WalletClient,\n SimulateContractParameters,\n ContractEventArgsFromTopics,\n parseEventLogs,\n zeroAddress,\n keccak256,\n toBytes,\n Hex,\n Account,\n} from \"viem\";\nimport { COIN_FACTORY_ADDRESS } from \"../constants\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport { GenericPublicClient } from \"src/utils/genericPublicClient\";\nimport { validateMetadataURIContent, ValidMetadataURI } from \"src/metadata\";\nimport { getAttribution } from \"../utils/attribution\";\nimport { base, baseSepolia } from \"viem/chains\";\nimport {\n COIN_ETH_PAIR_POOL_CONFIG,\n COIN_ZORA_PAIR_POOL_CONFIG,\n} from \"src/utils/poolConfigUtils\";\n\nexport type CoinDeploymentLogArgs = ContractEventArgsFromTopics<\n typeof zoraFactoryImplABI,\n \"CoinCreatedV4\"\n>;\n\nexport enum DeployCurrency {\n ZORA = 1,\n ETH = 2,\n}\n\nexport type CreateCoinArgs = {\n name: string;\n symbol: string;\n uri: ValidMetadataURI;\n chainId: number;\n owners?: Address[];\n payoutRecipient: Address;\n platformReferrer?: Address;\n currency?: DeployCurrency;\n};\n\nfunction getPoolConfig(currency: DeployCurrency, chainId: number) {\n if (currency === DeployCurrency.ZORA && chainId == baseSepolia.id) {\n throw new Error(\"ZORA is not supported on Base Sepolia\");\n }\n\n switch (currency) {\n case DeployCurrency.ZORA:\n return COIN_ZORA_PAIR_POOL_CONFIG[\n chainId as keyof typeof COIN_ZORA_PAIR_POOL_CONFIG\n ];\n case DeployCurrency.ETH:\n return COIN_ETH_PAIR_POOL_CONFIG[\n chainId as keyof typeof COIN_ETH_PAIR_POOL_CONFIG\n ];\n default:\n throw new Error(\"Invalid currency\");\n }\n}\n\nexport async function createCoinCall({\n name,\n symbol,\n uri,\n owners,\n payoutRecipient,\n currency,\n chainId = base.id,\n platformReferrer = \"0x0000000000000000000000000000000000000000\",\n}: CreateCoinArgs): Promise<\n SimulateContractParameters<typeof zoraFactoryImplABI, \"deploy\">\n> {\n if (!owners) {\n owners = [payoutRecipient];\n }\n\n if (!currency) {\n currency = chainId !== base.id ? DeployCurrency.ETH : DeployCurrency.ZORA;\n }\n\n const poolConfig = getPoolConfig(currency, chainId);\n\n // This will throw an error if the metadata is not valid\n await validateMetadataURIContent(uri);\n\n return {\n abi: zoraFactoryImplABI,\n functionName: \"deploy\",\n address: COIN_FACTORY_ADDRESS,\n args: [\n payoutRecipient,\n owners,\n uri,\n name,\n symbol,\n poolConfig,\n platformReferrer,\n zeroAddress, // hookAddress\n \"0x\" as Hex, // hookData\n keccak256(toBytes(Math.random().toString())), // coinSalt\n ],\n dataSuffix: getAttribution(),\n } as const;\n}\n\n/**\n * Gets the deployed coin address from transaction receipt logs\n * @param receipt Transaction receipt containing the CoinCreated event\n * @returns The deployment information if found\n */\nexport function getCoinCreateFromLogs(\n receipt: TransactionReceipt,\n): CoinDeploymentLogArgs | undefined {\n const eventLogs = parseEventLogs({\n abi: zoraFactoryImplABI,\n logs: receipt.logs,\n });\n\n return eventLogs.find((log) => log.eventName === \"CoinCreatedV4\")?.args;\n}\n\n// Update createCoin to return both receipt and coin address\nexport async function createCoin(\n call: CreateCoinArgs,\n walletClient: WalletClient,\n publicClient: GenericPublicClient,\n options?: {\n gasMultiplier?: number;\n account?: Account | Address;\n },\n) {\n validateClientNetwork(publicClient);\n\n const createCoinRequest = await createCoinCall(call);\n const { request } = await publicClient.simulateContract({\n ...createCoinRequest,\n account: options?.account ?? walletClient.account,\n });\n\n // Add a 2/5th buffer on gas.\n if (request.gas) {\n // Gas limit multiplier is a percentage argument.\n request.gas = (request.gas * BigInt(options?.gasMultiplier ?? 100)) / 100n;\n }\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const deployment = getCoinCreateFromLogs(receipt);\n\n return {\n hash,\n receipt,\n address: deployment?.coin,\n deployment,\n };\n}\n","import { coinFactoryAddress as zoraFactoryImplAddress } from \"@zoralabs/protocol-deployments\";\nimport { Address } from \"viem\";\nimport { base } from \"viem/chains\";\n\n// this is the same across all chains due to deterministic deploys.\nexport const COIN_FACTORY_ADDRESS = zoraFactoryImplAddress[\"8453\"] as Address;\n\nexport const SUPERCHAIN_WETH_ADDRESS =\n \"0x4200000000000000000000000000000000000006\";\n\nexport const USDC_WETH_POOLS_BY_CHAIN: Record<number, Address> = {\n [base.id]: \"0xd0b53D9277642d899DF5C87A3966A349A798F224\",\n};\n","import { PublicClient } from \"viem\";\nimport { base, baseSepolia } from \"viem/chains\";\n\nexport const validateClientNetwork = (\n publicClient: PublicClient<any, any, any, any>,\n) => {\n const clientChainId = publicClient?.chain?.id;\n if (clientChainId === base.id) {\n return;\n }\n if (clientChainId === baseSepolia.id) {\n return;\n }\n\n throw new Error(\n \"Client network needs to be base or baseSepolia for current coin deployments.\",\n );\n};\n","export type ValidMetadataURI =\n | `ipfs://${string}`\n | `ar://${string}`\n | `data:${string}`\n | `https://${string}`;\n\n/**\n * Clean the metadata URI to HTTPS format\n * @param metadataURI - The metadata URI to clean from IPFS or Arweave\n * @returns The cleaned metadata URI\n * @throws If the metadata URI is a data URI\n */\nexport function cleanAndValidateMetadataURI(uri: ValidMetadataURI) {\n if (uri.startsWith(\"ipfs://\")) {\n return uri.replace(\n \"ipfs://\",\n \"https://magic.decentralized-content.com/ipfs/\",\n );\n }\n if (uri.startsWith(\"ar://\")) {\n return uri.replace(\"ar://\", \"http://arweave.net/\");\n }\n if (uri.startsWith(\"data:\")) {\n return uri;\n // throw new Error(\"Data URIs are not supported\");\n }\n if (uri.startsWith(\"http://\") || uri.startsWith(\"https://\")) {\n return uri;\n }\n\n throw new Error(\"Invalid metadata URI\");\n}\n","export type ValidMetadataJSON = {\n name: string;\n description: string;\n image: string;\n animation_url?: string;\n content?: { uri: string; mime?: string };\n};\n\nfunction validateURIString(uri: unknown) {\n if (typeof uri !== \"string\") {\n throw new Error(\"URI must be a string\");\n }\n if (uri.startsWith(\"ipfs://\")) {\n return true;\n }\n if (uri.startsWith(\"ar://\")) {\n return true;\n }\n if (uri.startsWith(\"https://\")) {\n return true;\n }\n if (uri.startsWith(\"data:\")) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Validate the metadata JSON object\n * @param metadata - The metadata object to validate\n */\nexport function validateMetadataJSON(metadata: ValidMetadataJSON | unknown) {\n if (typeof metadata !== \"object\" || !metadata) {\n throw new Error(\"Metadata must be an object and exist\");\n }\n if (typeof (metadata as { name: unknown }).name !== \"string\") {\n throw new Error(\"Metadata name is required and must be a string\");\n }\n if (typeof (metadata as { description: unknown }).description !== \"string\") {\n throw new Error(\"Metadata description is required and must be a string\");\n }\n if (typeof (metadata as { image: unknown }).image === \"string\") {\n if (!validateURIString((metadata as { image: string }).image)) {\n throw new Error(\"Metadata image is not a valid URI\");\n }\n } else {\n throw new Error(\"Metadata image is required and must be a string\");\n }\n if (\"animation_url\" in metadata) {\n if (\n typeof (metadata as { animation_url?: unknown }).animation_url !==\n \"string\"\n ) {\n throw new Error(\"Metadata animation_url, if provided, must be a string\");\n }\n if (!validateURIString(metadata.animation_url)) {\n throw new Error(\"Metadata animation_url is not a valid URI\");\n }\n }\n const content =\n \"content\" in metadata && (metadata as { content?: unknown }).content;\n if (content) {\n if (typeof (content as { uri?: unknown }).uri !== \"string\") {\n throw new Error(\"If provided, content.uri must be a string\");\n }\n if (!validateURIString((content as { uri: string }).uri)) {\n throw new Error(\"If provided, content.uri must be a valid URI string\");\n }\n if (typeof (content as { mime?: unknown }).mime !== \"string\") {\n throw new Error(\"If provided, content.mime must be a string\");\n }\n }\n\n return true;\n}\n","import {\n cleanAndValidateMetadataURI,\n ValidMetadataURI,\n} from \"./cleanAndValidateMetadataURI\";\nimport { validateMetadataJSON } from \"./validateMetadataJSON\";\n\n/**\n * Validate the metadata URI Content\n * @param metadataURI - The metadata URI to validate\n * @returns true if the metadata is valid, throws an error otherwise\n */\nexport async function validateMetadataURIContent(\n metadataURI: ValidMetadataURI,\n) {\n const cleanedURI = cleanAndValidateMetadataURI(metadataURI);\n const response = await fetch(cleanedURI);\n if (!response.ok) {\n throw new Error(\"Metadata fetch failed\");\n }\n if (\n ![\"application/json\", \"text/plain\"].includes(\n response.headers.get(\"content-type\") ?? \"\",\n )\n ) {\n throw new Error(\"Metadata is not a valid JSON or plain text response type\");\n }\n const metadataJson = await response.json();\n return validateMetadataJSON(metadataJson);\n}\n","import { Hex, keccak256, slice, toHex } from \"viem\";\n\nexport function getAttribution(): Hex {\n const hash = keccak256(toHex(\"api-sdk.zora.engineering\"));\n return slice(hash, 0, 4) as Hex;\n}\n","import { encodeMultiCurvePoolConfig } from \"@zoralabs/protocol-deployments\";\nimport { parseUnits, zeroAddress } from \"viem\";\nimport { base, baseSepolia } from \"viem/chains\";\n\nconst ZORA_DECIMALS = 18;\n\n/**\n * =========================\n * COIN_ETH_PAIR_POOL_CONFIG\n * =========================\n */\n\nexport const ZORA_ADDRESS = \"0x1111111111166b7fe7bd91427724b487980afc69\";\n\nconst COIN_ETH_PAIR_LOWER_TICK = -250000;\nconst COIN_ETH_PAIR_UPPER_TICK = -195_000;\nconst COIN_ETH_PAIR_NUM_DISCOVERY_POSITIONS = 11;\nconst COIN_ETH_PAIR_MAX_DISCOVERY_SUPPLY_SHARE = parseUnits(\"0.05\", 18);\n\nexport const COIN_ETH_PAIR_POOL_CONFIG = {\n [base.id]: encodeMultiCurvePoolConfig({\n currency: zeroAddress,\n tickLower: [COIN_ETH_PAIR_LOWER_TICK],\n tickUpper: [COIN_ETH_PAIR_UPPER_TICK],\n numDiscoveryPositions: [COIN_ETH_PAIR_NUM_DISCOVERY_POSITIONS],\n maxDiscoverySupplyShare: [COIN_ETH_PAIR_MAX_DISCOVERY_SUPPLY_SHARE],\n }),\n [baseSepolia.id]: encodeMultiCurvePoolConfig({\n currency: zeroAddress,\n tickLower: [COIN_ETH_PAIR_LOWER_TICK],\n tickUpper: [COIN_ETH_PAIR_UPPER_TICK],\n numDiscoveryPositions: [COIN_ETH_PAIR_NUM_DISCOVERY_POSITIONS],\n maxDiscoverySupplyShare: [COIN_ETH_PAIR_MAX_DISCOVERY_SUPPLY_SHARE],\n }),\n};\n\nconst COIN_ZORA_PAIR_LOWER_TICK = -138_000; // ( -250000 in ETH land ~= $23 = -138_000 in Zora token land at .022)\nconst COIN_ZORA_PAIR_UPPER_TICK = -81_000; // (-195_000 ~= 5782 = -81_000 in Zora token land at .022)\nconst COIN_ZORA_PAIR_NUM_DISCOVERY_POSITIONS = 11;\nconst COIN_ZORA_PAIR_MAX_DISCOVERY_SUPPLY_SHARE = parseUnits(\n \"0.05\",\n ZORA_DECIMALS,\n);\n\nexport const COIN_ZORA_PAIR_POOL_CONFIG = {\n [base.id]: encodeMultiCurvePoolConfig({\n currency: ZORA_ADDRESS,\n tickLower: [COIN_ZORA_PAIR_LOWER_TICK],\n tickUpper: [COIN_ZORA_PAIR_UPPER_TICK],\n numDiscoveryPositions: [COIN_ZORA_PAIR_NUM_DISCOVERY_POSITIONS],\n maxDiscoverySupplyShare: [COIN_ZORA_PAIR_MAX_DISCOVERY_SUPPLY_SHARE],\n }),\n};\n","import { coinABI } from \"@zoralabs/protocol-deployments\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport {\n Address,\n TransactionReceipt,\n WalletClient,\n SimulateContractParameters,\n parseEther,\n zeroAddress,\n ContractEventArgsFromTopics,\n parseEventLogs,\n} from \"viem\";\nimport { baseSepolia } from \"viem/chains\";\nimport { GenericPublicClient } from \"src/utils/genericPublicClient\";\nimport { getAttribution } from \"../utils/attribution\";\n// Define trade event args type\n\nexport type SellEventArgs = ContractEventArgsFromTopics<\n typeof coinABI,\n \"CoinSell\"\n>;\nexport type BuyEventArgs = ContractEventArgsFromTopics<\n typeof coinABI,\n \"CoinBuy\"\n>;\n\nexport type TradeEventArgs = SellEventArgs | BuyEventArgs;\n\n// We'll use this address to ensure it will have funds to simulate an eth trade.\n// @dev: This only works on OP chains and is a fix for a bug. Another approach should be taken long term.\nconst OP_BRIDGE_ADDRESS =\n \"0x4200000000000000000000000000000000000016\" as Address;\n\n/**\n * Simulates a buy order to get the expected output amount\n * @param {Object} params - The simulation parameters\n * @param {Address} params.target - The target coin contract address\n * @param {bigint} params.requestedOrderSize - The desired input amount for the buy\n * @param {PublicClient} params.publicClient - The viem public client instance\n * @returns {Promise<{orderSize: bigint, amountOut: bigint}>} The simulated order size and output amount\n */\nexport async function simulateBuy({\n target,\n requestedOrderSize,\n publicClient,\n}: {\n target: Address;\n requestedOrderSize: bigint;\n publicClient: GenericPublicClient;\n}): Promise<{ orderSize: bigint; amountOut: bigint }> {\n const numberResult = await publicClient.simulateContract({\n address: target,\n abi: coinABI,\n functionName: \"buy\",\n dataSuffix: getAttribution(),\n args: [\n OP_BRIDGE_ADDRESS,\n requestedOrderSize,\n 0n, // minAmountOut\n 0n, // sqrtPriceLimitX96\n zeroAddress, // tradeReferrer\n ],\n // We want to ensure that the multicall3 contract has enough ETH to buy in the simulation\n stateOverride: [\n {\n address: baseSepolia.contracts.multicall3.address,\n balance: parseEther(\"10000000\"),\n },\n ],\n });\n const orderSize = numberResult.result[0];\n const amountOut = numberResult.result[1];\n return { orderSize, amountOut };\n}\n\n/**\n * Parameters for creating a trade call\n * @typedef {Object} TradeParams\n * @property {'sell' | 'buy'} direction - The trade direction\n * @property {Address} target - The target coin contract address\n * @property {Object} args - The trade arguments\n * @property {Address} args.recipient - The recipient of the trade output\n * @property {bigint} args.orderSize - The size of the order\n * @property {bigint} [args.minAmountOut] - The minimum amount to receive\n * @property {bigint} [args.sqrtPriceLimitX96] - The price limit for the trade\n * @property {Address} [args.tradeReferrer] - The referrer address for the trade\n */\nexport type TradeParams = {\n direction: \"sell\" | \"buy\";\n target: Address;\n args: {\n recipient: Address;\n orderSize: bigint;\n minAmountOut?: bigint;\n sqrtPriceLimitX96?: bigint;\n tradeReferrer?: Address;\n };\n};\n\n/**\n * Creates a trade call parameters object for buy or sell\n * @param {TradeParams} params - The trade parameters\n * @returns {SimulateContractParameters} The contract call parameters\n */\nexport function tradeCoinCall({\n target,\n direction,\n args: {\n recipient,\n orderSize,\n minAmountOut = 0n,\n sqrtPriceLimitX96 = 0n,\n tradeReferrer = zeroAddress,\n },\n}: TradeParams): SimulateContractParameters {\n return {\n abi: coinABI,\n functionName: direction,\n address: target,\n args: [\n recipient,\n orderSize,\n minAmountOut,\n sqrtPriceLimitX96,\n tradeReferrer,\n ],\n value: direction === \"buy\" ? orderSize : 0n,\n } as const;\n}\n\n/**\n * Gets the trade event from transaction receipt logs\n * @param {TransactionReceipt} receipt - The transaction receipt containing the logs\n * @param {'buy' | 'sell'} direction - The direction of the trade\n * @returns {TradeEventArgs | undefined} The decoded trade event args if found\n */\nexport function getTradeFromLogs(\n receipt: TransactionReceipt,\n direction: \"buy\" | \"sell\",\n): TradeEventArgs | undefined {\n const eventLogs = parseEventLogs({\n abi: coinABI,\n logs: receipt.logs,\n });\n\n if (direction === \"buy\") {\n return eventLogs.find((log) => log.eventName === \"CoinBuy\")?.args;\n }\n return eventLogs.find((log) => log.eventName === \"CoinSell\")?.args;\n}\n\n/**\n * Executes a trade transaction\n * @param {TradeParams} params - The trade parameters\n * @param {PublicClient} publicClient - The viem public client instance\n * @param {WalletClient} walletClient - The viem wallet client instance\n * @returns {Promise<{\n * hash: `0x${string}`,\n * receipt: TransactionReceipt,\n * trade: TradeEventArgs | undefined\n * }>} The transaction result with trade details\n */\nexport async function tradeCoin(\n params: TradeParams,\n walletClient: WalletClient,\n publicClient: GenericPublicClient,\n) {\n validateClientNetwork(publicClient);\n const { request } = await publicClient.simulateContract({\n ...tradeCoinCall(params),\n account: walletClient.account,\n });\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const trade = getTradeFromLogs(receipt, params.direction);\n\n return {\n hash,\n receipt,\n trade,\n };\n}\n","import { coinABI, iUniswapV3PoolABI } from \"@zoralabs/protocol-deployments\";\nimport {\n SUPERCHAIN_WETH_ADDRESS,\n USDC_WETH_POOLS_BY_CHAIN,\n} from \"../constants\";\nimport { GenericPublicClient } from \"../utils/genericPublicClient\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport {\n Address,\n erc20Abi,\n formatEther,\n isAddressEqual,\n zeroAddress,\n} from \"viem\";\n\ntype Slot0Result = {\n sqrtPriceX96: bigint;\n tick: number;\n observationIndex: number;\n observationCardinality: number;\n observationCardinalityNext: number;\n feeProtocol: number;\n unlocked: boolean;\n};\n\ntype PricingResult = {\n eth: bigint;\n usdc: bigint | null;\n usdcDecimal: number | null;\n ethDecimal: number;\n};\n\n/**\n * Represents the current state of a coin\n * @typedef {Object} OnchainCoinDetails\n * @property {bigint} balance - The user's balance of the coin\n * @property {PricingResult} marketCap - The market cap of the coin\n * @property {PricingResult} liquidity - The liquidity of the coin\n * @property {Address} pool - Pool address\n * @property {Slot0Result} poolState - Current state of the UniswapV3 pool\n * @property {Address[]} owners - List of owners for the coin\n * @property {Address} payoutRecipient - The payout recipient address\n */\nexport type OnchainCoinDetails = {\n balance: bigint;\n marketCap: PricingResult;\n liquidity: PricingResult;\n pool: Address;\n poolState: Slot0Result;\n owners: readonly Address[];\n payoutRecipient: Address;\n};\n\n/**\n * Gets the current state of a coin for a user\n * @param {Object} params - The query parameters\n * @param {Address} params.coin - The coin contract address\n * @param {Address} params.user - The user address to check balance for\n * @param {PublicClient} params.publicClient - The viem public client instance\n * @returns {Promise<OnchainCoinDetails>} The coin's current state\n */\nexport async function getOnchainCoinDetails({\n coin,\n user = zeroAddress,\n publicClient,\n}: {\n coin: Address;\n user?: Address;\n publicClient: GenericPublicClient;\n}): Promise<OnchainCoinDetails> {\n validateClientNetwork(publicClient);\n const [balance, pool, owners, payoutRecipient] = await publicClient.multicall(\n {\n contracts: [\n {\n address: coin,\n abi: coinABI,\n functionName: \"balanceOf\",\n args: [user],\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"poolAddress\",\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"owners\",\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"payoutRecipient\",\n },\n ],\n allowFailure: false,\n },\n );\n\n const USDC_WETH_POOL = USDC_WETH_POOLS_BY_CHAIN[publicClient.chain?.id || 0];\n\n const [\n coinWethPoolSlot0,\n coinWethPoolToken0,\n coinReservesRaw,\n coinTotalSupply,\n wethReservesRaw,\n usdcWethSlot0,\n ] = await publicClient.multicall({\n contracts: [\n {\n address: pool,\n abi: iUniswapV3PoolABI,\n functionName: \"slot0\",\n },\n {\n address: pool,\n abi: iUniswapV3PoolABI,\n functionName: \"token0\",\n },\n {\n address: coin,\n abi: erc20Abi,\n functionName: \"balanceOf\",\n args: [pool],\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"totalSupply\",\n },\n {\n address: SUPERCHAIN_WETH_ADDRESS,\n abi: erc20Abi,\n functionName: \"balanceOf\",\n args: [pool],\n },\n {\n address: USDC_WETH_POOL ?? coin,\n abi: iUniswapV3PoolABI,\n functionName: \"slot0\",\n },\n ],\n allowFailure: false,\n });\n\n const wethPriceInUsdc = USDC_WETH_POOL\n ? uniswapV3SqrtPriceToBigIntScaled(\n usdcWethSlot0.sqrtPriceX96,\n 18,\n 6,\n true,\n 18,\n )\n : null;\n\n const coinPriceInWeth = uniswapV3SqrtPriceToBigIntScaled(\n coinWethPoolSlot0.sqrtPriceX96,\n 18,\n 18,\n isAddressEqual(coinWethPoolToken0, coin),\n 18,\n );\n\n // Divide by 10^18 to remove percision from `coinPriceInWeth` after math since bigint is decimal.\n const marketCap = (coinPriceInWeth * coinTotalSupply) / 10n ** 18n;\n\n const wethLiquidity = wethReservesRaw;\n // Divide by 10^18 to remove percision from `coinPriceInWeth` after math since bigint is decimal.\n const tokenLiquidity = (coinReservesRaw * coinPriceInWeth) / 10n ** 18n;\n\n return {\n balance,\n pool,\n owners,\n payoutRecipient,\n marketCap: convertEthOutput(marketCap, wethPriceInUsdc),\n liquidity: convertEthOutput(\n wethLiquidity + tokenLiquidity,\n wethPriceInUsdc,\n ),\n poolState: coinWethPoolSlot0,\n };\n}\n\nfunction convertEthOutput(amountETH: bigint, wethToUsdc: bigint | null) {\n return {\n eth: amountETH,\n ethDecimal: parseFloat(formatEther(amountETH)),\n usdc: wethToUsdc ? amountETH * wethToUsdc : null,\n usdcDecimal: wethToUsdc\n ? parseFloat(formatEther((amountETH * wethToUsdc) / 10n ** 18n))\n : null,\n };\n}\n\nfunction uniswapV3SqrtPriceToBigIntScaled(\n sqrtPriceX96: bigint,\n token0Decimals: number,\n token1Decimals: number,\n isToken0Coin: boolean,\n scaleDecimals: number = 18,\n): bigint {\n // (sqrtPrice^2 / 2^192) => ratio\n // We'll do: ratioScaled = (sqrtPrice^2 * 10^scaleDecimals) / 2^192\n const numerator = sqrtPriceX96 * sqrtPriceX96;\n const denominator = 2n ** 192n;\n const scaleFactor = 10n ** BigInt(scaleDecimals);\n\n // raw ratioScaled\n let ratioScaled = (numerator * scaleFactor) / denominator; // BigInt\n\n // Adjust for difference in decimals:\n // ratioScaled *= 10^(dec0 - dec1)\n const decimalsDiff = BigInt(token0Decimals - token1Decimals);\n if (decimalsDiff > 0n) {\n ratioScaled *= 10n ** decimalsDiff;\n } else if (decimalsDiff < 0n) {\n ratioScaled /= 10n ** -decimalsDiff;\n }\n\n if (!isToken0Coin) {\n // We want the reciprocal: coin is token1 => coinPriceInToken0 = 1 / ratio\n // But we also want it scaled by 10^scaleDecimals\n // reciprocalScaled = (10^scaleDecimals * 10^(decimalsDiff)) / ratioScaled\n // (assuming ratioScaled != 0)\n if (ratioScaled === 0n) {\n return 0n; // or some huge number representing infinity\n }\n ratioScaled = (scaleFactor * scaleFactor) / ratioScaled;\n // or if we already included decimalsDiff above, handle carefully.\n }\n\n return ratioScaled;\n}\n","import { coinABI } from \"@zoralabs/protocol-deployments\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport {\n Address,\n parseEventLogs,\n SimulateContractParameters,\n WalletClient,\n} from \"viem\";\nimport { GenericPublicClient } from \"src/utils/genericPublicClient\";\nimport { getAttribution } from \"../utils/attribution\";\n\nexport type UpdateCoinURIArgs = {\n coin: Address;\n newURI: string;\n};\n\nexport function updateCoinURICall({\n newURI,\n coin,\n}: UpdateCoinURIArgs): SimulateContractParameters {\n if (!newURI.startsWith(\"ipfs://\")) {\n throw new Error(\"URI needs to be an ipfs:// prefix uri\");\n }\n\n return {\n abi: coinABI,\n address: coin,\n functionName: \"setContractURI\",\n args: [newURI],\n dataSuffix: getAttribution(),\n };\n}\n\nexport async function updateCoinURI(\n args: UpdateCoinURIArgs,\n walletClient: WalletClient,\n publicClient: GenericPublicClient,\n) {\n validateClientNetwork(publicClient);\n const call = updateCoinURICall(args);\n const { request } = await publicClient.simulateContract({\n ...call,\n account: walletClient.account!,\n });\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const eventLogs = parseEventLogs({ abi: coinABI, logs: receipt.logs });\n const uriUpdated = eventLogs.find(\n (log) => log.eventName === \"ContractURIUpdated\",\n );\n\n return { hash, receipt, uriUpdated };\n}\n","import { coinABI } from \"@zoralabs/protocol-deployments\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport {\n Address,\n parseEventLogs,\n SimulateContractParameters,\n WalletClient,\n} from \"viem\";\nimport { GenericPublicClient } from \"src/utils/genericPublicClient\";\nimport { getAttribution } from \"../utils/attribution\";\n\nexport type UpdatePayoutRecipientArgs = {\n coin: Address;\n newPayoutRecipient: string;\n};\n\nexport function updatePayoutRecipientCall({\n newPayoutRecipient,\n coin,\n}: UpdatePayoutRecipientArgs): SimulateContractParameters {\n return {\n abi: coinABI,\n address: coin,\n functionName: \"setPayoutRecipient\",\n args: [newPayoutRecipient],\n dataSuffix: getAttribution(),\n };\n}\n\nexport async function updatePayoutRecipient(\n args: UpdatePayoutRecipientArgs,\n walletClient: WalletClient,\n publicClient: GenericPublicClient,\n) {\n validateClientNetwork(publicClient);\n const call = updatePayoutRecipientCall(args);\n const { request } = await publicClient.simulateContract({\n ...call,\n account: walletClient.account!,\n });\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const eventLogs = parseEventLogs({ abi: coinABI, logs: receipt.logs });\n const payoutRecipientUpdated = eventLogs.find(\n (log) => log.eventName === \"CoinPayoutRecipientUpdated\",\n );\n\n return { hash, receipt, payoutRecipientUpdated };\n}\n","// This file is auto-generated by @hey-api/openapi-ts\n\nimport type { ClientOptions } from \"./types.gen\";\nimport {\n type Config,\n type ClientOptions as DefaultClientOptions,\n createClient,\n createConfig,\n} from \"@hey-api/client-fetch\";\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> =\n (\n override?: Config<DefaultClientOptions & T>,\n ) => Config<Required<DefaultClientOptions> & T>;\n\nexport const client = createClient(\n createConfig<ClientOptions>({\n baseUrl: \"https://api-sdk.zora.engineering/\",\n }),\n);\n","// This file is auto-generated by @hey-api/openapi-ts\n\nimport type {\n Options as ClientOptions,\n TDataShape,\n Client,\n} from \"@hey-api/client-fetch\";\nimport type {\n GetCoinData,\n GetCoinResponse,\n GetCoinCommentsData,\n GetCoinCommentsResponse,\n GetCoinsData,\n GetCoinsResponse,\n GetExploreData,\n GetExploreResponse,\n GetProfileData,\n GetProfileResponse,\n GetProfileBalancesData,\n GetProfileBalancesResponse,\n} from \"./types.gen\";\nimport { client as _heyApiClient } from \"./client.gen\";\n\nexport type Options<\n TData extends TDataShape = TDataShape,\n ThrowOnError extends boolean = boolean,\n> = ClientOptions<TData, ThrowOnError> & {\n /**\n * You can provide a client instance returned by `createClient()` instead of\n * individual options. This might be also useful if you want to implement a\n * custom client.\n */\n client?: Client;\n /**\n * You can pass arbitrary values through the `meta` object. This can be\n * used to access values that aren't defined as part of the SDK function.\n */\n meta?: Record<string, unknown>;\n};\n\n/**\n * zoraSDK_coin query\n */\nexport const getCoin = <ThrowOnError extends boolean = false>(\n options: Options<GetCoinData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetCoinResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/coin\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_coinComments query\n */\nexport const getCoinComments = <ThrowOnError extends boolean = false>(\n options: Options<GetCoinCommentsData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetCoinCommentsResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/coinComments\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_coins query\n */\nexport const getCoins = <ThrowOnError extends boolean = false>(\n options: Options<GetCoinsData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetCoinsResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/coins\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_explore query\n */\nexport const getExplore = <ThrowOnError extends boolean = false>(\n options: Options<GetExploreData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetExploreResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/explore\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_profile query\n */\nexport const getProfile = <ThrowOnError extends boolean = false>(\n options: Options<GetProfileData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetProfileResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/profile\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_profileBalances query\n */\nexport const getProfileBalances = <ThrowOnError extends boolean = false>(\n options: Options<GetProfileBalancesData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetProfileBalancesResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/profileBalances\",\n ...options,\n });\n};\n","let apiKey: string | undefined;\nexport function setApiKey(key: string) {\n apiKey = key;\n}\n\nexport function getApiKeyMeta() {\n if (!apiKey) {\n return {};\n }\n return {\n headers: {\n \"api-key\": apiKey,\n },\n };\n}\n","import {\n GetCoinCommentsData,\n GetCoinCommentsResponse,\n GetCoinData,\n GetCoinResponse,\n GetCoinsData,\n GetCoinsResponse,\n GetProfileBalancesData,\n GetProfileBalancesResponse,\n GetProfileData,\n GetProfileResponse,\n} from \"../client/types.gen\";\nimport {\n getCoin as getCoinSDK,\n getCoins as getCoinsSDK,\n getCoinComments as getCoinCommentsSDK,\n getProfile as getProfileSDK,\n getProfileBalances as getProfileBalancesSDK,\n} from \"../client/sdk.gen\";\nimport { getApiKeyMeta } from \"./api-key\";\nimport { RequestOptionsType } from \"./query-types\";\nimport { RequestResult } from \"@hey-api/client-fetch\";\n\nexport type { RequestResult };\n\ntype GetCoinQuery = GetCoinData[\"query\"];\nexport type { GetCoinQuery, GetCoinData };\nexport type { GetCoinResponse } from \"../client/types.gen\";\n\nexport type CoinData = NonNullable<GetCoinResponse[\"zora20Token\"]>;\n\nexport const getCoin = async (\n query: GetCoinQuery,\n options?: RequestOptionsType<GetCoinData>,\n): Promise<RequestResult<GetCoinResponse>> => {\n return await getCoinSDK({\n ...options,\n query,\n meta: getApiKeyMeta(),\n });\n};\n\ntype GetCoinsQuery = GetCoinsData[\"query\"];\nexport type { GetCoinsQuery, GetCoinsData };\nexport type { GetCoinsResponse } from \"../client/types.gen\";\n\nexport const getCoins = async (\n query: GetCoinsQuery,\n options?: RequestOptionsType<GetCoinsData>,\n): Promise<RequestResult<GetCoinsResponse>> => {\n return await getCoinsSDK({\n query: {\n coins: query.coins.map((coinData) => JSON.stringify(coinData)) as any,\n },\n meta: getApiKeyMeta(),\n ...options,\n });\n};\n\ntype GetCoinCommentsQuery = GetCoinCommentsData[\"query\"];\nexport type { GetCoinCommentsQuery, GetCoinCommentsData };\nexport type { GetCoinCommentsResponse } from \"../client/types.gen\";\n\nexport const getCoinComments = async (\n query: GetCoinCommentsQuery,\n options?: RequestOptionsType<GetCoinCommentsData>,\n): Promise<RequestResult<GetCoinCommentsResponse>> => {\n return await getCoinCommentsSDK({\n query,\n meta: getApiKeyMeta(),\n ...options,\n });\n};\n\ntype GetProfileQuery = GetProfileData[\"query\"];\nexport type { GetProfileQuery, GetProfileData };\nexport type { GetProfileResponse } from \"../client/types.gen\";\n\nexport const getProfile = async (\n query: GetProfileQuery,\n options?: RequestOptionsType<GetProfileData>,\n): Promise<RequestResult<GetProfileResponse>> => {\n return await getProfileSDK({\n query,\n meta: getApiKeyMeta(),\n ...options,\n });\n};\n\ntype GetProfileBalancesQuery = GetProfileBalancesData[\"query\"];\nexport type { GetProfileBalancesQuery, GetProfileBalancesData };\nexport type { GetProfileBalancesResponse } from \"../client/types.gen\";\n\nexport const getProfileBalances = async (\n query: GetProfileBalancesQuery,\n options?: RequestOptionsType<GetProfileBalancesData>,\n): Promise<RequestResult<GetProfileBalancesResponse>> => {\n return await getProfileBalancesSDK({\n query,\n meta: getApiKeyMeta(),\n ...options,\n });\n};\n","import { getExplore as getExploreSDK } from \"../client/sdk.gen\";\nimport type { GetExploreData, GetExploreResponse } from \"../client/types.gen\";\nimport { getApiKeyMeta } from \"./api-key\";\nimport { RequestOptionsType } from \"./query-types\";\n\n/**\n * The inner type for the explore queries that omits listType.\n * This is used to create the query object for the explore queries.\n */\nexport type QueryRequestType = Omit<GetExploreData[\"query\"], \"listType\">;\n\ntype ExploreResponse = { data?: GetExploreResponse };\n\nexport type ListType = GetExploreData[\"query\"][\"listType\"];\n\nexport type { ExploreResponse };\n\nexport type { GetExploreData };\n\n/**\n * Creates an explore query with the specified list type\n */\nconst createExploreQuery = (\n query: QueryRequestType,\n listType: ListType,\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n getExploreSDK({\n ...options,\n query: { ...query, listType },\n meta: getApiKeyMeta(),\n });\n\n/** Get top gaining coins */\nexport const getCoinsTopGainers = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"TOP_GAINERS\", options);\n\n/** Get coins with highest 24h volume */\nexport const getCoinsTopVolume24h = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"TOP_VOLUME_24H\", options);\n\n/** Get most valuable coins */\nexport const getCoinsMostValuable = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"MOST_VALUABLE\", options);\n\n/** Get newly created coins */\nexport const getCoinsNew = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> => createExploreQuery(query, \"NEW\", options);\n\n/** Get recently traded coins */\nexport const getCoinsLastTraded = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"LAST_TRADED\", options);\n\n/** Get recently traded unique coins */\nexport const getCoinsLastTradedUnique = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"LAST_TRADED_UNIQUE\", options);\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createCoin, createCoinCall, getCoinCreateFromLogs, } from "./actions/createCoin";
|
|
1
|
+
export { createCoin, createCoinCall, getCoinCreateFromLogs, DeployCurrency, } from "./actions/createCoin";
|
|
2
2
|
export type { CreateCoinArgs } from "./actions/createCoin";
|
|
3
3
|
export { simulateBuy, tradeCoin, tradeCoinCall, getTradeFromLogs, } from "./actions/tradeCoin";
|
|
4
4
|
export type { TradeParams } from "./actions/tradeCoin";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,cAAc,EACd,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,cAAc,EACd,qBAAqB,EACrB,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EACL,WAAW,EACX,SAAS,EACT,aAAa,EACb,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EACL,qBAAqB,EACrB,KAAK,kBAAkB,GACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,EACL,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,iCAAiC,CAAC;AACzC,YAAY,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAGjF,cAAc,eAAe,CAAC;AAC9B,mBAAmB,eAAe,CAAC;AAEnC,cAAc,eAAe,CAAC;AAC9B,mBAAmB,eAAe,CAAC;AAGnC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,cAAc,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
// src/actions/createCoin.ts
|
|
2
2
|
import { coinFactoryABI as zoraFactoryImplABI } from "@zoralabs/protocol-deployments";
|
|
3
3
|
import {
|
|
4
|
-
parseEventLogs
|
|
4
|
+
parseEventLogs,
|
|
5
|
+
zeroAddress as zeroAddress2,
|
|
6
|
+
keccak256 as keccak2562,
|
|
7
|
+
toBytes
|
|
5
8
|
} from "viem";
|
|
6
9
|
|
|
7
10
|
// src/constants.ts
|
|
@@ -40,7 +43,7 @@ function cleanAndValidateMetadataURI(uri) {
|
|
|
40
43
|
return uri.replace("ar://", "http://arweave.net/");
|
|
41
44
|
}
|
|
42
45
|
if (uri.startsWith("data:")) {
|
|
43
|
-
|
|
46
|
+
return uri;
|
|
44
47
|
}
|
|
45
48
|
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
46
49
|
return uri;
|
|
@@ -131,21 +134,87 @@ function getAttribution() {
|
|
|
131
134
|
}
|
|
132
135
|
|
|
133
136
|
// src/actions/createCoin.ts
|
|
134
|
-
|
|
137
|
+
import { base as base4, baseSepolia as baseSepolia3 } from "viem/chains";
|
|
138
|
+
|
|
139
|
+
// src/utils/poolConfigUtils.ts
|
|
140
|
+
import { encodeMultiCurvePoolConfig } from "@zoralabs/protocol-deployments";
|
|
141
|
+
import { parseUnits, zeroAddress } from "viem";
|
|
142
|
+
import { base as base3, baseSepolia as baseSepolia2 } from "viem/chains";
|
|
143
|
+
var ZORA_DECIMALS = 18;
|
|
144
|
+
var ZORA_ADDRESS = "0x1111111111166b7fe7bd91427724b487980afc69";
|
|
145
|
+
var COIN_ETH_PAIR_LOWER_TICK = -25e4;
|
|
146
|
+
var COIN_ETH_PAIR_UPPER_TICK = -195e3;
|
|
147
|
+
var COIN_ETH_PAIR_NUM_DISCOVERY_POSITIONS = 11;
|
|
148
|
+
var COIN_ETH_PAIR_MAX_DISCOVERY_SUPPLY_SHARE = parseUnits("0.05", 18);
|
|
149
|
+
var COIN_ETH_PAIR_POOL_CONFIG = {
|
|
150
|
+
[base3.id]: encodeMultiCurvePoolConfig({
|
|
151
|
+
currency: zeroAddress,
|
|
152
|
+
tickLower: [COIN_ETH_PAIR_LOWER_TICK],
|
|
153
|
+
tickUpper: [COIN_ETH_PAIR_UPPER_TICK],
|
|
154
|
+
numDiscoveryPositions: [COIN_ETH_PAIR_NUM_DISCOVERY_POSITIONS],
|
|
155
|
+
maxDiscoverySupplyShare: [COIN_ETH_PAIR_MAX_DISCOVERY_SUPPLY_SHARE]
|
|
156
|
+
}),
|
|
157
|
+
[baseSepolia2.id]: encodeMultiCurvePoolConfig({
|
|
158
|
+
currency: zeroAddress,
|
|
159
|
+
tickLower: [COIN_ETH_PAIR_LOWER_TICK],
|
|
160
|
+
tickUpper: [COIN_ETH_PAIR_UPPER_TICK],
|
|
161
|
+
numDiscoveryPositions: [COIN_ETH_PAIR_NUM_DISCOVERY_POSITIONS],
|
|
162
|
+
maxDiscoverySupplyShare: [COIN_ETH_PAIR_MAX_DISCOVERY_SUPPLY_SHARE]
|
|
163
|
+
})
|
|
164
|
+
};
|
|
165
|
+
var COIN_ZORA_PAIR_LOWER_TICK = -138e3;
|
|
166
|
+
var COIN_ZORA_PAIR_UPPER_TICK = -81e3;
|
|
167
|
+
var COIN_ZORA_PAIR_NUM_DISCOVERY_POSITIONS = 11;
|
|
168
|
+
var COIN_ZORA_PAIR_MAX_DISCOVERY_SUPPLY_SHARE = parseUnits(
|
|
169
|
+
"0.05",
|
|
170
|
+
ZORA_DECIMALS
|
|
171
|
+
);
|
|
172
|
+
var COIN_ZORA_PAIR_POOL_CONFIG = {
|
|
173
|
+
[base3.id]: encodeMultiCurvePoolConfig({
|
|
174
|
+
currency: ZORA_ADDRESS,
|
|
175
|
+
tickLower: [COIN_ZORA_PAIR_LOWER_TICK],
|
|
176
|
+
tickUpper: [COIN_ZORA_PAIR_UPPER_TICK],
|
|
177
|
+
numDiscoveryPositions: [COIN_ZORA_PAIR_NUM_DISCOVERY_POSITIONS],
|
|
178
|
+
maxDiscoverySupplyShare: [COIN_ZORA_PAIR_MAX_DISCOVERY_SUPPLY_SHARE]
|
|
179
|
+
})
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// src/actions/createCoin.ts
|
|
183
|
+
var DeployCurrency = /* @__PURE__ */ ((DeployCurrency2) => {
|
|
184
|
+
DeployCurrency2[DeployCurrency2["ZORA"] = 1] = "ZORA";
|
|
185
|
+
DeployCurrency2[DeployCurrency2["ETH"] = 2] = "ETH";
|
|
186
|
+
return DeployCurrency2;
|
|
187
|
+
})(DeployCurrency || {});
|
|
188
|
+
function getPoolConfig(currency, chainId) {
|
|
189
|
+
if (currency === 1 /* ZORA */ && chainId == baseSepolia3.id) {
|
|
190
|
+
throw new Error("ZORA is not supported on Base Sepolia");
|
|
191
|
+
}
|
|
192
|
+
switch (currency) {
|
|
193
|
+
case 1 /* ZORA */:
|
|
194
|
+
return COIN_ZORA_PAIR_POOL_CONFIG[chainId];
|
|
195
|
+
case 2 /* ETH */:
|
|
196
|
+
return COIN_ETH_PAIR_POOL_CONFIG[chainId];
|
|
197
|
+
default:
|
|
198
|
+
throw new Error("Invalid currency");
|
|
199
|
+
}
|
|
200
|
+
}
|
|
135
201
|
async function createCoinCall({
|
|
136
202
|
name,
|
|
137
203
|
symbol,
|
|
138
204
|
uri,
|
|
139
205
|
owners,
|
|
140
206
|
payoutRecipient,
|
|
141
|
-
|
|
207
|
+
currency,
|
|
208
|
+
chainId = base4.id,
|
|
142
209
|
platformReferrer = "0x0000000000000000000000000000000000000000"
|
|
143
210
|
}) {
|
|
144
211
|
if (!owners) {
|
|
145
212
|
owners = [payoutRecipient];
|
|
146
213
|
}
|
|
147
|
-
|
|
148
|
-
|
|
214
|
+
if (!currency) {
|
|
215
|
+
currency = chainId !== base4.id ? 2 /* ETH */ : 1 /* ZORA */;
|
|
216
|
+
}
|
|
217
|
+
const poolConfig = getPoolConfig(currency, chainId);
|
|
149
218
|
await validateMetadataURIContent(uri);
|
|
150
219
|
return {
|
|
151
220
|
abi: zoraFactoryImplABI,
|
|
@@ -159,9 +228,13 @@ async function createCoinCall({
|
|
|
159
228
|
symbol,
|
|
160
229
|
poolConfig,
|
|
161
230
|
platformReferrer,
|
|
162
|
-
|
|
231
|
+
zeroAddress2,
|
|
232
|
+
// hookAddress
|
|
233
|
+
"0x",
|
|
234
|
+
// hookData
|
|
235
|
+
keccak2562(toBytes(Math.random().toString()))
|
|
236
|
+
// coinSalt
|
|
163
237
|
],
|
|
164
|
-
value: initialPurchaseWei,
|
|
165
238
|
dataSuffix: getAttribution()
|
|
166
239
|
};
|
|
167
240
|
}
|
|
@@ -170,14 +243,14 @@ function getCoinCreateFromLogs(receipt) {
|
|
|
170
243
|
abi: zoraFactoryImplABI,
|
|
171
244
|
logs: receipt.logs
|
|
172
245
|
});
|
|
173
|
-
return eventLogs.find((log) => log.eventName === "
|
|
246
|
+
return eventLogs.find((log) => log.eventName === "CoinCreatedV4")?.args;
|
|
174
247
|
}
|
|
175
248
|
async function createCoin(call, walletClient, publicClient, options) {
|
|
176
249
|
validateClientNetwork(publicClient);
|
|
177
250
|
const createCoinRequest = await createCoinCall(call);
|
|
178
251
|
const { request } = await publicClient.simulateContract({
|
|
179
252
|
...createCoinRequest,
|
|
180
|
-
account: walletClient.account
|
|
253
|
+
account: options?.account ?? walletClient.account
|
|
181
254
|
});
|
|
182
255
|
if (request.gas) {
|
|
183
256
|
request.gas = request.gas * BigInt(options?.gasMultiplier ?? 100) / 100n;
|
|
@@ -197,10 +270,10 @@ async function createCoin(call, walletClient, publicClient, options) {
|
|
|
197
270
|
import { coinABI } from "@zoralabs/protocol-deployments";
|
|
198
271
|
import {
|
|
199
272
|
parseEther,
|
|
200
|
-
zeroAddress,
|
|
273
|
+
zeroAddress as zeroAddress3,
|
|
201
274
|
parseEventLogs as parseEventLogs2
|
|
202
275
|
} from "viem";
|
|
203
|
-
import { baseSepolia as
|
|
276
|
+
import { baseSepolia as baseSepolia4 } from "viem/chains";
|
|
204
277
|
var OP_BRIDGE_ADDRESS = "0x4200000000000000000000000000000000000016";
|
|
205
278
|
async function simulateBuy({
|
|
206
279
|
target,
|
|
@@ -219,13 +292,13 @@ async function simulateBuy({
|
|
|
219
292
|
// minAmountOut
|
|
220
293
|
0n,
|
|
221
294
|
// sqrtPriceLimitX96
|
|
222
|
-
|
|
295
|
+
zeroAddress3
|
|
223
296
|
// tradeReferrer
|
|
224
297
|
],
|
|
225
298
|
// We want to ensure that the multicall3 contract has enough ETH to buy in the simulation
|
|
226
299
|
stateOverride: [
|
|
227
300
|
{
|
|
228
|
-
address:
|
|
301
|
+
address: baseSepolia4.contracts.multicall3.address,
|
|
229
302
|
balance: parseEther("10000000")
|
|
230
303
|
}
|
|
231
304
|
]
|
|
@@ -242,7 +315,7 @@ function tradeCoinCall({
|
|
|
242
315
|
orderSize,
|
|
243
316
|
minAmountOut = 0n,
|
|
244
317
|
sqrtPriceLimitX96 = 0n,
|
|
245
|
-
tradeReferrer =
|
|
318
|
+
tradeReferrer = zeroAddress3
|
|
246
319
|
}
|
|
247
320
|
}) {
|
|
248
321
|
return {
|
|
@@ -291,11 +364,11 @@ import {
|
|
|
291
364
|
erc20Abi,
|
|
292
365
|
formatEther,
|
|
293
366
|
isAddressEqual,
|
|
294
|
-
zeroAddress as
|
|
367
|
+
zeroAddress as zeroAddress4
|
|
295
368
|
} from "viem";
|
|
296
369
|
async function getOnchainCoinDetails({
|
|
297
370
|
coin,
|
|
298
|
-
user =
|
|
371
|
+
user = zeroAddress4,
|
|
299
372
|
publicClient
|
|
300
373
|
}) {
|
|
301
374
|
validateClientNetwork(publicClient);
|
|
@@ -616,6 +689,7 @@ var getCoinsNew = (query = {}, options) => createExploreQuery(query, "NEW", opti
|
|
|
616
689
|
var getCoinsLastTraded = (query = {}, options) => createExploreQuery(query, "LAST_TRADED", options);
|
|
617
690
|
var getCoinsLastTradedUnique = (query = {}, options) => createExploreQuery(query, "LAST_TRADED_UNIQUE", options);
|
|
618
691
|
export {
|
|
692
|
+
DeployCurrency,
|
|
619
693
|
cleanAndValidateMetadataURI,
|
|
620
694
|
createCoin,
|
|
621
695
|
createCoinCall,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/actions/createCoin.ts","../src/constants.ts","../src/utils/validateClientNetwork.ts","../src/metadata/cleanAndValidateMetadataURI.ts","../src/metadata/validateMetadataJSON.ts","../src/metadata/validateMetadataURIContent.ts","../src/utils/attribution.ts","../src/actions/tradeCoin.ts","../src/actions/getOnchainCoinDetails.ts","../src/actions/updateCoinURI.ts","../src/actions/updatePayoutRecipient.ts","../src/client/client.gen.ts","../src/client/sdk.gen.ts","../src/api/api-key.ts","../src/api/queries.ts","../src/api/explore.ts"],"sourcesContent":["import { coinFactoryABI as zoraFactoryImplABI } from \"@zoralabs/protocol-deployments\";\nimport {\n Address,\n TransactionReceipt,\n WalletClient,\n SimulateContractParameters,\n ContractEventArgsFromTopics,\n parseEventLogs,\n Hex,\n} from \"viem\";\nimport { COIN_FACTORY_ADDRESS } from \"../constants\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport { GenericPublicClient } from \"src/utils/genericPublicClient\";\nimport { validateMetadataURIContent, ValidMetadataURI } from \"src/metadata\";\nimport { getAttribution } from \"../utils/attribution\";\n\nexport type CoinDeploymentLogArgs = ContractEventArgsFromTopics<\n typeof zoraFactoryImplABI,\n \"CoinCreated\"\n>;\n\n// This is the default pool config matching zora.co front-end. TODO: Allow users to customize further parameters within safe contract limits.\nconst POOL_CONFIG =\n \"0x00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc2f70fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcf2c0000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000b1a2bc2ec50000\" as Hex;\n\nexport type CreateCoinArgs = {\n name: string;\n symbol: string;\n uri: ValidMetadataURI;\n owners?: Address[];\n payoutRecipient: Address;\n platformReferrer?: Address;\n initialPurchaseWei?: bigint;\n};\n\nexport async function createCoinCall({\n name,\n symbol,\n uri,\n owners,\n payoutRecipient,\n initialPurchaseWei = 0n,\n platformReferrer = \"0x0000000000000000000000000000000000000000\",\n}: CreateCoinArgs): Promise<\n SimulateContractParameters<typeof zoraFactoryImplABI, \"deploy\">\n> {\n if (!owners) {\n owners = [payoutRecipient];\n }\n\n const orderSize: bigint = initialPurchaseWei;\n // The default pool config for\n const poolConfig = POOL_CONFIG;\n\n // This will throw an error if the metadata is not valid\n await validateMetadataURIContent(uri);\n\n return {\n abi: zoraFactoryImplABI,\n functionName: \"deploy\",\n address: COIN_FACTORY_ADDRESS,\n args: [\n payoutRecipient,\n owners,\n uri,\n name,\n symbol,\n poolConfig,\n platformReferrer,\n orderSize,\n ],\n value: initialPurchaseWei,\n dataSuffix: getAttribution(),\n } as const;\n}\n\n/**\n * Gets the deployed coin address from transaction receipt logs\n * @param receipt Transaction receipt containing the CoinCreated event\n * @returns The deployment information if found\n */\nexport function getCoinCreateFromLogs(\n receipt: TransactionReceipt,\n): CoinDeploymentLogArgs | undefined {\n const eventLogs = parseEventLogs({\n abi: zoraFactoryImplABI,\n logs: receipt.logs,\n });\n return eventLogs.find((log) => log.eventName === \"CoinCreated\")?.args;\n}\n\n// Update createCoin to return both receipt and coin address\nexport async function createCoin(\n call: CreateCoinArgs,\n walletClient: WalletClient,\n publicClient: GenericPublicClient,\n options?: {\n gasMultiplier?: number;\n },\n) {\n validateClientNetwork(publicClient);\n\n const createCoinRequest = await createCoinCall(call);\n const { request } = await publicClient.simulateContract({\n ...createCoinRequest,\n account: walletClient.account,\n });\n\n // Add a 2/5th buffer on gas.\n if (request.gas) {\n // Gas limit multiplier is a percentage argument.\n request.gas = (request.gas * BigInt(options?.gasMultiplier ?? 100)) / 100n;\n }\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const deployment = getCoinCreateFromLogs(receipt);\n\n return {\n hash,\n receipt,\n address: deployment?.coin,\n deployment,\n };\n}\n","import { coinFactoryAddress as zoraFactoryImplAddress } from \"@zoralabs/protocol-deployments\";\nimport { Address } from \"viem\";\nimport { base } from \"viem/chains\";\n\n// this is the same across all chains due to deterministic deploys.\nexport const COIN_FACTORY_ADDRESS = zoraFactoryImplAddress[\"8453\"] as Address;\n\nexport const SUPERCHAIN_WETH_ADDRESS =\n \"0x4200000000000000000000000000000000000006\";\n\nexport const USDC_WETH_POOLS_BY_CHAIN: Record<number, Address> = {\n [base.id]: \"0xd0b53D9277642d899DF5C87A3966A349A798F224\",\n};\n","import { PublicClient } from \"viem\";\nimport { base, baseSepolia } from \"viem/chains\";\n\nexport const validateClientNetwork = (\n publicClient: PublicClient<any, any, any, any>,\n) => {\n const clientChainId = publicClient?.chain?.id;\n if (clientChainId === base.id) {\n return;\n }\n if (clientChainId === baseSepolia.id) {\n return;\n }\n\n throw new Error(\n \"Client network needs to be base or baseSepolia for current coin deployments.\",\n );\n};\n","export type ValidMetadataURI =\n | `ipfs://${string}`\n | `ar://${string}`\n | `data:${string}`\n | `https://${string}`;\n\n/**\n * Clean the metadata URI to HTTPS format\n * @param metadataURI - The metadata URI to clean from IPFS or Arweave\n * @returns The cleaned metadata URI\n * @throws If the metadata URI is a data URI\n */\nexport function cleanAndValidateMetadataURI(uri: ValidMetadataURI) {\n if (uri.startsWith(\"ipfs://\")) {\n return uri.replace(\n \"ipfs://\",\n \"https://magic.decentralized-content.com/ipfs/\",\n );\n }\n if (uri.startsWith(\"ar://\")) {\n return uri.replace(\"ar://\", \"http://arweave.net/\");\n }\n if (uri.startsWith(\"data:\")) {\n throw new Error(\"Data URIs are not supported\");\n }\n if (uri.startsWith(\"http://\") || uri.startsWith(\"https://\")) {\n return uri;\n }\n\n throw new Error(\"Invalid metadata URI\");\n}\n","export type ValidMetadataJSON = {\n name: string;\n description: string;\n image: string;\n animation_url?: string;\n content?: { uri: string; mime?: string };\n};\n\nfunction validateURIString(uri: unknown) {\n if (typeof uri !== \"string\") {\n throw new Error(\"URI must be a string\");\n }\n if (uri.startsWith(\"ipfs://\")) {\n return true;\n }\n if (uri.startsWith(\"ar://\")) {\n return true;\n }\n if (uri.startsWith(\"https://\")) {\n return true;\n }\n if (uri.startsWith(\"data:\")) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Validate the metadata JSON object\n * @param metadata - The metadata object to validate\n */\nexport function validateMetadataJSON(metadata: ValidMetadataJSON | unknown) {\n if (typeof metadata !== \"object\" || !metadata) {\n throw new Error(\"Metadata must be an object and exist\");\n }\n if (typeof (metadata as { name: unknown }).name !== \"string\") {\n throw new Error(\"Metadata name is required and must be a string\");\n }\n if (typeof (metadata as { description: unknown }).description !== \"string\") {\n throw new Error(\"Metadata description is required and must be a string\");\n }\n if (typeof (metadata as { image: unknown }).image === \"string\") {\n if (!validateURIString((metadata as { image: string }).image)) {\n throw new Error(\"Metadata image is not a valid URI\");\n }\n } else {\n throw new Error(\"Metadata image is required and must be a string\");\n }\n if (\"animation_url\" in metadata) {\n if (\n typeof (metadata as { animation_url?: unknown }).animation_url !==\n \"string\"\n ) {\n throw new Error(\"Metadata animation_url, if provided, must be a string\");\n }\n if (!validateURIString(metadata.animation_url)) {\n throw new Error(\"Metadata animation_url is not a valid URI\");\n }\n }\n const content =\n \"content\" in metadata && (metadata as { content?: unknown }).content;\n if (content) {\n if (typeof (content as { uri?: unknown }).uri !== \"string\") {\n throw new Error(\"If provided, content.uri must be a string\");\n }\n if (!validateURIString((content as { uri: string }).uri)) {\n throw new Error(\"If provided, content.uri must be a valid URI string\");\n }\n if (typeof (content as { mime?: unknown }).mime !== \"string\") {\n throw new Error(\"If provided, content.mime must be a string\");\n }\n }\n\n return true;\n}\n","import {\n cleanAndValidateMetadataURI,\n ValidMetadataURI,\n} from \"./cleanAndValidateMetadataURI\";\nimport { validateMetadataJSON } from \"./validateMetadataJSON\";\n\n/**\n * Validate the metadata URI Content\n * @param metadataURI - The metadata URI to validate\n * @returns true if the metadata is valid, throws an error otherwise\n */\nexport async function validateMetadataURIContent(\n metadataURI: ValidMetadataURI,\n) {\n const cleanedURI = cleanAndValidateMetadataURI(metadataURI);\n const response = await fetch(cleanedURI);\n if (!response.ok) {\n throw new Error(\"Metadata fetch failed\");\n }\n if (\n ![\"application/json\", \"text/plain\"].includes(\n response.headers.get(\"content-type\") ?? \"\",\n )\n ) {\n throw new Error(\"Metadata is not a valid JSON or plain text response type\");\n }\n const metadataJson = await response.json();\n return validateMetadataJSON(metadataJson);\n}\n","import { Hex, keccak256, slice, toHex } from \"viem\";\n\nexport function getAttribution(): Hex {\n const hash = keccak256(toHex(\"api-sdk.zora.engineering\"));\n return slice(hash, 0, 4) as Hex;\n}\n","import { coinABI } from \"@zoralabs/protocol-deployments\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport {\n Address,\n TransactionReceipt,\n WalletClient,\n SimulateContractParameters,\n parseEther,\n zeroAddress,\n ContractEventArgsFromTopics,\n parseEventLogs,\n} from \"viem\";\nimport { baseSepolia } from \"viem/chains\";\nimport { GenericPublicClient } from \"src/utils/genericPublicClient\";\nimport { getAttribution } from \"../utils/attribution\";\n// Define trade event args type\n\nexport type SellEventArgs = ContractEventArgsFromTopics<\n typeof coinABI,\n \"CoinSell\"\n>;\nexport type BuyEventArgs = ContractEventArgsFromTopics<\n typeof coinABI,\n \"CoinBuy\"\n>;\n\nexport type TradeEventArgs = SellEventArgs | BuyEventArgs;\n\n// We'll use this address to ensure it will have funds to simulate an eth trade.\n// @dev: This only works on OP chains and is a fix for a bug. Another approach should be taken long term.\nconst OP_BRIDGE_ADDRESS =\n \"0x4200000000000000000000000000000000000016\" as Address;\n\n/**\n * Simulates a buy order to get the expected output amount\n * @param {Object} params - The simulation parameters\n * @param {Address} params.target - The target coin contract address\n * @param {bigint} params.requestedOrderSize - The desired input amount for the buy\n * @param {PublicClient} params.publicClient - The viem public client instance\n * @returns {Promise<{orderSize: bigint, amountOut: bigint}>} The simulated order size and output amount\n */\nexport async function simulateBuy({\n target,\n requestedOrderSize,\n publicClient,\n}: {\n target: Address;\n requestedOrderSize: bigint;\n publicClient: GenericPublicClient;\n}): Promise<{ orderSize: bigint; amountOut: bigint }> {\n const numberResult = await publicClient.simulateContract({\n address: target,\n abi: coinABI,\n functionName: \"buy\",\n dataSuffix: getAttribution(),\n args: [\n OP_BRIDGE_ADDRESS,\n requestedOrderSize,\n 0n, // minAmountOut\n 0n, // sqrtPriceLimitX96\n zeroAddress, // tradeReferrer\n ],\n // We want to ensure that the multicall3 contract has enough ETH to buy in the simulation\n stateOverride: [\n {\n address: baseSepolia.contracts.multicall3.address,\n balance: parseEther(\"10000000\"),\n },\n ],\n });\n const orderSize = numberResult.result[0];\n const amountOut = numberResult.result[1];\n return { orderSize, amountOut };\n}\n\n/**\n * Parameters for creating a trade call\n * @typedef {Object} TradeParams\n * @property {'sell' | 'buy'} direction - The trade direction\n * @property {Address} target - The target coin contract address\n * @property {Object} args - The trade arguments\n * @property {Address} args.recipient - The recipient of the trade output\n * @property {bigint} args.orderSize - The size of the order\n * @property {bigint} [args.minAmountOut] - The minimum amount to receive\n * @property {bigint} [args.sqrtPriceLimitX96] - The price limit for the trade\n * @property {Address} [args.tradeReferrer] - The referrer address for the trade\n */\nexport type TradeParams = {\n direction: \"sell\" | \"buy\";\n target: Address;\n args: {\n recipient: Address;\n orderSize: bigint;\n minAmountOut?: bigint;\n sqrtPriceLimitX96?: bigint;\n tradeReferrer?: Address;\n };\n};\n\n/**\n * Creates a trade call parameters object for buy or sell\n * @param {TradeParams} params - The trade parameters\n * @returns {SimulateContractParameters} The contract call parameters\n */\nexport function tradeCoinCall({\n target,\n direction,\n args: {\n recipient,\n orderSize,\n minAmountOut = 0n,\n sqrtPriceLimitX96 = 0n,\n tradeReferrer = zeroAddress,\n },\n}: TradeParams): SimulateContractParameters {\n return {\n abi: coinABI,\n functionName: direction,\n address: target,\n args: [\n recipient,\n orderSize,\n minAmountOut,\n sqrtPriceLimitX96,\n tradeReferrer,\n ],\n value: direction === \"buy\" ? orderSize : 0n,\n } as const;\n}\n\n/**\n * Gets the trade event from transaction receipt logs\n * @param {TransactionReceipt} receipt - The transaction receipt containing the logs\n * @param {'buy' | 'sell'} direction - The direction of the trade\n * @returns {TradeEventArgs | undefined} The decoded trade event args if found\n */\nexport function getTradeFromLogs(\n receipt: TransactionReceipt,\n direction: \"buy\" | \"sell\",\n): TradeEventArgs | undefined {\n const eventLogs = parseEventLogs({\n abi: coinABI,\n logs: receipt.logs,\n });\n\n if (direction === \"buy\") {\n return eventLogs.find((log) => log.eventName === \"CoinBuy\")?.args;\n }\n return eventLogs.find((log) => log.eventName === \"CoinSell\")?.args;\n}\n\n/**\n * Executes a trade transaction\n * @param {TradeParams} params - The trade parameters\n * @param {PublicClient} publicClient - The viem public client instance\n * @param {WalletClient} walletClient - The viem wallet client instance\n * @returns {Promise<{\n * hash: `0x${string}`,\n * receipt: TransactionReceipt,\n * trade: TradeEventArgs | undefined\n * }>} The transaction result with trade details\n */\nexport async function tradeCoin(\n params: TradeParams,\n walletClient: WalletClient,\n publicClient: GenericPublicClient,\n) {\n validateClientNetwork(publicClient);\n const { request } = await publicClient.simulateContract({\n ...tradeCoinCall(params),\n account: walletClient.account,\n });\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const trade = getTradeFromLogs(receipt, params.direction);\n\n return {\n hash,\n receipt,\n trade,\n };\n}\n","import { coinABI, iUniswapV3PoolABI } from \"@zoralabs/protocol-deployments\";\nimport {\n SUPERCHAIN_WETH_ADDRESS,\n USDC_WETH_POOLS_BY_CHAIN,\n} from \"../constants\";\nimport { GenericPublicClient } from \"../utils/genericPublicClient\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport {\n Address,\n erc20Abi,\n formatEther,\n isAddressEqual,\n zeroAddress,\n} from \"viem\";\n\ntype Slot0Result = {\n sqrtPriceX96: bigint;\n tick: number;\n observationIndex: number;\n observationCardinality: number;\n observationCardinalityNext: number;\n feeProtocol: number;\n unlocked: boolean;\n};\n\ntype PricingResult = {\n eth: bigint;\n usdc: bigint | null;\n usdcDecimal: number | null;\n ethDecimal: number;\n};\n\n/**\n * Represents the current state of a coin\n * @typedef {Object} OnchainCoinDetails\n * @property {bigint} balance - The user's balance of the coin\n * @property {PricingResult} marketCap - The market cap of the coin\n * @property {PricingResult} liquidity - The liquidity of the coin\n * @property {Address} pool - Pool address\n * @property {Slot0Result} poolState - Current state of the UniswapV3 pool\n * @property {Address[]} owners - List of owners for the coin\n * @property {Address} payoutRecipient - The payout recipient address\n */\nexport type OnchainCoinDetails = {\n balance: bigint;\n marketCap: PricingResult;\n liquidity: PricingResult;\n pool: Address;\n poolState: Slot0Result;\n owners: readonly Address[];\n payoutRecipient: Address;\n};\n\n/**\n * Gets the current state of a coin for a user\n * @param {Object} params - The query parameters\n * @param {Address} params.coin - The coin contract address\n * @param {Address} params.user - The user address to check balance for\n * @param {PublicClient} params.publicClient - The viem public client instance\n * @returns {Promise<OnchainCoinDetails>} The coin's current state\n */\nexport async function getOnchainCoinDetails({\n coin,\n user = zeroAddress,\n publicClient,\n}: {\n coin: Address;\n user?: Address;\n publicClient: GenericPublicClient;\n}): Promise<OnchainCoinDetails> {\n validateClientNetwork(publicClient);\n const [balance, pool, owners, payoutRecipient] = await publicClient.multicall(\n {\n contracts: [\n {\n address: coin,\n abi: coinABI,\n functionName: \"balanceOf\",\n args: [user],\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"poolAddress\",\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"owners\",\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"payoutRecipient\",\n },\n ],\n allowFailure: false,\n },\n );\n\n const USDC_WETH_POOL = USDC_WETH_POOLS_BY_CHAIN[publicClient.chain?.id || 0];\n\n const [\n coinWethPoolSlot0,\n coinWethPoolToken0,\n coinReservesRaw,\n coinTotalSupply,\n wethReservesRaw,\n usdcWethSlot0,\n ] = await publicClient.multicall({\n contracts: [\n {\n address: pool,\n abi: iUniswapV3PoolABI,\n functionName: \"slot0\",\n },\n {\n address: pool,\n abi: iUniswapV3PoolABI,\n functionName: \"token0\",\n },\n {\n address: coin,\n abi: erc20Abi,\n functionName: \"balanceOf\",\n args: [pool],\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"totalSupply\",\n },\n {\n address: SUPERCHAIN_WETH_ADDRESS,\n abi: erc20Abi,\n functionName: \"balanceOf\",\n args: [pool],\n },\n {\n address: USDC_WETH_POOL ?? coin,\n abi: iUniswapV3PoolABI,\n functionName: \"slot0\",\n },\n ],\n allowFailure: false,\n });\n\n const wethPriceInUsdc = USDC_WETH_POOL\n ? uniswapV3SqrtPriceToBigIntScaled(\n usdcWethSlot0.sqrtPriceX96,\n 18,\n 6,\n true,\n 18,\n )\n : null;\n\n const coinPriceInWeth = uniswapV3SqrtPriceToBigIntScaled(\n coinWethPoolSlot0.sqrtPriceX96,\n 18,\n 18,\n isAddressEqual(coinWethPoolToken0, coin),\n 18,\n );\n\n // Divide by 10^18 to remove percision from `coinPriceInWeth` after math since bigint is decimal.\n const marketCap = (coinPriceInWeth * coinTotalSupply) / 10n ** 18n;\n\n const wethLiquidity = wethReservesRaw;\n // Divide by 10^18 to remove percision from `coinPriceInWeth` after math since bigint is decimal.\n const tokenLiquidity = (coinReservesRaw * coinPriceInWeth) / 10n ** 18n;\n\n return {\n balance,\n pool,\n owners,\n payoutRecipient,\n marketCap: convertEthOutput(marketCap, wethPriceInUsdc),\n liquidity: convertEthOutput(\n wethLiquidity + tokenLiquidity,\n wethPriceInUsdc,\n ),\n poolState: coinWethPoolSlot0,\n };\n}\n\nfunction convertEthOutput(amountETH: bigint, wethToUsdc: bigint | null) {\n return {\n eth: amountETH,\n ethDecimal: parseFloat(formatEther(amountETH)),\n usdc: wethToUsdc ? amountETH * wethToUsdc : null,\n usdcDecimal: wethToUsdc\n ? parseFloat(formatEther((amountETH * wethToUsdc) / 10n ** 18n))\n : null,\n };\n}\n\nfunction uniswapV3SqrtPriceToBigIntScaled(\n sqrtPriceX96: bigint,\n token0Decimals: number,\n token1Decimals: number,\n isToken0Coin: boolean,\n scaleDecimals: number = 18,\n): bigint {\n // (sqrtPrice^2 / 2^192) => ratio\n // We'll do: ratioScaled = (sqrtPrice^2 * 10^scaleDecimals) / 2^192\n const numerator = sqrtPriceX96 * sqrtPriceX96;\n const denominator = 2n ** 192n;\n const scaleFactor = 10n ** BigInt(scaleDecimals);\n\n // raw ratioScaled\n let ratioScaled = (numerator * scaleFactor) / denominator; // BigInt\n\n // Adjust for difference in decimals:\n // ratioScaled *= 10^(dec0 - dec1)\n const decimalsDiff = BigInt(token0Decimals - token1Decimals);\n if (decimalsDiff > 0n) {\n ratioScaled *= 10n ** decimalsDiff;\n } else if (decimalsDiff < 0n) {\n ratioScaled /= 10n ** -decimalsDiff;\n }\n\n if (!isToken0Coin) {\n // We want the reciprocal: coin is token1 => coinPriceInToken0 = 1 / ratio\n // But we also want it scaled by 10^scaleDecimals\n // reciprocalScaled = (10^scaleDecimals * 10^(decimalsDiff)) / ratioScaled\n // (assuming ratioScaled != 0)\n if (ratioScaled === 0n) {\n return 0n; // or some huge number representing infinity\n }\n ratioScaled = (scaleFactor * scaleFactor) / ratioScaled;\n // or if we already included decimalsDiff above, handle carefully.\n }\n\n return ratioScaled;\n}\n","import { coinABI } from \"@zoralabs/protocol-deployments\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport {\n Address,\n parseEventLogs,\n SimulateContractParameters,\n WalletClient,\n} from \"viem\";\nimport { GenericPublicClient } from \"src/utils/genericPublicClient\";\nimport { getAttribution } from \"../utils/attribution\";\n\nexport type UpdateCoinURIArgs = {\n coin: Address;\n newURI: string;\n};\n\nexport function updateCoinURICall({\n newURI,\n coin,\n}: UpdateCoinURIArgs): SimulateContractParameters {\n if (!newURI.startsWith(\"ipfs://\")) {\n throw new Error(\"URI needs to be an ipfs:// prefix uri\");\n }\n\n return {\n abi: coinABI,\n address: coin,\n functionName: \"setContractURI\",\n args: [newURI],\n dataSuffix: getAttribution(),\n };\n}\n\nexport async function updateCoinURI(\n args: UpdateCoinURIArgs,\n walletClient: WalletClient,\n publicClient: GenericPublicClient,\n) {\n validateClientNetwork(publicClient);\n const call = updateCoinURICall(args);\n const { request } = await publicClient.simulateContract({\n ...call,\n account: walletClient.account!,\n });\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const eventLogs = parseEventLogs({ abi: coinABI, logs: receipt.logs });\n const uriUpdated = eventLogs.find(\n (log) => log.eventName === \"ContractURIUpdated\",\n );\n\n return { hash, receipt, uriUpdated };\n}\n","import { coinABI } from \"@zoralabs/protocol-deployments\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport {\n Address,\n parseEventLogs,\n SimulateContractParameters,\n WalletClient,\n} from \"viem\";\nimport { GenericPublicClient } from \"src/utils/genericPublicClient\";\nimport { getAttribution } from \"../utils/attribution\";\n\nexport type UpdatePayoutRecipientArgs = {\n coin: Address;\n newPayoutRecipient: string;\n};\n\nexport function updatePayoutRecipientCall({\n newPayoutRecipient,\n coin,\n}: UpdatePayoutRecipientArgs): SimulateContractParameters {\n return {\n abi: coinABI,\n address: coin,\n functionName: \"setPayoutRecipient\",\n args: [newPayoutRecipient],\n dataSuffix: getAttribution(),\n };\n}\n\nexport async function updatePayoutRecipient(\n args: UpdatePayoutRecipientArgs,\n walletClient: WalletClient,\n publicClient: GenericPublicClient,\n) {\n validateClientNetwork(publicClient);\n const call = updatePayoutRecipientCall(args);\n const { request } = await publicClient.simulateContract({\n ...call,\n account: walletClient.account!,\n });\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const eventLogs = parseEventLogs({ abi: coinABI, logs: receipt.logs });\n const payoutRecipientUpdated = eventLogs.find(\n (log) => log.eventName === \"CoinPayoutRecipientUpdated\",\n );\n\n return { hash, receipt, payoutRecipientUpdated };\n}\n","// This file is auto-generated by @hey-api/openapi-ts\n\nimport type { ClientOptions } from \"./types.gen\";\nimport {\n type Config,\n type ClientOptions as DefaultClientOptions,\n createClient,\n createConfig,\n} from \"@hey-api/client-fetch\";\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> =\n (\n override?: Config<DefaultClientOptions & T>,\n ) => Config<Required<DefaultClientOptions> & T>;\n\nexport const client = createClient(\n createConfig<ClientOptions>({\n baseUrl: \"https://api-sdk.zora.engineering/\",\n }),\n);\n","// This file is auto-generated by @hey-api/openapi-ts\n\nimport type {\n Options as ClientOptions,\n TDataShape,\n Client,\n} from \"@hey-api/client-fetch\";\nimport type {\n GetCoinData,\n GetCoinResponse,\n GetCoinCommentsData,\n GetCoinCommentsResponse,\n GetCoinsData,\n GetCoinsResponse,\n GetExploreData,\n GetExploreResponse,\n GetProfileData,\n GetProfileResponse,\n GetProfileBalancesData,\n GetProfileBalancesResponse,\n} from \"./types.gen\";\nimport { client as _heyApiClient } from \"./client.gen\";\n\nexport type Options<\n TData extends TDataShape = TDataShape,\n ThrowOnError extends boolean = boolean,\n> = ClientOptions<TData, ThrowOnError> & {\n /**\n * You can provide a client instance returned by `createClient()` instead of\n * individual options. This might be also useful if you want to implement a\n * custom client.\n */\n client?: Client;\n /**\n * You can pass arbitrary values through the `meta` object. This can be\n * used to access values that aren't defined as part of the SDK function.\n */\n meta?: Record<string, unknown>;\n};\n\n/**\n * zoraSDK_coin query\n */\nexport const getCoin = <ThrowOnError extends boolean = false>(\n options: Options<GetCoinData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetCoinResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/coin\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_coinComments query\n */\nexport const getCoinComments = <ThrowOnError extends boolean = false>(\n options: Options<GetCoinCommentsData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetCoinCommentsResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/coinComments\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_coins query\n */\nexport const getCoins = <ThrowOnError extends boolean = false>(\n options: Options<GetCoinsData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetCoinsResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/coins\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_explore query\n */\nexport const getExplore = <ThrowOnError extends boolean = false>(\n options: Options<GetExploreData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetExploreResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/explore\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_profile query\n */\nexport const getProfile = <ThrowOnError extends boolean = false>(\n options: Options<GetProfileData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetProfileResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/profile\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_profileBalances query\n */\nexport const getProfileBalances = <ThrowOnError extends boolean = false>(\n options: Options<GetProfileBalancesData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetProfileBalancesResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/profileBalances\",\n ...options,\n });\n};\n","let apiKey: string | undefined;\nexport function setApiKey(key: string) {\n apiKey = key;\n}\n\nexport function getApiKeyMeta() {\n if (!apiKey) {\n return {};\n }\n return {\n headers: {\n \"api-key\": apiKey,\n },\n };\n}\n","import {\n GetCoinCommentsData,\n GetCoinCommentsResponse,\n GetCoinData,\n GetCoinResponse,\n GetCoinsData,\n GetCoinsResponse,\n GetProfileBalancesData,\n GetProfileBalancesResponse,\n GetProfileData,\n GetProfileResponse,\n} from \"../client/types.gen\";\nimport {\n getCoin as getCoinSDK,\n getCoins as getCoinsSDK,\n getCoinComments as getCoinCommentsSDK,\n getProfile as getProfileSDK,\n getProfileBalances as getProfileBalancesSDK,\n} from \"../client/sdk.gen\";\nimport { getApiKeyMeta } from \"./api-key\";\nimport { RequestOptionsType } from \"./query-types\";\nimport { RequestResult } from \"@hey-api/client-fetch\";\n\nexport type { RequestResult };\n\ntype GetCoinQuery = GetCoinData[\"query\"];\nexport type { GetCoinQuery, GetCoinData };\nexport type { GetCoinResponse } from \"../client/types.gen\";\n\nexport type CoinData = NonNullable<GetCoinResponse[\"zora20Token\"]>;\n\nexport const getCoin = async (\n query: GetCoinQuery,\n options?: RequestOptionsType<GetCoinData>,\n): Promise<RequestResult<GetCoinResponse>> => {\n return await getCoinSDK({\n ...options,\n query,\n meta: getApiKeyMeta(),\n });\n};\n\ntype GetCoinsQuery = GetCoinsData[\"query\"];\nexport type { GetCoinsQuery, GetCoinsData };\nexport type { GetCoinsResponse } from \"../client/types.gen\";\n\nexport const getCoins = async (\n query: GetCoinsQuery,\n options?: RequestOptionsType<GetCoinsData>,\n): Promise<RequestResult<GetCoinsResponse>> => {\n return await getCoinsSDK({\n query: {\n coins: query.coins.map((coinData) => JSON.stringify(coinData)) as any,\n },\n meta: getApiKeyMeta(),\n ...options,\n });\n};\n\ntype GetCoinCommentsQuery = GetCoinCommentsData[\"query\"];\nexport type { GetCoinCommentsQuery, GetCoinCommentsData };\nexport type { GetCoinCommentsResponse } from \"../client/types.gen\";\n\nexport const getCoinComments = async (\n query: GetCoinCommentsQuery,\n options?: RequestOptionsType<GetCoinCommentsData>,\n): Promise<RequestResult<GetCoinCommentsResponse>> => {\n return await getCoinCommentsSDK({\n query,\n meta: getApiKeyMeta(),\n ...options,\n });\n};\n\ntype GetProfileQuery = GetProfileData[\"query\"];\nexport type { GetProfileQuery, GetProfileData };\nexport type { GetProfileResponse } from \"../client/types.gen\";\n\nexport const getProfile = async (\n query: GetProfileQuery,\n options?: RequestOptionsType<GetProfileData>,\n): Promise<RequestResult<GetProfileResponse>> => {\n return await getProfileSDK({\n query,\n meta: getApiKeyMeta(),\n ...options,\n });\n};\n\ntype GetProfileBalancesQuery = GetProfileBalancesData[\"query\"];\nexport type { GetProfileBalancesQuery, GetProfileBalancesData };\nexport type { GetProfileBalancesResponse } from \"../client/types.gen\";\n\nexport const getProfileBalances = async (\n query: GetProfileBalancesQuery,\n options?: RequestOptionsType<GetProfileBalancesData>,\n): Promise<RequestResult<GetProfileBalancesResponse>> => {\n return await getProfileBalancesSDK({\n query,\n meta: getApiKeyMeta(),\n ...options,\n });\n};\n","import { getExplore as getExploreSDK } from \"../client/sdk.gen\";\nimport type { GetExploreData, GetExploreResponse } from \"../client/types.gen\";\nimport { getApiKeyMeta } from \"./api-key\";\nimport { RequestOptionsType } from \"./query-types\";\n\n/**\n * The inner type for the explore queries that omits listType.\n * This is used to create the query object for the explore queries.\n */\nexport type QueryRequestType = Omit<GetExploreData[\"query\"], \"listType\">;\n\ntype ExploreResponse = { data?: GetExploreResponse };\n\nexport type ListType = GetExploreData[\"query\"][\"listType\"];\n\nexport type { ExploreResponse };\n\nexport type { GetExploreData };\n\n/**\n * Creates an explore query with the specified list type\n */\nconst createExploreQuery = (\n query: QueryRequestType,\n listType: ListType,\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n getExploreSDK({\n ...options,\n query: { ...query, listType },\n meta: getApiKeyMeta(),\n });\n\n/** Get top gaining coins */\nexport const getCoinsTopGainers = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"TOP_GAINERS\", options);\n\n/** Get coins with highest 24h volume */\nexport const getCoinsTopVolume24h = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"TOP_VOLUME_24H\", options);\n\n/** Get most valuable coins */\nexport const getCoinsMostValuable = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"MOST_VALUABLE\", options);\n\n/** Get newly created coins */\nexport const getCoinsNew = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> => createExploreQuery(query, \"NEW\", options);\n\n/** Get recently traded coins */\nexport const getCoinsLastTraded = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"LAST_TRADED\", options);\n\n/** Get recently traded unique coins */\nexport const getCoinsLastTradedUnique = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"LAST_TRADED_UNIQUE\", options);\n"],"mappings":";AAAA,SAAS,kBAAkB,0BAA0B;AACrD;AAAA,EAME;AAAA,OAEK;;;ACTP,SAAS,sBAAsB,8BAA8B;AAE7D,SAAS,YAAY;AAGd,IAAM,uBAAuB,uBAAuB,MAAM;AAE1D,IAAM,0BACX;AAEK,IAAM,2BAAoD;AAAA,EAC/D,CAAC,KAAK,EAAE,GAAG;AACb;;;ACXA,SAAS,QAAAA,OAAM,mBAAmB;AAE3B,IAAM,wBAAwB,CACnC,iBACG;AACH,QAAM,gBAAgB,cAAc,OAAO;AAC3C,MAAI,kBAAkBA,MAAK,IAAI;AAC7B;AAAA,EACF;AACA,MAAI,kBAAkB,YAAY,IAAI;AACpC;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;;;ACLO,SAAS,4BAA4B,KAAuB;AACjE,MAAI,IAAI,WAAW,SAAS,GAAG;AAC7B,WAAO,IAAI;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,MAAI,IAAI,WAAW,OAAO,GAAG;AAC3B,WAAO,IAAI,QAAQ,SAAS,qBAAqB;AAAA,EACnD;AACA,MAAI,IAAI,WAAW,OAAO,GAAG;AAC3B,UAAM,IAAI,MAAM,6BAA6B;AAAA,EAC/C;AACA,MAAI,IAAI,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AAc;AACtB,CAAC;AAGI,IAAM,qBAAqB,CAChC,QAA0B,CAAC,GAC3B,YAEA,mBAAmB,OAAO,eAAe,OAAO;AAG3C,IAAM,uBAAuB,CAClC,QAA0B,CAAC,GAC3B,YAEA,mBAAmB,OAAO,kBAAkB,OAAO;AAG9C,IAAM,uBAAuB,CAClC,QAA0B,CAAC,GAC3B,YAEA,mBAAmB,OAAO,iBAAiB,OAAO;AAG7C,IAAM,cAAc,CACzB,QAA0B,CAAC,GAC3B,YAC6B,mBAAmB,OAAO,OAAO,OAAO;AAGhE,IAAM,qBAAqB,CAChC,QAA0B,CAAC,GAC3B,YAEA,mBAAmB,OAAO,eAAe,OAAO;AAG3C,IAAM,2BAA2B,CACtC,QAA0B,CAAC,GAC3B,YAEA,mBAAmB,OAAO,sBAAsB,OAAO;","names":["base","parseEventLogs","baseSepolia","baseSepolia","parseEventLogs","coinABI","zeroAddress","coinABI","coinABI","parseEventLogs","coinABI","parseEventLogs","coinABI","parseEventLogs","coinABI","parseEventLogs","getCoin","getCoins","getCoinComments","getProfile","getProfileBalances"]}
|
|
1
|
+
{"version":3,"sources":["../src/actions/createCoin.ts","../src/constants.ts","../src/utils/validateClientNetwork.ts","../src/metadata/cleanAndValidateMetadataURI.ts","../src/metadata/validateMetadataJSON.ts","../src/metadata/validateMetadataURIContent.ts","../src/utils/attribution.ts","../src/utils/poolConfigUtils.ts","../src/actions/tradeCoin.ts","../src/actions/getOnchainCoinDetails.ts","../src/actions/updateCoinURI.ts","../src/actions/updatePayoutRecipient.ts","../src/client/client.gen.ts","../src/client/sdk.gen.ts","../src/api/api-key.ts","../src/api/queries.ts","../src/api/explore.ts"],"sourcesContent":["import { coinFactoryABI as zoraFactoryImplABI } from \"@zoralabs/protocol-deployments\";\nimport {\n Address,\n TransactionReceipt,\n WalletClient,\n SimulateContractParameters,\n ContractEventArgsFromTopics,\n parseEventLogs,\n zeroAddress,\n keccak256,\n toBytes,\n Hex,\n Account,\n} from \"viem\";\nimport { COIN_FACTORY_ADDRESS } from \"../constants\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport { GenericPublicClient } from \"src/utils/genericPublicClient\";\nimport { validateMetadataURIContent, ValidMetadataURI } from \"src/metadata\";\nimport { getAttribution } from \"../utils/attribution\";\nimport { base, baseSepolia } from \"viem/chains\";\nimport {\n COIN_ETH_PAIR_POOL_CONFIG,\n COIN_ZORA_PAIR_POOL_CONFIG,\n} from \"src/utils/poolConfigUtils\";\n\nexport type CoinDeploymentLogArgs = ContractEventArgsFromTopics<\n typeof zoraFactoryImplABI,\n \"CoinCreatedV4\"\n>;\n\nexport enum DeployCurrency {\n ZORA = 1,\n ETH = 2,\n}\n\nexport type CreateCoinArgs = {\n name: string;\n symbol: string;\n uri: ValidMetadataURI;\n chainId: number;\n owners?: Address[];\n payoutRecipient: Address;\n platformReferrer?: Address;\n currency?: DeployCurrency;\n};\n\nfunction getPoolConfig(currency: DeployCurrency, chainId: number) {\n if (currency === DeployCurrency.ZORA && chainId == baseSepolia.id) {\n throw new Error(\"ZORA is not supported on Base Sepolia\");\n }\n\n switch (currency) {\n case DeployCurrency.ZORA:\n return COIN_ZORA_PAIR_POOL_CONFIG[\n chainId as keyof typeof COIN_ZORA_PAIR_POOL_CONFIG\n ];\n case DeployCurrency.ETH:\n return COIN_ETH_PAIR_POOL_CONFIG[\n chainId as keyof typeof COIN_ETH_PAIR_POOL_CONFIG\n ];\n default:\n throw new Error(\"Invalid currency\");\n }\n}\n\nexport async function createCoinCall({\n name,\n symbol,\n uri,\n owners,\n payoutRecipient,\n currency,\n chainId = base.id,\n platformReferrer = \"0x0000000000000000000000000000000000000000\",\n}: CreateCoinArgs): Promise<\n SimulateContractParameters<typeof zoraFactoryImplABI, \"deploy\">\n> {\n if (!owners) {\n owners = [payoutRecipient];\n }\n\n if (!currency) {\n currency = chainId !== base.id ? DeployCurrency.ETH : DeployCurrency.ZORA;\n }\n\n const poolConfig = getPoolConfig(currency, chainId);\n\n // This will throw an error if the metadata is not valid\n await validateMetadataURIContent(uri);\n\n return {\n abi: zoraFactoryImplABI,\n functionName: \"deploy\",\n address: COIN_FACTORY_ADDRESS,\n args: [\n payoutRecipient,\n owners,\n uri,\n name,\n symbol,\n poolConfig,\n platformReferrer,\n zeroAddress, // hookAddress\n \"0x\" as Hex, // hookData\n keccak256(toBytes(Math.random().toString())), // coinSalt\n ],\n dataSuffix: getAttribution(),\n } as const;\n}\n\n/**\n * Gets the deployed coin address from transaction receipt logs\n * @param receipt Transaction receipt containing the CoinCreated event\n * @returns The deployment information if found\n */\nexport function getCoinCreateFromLogs(\n receipt: TransactionReceipt,\n): CoinDeploymentLogArgs | undefined {\n const eventLogs = parseEventLogs({\n abi: zoraFactoryImplABI,\n logs: receipt.logs,\n });\n\n return eventLogs.find((log) => log.eventName === \"CoinCreatedV4\")?.args;\n}\n\n// Update createCoin to return both receipt and coin address\nexport async function createCoin(\n call: CreateCoinArgs,\n walletClient: WalletClient,\n publicClient: GenericPublicClient,\n options?: {\n gasMultiplier?: number;\n account?: Account | Address;\n },\n) {\n validateClientNetwork(publicClient);\n\n const createCoinRequest = await createCoinCall(call);\n const { request } = await publicClient.simulateContract({\n ...createCoinRequest,\n account: options?.account ?? walletClient.account,\n });\n\n // Add a 2/5th buffer on gas.\n if (request.gas) {\n // Gas limit multiplier is a percentage argument.\n request.gas = (request.gas * BigInt(options?.gasMultiplier ?? 100)) / 100n;\n }\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const deployment = getCoinCreateFromLogs(receipt);\n\n return {\n hash,\n receipt,\n address: deployment?.coin,\n deployment,\n };\n}\n","import { coinFactoryAddress as zoraFactoryImplAddress } from \"@zoralabs/protocol-deployments\";\nimport { Address } from \"viem\";\nimport { base } from \"viem/chains\";\n\n// this is the same across all chains due to deterministic deploys.\nexport const COIN_FACTORY_ADDRESS = zoraFactoryImplAddress[\"8453\"] as Address;\n\nexport const SUPERCHAIN_WETH_ADDRESS =\n \"0x4200000000000000000000000000000000000006\";\n\nexport const USDC_WETH_POOLS_BY_CHAIN: Record<number, Address> = {\n [base.id]: \"0xd0b53D9277642d899DF5C87A3966A349A798F224\",\n};\n","import { PublicClient } from \"viem\";\nimport { base, baseSepolia } from \"viem/chains\";\n\nexport const validateClientNetwork = (\n publicClient: PublicClient<any, any, any, any>,\n) => {\n const clientChainId = publicClient?.chain?.id;\n if (clientChainId === base.id) {\n return;\n }\n if (clientChainId === baseSepolia.id) {\n return;\n }\n\n throw new Error(\n \"Client network needs to be base or baseSepolia for current coin deployments.\",\n );\n};\n","export type ValidMetadataURI =\n | `ipfs://${string}`\n | `ar://${string}`\n | `data:${string}`\n | `https://${string}`;\n\n/**\n * Clean the metadata URI to HTTPS format\n * @param metadataURI - The metadata URI to clean from IPFS or Arweave\n * @returns The cleaned metadata URI\n * @throws If the metadata URI is a data URI\n */\nexport function cleanAndValidateMetadataURI(uri: ValidMetadataURI) {\n if (uri.startsWith(\"ipfs://\")) {\n return uri.replace(\n \"ipfs://\",\n \"https://magic.decentralized-content.com/ipfs/\",\n );\n }\n if (uri.startsWith(\"ar://\")) {\n return uri.replace(\"ar://\", \"http://arweave.net/\");\n }\n if (uri.startsWith(\"data:\")) {\n return uri;\n // throw new Error(\"Data URIs are not supported\");\n }\n if (uri.startsWith(\"http://\") || uri.startsWith(\"https://\")) {\n return uri;\n }\n\n throw new Error(\"Invalid metadata URI\");\n}\n","export type ValidMetadataJSON = {\n name: string;\n description: string;\n image: string;\n animation_url?: string;\n content?: { uri: string; mime?: string };\n};\n\nfunction validateURIString(uri: unknown) {\n if (typeof uri !== \"string\") {\n throw new Error(\"URI must be a string\");\n }\n if (uri.startsWith(\"ipfs://\")) {\n return true;\n }\n if (uri.startsWith(\"ar://\")) {\n return true;\n }\n if (uri.startsWith(\"https://\")) {\n return true;\n }\n if (uri.startsWith(\"data:\")) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Validate the metadata JSON object\n * @param metadata - The metadata object to validate\n */\nexport function validateMetadataJSON(metadata: ValidMetadataJSON | unknown) {\n if (typeof metadata !== \"object\" || !metadata) {\n throw new Error(\"Metadata must be an object and exist\");\n }\n if (typeof (metadata as { name: unknown }).name !== \"string\") {\n throw new Error(\"Metadata name is required and must be a string\");\n }\n if (typeof (metadata as { description: unknown }).description !== \"string\") {\n throw new Error(\"Metadata description is required and must be a string\");\n }\n if (typeof (metadata as { image: unknown }).image === \"string\") {\n if (!validateURIString((metadata as { image: string }).image)) {\n throw new Error(\"Metadata image is not a valid URI\");\n }\n } else {\n throw new Error(\"Metadata image is required and must be a string\");\n }\n if (\"animation_url\" in metadata) {\n if (\n typeof (metadata as { animation_url?: unknown }).animation_url !==\n \"string\"\n ) {\n throw new Error(\"Metadata animation_url, if provided, must be a string\");\n }\n if (!validateURIString(metadata.animation_url)) {\n throw new Error(\"Metadata animation_url is not a valid URI\");\n }\n }\n const content =\n \"content\" in metadata && (metadata as { content?: unknown }).content;\n if (content) {\n if (typeof (content as { uri?: unknown }).uri !== \"string\") {\n throw new Error(\"If provided, content.uri must be a string\");\n }\n if (!validateURIString((content as { uri: string }).uri)) {\n throw new Error(\"If provided, content.uri must be a valid URI string\");\n }\n if (typeof (content as { mime?: unknown }).mime !== \"string\") {\n throw new Error(\"If provided, content.mime must be a string\");\n }\n }\n\n return true;\n}\n","import {\n cleanAndValidateMetadataURI,\n ValidMetadataURI,\n} from \"./cleanAndValidateMetadataURI\";\nimport { validateMetadataJSON } from \"./validateMetadataJSON\";\n\n/**\n * Validate the metadata URI Content\n * @param metadataURI - The metadata URI to validate\n * @returns true if the metadata is valid, throws an error otherwise\n */\nexport async function validateMetadataURIContent(\n metadataURI: ValidMetadataURI,\n) {\n const cleanedURI = cleanAndValidateMetadataURI(metadataURI);\n const response = await fetch(cleanedURI);\n if (!response.ok) {\n throw new Error(\"Metadata fetch failed\");\n }\n if (\n ![\"application/json\", \"text/plain\"].includes(\n response.headers.get(\"content-type\") ?? \"\",\n )\n ) {\n throw new Error(\"Metadata is not a valid JSON or plain text response type\");\n }\n const metadataJson = await response.json();\n return validateMetadataJSON(metadataJson);\n}\n","import { Hex, keccak256, slice, toHex } from \"viem\";\n\nexport function getAttribution(): Hex {\n const hash = keccak256(toHex(\"api-sdk.zora.engineering\"));\n return slice(hash, 0, 4) as Hex;\n}\n","import { encodeMultiCurvePoolConfig } from \"@zoralabs/protocol-deployments\";\nimport { parseUnits, zeroAddress } from \"viem\";\nimport { base, baseSepolia } from \"viem/chains\";\n\nconst ZORA_DECIMALS = 18;\n\n/**\n * =========================\n * COIN_ETH_PAIR_POOL_CONFIG\n * =========================\n */\n\nexport const ZORA_ADDRESS = \"0x1111111111166b7fe7bd91427724b487980afc69\";\n\nconst COIN_ETH_PAIR_LOWER_TICK = -250000;\nconst COIN_ETH_PAIR_UPPER_TICK = -195_000;\nconst COIN_ETH_PAIR_NUM_DISCOVERY_POSITIONS = 11;\nconst COIN_ETH_PAIR_MAX_DISCOVERY_SUPPLY_SHARE = parseUnits(\"0.05\", 18);\n\nexport const COIN_ETH_PAIR_POOL_CONFIG = {\n [base.id]: encodeMultiCurvePoolConfig({\n currency: zeroAddress,\n tickLower: [COIN_ETH_PAIR_LOWER_TICK],\n tickUpper: [COIN_ETH_PAIR_UPPER_TICK],\n numDiscoveryPositions: [COIN_ETH_PAIR_NUM_DISCOVERY_POSITIONS],\n maxDiscoverySupplyShare: [COIN_ETH_PAIR_MAX_DISCOVERY_SUPPLY_SHARE],\n }),\n [baseSepolia.id]: encodeMultiCurvePoolConfig({\n currency: zeroAddress,\n tickLower: [COIN_ETH_PAIR_LOWER_TICK],\n tickUpper: [COIN_ETH_PAIR_UPPER_TICK],\n numDiscoveryPositions: [COIN_ETH_PAIR_NUM_DISCOVERY_POSITIONS],\n maxDiscoverySupplyShare: [COIN_ETH_PAIR_MAX_DISCOVERY_SUPPLY_SHARE],\n }),\n};\n\nconst COIN_ZORA_PAIR_LOWER_TICK = -138_000; // ( -250000 in ETH land ~= $23 = -138_000 in Zora token land at .022)\nconst COIN_ZORA_PAIR_UPPER_TICK = -81_000; // (-195_000 ~= 5782 = -81_000 in Zora token land at .022)\nconst COIN_ZORA_PAIR_NUM_DISCOVERY_POSITIONS = 11;\nconst COIN_ZORA_PAIR_MAX_DISCOVERY_SUPPLY_SHARE = parseUnits(\n \"0.05\",\n ZORA_DECIMALS,\n);\n\nexport const COIN_ZORA_PAIR_POOL_CONFIG = {\n [base.id]: encodeMultiCurvePoolConfig({\n currency: ZORA_ADDRESS,\n tickLower: [COIN_ZORA_PAIR_LOWER_TICK],\n tickUpper: [COIN_ZORA_PAIR_UPPER_TICK],\n numDiscoveryPositions: [COIN_ZORA_PAIR_NUM_DISCOVERY_POSITIONS],\n maxDiscoverySupplyShare: [COIN_ZORA_PAIR_MAX_DISCOVERY_SUPPLY_SHARE],\n }),\n};\n","import { coinABI } from \"@zoralabs/protocol-deployments\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport {\n Address,\n TransactionReceipt,\n WalletClient,\n SimulateContractParameters,\n parseEther,\n zeroAddress,\n ContractEventArgsFromTopics,\n parseEventLogs,\n} from \"viem\";\nimport { baseSepolia } from \"viem/chains\";\nimport { GenericPublicClient } from \"src/utils/genericPublicClient\";\nimport { getAttribution } from \"../utils/attribution\";\n// Define trade event args type\n\nexport type SellEventArgs = ContractEventArgsFromTopics<\n typeof coinABI,\n \"CoinSell\"\n>;\nexport type BuyEventArgs = ContractEventArgsFromTopics<\n typeof coinABI,\n \"CoinBuy\"\n>;\n\nexport type TradeEventArgs = SellEventArgs | BuyEventArgs;\n\n// We'll use this address to ensure it will have funds to simulate an eth trade.\n// @dev: This only works on OP chains and is a fix for a bug. Another approach should be taken long term.\nconst OP_BRIDGE_ADDRESS =\n \"0x4200000000000000000000000000000000000016\" as Address;\n\n/**\n * Simulates a buy order to get the expected output amount\n * @param {Object} params - The simulation parameters\n * @param {Address} params.target - The target coin contract address\n * @param {bigint} params.requestedOrderSize - The desired input amount for the buy\n * @param {PublicClient} params.publicClient - The viem public client instance\n * @returns {Promise<{orderSize: bigint, amountOut: bigint}>} The simulated order size and output amount\n */\nexport async function simulateBuy({\n target,\n requestedOrderSize,\n publicClient,\n}: {\n target: Address;\n requestedOrderSize: bigint;\n publicClient: GenericPublicClient;\n}): Promise<{ orderSize: bigint; amountOut: bigint }> {\n const numberResult = await publicClient.simulateContract({\n address: target,\n abi: coinABI,\n functionName: \"buy\",\n dataSuffix: getAttribution(),\n args: [\n OP_BRIDGE_ADDRESS,\n requestedOrderSize,\n 0n, // minAmountOut\n 0n, // sqrtPriceLimitX96\n zeroAddress, // tradeReferrer\n ],\n // We want to ensure that the multicall3 contract has enough ETH to buy in the simulation\n stateOverride: [\n {\n address: baseSepolia.contracts.multicall3.address,\n balance: parseEther(\"10000000\"),\n },\n ],\n });\n const orderSize = numberResult.result[0];\n const amountOut = numberResult.result[1];\n return { orderSize, amountOut };\n}\n\n/**\n * Parameters for creating a trade call\n * @typedef {Object} TradeParams\n * @property {'sell' | 'buy'} direction - The trade direction\n * @property {Address} target - The target coin contract address\n * @property {Object} args - The trade arguments\n * @property {Address} args.recipient - The recipient of the trade output\n * @property {bigint} args.orderSize - The size of the order\n * @property {bigint} [args.minAmountOut] - The minimum amount to receive\n * @property {bigint} [args.sqrtPriceLimitX96] - The price limit for the trade\n * @property {Address} [args.tradeReferrer] - The referrer address for the trade\n */\nexport type TradeParams = {\n direction: \"sell\" | \"buy\";\n target: Address;\n args: {\n recipient: Address;\n orderSize: bigint;\n minAmountOut?: bigint;\n sqrtPriceLimitX96?: bigint;\n tradeReferrer?: Address;\n };\n};\n\n/**\n * Creates a trade call parameters object for buy or sell\n * @param {TradeParams} params - The trade parameters\n * @returns {SimulateContractParameters} The contract call parameters\n */\nexport function tradeCoinCall({\n target,\n direction,\n args: {\n recipient,\n orderSize,\n minAmountOut = 0n,\n sqrtPriceLimitX96 = 0n,\n tradeReferrer = zeroAddress,\n },\n}: TradeParams): SimulateContractParameters {\n return {\n abi: coinABI,\n functionName: direction,\n address: target,\n args: [\n recipient,\n orderSize,\n minAmountOut,\n sqrtPriceLimitX96,\n tradeReferrer,\n ],\n value: direction === \"buy\" ? orderSize : 0n,\n } as const;\n}\n\n/**\n * Gets the trade event from transaction receipt logs\n * @param {TransactionReceipt} receipt - The transaction receipt containing the logs\n * @param {'buy' | 'sell'} direction - The direction of the trade\n * @returns {TradeEventArgs | undefined} The decoded trade event args if found\n */\nexport function getTradeFromLogs(\n receipt: TransactionReceipt,\n direction: \"buy\" | \"sell\",\n): TradeEventArgs | undefined {\n const eventLogs = parseEventLogs({\n abi: coinABI,\n logs: receipt.logs,\n });\n\n if (direction === \"buy\") {\n return eventLogs.find((log) => log.eventName === \"CoinBuy\")?.args;\n }\n return eventLogs.find((log) => log.eventName === \"CoinSell\")?.args;\n}\n\n/**\n * Executes a trade transaction\n * @param {TradeParams} params - The trade parameters\n * @param {PublicClient} publicClient - The viem public client instance\n * @param {WalletClient} walletClient - The viem wallet client instance\n * @returns {Promise<{\n * hash: `0x${string}`,\n * receipt: TransactionReceipt,\n * trade: TradeEventArgs | undefined\n * }>} The transaction result with trade details\n */\nexport async function tradeCoin(\n params: TradeParams,\n walletClient: WalletClient,\n publicClient: GenericPublicClient,\n) {\n validateClientNetwork(publicClient);\n const { request } = await publicClient.simulateContract({\n ...tradeCoinCall(params),\n account: walletClient.account,\n });\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const trade = getTradeFromLogs(receipt, params.direction);\n\n return {\n hash,\n receipt,\n trade,\n };\n}\n","import { coinABI, iUniswapV3PoolABI } from \"@zoralabs/protocol-deployments\";\nimport {\n SUPERCHAIN_WETH_ADDRESS,\n USDC_WETH_POOLS_BY_CHAIN,\n} from \"../constants\";\nimport { GenericPublicClient } from \"../utils/genericPublicClient\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport {\n Address,\n erc20Abi,\n formatEther,\n isAddressEqual,\n zeroAddress,\n} from \"viem\";\n\ntype Slot0Result = {\n sqrtPriceX96: bigint;\n tick: number;\n observationIndex: number;\n observationCardinality: number;\n observationCardinalityNext: number;\n feeProtocol: number;\n unlocked: boolean;\n};\n\ntype PricingResult = {\n eth: bigint;\n usdc: bigint | null;\n usdcDecimal: number | null;\n ethDecimal: number;\n};\n\n/**\n * Represents the current state of a coin\n * @typedef {Object} OnchainCoinDetails\n * @property {bigint} balance - The user's balance of the coin\n * @property {PricingResult} marketCap - The market cap of the coin\n * @property {PricingResult} liquidity - The liquidity of the coin\n * @property {Address} pool - Pool address\n * @property {Slot0Result} poolState - Current state of the UniswapV3 pool\n * @property {Address[]} owners - List of owners for the coin\n * @property {Address} payoutRecipient - The payout recipient address\n */\nexport type OnchainCoinDetails = {\n balance: bigint;\n marketCap: PricingResult;\n liquidity: PricingResult;\n pool: Address;\n poolState: Slot0Result;\n owners: readonly Address[];\n payoutRecipient: Address;\n};\n\n/**\n * Gets the current state of a coin for a user\n * @param {Object} params - The query parameters\n * @param {Address} params.coin - The coin contract address\n * @param {Address} params.user - The user address to check balance for\n * @param {PublicClient} params.publicClient - The viem public client instance\n * @returns {Promise<OnchainCoinDetails>} The coin's current state\n */\nexport async function getOnchainCoinDetails({\n coin,\n user = zeroAddress,\n publicClient,\n}: {\n coin: Address;\n user?: Address;\n publicClient: GenericPublicClient;\n}): Promise<OnchainCoinDetails> {\n validateClientNetwork(publicClient);\n const [balance, pool, owners, payoutRecipient] = await publicClient.multicall(\n {\n contracts: [\n {\n address: coin,\n abi: coinABI,\n functionName: \"balanceOf\",\n args: [user],\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"poolAddress\",\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"owners\",\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"payoutRecipient\",\n },\n ],\n allowFailure: false,\n },\n );\n\n const USDC_WETH_POOL = USDC_WETH_POOLS_BY_CHAIN[publicClient.chain?.id || 0];\n\n const [\n coinWethPoolSlot0,\n coinWethPoolToken0,\n coinReservesRaw,\n coinTotalSupply,\n wethReservesRaw,\n usdcWethSlot0,\n ] = await publicClient.multicall({\n contracts: [\n {\n address: pool,\n abi: iUniswapV3PoolABI,\n functionName: \"slot0\",\n },\n {\n address: pool,\n abi: iUniswapV3PoolABI,\n functionName: \"token0\",\n },\n {\n address: coin,\n abi: erc20Abi,\n functionName: \"balanceOf\",\n args: [pool],\n },\n {\n address: coin,\n abi: coinABI,\n functionName: \"totalSupply\",\n },\n {\n address: SUPERCHAIN_WETH_ADDRESS,\n abi: erc20Abi,\n functionName: \"balanceOf\",\n args: [pool],\n },\n {\n address: USDC_WETH_POOL ?? coin,\n abi: iUniswapV3PoolABI,\n functionName: \"slot0\",\n },\n ],\n allowFailure: false,\n });\n\n const wethPriceInUsdc = USDC_WETH_POOL\n ? uniswapV3SqrtPriceToBigIntScaled(\n usdcWethSlot0.sqrtPriceX96,\n 18,\n 6,\n true,\n 18,\n )\n : null;\n\n const coinPriceInWeth = uniswapV3SqrtPriceToBigIntScaled(\n coinWethPoolSlot0.sqrtPriceX96,\n 18,\n 18,\n isAddressEqual(coinWethPoolToken0, coin),\n 18,\n );\n\n // Divide by 10^18 to remove percision from `coinPriceInWeth` after math since bigint is decimal.\n const marketCap = (coinPriceInWeth * coinTotalSupply) / 10n ** 18n;\n\n const wethLiquidity = wethReservesRaw;\n // Divide by 10^18 to remove percision from `coinPriceInWeth` after math since bigint is decimal.\n const tokenLiquidity = (coinReservesRaw * coinPriceInWeth) / 10n ** 18n;\n\n return {\n balance,\n pool,\n owners,\n payoutRecipient,\n marketCap: convertEthOutput(marketCap, wethPriceInUsdc),\n liquidity: convertEthOutput(\n wethLiquidity + tokenLiquidity,\n wethPriceInUsdc,\n ),\n poolState: coinWethPoolSlot0,\n };\n}\n\nfunction convertEthOutput(amountETH: bigint, wethToUsdc: bigint | null) {\n return {\n eth: amountETH,\n ethDecimal: parseFloat(formatEther(amountETH)),\n usdc: wethToUsdc ? amountETH * wethToUsdc : null,\n usdcDecimal: wethToUsdc\n ? parseFloat(formatEther((amountETH * wethToUsdc) / 10n ** 18n))\n : null,\n };\n}\n\nfunction uniswapV3SqrtPriceToBigIntScaled(\n sqrtPriceX96: bigint,\n token0Decimals: number,\n token1Decimals: number,\n isToken0Coin: boolean,\n scaleDecimals: number = 18,\n): bigint {\n // (sqrtPrice^2 / 2^192) => ratio\n // We'll do: ratioScaled = (sqrtPrice^2 * 10^scaleDecimals) / 2^192\n const numerator = sqrtPriceX96 * sqrtPriceX96;\n const denominator = 2n ** 192n;\n const scaleFactor = 10n ** BigInt(scaleDecimals);\n\n // raw ratioScaled\n let ratioScaled = (numerator * scaleFactor) / denominator; // BigInt\n\n // Adjust for difference in decimals:\n // ratioScaled *= 10^(dec0 - dec1)\n const decimalsDiff = BigInt(token0Decimals - token1Decimals);\n if (decimalsDiff > 0n) {\n ratioScaled *= 10n ** decimalsDiff;\n } else if (decimalsDiff < 0n) {\n ratioScaled /= 10n ** -decimalsDiff;\n }\n\n if (!isToken0Coin) {\n // We want the reciprocal: coin is token1 => coinPriceInToken0 = 1 / ratio\n // But we also want it scaled by 10^scaleDecimals\n // reciprocalScaled = (10^scaleDecimals * 10^(decimalsDiff)) / ratioScaled\n // (assuming ratioScaled != 0)\n if (ratioScaled === 0n) {\n return 0n; // or some huge number representing infinity\n }\n ratioScaled = (scaleFactor * scaleFactor) / ratioScaled;\n // or if we already included decimalsDiff above, handle carefully.\n }\n\n return ratioScaled;\n}\n","import { coinABI } from \"@zoralabs/protocol-deployments\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport {\n Address,\n parseEventLogs,\n SimulateContractParameters,\n WalletClient,\n} from \"viem\";\nimport { GenericPublicClient } from \"src/utils/genericPublicClient\";\nimport { getAttribution } from \"../utils/attribution\";\n\nexport type UpdateCoinURIArgs = {\n coin: Address;\n newURI: string;\n};\n\nexport function updateCoinURICall({\n newURI,\n coin,\n}: UpdateCoinURIArgs): SimulateContractParameters {\n if (!newURI.startsWith(\"ipfs://\")) {\n throw new Error(\"URI needs to be an ipfs:// prefix uri\");\n }\n\n return {\n abi: coinABI,\n address: coin,\n functionName: \"setContractURI\",\n args: [newURI],\n dataSuffix: getAttribution(),\n };\n}\n\nexport async function updateCoinURI(\n args: UpdateCoinURIArgs,\n walletClient: WalletClient,\n publicClient: GenericPublicClient,\n) {\n validateClientNetwork(publicClient);\n const call = updateCoinURICall(args);\n const { request } = await publicClient.simulateContract({\n ...call,\n account: walletClient.account!,\n });\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const eventLogs = parseEventLogs({ abi: coinABI, logs: receipt.logs });\n const uriUpdated = eventLogs.find(\n (log) => log.eventName === \"ContractURIUpdated\",\n );\n\n return { hash, receipt, uriUpdated };\n}\n","import { coinABI } from \"@zoralabs/protocol-deployments\";\nimport { validateClientNetwork } from \"../utils/validateClientNetwork\";\nimport {\n Address,\n parseEventLogs,\n SimulateContractParameters,\n WalletClient,\n} from \"viem\";\nimport { GenericPublicClient } from \"src/utils/genericPublicClient\";\nimport { getAttribution } from \"../utils/attribution\";\n\nexport type UpdatePayoutRecipientArgs = {\n coin: Address;\n newPayoutRecipient: string;\n};\n\nexport function updatePayoutRecipientCall({\n newPayoutRecipient,\n coin,\n}: UpdatePayoutRecipientArgs): SimulateContractParameters {\n return {\n abi: coinABI,\n address: coin,\n functionName: \"setPayoutRecipient\",\n args: [newPayoutRecipient],\n dataSuffix: getAttribution(),\n };\n}\n\nexport async function updatePayoutRecipient(\n args: UpdatePayoutRecipientArgs,\n walletClient: WalletClient,\n publicClient: GenericPublicClient,\n) {\n validateClientNetwork(publicClient);\n const call = updatePayoutRecipientCall(args);\n const { request } = await publicClient.simulateContract({\n ...call,\n account: walletClient.account!,\n });\n const hash = await walletClient.writeContract(request);\n const receipt = await publicClient.waitForTransactionReceipt({ hash });\n const eventLogs = parseEventLogs({ abi: coinABI, logs: receipt.logs });\n const payoutRecipientUpdated = eventLogs.find(\n (log) => log.eventName === \"CoinPayoutRecipientUpdated\",\n );\n\n return { hash, receipt, payoutRecipientUpdated };\n}\n","// This file is auto-generated by @hey-api/openapi-ts\n\nimport type { ClientOptions } from \"./types.gen\";\nimport {\n type Config,\n type ClientOptions as DefaultClientOptions,\n createClient,\n createConfig,\n} from \"@hey-api/client-fetch\";\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> =\n (\n override?: Config<DefaultClientOptions & T>,\n ) => Config<Required<DefaultClientOptions> & T>;\n\nexport const client = createClient(\n createConfig<ClientOptions>({\n baseUrl: \"https://api-sdk.zora.engineering/\",\n }),\n);\n","// This file is auto-generated by @hey-api/openapi-ts\n\nimport type {\n Options as ClientOptions,\n TDataShape,\n Client,\n} from \"@hey-api/client-fetch\";\nimport type {\n GetCoinData,\n GetCoinResponse,\n GetCoinCommentsData,\n GetCoinCommentsResponse,\n GetCoinsData,\n GetCoinsResponse,\n GetExploreData,\n GetExploreResponse,\n GetProfileData,\n GetProfileResponse,\n GetProfileBalancesData,\n GetProfileBalancesResponse,\n} from \"./types.gen\";\nimport { client as _heyApiClient } from \"./client.gen\";\n\nexport type Options<\n TData extends TDataShape = TDataShape,\n ThrowOnError extends boolean = boolean,\n> = ClientOptions<TData, ThrowOnError> & {\n /**\n * You can provide a client instance returned by `createClient()` instead of\n * individual options. This might be also useful if you want to implement a\n * custom client.\n */\n client?: Client;\n /**\n * You can pass arbitrary values through the `meta` object. This can be\n * used to access values that aren't defined as part of the SDK function.\n */\n meta?: Record<string, unknown>;\n};\n\n/**\n * zoraSDK_coin query\n */\nexport const getCoin = <ThrowOnError extends boolean = false>(\n options: Options<GetCoinData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetCoinResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/coin\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_coinComments query\n */\nexport const getCoinComments = <ThrowOnError extends boolean = false>(\n options: Options<GetCoinCommentsData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetCoinCommentsResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/coinComments\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_coins query\n */\nexport const getCoins = <ThrowOnError extends boolean = false>(\n options: Options<GetCoinsData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetCoinsResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/coins\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_explore query\n */\nexport const getExplore = <ThrowOnError extends boolean = false>(\n options: Options<GetExploreData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetExploreResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/explore\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_profile query\n */\nexport const getProfile = <ThrowOnError extends boolean = false>(\n options: Options<GetProfileData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetProfileResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/profile\",\n ...options,\n });\n};\n\n/**\n * zoraSDK_profileBalances query\n */\nexport const getProfileBalances = <ThrowOnError extends boolean = false>(\n options: Options<GetProfileBalancesData, ThrowOnError>,\n) => {\n return (options.client ?? _heyApiClient).get<\n GetProfileBalancesResponse,\n unknown,\n ThrowOnError\n >({\n url: \"/profileBalances\",\n ...options,\n });\n};\n","let apiKey: string | undefined;\nexport function setApiKey(key: string) {\n apiKey = key;\n}\n\nexport function getApiKeyMeta() {\n if (!apiKey) {\n return {};\n }\n return {\n headers: {\n \"api-key\": apiKey,\n },\n };\n}\n","import {\n GetCoinCommentsData,\n GetCoinCommentsResponse,\n GetCoinData,\n GetCoinResponse,\n GetCoinsData,\n GetCoinsResponse,\n GetProfileBalancesData,\n GetProfileBalancesResponse,\n GetProfileData,\n GetProfileResponse,\n} from \"../client/types.gen\";\nimport {\n getCoin as getCoinSDK,\n getCoins as getCoinsSDK,\n getCoinComments as getCoinCommentsSDK,\n getProfile as getProfileSDK,\n getProfileBalances as getProfileBalancesSDK,\n} from \"../client/sdk.gen\";\nimport { getApiKeyMeta } from \"./api-key\";\nimport { RequestOptionsType } from \"./query-types\";\nimport { RequestResult } from \"@hey-api/client-fetch\";\n\nexport type { RequestResult };\n\ntype GetCoinQuery = GetCoinData[\"query\"];\nexport type { GetCoinQuery, GetCoinData };\nexport type { GetCoinResponse } from \"../client/types.gen\";\n\nexport type CoinData = NonNullable<GetCoinResponse[\"zora20Token\"]>;\n\nexport const getCoin = async (\n query: GetCoinQuery,\n options?: RequestOptionsType<GetCoinData>,\n): Promise<RequestResult<GetCoinResponse>> => {\n return await getCoinSDK({\n ...options,\n query,\n meta: getApiKeyMeta(),\n });\n};\n\ntype GetCoinsQuery = GetCoinsData[\"query\"];\nexport type { GetCoinsQuery, GetCoinsData };\nexport type { GetCoinsResponse } from \"../client/types.gen\";\n\nexport const getCoins = async (\n query: GetCoinsQuery,\n options?: RequestOptionsType<GetCoinsData>,\n): Promise<RequestResult<GetCoinsResponse>> => {\n return await getCoinsSDK({\n query: {\n coins: query.coins.map((coinData) => JSON.stringify(coinData)) as any,\n },\n meta: getApiKeyMeta(),\n ...options,\n });\n};\n\ntype GetCoinCommentsQuery = GetCoinCommentsData[\"query\"];\nexport type { GetCoinCommentsQuery, GetCoinCommentsData };\nexport type { GetCoinCommentsResponse } from \"../client/types.gen\";\n\nexport const getCoinComments = async (\n query: GetCoinCommentsQuery,\n options?: RequestOptionsType<GetCoinCommentsData>,\n): Promise<RequestResult<GetCoinCommentsResponse>> => {\n return await getCoinCommentsSDK({\n query,\n meta: getApiKeyMeta(),\n ...options,\n });\n};\n\ntype GetProfileQuery = GetProfileData[\"query\"];\nexport type { GetProfileQuery, GetProfileData };\nexport type { GetProfileResponse } from \"../client/types.gen\";\n\nexport const getProfile = async (\n query: GetProfileQuery,\n options?: RequestOptionsType<GetProfileData>,\n): Promise<RequestResult<GetProfileResponse>> => {\n return await getProfileSDK({\n query,\n meta: getApiKeyMeta(),\n ...options,\n });\n};\n\ntype GetProfileBalancesQuery = GetProfileBalancesData[\"query\"];\nexport type { GetProfileBalancesQuery, GetProfileBalancesData };\nexport type { GetProfileBalancesResponse } from \"../client/types.gen\";\n\nexport const getProfileBalances = async (\n query: GetProfileBalancesQuery,\n options?: RequestOptionsType<GetProfileBalancesData>,\n): Promise<RequestResult<GetProfileBalancesResponse>> => {\n return await getProfileBalancesSDK({\n query,\n meta: getApiKeyMeta(),\n ...options,\n });\n};\n","import { getExplore as getExploreSDK } from \"../client/sdk.gen\";\nimport type { GetExploreData, GetExploreResponse } from \"../client/types.gen\";\nimport { getApiKeyMeta } from \"./api-key\";\nimport { RequestOptionsType } from \"./query-types\";\n\n/**\n * The inner type for the explore queries that omits listType.\n * This is used to create the query object for the explore queries.\n */\nexport type QueryRequestType = Omit<GetExploreData[\"query\"], \"listType\">;\n\ntype ExploreResponse = { data?: GetExploreResponse };\n\nexport type ListType = GetExploreData[\"query\"][\"listType\"];\n\nexport type { ExploreResponse };\n\nexport type { GetExploreData };\n\n/**\n * Creates an explore query with the specified list type\n */\nconst createExploreQuery = (\n query: QueryRequestType,\n listType: ListType,\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n getExploreSDK({\n ...options,\n query: { ...query, listType },\n meta: getApiKeyMeta(),\n });\n\n/** Get top gaining coins */\nexport const getCoinsTopGainers = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"TOP_GAINERS\", options);\n\n/** Get coins with highest 24h volume */\nexport const getCoinsTopVolume24h = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"TOP_VOLUME_24H\", options);\n\n/** Get most valuable coins */\nexport const getCoinsMostValuable = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"MOST_VALUABLE\", options);\n\n/** Get newly created coins */\nexport const getCoinsNew = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> => createExploreQuery(query, \"NEW\", options);\n\n/** Get recently traded coins */\nexport const getCoinsLastTraded = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"LAST_TRADED\", options);\n\n/** Get recently traded unique coins */\nexport const getCoinsLastTradedUnique = (\n query: QueryRequestType = {},\n options?: RequestOptionsType<GetExploreData>,\n): Promise<ExploreResponse> =>\n createExploreQuery(query, \"LAST_TRADED_UNIQUE\", options);\n"],"mappings":";AAAA,SAAS,kBAAkB,0BAA0B;AACrD;AAAA,EAME;AAAA,EACA,eAAAA;AAAA,EACA,aAAAC;AAAA,EACA;AAAA,OAGK;;;ACbP,SAAS,sBAAsB,8BAA8B;AAE7D,SAAS,YAAY;AAGd,IAAM,uBAAuB,uBAAuB,MAAM;AAE1D,IAAM,0BACX;AAEK,IAAM,2BAAoD;AAAA,EAC/D,CAAC,KAAK,EAAE,GAAG;AACb;;;ACXA,SAAS,QAAAC,OAAM,mBAAmB;AAE3B,IAAM,wBAAwB,CACnC,iBACG;AACH,QAAM,gBAAgB,cAAc,OAAO;AAC3C,MAAI,kBAAkBA,MAAK,IAAI;AAC7B;AAAA,EACF;AACA,MAAI,kBAAkB,YAAY,IAAI;AACpC;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;;;ACLO,SAAS,4BAA4B,KAAuB;AACjE,MAAI,IAAI,WAAW,SAAS,GAAG;AAC7B,WAAO,IAAI;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,MAAI,IAAI,WAAW,OAAO,GAAG;AAC3B,WAAO,IAAI,QAAQ,SAAS,q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B,OACA,YACoD;AACpD,SAAO,MAAM,gBAAmB;AAAA,IAC9B;AAAA,IACA,MAAM,cAAc;AAAA,IACpB,GAAG;AAAA,EACL,CAAC;AACH;AAMO,IAAMC,cAAa,OACxB,OACA,YAC+C;AAC/C,SAAO,MAAM,WAAc;AAAA,IACzB;AAAA,IACA,MAAM,cAAc;AAAA,IACpB,GAAG;AAAA,EACL,CAAC;AACH;AAMO,IAAMC,sBAAqB,OAChC,OACA,YACuD;AACvD,SAAO,MAAM,mBAAsB;AAAA,IACjC;AAAA,IACA,MAAM,cAAc;AAAA,IACpB,GAAG;AAAA,EACL,CAAC;AACH;;;AChFA,IAAM,qBAAqB,CACzB,OACA,UACA,YAEA,WAAc;AAAA,EACZ,GAAG;AAAA,EACH,OAAO,EAAE,GAAG,OAAO,SAAS;AAAA,EAC5B,MAAM,cAAc;AACtB,CAAC;AAGI,IAAM,qBAAqB,CAChC,QAA0B,CAAC,GAC3B,YAEA,mBAAmB,OAAO,eAAe,OAAO;AAG3C,IAAM,uBAAuB,CAClC,QAA0B,CAAC,GAC3B,YAEA,mBAAmB,OAAO,kBAAkB,OAAO;AAG9C,IAAM,uBAAuB,CAClC,QAA0B,CAAC,GAC3B,YAEA,mBAAmB,OAAO,iBAAiB,OAAO;AAG7C,IAAM,cAAc,CACzB,QAA0B,CAAC,GAC3B,YAC6B,mBAAmB,OAAO,OAAO,OAAO;AAGhE,IAAM,qBAAqB,CAChC,QAA0B,CAAC,GAC3B,YAEA,mBAAmB,OAAO,eAAe,OAAO;AAG3C,IAAM,2BAA2B,CACtC,QAA0B,CAAC,GAC3B,YAEA,mBAAmB,OAAO,sBAAsB,OAAO;","names":["zeroAddress","keccak256","base","base","baseSepolia","base","baseSepolia","DeployCurrency","baseSepolia","base","zeroAddress","keccak256","zeroAddress","parseEventLogs","baseSepolia","zeroAddress","baseSepolia","parseEventLogs","coinABI","zeroAddress","coinABI","coinABI","parseEventLogs","coinABI","parseEventLogs","coinABI","parseEventLogs","coinABI","parseEventLogs","getCoin","getCoins","getCoinComments","getProfile","getProfileBalances"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanAndValidateMetadataURI.d.ts","sourceRoot":"","sources":["../../src/metadata/cleanAndValidateMetadataURI.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GACxB,UAAU,MAAM,EAAE,GAClB,QAAQ,MAAM,EAAE,GAChB,QAAQ,MAAM,EAAE,GAChB,WAAW,MAAM,EAAE,CAAC;AAExB;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"cleanAndValidateMetadataURI.d.ts","sourceRoot":"","sources":["../../src/metadata/cleanAndValidateMetadataURI.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GACxB,UAAU,MAAM,EAAE,GAClB,QAAQ,MAAM,EAAE,GAChB,QAAQ,MAAM,EAAE,GAChB,WAAW,MAAM,EAAE,CAAC;AAExB;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,gBAAgB,UAmBhE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* =========================
|
|
3
|
+
* COIN_ETH_PAIR_POOL_CONFIG
|
|
4
|
+
* =========================
|
|
5
|
+
*/
|
|
6
|
+
export declare const ZORA_ADDRESS = "0x1111111111166b7fe7bd91427724b487980afc69";
|
|
7
|
+
export declare const COIN_ETH_PAIR_POOL_CONFIG: {
|
|
8
|
+
8453: `0x${string}`;
|
|
9
|
+
84532: `0x${string}`;
|
|
10
|
+
};
|
|
11
|
+
export declare const COIN_ZORA_PAIR_POOL_CONFIG: {
|
|
12
|
+
8453: `0x${string}`;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=poolConfigUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poolConfigUtils.d.ts","sourceRoot":"","sources":["../../src/utils/poolConfigUtils.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AAEH,eAAO,MAAM,YAAY,+CAA+C,CAAC;AAOzE,eAAO,MAAM,yBAAyB;;;CAerC,CAAC;AAUF,eAAO,MAAM,0BAA0B;;CAQtC,CAAC"}
|
package/package.json
CHANGED
|
@@ -6,40 +6,71 @@ import {
|
|
|
6
6
|
SimulateContractParameters,
|
|
7
7
|
ContractEventArgsFromTopics,
|
|
8
8
|
parseEventLogs,
|
|
9
|
+
zeroAddress,
|
|
10
|
+
keccak256,
|
|
11
|
+
toBytes,
|
|
9
12
|
Hex,
|
|
13
|
+
Account,
|
|
10
14
|
} from "viem";
|
|
11
15
|
import { COIN_FACTORY_ADDRESS } from "../constants";
|
|
12
16
|
import { validateClientNetwork } from "../utils/validateClientNetwork";
|
|
13
17
|
import { GenericPublicClient } from "src/utils/genericPublicClient";
|
|
14
18
|
import { validateMetadataURIContent, ValidMetadataURI } from "src/metadata";
|
|
15
19
|
import { getAttribution } from "../utils/attribution";
|
|
20
|
+
import { base, baseSepolia } from "viem/chains";
|
|
21
|
+
import {
|
|
22
|
+
COIN_ETH_PAIR_POOL_CONFIG,
|
|
23
|
+
COIN_ZORA_PAIR_POOL_CONFIG,
|
|
24
|
+
} from "src/utils/poolConfigUtils";
|
|
16
25
|
|
|
17
26
|
export type CoinDeploymentLogArgs = ContractEventArgsFromTopics<
|
|
18
27
|
typeof zoraFactoryImplABI,
|
|
19
|
-
"
|
|
28
|
+
"CoinCreatedV4"
|
|
20
29
|
>;
|
|
21
30
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
export enum DeployCurrency {
|
|
32
|
+
ZORA = 1,
|
|
33
|
+
ETH = 2,
|
|
34
|
+
}
|
|
25
35
|
|
|
26
36
|
export type CreateCoinArgs = {
|
|
27
37
|
name: string;
|
|
28
38
|
symbol: string;
|
|
29
39
|
uri: ValidMetadataURI;
|
|
40
|
+
chainId: number;
|
|
30
41
|
owners?: Address[];
|
|
31
42
|
payoutRecipient: Address;
|
|
32
43
|
platformReferrer?: Address;
|
|
33
|
-
|
|
44
|
+
currency?: DeployCurrency;
|
|
34
45
|
};
|
|
35
46
|
|
|
47
|
+
function getPoolConfig(currency: DeployCurrency, chainId: number) {
|
|
48
|
+
if (currency === DeployCurrency.ZORA && chainId == baseSepolia.id) {
|
|
49
|
+
throw new Error("ZORA is not supported on Base Sepolia");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
switch (currency) {
|
|
53
|
+
case DeployCurrency.ZORA:
|
|
54
|
+
return COIN_ZORA_PAIR_POOL_CONFIG[
|
|
55
|
+
chainId as keyof typeof COIN_ZORA_PAIR_POOL_CONFIG
|
|
56
|
+
];
|
|
57
|
+
case DeployCurrency.ETH:
|
|
58
|
+
return COIN_ETH_PAIR_POOL_CONFIG[
|
|
59
|
+
chainId as keyof typeof COIN_ETH_PAIR_POOL_CONFIG
|
|
60
|
+
];
|
|
61
|
+
default:
|
|
62
|
+
throw new Error("Invalid currency");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
36
66
|
export async function createCoinCall({
|
|
37
67
|
name,
|
|
38
68
|
symbol,
|
|
39
69
|
uri,
|
|
40
70
|
owners,
|
|
41
71
|
payoutRecipient,
|
|
42
|
-
|
|
72
|
+
currency,
|
|
73
|
+
chainId = base.id,
|
|
43
74
|
platformReferrer = "0x0000000000000000000000000000000000000000",
|
|
44
75
|
}: CreateCoinArgs): Promise<
|
|
45
76
|
SimulateContractParameters<typeof zoraFactoryImplABI, "deploy">
|
|
@@ -48,9 +79,11 @@ export async function createCoinCall({
|
|
|
48
79
|
owners = [payoutRecipient];
|
|
49
80
|
}
|
|
50
81
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
82
|
+
if (!currency) {
|
|
83
|
+
currency = chainId !== base.id ? DeployCurrency.ETH : DeployCurrency.ZORA;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const poolConfig = getPoolConfig(currency, chainId);
|
|
54
87
|
|
|
55
88
|
// This will throw an error if the metadata is not valid
|
|
56
89
|
await validateMetadataURIContent(uri);
|
|
@@ -67,9 +100,10 @@ export async function createCoinCall({
|
|
|
67
100
|
symbol,
|
|
68
101
|
poolConfig,
|
|
69
102
|
platformReferrer,
|
|
70
|
-
|
|
103
|
+
zeroAddress, // hookAddress
|
|
104
|
+
"0x" as Hex, // hookData
|
|
105
|
+
keccak256(toBytes(Math.random().toString())), // coinSalt
|
|
71
106
|
],
|
|
72
|
-
value: initialPurchaseWei,
|
|
73
107
|
dataSuffix: getAttribution(),
|
|
74
108
|
} as const;
|
|
75
109
|
}
|
|
@@ -86,7 +120,8 @@ export function getCoinCreateFromLogs(
|
|
|
86
120
|
abi: zoraFactoryImplABI,
|
|
87
121
|
logs: receipt.logs,
|
|
88
122
|
});
|
|
89
|
-
|
|
123
|
+
|
|
124
|
+
return eventLogs.find((log) => log.eventName === "CoinCreatedV4")?.args;
|
|
90
125
|
}
|
|
91
126
|
|
|
92
127
|
// Update createCoin to return both receipt and coin address
|
|
@@ -96,6 +131,7 @@ export async function createCoin(
|
|
|
96
131
|
publicClient: GenericPublicClient,
|
|
97
132
|
options?: {
|
|
98
133
|
gasMultiplier?: number;
|
|
134
|
+
account?: Account | Address;
|
|
99
135
|
},
|
|
100
136
|
) {
|
|
101
137
|
validateClientNetwork(publicClient);
|
|
@@ -103,7 +139,7 @@ export async function createCoin(
|
|
|
103
139
|
const createCoinRequest = await createCoinCall(call);
|
|
104
140
|
const { request } = await publicClient.simulateContract({
|
|
105
141
|
...createCoinRequest,
|
|
106
|
-
account: walletClient.account,
|
|
142
|
+
account: options?.account ?? walletClient.account,
|
|
107
143
|
});
|
|
108
144
|
|
|
109
145
|
// Add a 2/5th buffer on gas.
|
package/src/index.ts
CHANGED
|
@@ -21,7 +21,8 @@ export function cleanAndValidateMetadataURI(uri: ValidMetadataURI) {
|
|
|
21
21
|
return uri.replace("ar://", "http://arweave.net/");
|
|
22
22
|
}
|
|
23
23
|
if (uri.startsWith("data:")) {
|
|
24
|
-
|
|
24
|
+
return uri;
|
|
25
|
+
// throw new Error("Data URIs are not supported");
|
|
25
26
|
}
|
|
26
27
|
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
27
28
|
return uri;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { encodeMultiCurvePoolConfig } from "@zoralabs/protocol-deployments";
|
|
2
|
+
import { parseUnits, zeroAddress } from "viem";
|
|
3
|
+
import { base, baseSepolia } from "viem/chains";
|
|
4
|
+
|
|
5
|
+
const ZORA_DECIMALS = 18;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* =========================
|
|
9
|
+
* COIN_ETH_PAIR_POOL_CONFIG
|
|
10
|
+
* =========================
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const ZORA_ADDRESS = "0x1111111111166b7fe7bd91427724b487980afc69";
|
|
14
|
+
|
|
15
|
+
const COIN_ETH_PAIR_LOWER_TICK = -250000;
|
|
16
|
+
const COIN_ETH_PAIR_UPPER_TICK = -195_000;
|
|
17
|
+
const COIN_ETH_PAIR_NUM_DISCOVERY_POSITIONS = 11;
|
|
18
|
+
const COIN_ETH_PAIR_MAX_DISCOVERY_SUPPLY_SHARE = parseUnits("0.05", 18);
|
|
19
|
+
|
|
20
|
+
export const COIN_ETH_PAIR_POOL_CONFIG = {
|
|
21
|
+
[base.id]: encodeMultiCurvePoolConfig({
|
|
22
|
+
currency: zeroAddress,
|
|
23
|
+
tickLower: [COIN_ETH_PAIR_LOWER_TICK],
|
|
24
|
+
tickUpper: [COIN_ETH_PAIR_UPPER_TICK],
|
|
25
|
+
numDiscoveryPositions: [COIN_ETH_PAIR_NUM_DISCOVERY_POSITIONS],
|
|
26
|
+
maxDiscoverySupplyShare: [COIN_ETH_PAIR_MAX_DISCOVERY_SUPPLY_SHARE],
|
|
27
|
+
}),
|
|
28
|
+
[baseSepolia.id]: encodeMultiCurvePoolConfig({
|
|
29
|
+
currency: zeroAddress,
|
|
30
|
+
tickLower: [COIN_ETH_PAIR_LOWER_TICK],
|
|
31
|
+
tickUpper: [COIN_ETH_PAIR_UPPER_TICK],
|
|
32
|
+
numDiscoveryPositions: [COIN_ETH_PAIR_NUM_DISCOVERY_POSITIONS],
|
|
33
|
+
maxDiscoverySupplyShare: [COIN_ETH_PAIR_MAX_DISCOVERY_SUPPLY_SHARE],
|
|
34
|
+
}),
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const COIN_ZORA_PAIR_LOWER_TICK = -138_000; // ( -250000 in ETH land ~= $23 = -138_000 in Zora token land at .022)
|
|
38
|
+
const COIN_ZORA_PAIR_UPPER_TICK = -81_000; // (-195_000 ~= 5782 = -81_000 in Zora token land at .022)
|
|
39
|
+
const COIN_ZORA_PAIR_NUM_DISCOVERY_POSITIONS = 11;
|
|
40
|
+
const COIN_ZORA_PAIR_MAX_DISCOVERY_SUPPLY_SHARE = parseUnits(
|
|
41
|
+
"0.05",
|
|
42
|
+
ZORA_DECIMALS,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export const COIN_ZORA_PAIR_POOL_CONFIG = {
|
|
46
|
+
[base.id]: encodeMultiCurvePoolConfig({
|
|
47
|
+
currency: ZORA_ADDRESS,
|
|
48
|
+
tickLower: [COIN_ZORA_PAIR_LOWER_TICK],
|
|
49
|
+
tickUpper: [COIN_ZORA_PAIR_UPPER_TICK],
|
|
50
|
+
numDiscoveryPositions: [COIN_ZORA_PAIR_NUM_DISCOVERY_POSITIONS],
|
|
51
|
+
maxDiscoverySupplyShare: [COIN_ZORA_PAIR_MAX_DISCOVERY_SUPPLY_SHARE],
|
|
52
|
+
}),
|
|
53
|
+
};
|