@zoralabs/protocol-sdk 0.9.6 → 0.11.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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +17 -0
- package/dist/anvil.d.ts +11 -1
- package/dist/anvil.d.ts.map +1 -1
- package/dist/apis/multicall3.d.ts +9 -0
- package/dist/apis/multicall3.d.ts.map +1 -0
- package/dist/apis/subgraph-getter.d.ts +9 -0
- package/dist/apis/subgraph-getter.d.ts.map +1 -0
- package/dist/create/1155-create-helper.test.d.ts +3 -0
- package/dist/create/1155-create-helper.test.d.ts.map +1 -0
- package/dist/create/contract-getter.d.ts +3 -6
- package/dist/create/contract-getter.d.ts.map +1 -1
- package/dist/fixtures/contract-setup.d.ts +16 -0
- package/dist/fixtures/contract-setup.d.ts.map +1 -0
- package/dist/fixtures/mint-query-results.d.ts +10 -0
- package/dist/fixtures/mint-query-results.d.ts.map +1 -0
- package/dist/fixtures/rewards-query-results.d.ts +6 -0
- package/dist/fixtures/rewards-query-results.d.ts.map +1 -0
- package/dist/index.cjs +989 -238
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1013 -238
- package/dist/index.js.map +1 -1
- package/dist/mint/subgraph-mint-getter.d.ts +3 -5
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -1
- package/dist/rewards/rewards-client.d.ts +34 -0
- package/dist/rewards/rewards-client.d.ts.map +1 -0
- package/dist/rewards/rewards-queries.d.ts +34 -0
- package/dist/rewards/rewards-queries.d.ts.map +1 -0
- package/dist/rewards/subgraph-queries.d.ts +20 -0
- package/dist/rewards/subgraph-queries.d.ts.map +1 -0
- package/dist/rewards/subgraph-rewards-getter.d.ts +15 -0
- package/dist/rewards/subgraph-rewards-getter.d.ts.map +1 -0
- package/dist/sdk.d.ts +9 -0
- package/dist/sdk.d.ts.map +1 -1
- package/dist/secondary/conversions.d.ts +7 -0
- package/dist/secondary/conversions.d.ts.map +1 -0
- package/dist/secondary/secondary-client.d.ts +67 -0
- package/dist/secondary/secondary-client.d.ts.map +1 -0
- package/dist/secondary/slippage.d.ts +25 -0
- package/dist/secondary/slippage.d.ts.map +1 -0
- package/dist/secondary/types.d.ts +37 -0
- package/dist/secondary/types.d.ts.map +1 -0
- package/dist/secondary/uniswap/abis.d.ts +152 -0
- package/dist/secondary/uniswap/abis.d.ts.map +1 -0
- package/dist/secondary/uniswap/uniswapQuote.d.ts +13 -0
- package/dist/secondary/uniswap/uniswapQuote.d.ts.map +1 -0
- package/dist/secondary/uniswap/uniswapQuoteExact.d.ts +37 -0
- package/dist/secondary/uniswap/uniswapQuoteExact.d.ts.map +1 -0
- package/dist/secondary/uniswap/uniswapReserves.d.ts +3 -0
- package/dist/secondary/uniswap/uniswapReserves.d.ts.map +1 -0
- package/dist/secondary/utils.d.ts +10 -0
- package/dist/secondary/utils.d.ts.map +1 -0
- package/dist/sparks/sparks-contracts.d.ts.map +1 -1
- package/dist/types.d.ts +3 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +2 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/apis/multicall3.ts +19 -0
- package/src/apis/subgraph-getter.ts +33 -0
- package/src/create/1155-create-helper.test.ts +18 -18
- package/src/create/contract-getter.ts +7 -29
- package/src/fixtures/contract-setup.ts +57 -0
- package/src/fixtures/mint-query-results.ts +55 -0
- package/src/fixtures/rewards-query-results.ts +25 -0
- package/src/mint/mint-client.test.ts +18 -46
- package/src/mint/subgraph-mint-getter.ts +7 -27
- package/src/rewards/rewards-client.test.ts +310 -0
- package/src/rewards/rewards-client.ts +67 -0
- package/src/rewards/rewards-queries.ts +253 -0
- package/src/rewards/subgraph-queries.ts +49 -0
- package/src/rewards/subgraph-rewards-getter.ts +33 -0
- package/src/sdk.ts +29 -0
- package/src/secondary/conversions.ts +20 -0
- package/src/secondary/secondary-client.test.ts +276 -0
- package/src/secondary/secondary-client.ts +374 -0
- package/src/secondary/slippage.ts +42 -0
- package/src/secondary/types.ts +64 -0
- package/src/secondary/uniswap/abis.ts +20 -0
- package/src/secondary/uniswap/uniswapQuote.ts +134 -0
- package/src/secondary/uniswap/uniswapQuoteExact.ts +114 -0
- package/src/secondary/uniswap/uniswapReserves.ts +34 -0
- package/src/secondary/utils.ts +40 -0
- package/src/sparks/sparks-contracts.ts +1 -3
- package/src/types.ts +6 -7
- package/src/utils.ts +7 -1
package/dist/index.cjs
CHANGED
|
@@ -397,12 +397,12 @@ var require_semver = __commonJS({
|
|
|
397
397
|
this.prerelease = [];
|
|
398
398
|
break;
|
|
399
399
|
case "pre": {
|
|
400
|
-
const
|
|
400
|
+
const base4 = Number(identifierBase) ? 1 : 0;
|
|
401
401
|
if (!identifier && identifierBase === false) {
|
|
402
402
|
throw new Error("invalid increment argument: identifier is empty");
|
|
403
403
|
}
|
|
404
404
|
if (this.prerelease.length === 0) {
|
|
405
|
-
this.prerelease = [
|
|
405
|
+
this.prerelease = [base4];
|
|
406
406
|
} else {
|
|
407
407
|
let i = this.prerelease.length;
|
|
408
408
|
while (--i >= 0) {
|
|
@@ -415,11 +415,11 @@ var require_semver = __commonJS({
|
|
|
415
415
|
if (identifier === this.prerelease.join(".") && identifierBase === false) {
|
|
416
416
|
throw new Error("invalid increment argument: identifier already exists");
|
|
417
417
|
}
|
|
418
|
-
this.prerelease.push(
|
|
418
|
+
this.prerelease.push(base4);
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
421
|
if (identifier) {
|
|
422
|
-
let prerelease = [identifier,
|
|
422
|
+
let prerelease = [identifier, base4];
|
|
423
423
|
if (identifierBase === false) {
|
|
424
424
|
prerelease = [identifier];
|
|
425
425
|
}
|
|
@@ -2551,136 +2551,6 @@ var toContractCreationConfigOrAddress = ({
|
|
|
2551
2551
|
// src/premint/premint-client.ts
|
|
2552
2552
|
var import_protocol_deployments4 = require("@zoralabs/protocol-deployments");
|
|
2553
2553
|
|
|
2554
|
-
// src/retries.ts
|
|
2555
|
-
async function wait(delayMs) {
|
|
2556
|
-
return new Promise((resolve) => {
|
|
2557
|
-
setTimeout(resolve, delayMs);
|
|
2558
|
-
});
|
|
2559
|
-
}
|
|
2560
|
-
var retryInternal = async ({
|
|
2561
|
-
tryFn,
|
|
2562
|
-
maxTries = 3,
|
|
2563
|
-
atTry,
|
|
2564
|
-
linearBackoffMS = 200,
|
|
2565
|
-
shouldRetryOnError = () => true
|
|
2566
|
-
}) => {
|
|
2567
|
-
try {
|
|
2568
|
-
return await tryFn();
|
|
2569
|
-
} catch (err) {
|
|
2570
|
-
if (shouldRetryOnError(err)) {
|
|
2571
|
-
if (atTry <= maxTries) {
|
|
2572
|
-
await wait(atTry * linearBackoffMS);
|
|
2573
|
-
return await retryInternal({
|
|
2574
|
-
tryFn,
|
|
2575
|
-
maxTries,
|
|
2576
|
-
atTry: atTry + 1,
|
|
2577
|
-
linearBackoffMS,
|
|
2578
|
-
shouldRetryOnError
|
|
2579
|
-
});
|
|
2580
|
-
}
|
|
2581
|
-
}
|
|
2582
|
-
throw err;
|
|
2583
|
-
}
|
|
2584
|
-
};
|
|
2585
|
-
var retriesGeneric = async (params) => {
|
|
2586
|
-
return retryInternal({
|
|
2587
|
-
...params,
|
|
2588
|
-
atTry: 1
|
|
2589
|
-
});
|
|
2590
|
-
};
|
|
2591
|
-
|
|
2592
|
-
// src/apis/http-api-base.ts
|
|
2593
|
-
var BadResponseError = class extends Error {
|
|
2594
|
-
constructor(message, status, json) {
|
|
2595
|
-
super(message);
|
|
2596
|
-
this.name = "BadResponseError";
|
|
2597
|
-
this.status = status;
|
|
2598
|
-
this.json = json;
|
|
2599
|
-
}
|
|
2600
|
-
};
|
|
2601
|
-
var get = async (url) => {
|
|
2602
|
-
const response = await fetch(url, { method: "GET" });
|
|
2603
|
-
if (response.status !== 200) {
|
|
2604
|
-
let json;
|
|
2605
|
-
try {
|
|
2606
|
-
json = await response.json();
|
|
2607
|
-
} catch (e) {
|
|
2608
|
-
}
|
|
2609
|
-
throw new BadResponseError(
|
|
2610
|
-
`Invalid response, status ${response.status}`,
|
|
2611
|
-
response.status,
|
|
2612
|
-
json
|
|
2613
|
-
);
|
|
2614
|
-
}
|
|
2615
|
-
return await response.json();
|
|
2616
|
-
};
|
|
2617
|
-
var post = async (url, data) => {
|
|
2618
|
-
const controller = new AbortController();
|
|
2619
|
-
const { signal } = controller;
|
|
2620
|
-
const timeout = 30 * 60 * 1e3;
|
|
2621
|
-
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
2622
|
-
const response = await fetch(url, {
|
|
2623
|
-
method: "POST",
|
|
2624
|
-
headers: {
|
|
2625
|
-
"content-type": "application/json",
|
|
2626
|
-
accept: "application/json"
|
|
2627
|
-
},
|
|
2628
|
-
body: JSON.stringify(data),
|
|
2629
|
-
signal
|
|
2630
|
-
});
|
|
2631
|
-
clearTimeout(timeoutId);
|
|
2632
|
-
if (response.status !== 200) {
|
|
2633
|
-
let json;
|
|
2634
|
-
try {
|
|
2635
|
-
json = await response.json();
|
|
2636
|
-
} catch (e) {
|
|
2637
|
-
}
|
|
2638
|
-
throw new BadResponseError(
|
|
2639
|
-
`Bad response: ${response.status}`,
|
|
2640
|
-
response.status,
|
|
2641
|
-
json
|
|
2642
|
-
);
|
|
2643
|
-
}
|
|
2644
|
-
return await response.json();
|
|
2645
|
-
};
|
|
2646
|
-
var defaultShouldRetry = (err) => {
|
|
2647
|
-
return err instanceof BadResponseError && err.status >= 500;
|
|
2648
|
-
};
|
|
2649
|
-
var retries = async (tryFn, maxTries = 3, linearBackoffMS = 200, shouldRetry = defaultShouldRetry) => {
|
|
2650
|
-
return retriesGeneric({
|
|
2651
|
-
tryFn,
|
|
2652
|
-
maxTries,
|
|
2653
|
-
linearBackoffMS,
|
|
2654
|
-
shouldRetryOnError: shouldRetry
|
|
2655
|
-
});
|
|
2656
|
-
};
|
|
2657
|
-
var httpClient = {
|
|
2658
|
-
get,
|
|
2659
|
-
post,
|
|
2660
|
-
retries
|
|
2661
|
-
};
|
|
2662
|
-
|
|
2663
|
-
// src/apis/subgraph-querier.ts
|
|
2664
|
-
var SubgraphQuerier = class {
|
|
2665
|
-
constructor(httpClient2) {
|
|
2666
|
-
this.httpClient = httpClient2;
|
|
2667
|
-
}
|
|
2668
|
-
async query({
|
|
2669
|
-
subgraphUrl,
|
|
2670
|
-
query,
|
|
2671
|
-
variables
|
|
2672
|
-
}) {
|
|
2673
|
-
const { retries: retries2, post: post2 } = this.httpClient;
|
|
2674
|
-
const result = await retries2(async () => {
|
|
2675
|
-
return await post2(subgraphUrl, {
|
|
2676
|
-
query,
|
|
2677
|
-
variables
|
|
2678
|
-
});
|
|
2679
|
-
});
|
|
2680
|
-
return result?.data;
|
|
2681
|
-
}
|
|
2682
|
-
};
|
|
2683
|
-
|
|
2684
2554
|
// src/mint/subgraph-queries.ts
|
|
2685
2555
|
var NFT_SALE_STRATEGY_FRAGMENT = `
|
|
2686
2556
|
fragment SaleStrategy on SalesStrategyConfig {
|
|
@@ -2807,59 +2677,209 @@ function buildPremintsOfContractQuery({
|
|
|
2807
2677
|
};
|
|
2808
2678
|
}
|
|
2809
2679
|
|
|
2810
|
-
// src/
|
|
2811
|
-
var
|
|
2812
|
-
|
|
2813
|
-
|
|
2680
|
+
// src/apis/subgraph-querier.ts
|
|
2681
|
+
var SubgraphQuerier = class {
|
|
2682
|
+
constructor(httpClient2) {
|
|
2683
|
+
this.httpClient = httpClient2;
|
|
2684
|
+
}
|
|
2685
|
+
async query({
|
|
2686
|
+
subgraphUrl,
|
|
2687
|
+
query,
|
|
2688
|
+
variables
|
|
2689
|
+
}) {
|
|
2690
|
+
const { retries: retries2, post: post2 } = this.httpClient;
|
|
2691
|
+
const result = await retries2(async () => {
|
|
2692
|
+
return await post2(subgraphUrl, {
|
|
2693
|
+
query,
|
|
2694
|
+
variables
|
|
2695
|
+
});
|
|
2696
|
+
});
|
|
2697
|
+
return result?.data;
|
|
2814
2698
|
}
|
|
2815
|
-
return networkConfigByChain[chainId];
|
|
2816
2699
|
};
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2700
|
+
|
|
2701
|
+
// src/retries.ts
|
|
2702
|
+
async function wait(delayMs) {
|
|
2703
|
+
return new Promise((resolve) => {
|
|
2704
|
+
setTimeout(resolve, delayMs);
|
|
2705
|
+
});
|
|
2706
|
+
}
|
|
2707
|
+
var retryInternal = async ({
|
|
2708
|
+
tryFn,
|
|
2709
|
+
maxTries = 3,
|
|
2710
|
+
atTry,
|
|
2711
|
+
linearBackoffMS = 200,
|
|
2712
|
+
shouldRetryOnError = () => true
|
|
2713
|
+
}) => {
|
|
2714
|
+
try {
|
|
2715
|
+
return await tryFn();
|
|
2716
|
+
} catch (err) {
|
|
2717
|
+
if (shouldRetryOnError(err)) {
|
|
2718
|
+
if (atTry <= maxTries) {
|
|
2719
|
+
await wait(atTry * linearBackoffMS);
|
|
2720
|
+
return await retryInternal({
|
|
2721
|
+
tryFn,
|
|
2722
|
+
maxTries,
|
|
2723
|
+
atTry: atTry + 1,
|
|
2724
|
+
linearBackoffMS,
|
|
2725
|
+
shouldRetryOnError
|
|
2726
|
+
});
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
throw err;
|
|
2838
2730
|
}
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2731
|
+
};
|
|
2732
|
+
var retriesGeneric = async (params) => {
|
|
2733
|
+
return retryInternal({
|
|
2734
|
+
...params,
|
|
2735
|
+
atTry: 1
|
|
2736
|
+
});
|
|
2737
|
+
};
|
|
2738
|
+
|
|
2739
|
+
// src/apis/http-api-base.ts
|
|
2740
|
+
var BadResponseError = class extends Error {
|
|
2741
|
+
constructor(message, status, json) {
|
|
2742
|
+
super(message);
|
|
2743
|
+
this.name = "BadResponseError";
|
|
2744
|
+
this.status = status;
|
|
2745
|
+
this.json = json;
|
|
2848
2746
|
}
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2747
|
+
};
|
|
2748
|
+
var get = async (url) => {
|
|
2749
|
+
const response = await fetch(url, { method: "GET" });
|
|
2750
|
+
if (response.status !== 200) {
|
|
2751
|
+
let json;
|
|
2752
|
+
try {
|
|
2753
|
+
json = await response.json();
|
|
2754
|
+
} catch (e) {
|
|
2755
|
+
}
|
|
2756
|
+
throw new BadResponseError(
|
|
2757
|
+
`Invalid response, status ${response.status}`,
|
|
2758
|
+
response.status,
|
|
2759
|
+
json
|
|
2760
|
+
);
|
|
2761
|
+
}
|
|
2762
|
+
return await response.json();
|
|
2763
|
+
};
|
|
2764
|
+
var post = async (url, data) => {
|
|
2765
|
+
const controller = new AbortController();
|
|
2766
|
+
const { signal } = controller;
|
|
2767
|
+
const timeout = 30 * 60 * 1e3;
|
|
2768
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
2769
|
+
const response = await fetch(url, {
|
|
2770
|
+
method: "POST",
|
|
2771
|
+
headers: {
|
|
2772
|
+
"content-type": "application/json",
|
|
2773
|
+
accept: "application/json"
|
|
2774
|
+
},
|
|
2775
|
+
body: JSON.stringify(data),
|
|
2776
|
+
signal
|
|
2777
|
+
});
|
|
2778
|
+
clearTimeout(timeoutId);
|
|
2779
|
+
if (response.status !== 200) {
|
|
2780
|
+
let json;
|
|
2781
|
+
try {
|
|
2782
|
+
json = await response.json();
|
|
2783
|
+
} catch (e) {
|
|
2784
|
+
}
|
|
2785
|
+
throw new BadResponseError(
|
|
2786
|
+
`Bad response: ${response.status}`,
|
|
2787
|
+
response.status,
|
|
2788
|
+
json
|
|
2789
|
+
);
|
|
2790
|
+
}
|
|
2791
|
+
return await response.json();
|
|
2792
|
+
};
|
|
2793
|
+
var defaultShouldRetry = (err) => {
|
|
2794
|
+
return err instanceof BadResponseError && err.status >= 500;
|
|
2795
|
+
};
|
|
2796
|
+
var retries = async (tryFn, maxTries = 3, linearBackoffMS = 200, shouldRetry = defaultShouldRetry) => {
|
|
2797
|
+
return retriesGeneric({
|
|
2798
|
+
tryFn,
|
|
2799
|
+
maxTries,
|
|
2800
|
+
linearBackoffMS,
|
|
2801
|
+
shouldRetryOnError: shouldRetry
|
|
2802
|
+
});
|
|
2803
|
+
};
|
|
2804
|
+
var httpClient = {
|
|
2805
|
+
get,
|
|
2806
|
+
post,
|
|
2807
|
+
retries
|
|
2808
|
+
};
|
|
2809
|
+
|
|
2810
|
+
// src/apis/subgraph-getter.ts
|
|
2811
|
+
var SubgraphGetter = class {
|
|
2812
|
+
constructor(chainId, subgraphQuerier) {
|
|
2813
|
+
this.subgraphQuerier = subgraphQuerier || new SubgraphQuerier(httpClient);
|
|
2814
|
+
this.networkConfig = getApiNetworkConfigForChain(chainId);
|
|
2815
|
+
}
|
|
2816
|
+
async querySubgraphWithRetries({
|
|
2817
|
+
query,
|
|
2818
|
+
variables,
|
|
2819
|
+
parseResponseData
|
|
2820
|
+
}) {
|
|
2821
|
+
const responseData = await this.subgraphQuerier.query({
|
|
2822
|
+
subgraphUrl: this.networkConfig.subgraphUrl,
|
|
2823
|
+
query,
|
|
2824
|
+
variables
|
|
2825
|
+
});
|
|
2826
|
+
return parseResponseData(responseData);
|
|
2827
|
+
}
|
|
2828
|
+
};
|
|
2829
|
+
|
|
2830
|
+
// src/mint/subgraph-mint-getter.ts
|
|
2831
|
+
var getApiNetworkConfigForChain = (chainId) => {
|
|
2832
|
+
if (!networkConfigByChain[chainId]) {
|
|
2833
|
+
throw new Error(`chain id ${chainId} network not configured `);
|
|
2834
|
+
}
|
|
2835
|
+
return networkConfigByChain[chainId];
|
|
2836
|
+
};
|
|
2837
|
+
function parseSalesConfig(targetStrategy, contractMintFee) {
|
|
2838
|
+
if (targetStrategy.type === "FIXED_PRICE")
|
|
2839
|
+
return {
|
|
2840
|
+
saleType: "fixedPrice",
|
|
2841
|
+
...targetStrategy.fixedPrice,
|
|
2842
|
+
maxTokensPerAddress: BigInt(
|
|
2843
|
+
targetStrategy.fixedPrice.maxTokensPerAddress
|
|
2844
|
+
),
|
|
2845
|
+
pricePerToken: BigInt(targetStrategy.fixedPrice.pricePerToken),
|
|
2846
|
+
mintFeePerQuantity: contractMintFee
|
|
2847
|
+
};
|
|
2848
|
+
if (targetStrategy.type === "ERC_20_MINTER") {
|
|
2849
|
+
return {
|
|
2850
|
+
saleType: "erc20",
|
|
2851
|
+
...targetStrategy.erc20Minter,
|
|
2852
|
+
maxTokensPerAddress: BigInt(
|
|
2853
|
+
targetStrategy.erc20Minter.maxTokensPerAddress
|
|
2854
|
+
),
|
|
2855
|
+
pricePerToken: BigInt(targetStrategy.erc20Minter.pricePerToken),
|
|
2856
|
+
mintFeePerQuantity: 0n
|
|
2857
|
+
};
|
|
2858
|
+
}
|
|
2859
|
+
if (targetStrategy.type === "PRESALE") {
|
|
2860
|
+
return {
|
|
2861
|
+
saleType: "allowlist",
|
|
2862
|
+
address: targetStrategy.presale.address,
|
|
2863
|
+
merkleRoot: targetStrategy.presale.merkleRoot,
|
|
2864
|
+
saleStart: targetStrategy.presale.presaleStart,
|
|
2865
|
+
saleEnd: targetStrategy.presale.presaleEnd,
|
|
2866
|
+
mintFeePerQuantity: contractMintFee
|
|
2867
|
+
};
|
|
2868
|
+
}
|
|
2869
|
+
if (targetStrategy.type === "ZORA_TIMED") {
|
|
2870
|
+
return {
|
|
2871
|
+
saleType: "timed",
|
|
2872
|
+
address: targetStrategy.zoraTimedMinter.address,
|
|
2873
|
+
mintFee: BigInt(targetStrategy.zoraTimedMinter.mintFee),
|
|
2874
|
+
saleStart: targetStrategy.zoraTimedMinter.saleStart,
|
|
2875
|
+
saleEnd: targetStrategy.zoraTimedMinter.saleEnd,
|
|
2876
|
+
erc20Z: targetStrategy.zoraTimedMinter.erc20Z.id,
|
|
2877
|
+
pool: targetStrategy.zoraTimedMinter.erc20Z.pool,
|
|
2878
|
+
secondaryActivated: targetStrategy.zoraTimedMinter.secondaryActivated,
|
|
2879
|
+
mintFeePerQuantity: BigInt(targetStrategy.zoraTimedMinter.mintFee),
|
|
2880
|
+
marketCountdown: targetStrategy.zoraTimedMinter.marketCountdown ? BigInt(targetStrategy.zoraTimedMinter.marketCountdown) : void 0,
|
|
2881
|
+
minimumMarketEth: targetStrategy.zoraTimedMinter.minimumMarketEth ? BigInt(targetStrategy.zoraTimedMinter.minimumMarketEth) : void 0
|
|
2882
|
+
};
|
|
2863
2883
|
}
|
|
2864
2884
|
throw new Error("Unknown saleType");
|
|
2865
2885
|
}
|
|
@@ -2916,8 +2936,9 @@ function getTargetStrategy({
|
|
|
2916
2936
|
}
|
|
2917
2937
|
return targetStrategy;
|
|
2918
2938
|
}
|
|
2919
|
-
var SubgraphMintGetter = class {
|
|
2939
|
+
var SubgraphMintGetter = class extends SubgraphGetter {
|
|
2920
2940
|
constructor(chainId, subgraphQuerier) {
|
|
2941
|
+
super(chainId, subgraphQuerier);
|
|
2921
2942
|
this.getMintable = async ({
|
|
2922
2943
|
tokenAddress,
|
|
2923
2944
|
tokenId,
|
|
@@ -2942,24 +2963,10 @@ var SubgraphMintGetter = class {
|
|
|
2942
2963
|
blockTime
|
|
2943
2964
|
});
|
|
2944
2965
|
};
|
|
2945
|
-
this.subgraphQuerier = subgraphQuerier || new SubgraphQuerier(httpClient);
|
|
2946
|
-
this.networkConfig = getApiNetworkConfigForChain(chainId);
|
|
2947
2966
|
}
|
|
2948
2967
|
async getContractMintFee(contract) {
|
|
2949
2968
|
return BigInt(contract.mintFeePerQuantity);
|
|
2950
2969
|
}
|
|
2951
|
-
async querySubgraphWithRetries({
|
|
2952
|
-
query,
|
|
2953
|
-
variables,
|
|
2954
|
-
parseResponseData
|
|
2955
|
-
}) {
|
|
2956
|
-
const responseData = await this.subgraphQuerier.query({
|
|
2957
|
-
subgraphUrl: this.networkConfig.subgraphUrl,
|
|
2958
|
-
query,
|
|
2959
|
-
variables
|
|
2960
|
-
});
|
|
2961
|
-
return parseResponseData(responseData);
|
|
2962
|
-
}
|
|
2963
2970
|
async getContractMintable({
|
|
2964
2971
|
tokenAddress,
|
|
2965
2972
|
preferredSaleType,
|
|
@@ -3064,6 +3071,7 @@ function mintRecipientOrAccount({
|
|
|
3064
3071
|
}) {
|
|
3065
3072
|
return mintRecipient || (typeof minterAccount === "string" ? minterAccount : minterAccount.address);
|
|
3066
3073
|
}
|
|
3074
|
+
var addressOrAccountAddress = (address) => typeof address === "string" ? address : address.address;
|
|
3067
3075
|
|
|
3068
3076
|
// src/premint/premint-client.ts
|
|
3069
3077
|
var defaultTokenConfigV1MintArguments = () => ({
|
|
@@ -5134,7 +5142,6 @@ var sumBalances = (mintAccountBalances) => {
|
|
|
5134
5142
|
// src/sparks/sparks-contracts.ts
|
|
5135
5143
|
var import_protocol_deployments11 = require("@zoralabs/protocol-deployments");
|
|
5136
5144
|
var import_viem11 = require("viem");
|
|
5137
|
-
var addressOrAccountAddress = (address) => typeof address === "string" ? address : address.address;
|
|
5138
5145
|
var mintWithEthParams = ({
|
|
5139
5146
|
tokenId,
|
|
5140
5147
|
quantity,
|
|
@@ -5388,22 +5395,9 @@ function buildContractInfoQuery({
|
|
|
5388
5395
|
}
|
|
5389
5396
|
|
|
5390
5397
|
// src/create/contract-getter.ts
|
|
5391
|
-
var SubgraphContractGetter = class {
|
|
5398
|
+
var SubgraphContractGetter = class extends SubgraphGetter {
|
|
5392
5399
|
constructor(chainId, subgraphQuerier) {
|
|
5393
|
-
|
|
5394
|
-
this.networkConfig = getApiNetworkConfigForChain(chainId);
|
|
5395
|
-
}
|
|
5396
|
-
async querySubgraphWithRetries({
|
|
5397
|
-
query,
|
|
5398
|
-
variables,
|
|
5399
|
-
parseResponseData
|
|
5400
|
-
}) {
|
|
5401
|
-
const responseData = await this.subgraphQuerier.query({
|
|
5402
|
-
subgraphUrl: this.networkConfig.subgraphUrl,
|
|
5403
|
-
query,
|
|
5404
|
-
variables
|
|
5405
|
-
});
|
|
5406
|
-
return parseResponseData(responseData);
|
|
5400
|
+
super(chainId, subgraphQuerier);
|
|
5407
5401
|
}
|
|
5408
5402
|
async getContractInfo({
|
|
5409
5403
|
contractAddress,
|
|
@@ -5434,6 +5428,749 @@ var SubgraphContractGetter = class {
|
|
|
5434
5428
|
}
|
|
5435
5429
|
};
|
|
5436
5430
|
|
|
5431
|
+
// src/rewards/rewards-queries.ts
|
|
5432
|
+
var import_protocol_deployments12 = require("@zoralabs/protocol-deployments");
|
|
5433
|
+
var import_viem12 = require("viem");
|
|
5434
|
+
|
|
5435
|
+
// src/apis/multicall3.ts
|
|
5436
|
+
var multicall3Abi = [
|
|
5437
|
+
"struct Call { address target; bytes callData; }",
|
|
5438
|
+
"struct Call3 { address target; bool allowFailure; bytes callData; }",
|
|
5439
|
+
"struct Call3Value { address target; bool allowFailure; uint256 value; bytes callData; }",
|
|
5440
|
+
"struct Result { bool success; bytes returnData; }",
|
|
5441
|
+
"function aggregate(Call[] calldata calls) public payable returns (uint256 blockNumber, bytes[] memory returnData)",
|
|
5442
|
+
"function aggregate3(Call3[] calldata calls) public payable returns (Result[] memory returnData)",
|
|
5443
|
+
"function aggregate3Value(Call3Value[] calldata calls) public payable returns (Result[] memory returnData)"
|
|
5444
|
+
];
|
|
5445
|
+
var multicall3Address = "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
5446
|
+
|
|
5447
|
+
// src/rewards/rewards-queries.ts
|
|
5448
|
+
function aggregateUnclaimedFees(unclaimedFees, wethAddress2) {
|
|
5449
|
+
let ethBalance = 0n;
|
|
5450
|
+
const unclaimedFeesAggregate = unclaimedFees.reduce(
|
|
5451
|
+
(acc, fee) => {
|
|
5452
|
+
const addFee = (token, amount) => {
|
|
5453
|
+
if (token === wethAddress2) {
|
|
5454
|
+
ethBalance += amount;
|
|
5455
|
+
} else if (acc[token]) {
|
|
5456
|
+
acc[token] += amount;
|
|
5457
|
+
} else {
|
|
5458
|
+
acc[token] = amount;
|
|
5459
|
+
}
|
|
5460
|
+
};
|
|
5461
|
+
addFee(fee.token0, fee.token0Amount * 75n / 100n);
|
|
5462
|
+
addFee(fee.token1, fee.token1Amount * 75n / 100n);
|
|
5463
|
+
return acc;
|
|
5464
|
+
},
|
|
5465
|
+
{}
|
|
5466
|
+
);
|
|
5467
|
+
return {
|
|
5468
|
+
eth: ethBalance * 75n / 100n,
|
|
5469
|
+
// Apply 75% fee to ETH balance
|
|
5470
|
+
erc20: unclaimedFeesAggregate
|
|
5471
|
+
};
|
|
5472
|
+
}
|
|
5473
|
+
var getRewardsBalance = async ({
|
|
5474
|
+
account,
|
|
5475
|
+
// The account to check rewards for (Address or Account object)
|
|
5476
|
+
publicClient,
|
|
5477
|
+
// The public client for making blockchain queries
|
|
5478
|
+
chainId,
|
|
5479
|
+
// The ID of the blockchain network
|
|
5480
|
+
rewardsGetter
|
|
5481
|
+
// Interface for getting ERC20Z tokens for a creator
|
|
5482
|
+
}) => {
|
|
5483
|
+
const address = typeof account === "string" ? account : account.address;
|
|
5484
|
+
const erc20Zs = await rewardsGetter.getErc20ZzForCreator({ address });
|
|
5485
|
+
const result = await publicClient.multicall({
|
|
5486
|
+
contracts: [
|
|
5487
|
+
{
|
|
5488
|
+
address: import_protocol_deployments12.protocolRewardsAddress[chainId],
|
|
5489
|
+
abi: import_protocol_deployments12.protocolRewardsABI,
|
|
5490
|
+
functionName: "balanceOf",
|
|
5491
|
+
args: [address]
|
|
5492
|
+
},
|
|
5493
|
+
{
|
|
5494
|
+
address: import_protocol_deployments12.erc20ZRoyaltiesAddress[chainId],
|
|
5495
|
+
abi: import_protocol_deployments12.erc20ZRoyaltiesABI,
|
|
5496
|
+
functionName: "getUnclaimedFeesBatch",
|
|
5497
|
+
args: [erc20Zs]
|
|
5498
|
+
}
|
|
5499
|
+
],
|
|
5500
|
+
multicallAddress: multicall3Address,
|
|
5501
|
+
allowFailure: false
|
|
5502
|
+
});
|
|
5503
|
+
const protocolRewardsBalance = result[0];
|
|
5504
|
+
const wethAddressForChain = import_protocol_deployments12.wethAddress[chainId];
|
|
5505
|
+
const unclaimedFeesAggregate = aggregateUnclaimedFees(
|
|
5506
|
+
result[1],
|
|
5507
|
+
wethAddressForChain
|
|
5508
|
+
);
|
|
5509
|
+
return {
|
|
5510
|
+
protocolRewards: protocolRewardsBalance,
|
|
5511
|
+
secondaryRoyalties: unclaimedFeesAggregate
|
|
5512
|
+
};
|
|
5513
|
+
};
|
|
5514
|
+
var withdrawProtocolRewards = ({
|
|
5515
|
+
withdrawFor,
|
|
5516
|
+
chainId
|
|
5517
|
+
}) => {
|
|
5518
|
+
return makeContractParameters({
|
|
5519
|
+
abi: import_protocol_deployments12.protocolRewardsABI,
|
|
5520
|
+
functionName: "withdrawFor",
|
|
5521
|
+
address: import_protocol_deployments12.protocolRewardsAddress[chainId],
|
|
5522
|
+
args: [withdrawFor, 0n]
|
|
5523
|
+
});
|
|
5524
|
+
};
|
|
5525
|
+
var makeClaimSecondaryRoyaltiesCalls = async ({
|
|
5526
|
+
claimFor,
|
|
5527
|
+
chainId,
|
|
5528
|
+
rewardsGetter
|
|
5529
|
+
}) => {
|
|
5530
|
+
const erc20z = await rewardsGetter.getErc20ZzForCreator({
|
|
5531
|
+
address: claimFor
|
|
5532
|
+
});
|
|
5533
|
+
const royaltiesAddress = import_protocol_deployments12.erc20ZRoyaltiesAddress[chainId];
|
|
5534
|
+
if (erc20z.length === 0) {
|
|
5535
|
+
return [];
|
|
5536
|
+
}
|
|
5537
|
+
return erc20z.map((erc20z2) => ({
|
|
5538
|
+
target: royaltiesAddress,
|
|
5539
|
+
callData: (0, import_viem12.encodeFunctionData)({
|
|
5540
|
+
abi: import_protocol_deployments12.erc20ZRoyaltiesABI,
|
|
5541
|
+
functionName: "claimFor",
|
|
5542
|
+
args: [erc20z2]
|
|
5543
|
+
}),
|
|
5544
|
+
allowFailure: false
|
|
5545
|
+
}));
|
|
5546
|
+
};
|
|
5547
|
+
var createProtocolRewardsCall = (chainId, withdrawFor) => ({
|
|
5548
|
+
target: import_protocol_deployments12.protocolRewardsAddress[chainId],
|
|
5549
|
+
callData: (0, import_viem12.encodeFunctionData)({
|
|
5550
|
+
abi: import_protocol_deployments12.protocolRewardsABI,
|
|
5551
|
+
functionName: "withdrawFor",
|
|
5552
|
+
args: [withdrawFor, 0n]
|
|
5553
|
+
}),
|
|
5554
|
+
allowFailure: false
|
|
5555
|
+
});
|
|
5556
|
+
var createMulticallParameters = (calls, account) => makeContractParameters({
|
|
5557
|
+
abi: (0, import_viem12.parseAbi)(multicall3Abi),
|
|
5558
|
+
functionName: "aggregate3",
|
|
5559
|
+
address: multicall3Address,
|
|
5560
|
+
args: [calls],
|
|
5561
|
+
account
|
|
5562
|
+
});
|
|
5563
|
+
var withdrawRewards = async ({
|
|
5564
|
+
account,
|
|
5565
|
+
withdrawFor,
|
|
5566
|
+
claimSecondaryRoyalties = true,
|
|
5567
|
+
chainId,
|
|
5568
|
+
rewardsGetter
|
|
5569
|
+
}) => {
|
|
5570
|
+
if (!claimSecondaryRoyalties) {
|
|
5571
|
+
return {
|
|
5572
|
+
...withdrawProtocolRewards({ chainId, withdrawFor }),
|
|
5573
|
+
account
|
|
5574
|
+
};
|
|
5575
|
+
}
|
|
5576
|
+
const protocolRewardsCall = createProtocolRewardsCall(chainId, withdrawFor);
|
|
5577
|
+
const secondaryRoyaltiesCalls = await makeClaimSecondaryRoyaltiesCalls({
|
|
5578
|
+
chainId,
|
|
5579
|
+
claimFor: withdrawFor,
|
|
5580
|
+
rewardsGetter
|
|
5581
|
+
});
|
|
5582
|
+
const allCalls = [protocolRewardsCall, ...secondaryRoyaltiesCalls];
|
|
5583
|
+
return createMulticallParameters(allCalls, account);
|
|
5584
|
+
};
|
|
5585
|
+
|
|
5586
|
+
// src/rewards/rewards-client.ts
|
|
5587
|
+
var RewardsClient = class {
|
|
5588
|
+
constructor({
|
|
5589
|
+
chainId,
|
|
5590
|
+
publicClient,
|
|
5591
|
+
rewardsGetter
|
|
5592
|
+
}) {
|
|
5593
|
+
this.chainId = chainId;
|
|
5594
|
+
this.publicClient = publicClient;
|
|
5595
|
+
this.rewardsGetter = rewardsGetter;
|
|
5596
|
+
}
|
|
5597
|
+
/** Withdraws rewards for a given account */
|
|
5598
|
+
async withdrawRewards({
|
|
5599
|
+
account,
|
|
5600
|
+
withdrawFor,
|
|
5601
|
+
claimSecondaryRoyalties
|
|
5602
|
+
}) {
|
|
5603
|
+
return {
|
|
5604
|
+
parameters: await withdrawRewards({
|
|
5605
|
+
chainId: this.chainId,
|
|
5606
|
+
rewardsGetter: this.rewardsGetter,
|
|
5607
|
+
withdrawFor,
|
|
5608
|
+
claimSecondaryRoyalties,
|
|
5609
|
+
account
|
|
5610
|
+
})
|
|
5611
|
+
};
|
|
5612
|
+
}
|
|
5613
|
+
/** Retrieves the rewards balances for a given account */
|
|
5614
|
+
async getRewardsBalances(params) {
|
|
5615
|
+
return getRewardsBalance({
|
|
5616
|
+
account: params.account,
|
|
5617
|
+
chainId: this.chainId,
|
|
5618
|
+
publicClient: this.publicClient,
|
|
5619
|
+
rewardsGetter: this.rewardsGetter
|
|
5620
|
+
});
|
|
5621
|
+
}
|
|
5622
|
+
};
|
|
5623
|
+
|
|
5624
|
+
// src/rewards/subgraph-queries.ts
|
|
5625
|
+
function buildCreatorERC20zs({
|
|
5626
|
+
address
|
|
5627
|
+
}) {
|
|
5628
|
+
return {
|
|
5629
|
+
query: `
|
|
5630
|
+
query ($address: Bytes!) {
|
|
5631
|
+
zoraCreateTokens(
|
|
5632
|
+
where: { royalties_: { user: $address }, salesStrategies_: { type: "ZORA_TIMED" } }
|
|
5633
|
+
) {
|
|
5634
|
+
royalties {
|
|
5635
|
+
user
|
|
5636
|
+
}
|
|
5637
|
+
salesStrategies {
|
|
5638
|
+
zoraTimedMinter {
|
|
5639
|
+
erc20Z {
|
|
5640
|
+
id
|
|
5641
|
+
}
|
|
5642
|
+
}
|
|
5643
|
+
}
|
|
5644
|
+
}
|
|
5645
|
+
}
|
|
5646
|
+
`,
|
|
5647
|
+
variables: { address },
|
|
5648
|
+
parseResponseData: (responseData) => {
|
|
5649
|
+
return responseData?.zoraCreateTokens;
|
|
5650
|
+
}
|
|
5651
|
+
};
|
|
5652
|
+
}
|
|
5653
|
+
|
|
5654
|
+
// src/rewards/subgraph-rewards-getter.ts
|
|
5655
|
+
var SubgraphRewardsGetter = class extends SubgraphGetter {
|
|
5656
|
+
constructor(chainId, subgraphQuerier) {
|
|
5657
|
+
super(chainId, subgraphQuerier);
|
|
5658
|
+
}
|
|
5659
|
+
async getErc20ZzForCreator({
|
|
5660
|
+
address
|
|
5661
|
+
}) {
|
|
5662
|
+
const queryResults = await this.querySubgraphWithRetries(
|
|
5663
|
+
buildCreatorERC20zs({ address })
|
|
5664
|
+
);
|
|
5665
|
+
return queryResults?.map(
|
|
5666
|
+
(result) => result.salesStrategies[0].zoraTimedMinter.erc20Z.id
|
|
5667
|
+
) || [];
|
|
5668
|
+
}
|
|
5669
|
+
};
|
|
5670
|
+
|
|
5671
|
+
// src/secondary/secondary-client.ts
|
|
5672
|
+
var import_viem17 = require("viem");
|
|
5673
|
+
var import_protocol_deployments15 = require("@zoralabs/protocol-deployments");
|
|
5674
|
+
|
|
5675
|
+
// src/secondary/uniswap/uniswapQuote.ts
|
|
5676
|
+
var import_viem16 = require("viem");
|
|
5677
|
+
|
|
5678
|
+
// src/secondary/uniswap/uniswapReserves.ts
|
|
5679
|
+
var import_viem14 = require("viem");
|
|
5680
|
+
var import_chains2 = require("viem/chains");
|
|
5681
|
+
|
|
5682
|
+
// src/secondary/uniswap/abis.ts
|
|
5683
|
+
var import_viem13 = require("viem");
|
|
5684
|
+
var uniswapQuoterABI = (0, import_viem13.parseAbi)([
|
|
5685
|
+
"struct QuoteExactInputSingleParams { address tokenIn; address tokenOut; uint256 amountIn; uint24 fee; uint160 sqrtPriceLimitX96; }",
|
|
5686
|
+
"struct QuoteExactOutputSingleParams { address tokenIn; address tokenOut; uint256 amount; uint24 fee; uint160 sqrtPriceLimitX96; }",
|
|
5687
|
+
"function quoteExactInputSingle(QuoteExactInputSingleParams calldata params) external returns (uint256 amountOut, uint160 sqrtPriceX96After, uint32 initializedTicksCrossed, uint256 gasEstimate)",
|
|
5688
|
+
"function quoteExactOutputSingle(QuoteExactOutputSingleParams calldata params) external returns (uint256 amountIn, uint160 sqrtPriceX96After, uint32 initializedTicksCrossed, uint256 gasEstimate)"
|
|
5689
|
+
]);
|
|
5690
|
+
var uniswapV3PoolAbi = (0, import_viem13.parseAbi)([
|
|
5691
|
+
"function fee() external view returns (uint24)",
|
|
5692
|
+
"function liquidity() external view returns (uint128)",
|
|
5693
|
+
"function slot0() external view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)",
|
|
5694
|
+
"function token0() external view returns (address)",
|
|
5695
|
+
"function token1() external view returns (address)"
|
|
5696
|
+
]);
|
|
5697
|
+
var uniswapV2USDCAbi = (0, import_viem13.parseAbi)([
|
|
5698
|
+
"function getReserves() external view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast)"
|
|
5699
|
+
]);
|
|
5700
|
+
|
|
5701
|
+
// src/secondary/uniswap/uniswapReserves.ts
|
|
5702
|
+
var uniswapV2USDCMainnetAddress = "0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc";
|
|
5703
|
+
function getUniswapV2USDCReserves() {
|
|
5704
|
+
const mainnetClient = (0, import_viem14.createPublicClient)({
|
|
5705
|
+
chain: import_chains2.mainnet,
|
|
5706
|
+
transport: (0, import_viem14.http)()
|
|
5707
|
+
});
|
|
5708
|
+
return mainnetClient.readContract({
|
|
5709
|
+
address: uniswapV2USDCMainnetAddress,
|
|
5710
|
+
abi: uniswapV2USDCAbi,
|
|
5711
|
+
functionName: "getReserves"
|
|
5712
|
+
});
|
|
5713
|
+
}
|
|
5714
|
+
function toEthPriceInUSDC({
|
|
5715
|
+
reserve0,
|
|
5716
|
+
reserve1
|
|
5717
|
+
}) {
|
|
5718
|
+
return Number(reserve0 * BigInt(1e14) / reserve1) / 100;
|
|
5719
|
+
}
|
|
5720
|
+
async function getEthPriceInUSDC() {
|
|
5721
|
+
const reserves = await getUniswapV2USDCReserves();
|
|
5722
|
+
return toEthPriceInUSDC({ reserve0: reserves[0], reserve1: reserves[1] });
|
|
5723
|
+
}
|
|
5724
|
+
|
|
5725
|
+
// src/secondary/conversions.ts
|
|
5726
|
+
var import_viem15 = require("viem");
|
|
5727
|
+
var WEI_PER_SPARK = 1000000000000n;
|
|
5728
|
+
function convertWeiToSparks(wei) {
|
|
5729
|
+
return BigInt(wei) / WEI_PER_SPARK;
|
|
5730
|
+
}
|
|
5731
|
+
function convertWeiToUSD({
|
|
5732
|
+
amount,
|
|
5733
|
+
ethPriceInUSD
|
|
5734
|
+
}) {
|
|
5735
|
+
const amountInEth = (0, import_viem15.formatEther)(amount);
|
|
5736
|
+
return parseFloat(amountInEth) * ethPriceInUSD;
|
|
5737
|
+
}
|
|
5738
|
+
|
|
5739
|
+
// src/secondary/uniswap/uniswapQuote.ts
|
|
5740
|
+
var import_protocol_deployments13 = require("@zoralabs/protocol-deployments");
|
|
5741
|
+
|
|
5742
|
+
// src/secondary/uniswap/uniswapQuoteExact.ts
|
|
5743
|
+
var import_chains3 = require("viem/chains");
|
|
5744
|
+
var UniswapQuoterAddress = {
|
|
5745
|
+
[import_chains3.mainnet.id]: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
|
|
5746
|
+
[import_chains3.sepolia.id]: "0xEd1f6473345F45b75F8179591dd5bA1888cf2FB3",
|
|
5747
|
+
[import_chains3.zora.id]: "0x11867e1b3348F3ce4FcC170BC5af3d23E07E64Df",
|
|
5748
|
+
[import_chains3.zoraSepolia.id]: "0xC195976fEF0985886E37036E2DF62bF371E12Df0",
|
|
5749
|
+
[import_chains3.base.id]: "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",
|
|
5750
|
+
[import_chains3.baseSepolia.id]: "0xC5290058841028F1614F3A6F0F5816cAd0df5E27",
|
|
5751
|
+
[import_chains3.optimism.id]: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
|
|
5752
|
+
[import_chains3.arbitrum.id]: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
|
|
5753
|
+
[import_chains3.blast.id]: "0x6Cdcd65e03c1CEc3730AeeCd45bc140D57A25C77"
|
|
5754
|
+
};
|
|
5755
|
+
async function quoteExactOutputSingle({
|
|
5756
|
+
tokenIn,
|
|
5757
|
+
tokenOut,
|
|
5758
|
+
amountOut,
|
|
5759
|
+
fee,
|
|
5760
|
+
chainId,
|
|
5761
|
+
client
|
|
5762
|
+
}) {
|
|
5763
|
+
const quote = await client.simulateContract({
|
|
5764
|
+
abi: uniswapQuoterABI,
|
|
5765
|
+
address: UniswapQuoterAddress[chainId],
|
|
5766
|
+
functionName: "quoteExactOutputSingle",
|
|
5767
|
+
args: [
|
|
5768
|
+
{
|
|
5769
|
+
tokenIn,
|
|
5770
|
+
tokenOut,
|
|
5771
|
+
amount: amountOut,
|
|
5772
|
+
fee,
|
|
5773
|
+
sqrtPriceLimitX96: 0n
|
|
5774
|
+
}
|
|
5775
|
+
]
|
|
5776
|
+
});
|
|
5777
|
+
return quote.result[0];
|
|
5778
|
+
}
|
|
5779
|
+
async function quoteExactInputSingle({
|
|
5780
|
+
tokenIn,
|
|
5781
|
+
tokenOut,
|
|
5782
|
+
amountIn,
|
|
5783
|
+
fee,
|
|
5784
|
+
chainId,
|
|
5785
|
+
client
|
|
5786
|
+
}) {
|
|
5787
|
+
const quote = await client.simulateContract({
|
|
5788
|
+
abi: uniswapQuoterABI,
|
|
5789
|
+
address: UniswapQuoterAddress[chainId],
|
|
5790
|
+
functionName: "quoteExactInputSingle",
|
|
5791
|
+
args: [
|
|
5792
|
+
{
|
|
5793
|
+
tokenIn,
|
|
5794
|
+
tokenOut,
|
|
5795
|
+
amountIn,
|
|
5796
|
+
fee,
|
|
5797
|
+
sqrtPriceLimitX96: 0n
|
|
5798
|
+
}
|
|
5799
|
+
]
|
|
5800
|
+
});
|
|
5801
|
+
return quote.result[0];
|
|
5802
|
+
}
|
|
5803
|
+
|
|
5804
|
+
// src/secondary/uniswap/uniswapQuote.ts
|
|
5805
|
+
async function getPoolInfo({
|
|
5806
|
+
poolAddress,
|
|
5807
|
+
client,
|
|
5808
|
+
WETH,
|
|
5809
|
+
erc20z
|
|
5810
|
+
}) {
|
|
5811
|
+
const [fee, wethBalance, erc20zBalance] = await client.multicall({
|
|
5812
|
+
contracts: [
|
|
5813
|
+
{
|
|
5814
|
+
abi: uniswapV3PoolAbi,
|
|
5815
|
+
address: poolAddress,
|
|
5816
|
+
functionName: "fee"
|
|
5817
|
+
},
|
|
5818
|
+
// get WETH and erc20z balance for pool
|
|
5819
|
+
{
|
|
5820
|
+
abi: import_viem16.erc20Abi,
|
|
5821
|
+
address: WETH,
|
|
5822
|
+
functionName: "balanceOf",
|
|
5823
|
+
args: [poolAddress]
|
|
5824
|
+
},
|
|
5825
|
+
{
|
|
5826
|
+
abi: import_viem16.erc20Abi,
|
|
5827
|
+
address: erc20z,
|
|
5828
|
+
functionName: "balanceOf",
|
|
5829
|
+
args: [poolAddress]
|
|
5830
|
+
}
|
|
5831
|
+
],
|
|
5832
|
+
multicallAddress: multicall3Address,
|
|
5833
|
+
allowFailure: false
|
|
5834
|
+
});
|
|
5835
|
+
return {
|
|
5836
|
+
wethBalance,
|
|
5837
|
+
erc20zBalance,
|
|
5838
|
+
fee
|
|
5839
|
+
};
|
|
5840
|
+
}
|
|
5841
|
+
async function getUniswapQuote(input, client) {
|
|
5842
|
+
const { type, quantity, poolAddress, chainId, erc20z } = input;
|
|
5843
|
+
const WETH = import_protocol_deployments13.wethAddress[chainId];
|
|
5844
|
+
const pool = await getPoolInfo({ poolAddress, WETH, erc20z, client });
|
|
5845
|
+
const { fee, wethBalance, erc20zBalance } = pool;
|
|
5846
|
+
const amountWithDecimals = input.quantity * 10n ** 18n;
|
|
5847
|
+
const amount = type === "buy" ? await quoteExactOutputSingle({
|
|
5848
|
+
tokenIn: WETH,
|
|
5849
|
+
tokenOut: erc20z,
|
|
5850
|
+
amountOut: amountWithDecimals,
|
|
5851
|
+
fee,
|
|
5852
|
+
chainId,
|
|
5853
|
+
client
|
|
5854
|
+
}) : await quoteExactInputSingle({
|
|
5855
|
+
tokenIn: erc20z,
|
|
5856
|
+
tokenOut: WETH,
|
|
5857
|
+
amountIn: amountWithDecimals,
|
|
5858
|
+
fee,
|
|
5859
|
+
chainId,
|
|
5860
|
+
client
|
|
5861
|
+
});
|
|
5862
|
+
const price = amount;
|
|
5863
|
+
const pricePerToken = amount / BigInt(quantity);
|
|
5864
|
+
const getUsdPrice = async () => {
|
|
5865
|
+
const ethPriceInUSD = await getEthPriceInUSDC();
|
|
5866
|
+
return {
|
|
5867
|
+
perToken: convertWeiToUSD({ amount: pricePerToken, ethPriceInUSD }),
|
|
5868
|
+
total: convertWeiToUSD({ amount: price, ethPriceInUSD })
|
|
5869
|
+
};
|
|
5870
|
+
};
|
|
5871
|
+
return {
|
|
5872
|
+
amount,
|
|
5873
|
+
poolBalance: {
|
|
5874
|
+
erc20z: erc20zBalance,
|
|
5875
|
+
weth: wethBalance
|
|
5876
|
+
},
|
|
5877
|
+
price: {
|
|
5878
|
+
wei: {
|
|
5879
|
+
perToken: pricePerToken,
|
|
5880
|
+
total: price
|
|
5881
|
+
},
|
|
5882
|
+
sparks: {
|
|
5883
|
+
perToken: convertWeiToSparks(pricePerToken),
|
|
5884
|
+
total: convertWeiToSparks(price)
|
|
5885
|
+
},
|
|
5886
|
+
usdc: getUsdPrice
|
|
5887
|
+
}
|
|
5888
|
+
};
|
|
5889
|
+
}
|
|
5890
|
+
|
|
5891
|
+
// src/secondary/slippage.ts
|
|
5892
|
+
var SCALE = 1e18;
|
|
5893
|
+
var ONE_SCALED = BigInt(SCALE);
|
|
5894
|
+
function calculateSlippageUp(amount, slippage) {
|
|
5895
|
+
return typeof amount === "bigint" ? amount * (ONE_SCALED + BigInt(slippage * SCALE)) / ONE_SCALED : parseFloat(String(amount)) * (1 + slippage);
|
|
5896
|
+
}
|
|
5897
|
+
function calculateSlippageDown(amount, slippage) {
|
|
5898
|
+
return typeof amount === "bigint" ? amount * (ONE_SCALED - BigInt(slippage * SCALE)) / ONE_SCALED : parseFloat(String(amount)) * (1 - slippage);
|
|
5899
|
+
}
|
|
5900
|
+
|
|
5901
|
+
// src/secondary/utils.ts
|
|
5902
|
+
var import_protocol_deployments14 = require("@zoralabs/protocol-deployments");
|
|
5903
|
+
async function getSecondaryInfo({
|
|
5904
|
+
contract,
|
|
5905
|
+
tokenId,
|
|
5906
|
+
publicClient,
|
|
5907
|
+
chainId
|
|
5908
|
+
}) {
|
|
5909
|
+
const result = await publicClient.readContract({
|
|
5910
|
+
abi: import_protocol_deployments14.zoraTimedSaleStrategyABI,
|
|
5911
|
+
address: import_protocol_deployments14.zoraTimedSaleStrategyAddress[chainId],
|
|
5912
|
+
functionName: "sale",
|
|
5913
|
+
args: [contract, tokenId]
|
|
5914
|
+
});
|
|
5915
|
+
if (!result.erc20zAddress) {
|
|
5916
|
+
return void 0;
|
|
5917
|
+
}
|
|
5918
|
+
return {
|
|
5919
|
+
erc20z: result.erc20zAddress,
|
|
5920
|
+
pool: result.poolAddress,
|
|
5921
|
+
secondaryActivated: result.secondaryActivated,
|
|
5922
|
+
saleEnd: result.saleEnd === 0n ? void 0 : result.saleEnd
|
|
5923
|
+
};
|
|
5924
|
+
}
|
|
5925
|
+
|
|
5926
|
+
// src/secondary/secondary-client.ts
|
|
5927
|
+
var UNISWAP_SLIPPAGE = 5e-3;
|
|
5928
|
+
var ERROR_INSUFFICIENT_WALLET_FUNDS = "Insufficient wallet funds";
|
|
5929
|
+
var ERROR_INSUFFICIENT_POOL_SUPPLY = "Insufficient pool supply";
|
|
5930
|
+
var ERROR_SECONDARY_NOT_CONFIGURED = "Secondary not configured for given contract and token";
|
|
5931
|
+
var ERROR_SECONDARY_NOT_STARTED = "Secondary market has not started";
|
|
5932
|
+
function makeError(errorMessage) {
|
|
5933
|
+
return { error: errorMessage };
|
|
5934
|
+
}
|
|
5935
|
+
async function makeBuy({
|
|
5936
|
+
erc20z,
|
|
5937
|
+
poolBalance,
|
|
5938
|
+
amount,
|
|
5939
|
+
quantity,
|
|
5940
|
+
account,
|
|
5941
|
+
recipient,
|
|
5942
|
+
chainId,
|
|
5943
|
+
slippage,
|
|
5944
|
+
publicClient
|
|
5945
|
+
}) {
|
|
5946
|
+
const costWithSlippage = calculateSlippageUp(amount, slippage);
|
|
5947
|
+
const availableToBuy = poolBalance.erc20z / BigInt(1e18) - 1n;
|
|
5948
|
+
const accountAddress = addressOrAccountAddress(account);
|
|
5949
|
+
const availableToSpend = await publicClient.getBalance({
|
|
5950
|
+
address: accountAddress
|
|
5951
|
+
});
|
|
5952
|
+
if (costWithSlippage > availableToSpend) {
|
|
5953
|
+
return makeError(ERROR_INSUFFICIENT_WALLET_FUNDS);
|
|
5954
|
+
}
|
|
5955
|
+
if (availableToBuy < BigInt(quantity)) {
|
|
5956
|
+
return makeError(ERROR_INSUFFICIENT_POOL_SUPPLY);
|
|
5957
|
+
}
|
|
5958
|
+
return {
|
|
5959
|
+
parameters: makeContractParameters({
|
|
5960
|
+
abi: import_protocol_deployments15.secondarySwapABI,
|
|
5961
|
+
address: import_protocol_deployments15.secondarySwapAddress[chainId],
|
|
5962
|
+
functionName: "buy1155",
|
|
5963
|
+
args: [
|
|
5964
|
+
erc20z,
|
|
5965
|
+
quantity,
|
|
5966
|
+
recipient || accountAddress,
|
|
5967
|
+
accountAddress,
|
|
5968
|
+
costWithSlippage,
|
|
5969
|
+
0n
|
|
5970
|
+
],
|
|
5971
|
+
account,
|
|
5972
|
+
value: costWithSlippage
|
|
5973
|
+
})
|
|
5974
|
+
};
|
|
5975
|
+
}
|
|
5976
|
+
async function buyWithSlippage({
|
|
5977
|
+
contract,
|
|
5978
|
+
tokenId,
|
|
5979
|
+
publicClient,
|
|
5980
|
+
quantity,
|
|
5981
|
+
chainId,
|
|
5982
|
+
account,
|
|
5983
|
+
slippage = UNISWAP_SLIPPAGE,
|
|
5984
|
+
recipient
|
|
5985
|
+
}) {
|
|
5986
|
+
const secondaryInfo = await getSecondaryInfo({
|
|
5987
|
+
contract,
|
|
5988
|
+
tokenId,
|
|
5989
|
+
publicClient,
|
|
5990
|
+
chainId
|
|
5991
|
+
});
|
|
5992
|
+
if (!secondaryInfo) {
|
|
5993
|
+
return makeError(ERROR_SECONDARY_NOT_CONFIGURED);
|
|
5994
|
+
}
|
|
5995
|
+
const { erc20z, pool, secondaryActivated } = secondaryInfo;
|
|
5996
|
+
if (!secondaryActivated) {
|
|
5997
|
+
return makeError(ERROR_SECONDARY_NOT_STARTED);
|
|
5998
|
+
}
|
|
5999
|
+
const { poolBalance, amount, price } = await getUniswapQuote(
|
|
6000
|
+
{
|
|
6001
|
+
type: "buy",
|
|
6002
|
+
quantity,
|
|
6003
|
+
poolAddress: pool,
|
|
6004
|
+
erc20z,
|
|
6005
|
+
chainId
|
|
6006
|
+
},
|
|
6007
|
+
publicClient
|
|
6008
|
+
);
|
|
6009
|
+
const call = await makeBuy({
|
|
6010
|
+
erc20z,
|
|
6011
|
+
poolBalance,
|
|
6012
|
+
amount,
|
|
6013
|
+
quantity,
|
|
6014
|
+
account,
|
|
6015
|
+
recipient,
|
|
6016
|
+
chainId,
|
|
6017
|
+
slippage,
|
|
6018
|
+
publicClient
|
|
6019
|
+
});
|
|
6020
|
+
return {
|
|
6021
|
+
...call,
|
|
6022
|
+
price
|
|
6023
|
+
};
|
|
6024
|
+
}
|
|
6025
|
+
async function makeSell({
|
|
6026
|
+
contract,
|
|
6027
|
+
tokenId,
|
|
6028
|
+
poolBalance,
|
|
6029
|
+
amount,
|
|
6030
|
+
quantity,
|
|
6031
|
+
account,
|
|
6032
|
+
recipient,
|
|
6033
|
+
chainId,
|
|
6034
|
+
slippage,
|
|
6035
|
+
publicClient
|
|
6036
|
+
}) {
|
|
6037
|
+
const accountAddress = addressOrAccountAddress(account);
|
|
6038
|
+
const tokenCount = await publicClient.readContract({
|
|
6039
|
+
abi: import_protocol_deployments15.zoraCreator1155ImplABI,
|
|
6040
|
+
address: contract,
|
|
6041
|
+
functionName: "balanceOf",
|
|
6042
|
+
args: [accountAddress, tokenId]
|
|
6043
|
+
});
|
|
6044
|
+
const availableToSell = tokenCount ?? 0n;
|
|
6045
|
+
const availableToReceive = poolBalance.weth;
|
|
6046
|
+
if (quantity > availableToSell) {
|
|
6047
|
+
return makeError(ERROR_INSUFFICIENT_WALLET_FUNDS);
|
|
6048
|
+
}
|
|
6049
|
+
if (amount > availableToReceive) {
|
|
6050
|
+
return makeError(ERROR_INSUFFICIENT_POOL_SUPPLY);
|
|
6051
|
+
}
|
|
6052
|
+
const receivedWithSlippage = calculateSlippageDown(amount, slippage);
|
|
6053
|
+
const data = (0, import_viem17.encodeAbiParameters)(import_protocol_deployments15.safeTransferSwapAbiParameters, [
|
|
6054
|
+
recipient || accountAddress,
|
|
6055
|
+
receivedWithSlippage,
|
|
6056
|
+
0n
|
|
6057
|
+
]);
|
|
6058
|
+
return {
|
|
6059
|
+
parameters: makeContractParameters({
|
|
6060
|
+
abi: import_protocol_deployments15.zoraCreator1155ImplABI,
|
|
6061
|
+
address: contract,
|
|
6062
|
+
functionName: "safeTransferFrom",
|
|
6063
|
+
account,
|
|
6064
|
+
args: [
|
|
6065
|
+
accountAddress,
|
|
6066
|
+
import_protocol_deployments15.secondarySwapAddress[chainId],
|
|
6067
|
+
tokenId,
|
|
6068
|
+
quantity,
|
|
6069
|
+
data
|
|
6070
|
+
]
|
|
6071
|
+
})
|
|
6072
|
+
};
|
|
6073
|
+
}
|
|
6074
|
+
async function sellWithSlippage({
|
|
6075
|
+
contract,
|
|
6076
|
+
tokenId,
|
|
6077
|
+
publicClient,
|
|
6078
|
+
quantity,
|
|
6079
|
+
chainId,
|
|
6080
|
+
account,
|
|
6081
|
+
slippage = UNISWAP_SLIPPAGE,
|
|
6082
|
+
recipient
|
|
6083
|
+
}) {
|
|
6084
|
+
const secondaryInfo = await getSecondaryInfo({
|
|
6085
|
+
contract,
|
|
6086
|
+
tokenId,
|
|
6087
|
+
publicClient,
|
|
6088
|
+
chainId
|
|
6089
|
+
});
|
|
6090
|
+
if (!secondaryInfo) {
|
|
6091
|
+
return makeError(ERROR_SECONDARY_NOT_CONFIGURED);
|
|
6092
|
+
}
|
|
6093
|
+
const { pool, secondaryActivated, erc20z } = secondaryInfo;
|
|
6094
|
+
if (!secondaryActivated) {
|
|
6095
|
+
return makeError(ERROR_SECONDARY_NOT_STARTED);
|
|
6096
|
+
}
|
|
6097
|
+
const { poolBalance, amount, price } = await getUniswapQuote(
|
|
6098
|
+
{ type: "sell", quantity, poolAddress: pool, chainId, erc20z },
|
|
6099
|
+
publicClient
|
|
6100
|
+
);
|
|
6101
|
+
const call = await makeSell({
|
|
6102
|
+
contract,
|
|
6103
|
+
tokenId,
|
|
6104
|
+
poolBalance,
|
|
6105
|
+
amount,
|
|
6106
|
+
quantity,
|
|
6107
|
+
account,
|
|
6108
|
+
recipient,
|
|
6109
|
+
chainId,
|
|
6110
|
+
slippage,
|
|
6111
|
+
publicClient
|
|
6112
|
+
});
|
|
6113
|
+
return {
|
|
6114
|
+
...call,
|
|
6115
|
+
price
|
|
6116
|
+
};
|
|
6117
|
+
}
|
|
6118
|
+
var SecondaryClient = class {
|
|
6119
|
+
/**
|
|
6120
|
+
* Creates a new SecondaryClient instance.
|
|
6121
|
+
* @param publicClient - The public client for interacting with the blockchain.
|
|
6122
|
+
* @param chainId - The ID of the blockchain network.
|
|
6123
|
+
*/
|
|
6124
|
+
constructor({
|
|
6125
|
+
publicClient,
|
|
6126
|
+
chainId
|
|
6127
|
+
}) {
|
|
6128
|
+
this.publicClient = publicClient;
|
|
6129
|
+
this.chainId = chainId;
|
|
6130
|
+
}
|
|
6131
|
+
/**
|
|
6132
|
+
* Get the secondary info for a given contract and token ID.
|
|
6133
|
+
* @param contract - The address of the contract.
|
|
6134
|
+
* @param tokenId - The ID of the token.
|
|
6135
|
+
* @returns A promise that resolves to the secondary info.
|
|
6136
|
+
*/
|
|
6137
|
+
async getSecondaryInfo({
|
|
6138
|
+
contract,
|
|
6139
|
+
tokenId
|
|
6140
|
+
}) {
|
|
6141
|
+
return getSecondaryInfo({
|
|
6142
|
+
contract,
|
|
6143
|
+
tokenId,
|
|
6144
|
+
publicClient: this.publicClient,
|
|
6145
|
+
chainId: this.chainId
|
|
6146
|
+
});
|
|
6147
|
+
}
|
|
6148
|
+
/**
|
|
6149
|
+
* Prepares a buy operation with slippage protection for purchasing a quantity of ERC1155 tokens with ETH on the secondary market.
|
|
6150
|
+
* @param input - The input parameters for the buy operation.
|
|
6151
|
+
* @returns A promise that resolves to the result of the buy operation, including price breakdown and transaction parameters.
|
|
6152
|
+
*/
|
|
6153
|
+
async buy1155OnSecondary(input) {
|
|
6154
|
+
return buyWithSlippage({
|
|
6155
|
+
...input,
|
|
6156
|
+
publicClient: this.publicClient,
|
|
6157
|
+
chainId: this.chainId
|
|
6158
|
+
});
|
|
6159
|
+
}
|
|
6160
|
+
/**
|
|
6161
|
+
* Prepares a sell operation with slippage protection for selling a quantity of ERC1155 tokens for ETH on the secondary market.
|
|
6162
|
+
* @param input - The input parameters for the sell operation.
|
|
6163
|
+
* @returns A promise that resolves to the result of the sell operation, including price breakdown and transaction parameters.
|
|
6164
|
+
*/
|
|
6165
|
+
async sell1155OnSecondary(input) {
|
|
6166
|
+
return sellWithSlippage({
|
|
6167
|
+
...input,
|
|
6168
|
+
publicClient: this.publicClient,
|
|
6169
|
+
chainId: this.chainId
|
|
6170
|
+
});
|
|
6171
|
+
}
|
|
6172
|
+
};
|
|
6173
|
+
|
|
5437
6174
|
// src/sdk.ts
|
|
5438
6175
|
function createCreatorClient(clientConfig) {
|
|
5439
6176
|
const premintClient = new PremintClient({
|
|
@@ -5446,12 +6183,19 @@ function createCreatorClient(clientConfig) {
|
|
|
5446
6183
|
publicClient: clientConfig.publicClient,
|
|
5447
6184
|
contractGetter: clientConfig.contractGetter || new SubgraphContractGetter(clientConfig.chainId)
|
|
5448
6185
|
});
|
|
6186
|
+
const rewardsClient = new RewardsClient({
|
|
6187
|
+
chainId: clientConfig.chainId,
|
|
6188
|
+
publicClient: clientConfig.publicClient,
|
|
6189
|
+
rewardsGetter: clientConfig.rewardsGetter || new SubgraphRewardsGetter(clientConfig.chainId)
|
|
6190
|
+
});
|
|
5449
6191
|
return {
|
|
5450
6192
|
createPremint: (p) => premintClient.createPremint(p),
|
|
5451
6193
|
updatePremint: (p) => premintClient.updatePremint(p),
|
|
5452
6194
|
deletePremint: (p) => premintClient.deletePremint(p),
|
|
5453
6195
|
create1155: (p) => create1155CreatorClient.createNew1155(p),
|
|
5454
|
-
create1155OnExistingContract: (p) => create1155CreatorClient.createNew1155OnExistingContract(p)
|
|
6196
|
+
create1155OnExistingContract: (p) => create1155CreatorClient.createNew1155OnExistingContract(p),
|
|
6197
|
+
getRewardsBalances: (p) => rewardsClient.getRewardsBalances(p),
|
|
6198
|
+
withdrawRewards: (p) => rewardsClient.withdrawRewards(p)
|
|
5455
6199
|
};
|
|
5456
6200
|
}
|
|
5457
6201
|
function createCollectorClient(params) {
|
|
@@ -5462,6 +6206,10 @@ function createCollectorClient(params) {
|
|
|
5462
6206
|
premintGetter: premintGetterToUse,
|
|
5463
6207
|
mintGetter: mintGetterToUse
|
|
5464
6208
|
});
|
|
6209
|
+
const secondaryClient = new SecondaryClient({
|
|
6210
|
+
publicClient: params.publicClient,
|
|
6211
|
+
chainId: params.chainId
|
|
6212
|
+
});
|
|
5465
6213
|
return {
|
|
5466
6214
|
getPremint: (p) => premintGetterToUse.get({
|
|
5467
6215
|
collectionAddress: p.address,
|
|
@@ -5471,7 +6219,10 @@ function createCollectorClient(params) {
|
|
|
5471
6219
|
getToken: (p) => mintClient.get(p),
|
|
5472
6220
|
getTokensOfContract: (p) => mintClient.getOfContract(p),
|
|
5473
6221
|
mint: (p) => mintClient.mint(p),
|
|
5474
|
-
getMintCosts: (p) => mintClient.getMintCosts(p)
|
|
6222
|
+
getMintCosts: (p) => mintClient.getMintCosts(p),
|
|
6223
|
+
buy1155OnSecondary: (p) => secondaryClient.buy1155OnSecondary(p),
|
|
6224
|
+
sell1155OnSecondary: (p) => secondaryClient.sell1155OnSecondary(p),
|
|
6225
|
+
getSecondaryInfo: (p) => secondaryClient.getSecondaryInfo(p)
|
|
5475
6226
|
};
|
|
5476
6227
|
}
|
|
5477
6228
|
|
|
@@ -5507,7 +6258,7 @@ function coerce3(o) {
|
|
|
5507
6258
|
}
|
|
5508
6259
|
|
|
5509
6260
|
// ../../node_modules/.pnpm/multiformats@13.2.1/node_modules/multiformats/dist/src/vendor/base-x.js
|
|
5510
|
-
function
|
|
6261
|
+
function base3(ALPHABET, name) {
|
|
5511
6262
|
if (ALPHABET.length >= 255) {
|
|
5512
6263
|
throw new TypeError("Alphabet too long");
|
|
5513
6264
|
}
|
|
@@ -5638,7 +6389,7 @@ function base2(ALPHABET, name) {
|
|
|
5638
6389
|
decode: decode5
|
|
5639
6390
|
};
|
|
5640
6391
|
}
|
|
5641
|
-
var src =
|
|
6392
|
+
var src = base3;
|
|
5642
6393
|
var _brrp__multiformats_scope_baseX = src;
|
|
5643
6394
|
var base_x_default = _brrp__multiformats_scope_baseX;
|
|
5644
6395
|
|
|
@@ -5999,13 +6750,13 @@ var Digest = class {
|
|
|
5999
6750
|
};
|
|
6000
6751
|
|
|
6001
6752
|
// ../../node_modules/.pnpm/multiformats@13.2.1/node_modules/multiformats/dist/src/cid.js
|
|
6002
|
-
function format(link,
|
|
6753
|
+
function format(link, base4) {
|
|
6003
6754
|
const { bytes, version } = link;
|
|
6004
6755
|
switch (version) {
|
|
6005
6756
|
case 0:
|
|
6006
|
-
return toStringV0(bytes, baseCache(link),
|
|
6757
|
+
return toStringV0(bytes, baseCache(link), base4 ?? base58btc.encoder);
|
|
6007
6758
|
default:
|
|
6008
|
-
return toStringV1(bytes, baseCache(link),
|
|
6759
|
+
return toStringV1(bytes, baseCache(link), base4 ?? base32.encoder);
|
|
6009
6760
|
}
|
|
6010
6761
|
}
|
|
6011
6762
|
var cache = /* @__PURE__ */ new WeakMap();
|
|
@@ -6097,8 +6848,8 @@ var CID = class _CID {
|
|
|
6097
6848
|
const unknown = other;
|
|
6098
6849
|
return unknown != null && self.code === unknown.code && self.version === unknown.version && equals2(self.multihash, unknown.multihash);
|
|
6099
6850
|
}
|
|
6100
|
-
toString(
|
|
6101
|
-
return format(this,
|
|
6851
|
+
toString(base4) {
|
|
6852
|
+
return format(this, base4);
|
|
6102
6853
|
}
|
|
6103
6854
|
toJSON() {
|
|
6104
6855
|
return { "/": format(this) };
|
|
@@ -6257,8 +7008,8 @@ var CID = class _CID {
|
|
|
6257
7008
|
* throw an error if encoding of the CID is not compatible with supplied (or
|
|
6258
7009
|
* a default decoder).
|
|
6259
7010
|
*/
|
|
6260
|
-
static parse(source,
|
|
6261
|
-
const [prefix, bytes] = parseCIDtoBytes(source,
|
|
7011
|
+
static parse(source, base4) {
|
|
7012
|
+
const [prefix, bytes] = parseCIDtoBytes(source, base4);
|
|
6262
7013
|
const cid = _CID.decode(bytes);
|
|
6263
7014
|
if (cid.version === 0 && source[0] !== "Q") {
|
|
6264
7015
|
throw Error("Version 0 CID string must not include multibase prefix");
|
|
@@ -6267,50 +7018,50 @@ var CID = class _CID {
|
|
|
6267
7018
|
return cid;
|
|
6268
7019
|
}
|
|
6269
7020
|
};
|
|
6270
|
-
function parseCIDtoBytes(source,
|
|
7021
|
+
function parseCIDtoBytes(source, base4) {
|
|
6271
7022
|
switch (source[0]) {
|
|
6272
7023
|
case "Q": {
|
|
6273
|
-
const decoder =
|
|
7024
|
+
const decoder = base4 ?? base58btc;
|
|
6274
7025
|
return [
|
|
6275
7026
|
base58btc.prefix,
|
|
6276
7027
|
decoder.decode(`${base58btc.prefix}${source}`)
|
|
6277
7028
|
];
|
|
6278
7029
|
}
|
|
6279
7030
|
case base58btc.prefix: {
|
|
6280
|
-
const decoder =
|
|
7031
|
+
const decoder = base4 ?? base58btc;
|
|
6281
7032
|
return [base58btc.prefix, decoder.decode(source)];
|
|
6282
7033
|
}
|
|
6283
7034
|
case base32.prefix: {
|
|
6284
|
-
const decoder =
|
|
7035
|
+
const decoder = base4 ?? base32;
|
|
6285
7036
|
return [base32.prefix, decoder.decode(source)];
|
|
6286
7037
|
}
|
|
6287
7038
|
default: {
|
|
6288
|
-
if (
|
|
7039
|
+
if (base4 == null) {
|
|
6289
7040
|
throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");
|
|
6290
7041
|
}
|
|
6291
|
-
return [source[0],
|
|
7042
|
+
return [source[0], base4.decode(source)];
|
|
6292
7043
|
}
|
|
6293
7044
|
}
|
|
6294
7045
|
}
|
|
6295
|
-
function toStringV0(bytes, cache2,
|
|
6296
|
-
const { prefix } =
|
|
7046
|
+
function toStringV0(bytes, cache2, base4) {
|
|
7047
|
+
const { prefix } = base4;
|
|
6297
7048
|
if (prefix !== base58btc.prefix) {
|
|
6298
|
-
throw Error(`Cannot string encode V0 in ${
|
|
7049
|
+
throw Error(`Cannot string encode V0 in ${base4.name} encoding`);
|
|
6299
7050
|
}
|
|
6300
7051
|
const cid = cache2.get(prefix);
|
|
6301
7052
|
if (cid == null) {
|
|
6302
|
-
const cid2 =
|
|
7053
|
+
const cid2 = base4.encode(bytes).slice(1);
|
|
6303
7054
|
cache2.set(prefix, cid2);
|
|
6304
7055
|
return cid2;
|
|
6305
7056
|
} else {
|
|
6306
7057
|
return cid;
|
|
6307
7058
|
}
|
|
6308
7059
|
}
|
|
6309
|
-
function toStringV1(bytes, cache2,
|
|
6310
|
-
const { prefix } =
|
|
7060
|
+
function toStringV1(bytes, cache2, base4) {
|
|
7061
|
+
const { prefix } = base4;
|
|
6311
7062
|
const cid = cache2.get(prefix);
|
|
6312
7063
|
if (cid == null) {
|
|
6313
|
-
const cid2 =
|
|
7064
|
+
const cid2 = base4.encode(bytes);
|
|
6314
7065
|
cache2.set(prefix, cid2);
|
|
6315
7066
|
return cid2;
|
|
6316
7067
|
} else {
|