@curator-studio/sdk 0.1.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.
@@ -0,0 +1,298 @@
1
+ import { Client, gql } from "@urql/core";
2
+ import type { Address } from "viem";
3
+ import { type SupportedChainId } from "../config";
4
+ export type Allocation = {
5
+ recipient: Address;
6
+ weight: string;
7
+ label?: string;
8
+ };
9
+ export type Strategy = {
10
+ id: Address;
11
+ chainId: number;
12
+ tenantId: string | null;
13
+ owner: Address;
14
+ sourceStrategy: Address | null;
15
+ metadataURI: string | null;
16
+ feeRecipient: Address | null;
17
+ feeBps: number;
18
+ ensLabel: string | null;
19
+ metadata: {
20
+ title: string;
21
+ description: string;
22
+ image?: string;
23
+ };
24
+ allocations: Allocation[];
25
+ allocationsVersion: number;
26
+ timesForked: number;
27
+ uniqueDonors: number;
28
+ createdAt: bigint;
29
+ createdAtBlock: bigint;
30
+ lastUpdatedAt: bigint;
31
+ lastUpdatedAtBlock: bigint;
32
+ };
33
+ export type Distribution = {
34
+ id: string;
35
+ strategyId: Address;
36
+ token: Address;
37
+ totalAmount: string;
38
+ totalAmountUSD: string;
39
+ allocationsVersion: number;
40
+ allocations: Allocation[];
41
+ timestamp: bigint;
42
+ blockNumber: bigint;
43
+ txHash: Address;
44
+ };
45
+ export type Payout = {
46
+ id: string;
47
+ strategyId: Address;
48
+ distributionId: string;
49
+ recipient: Address;
50
+ token: Address;
51
+ amount: string;
52
+ amountUSD: string;
53
+ timestamp: bigint;
54
+ blockNumber: bigint;
55
+ txHash: Address;
56
+ };
57
+ export type Transfer = {
58
+ id: string;
59
+ strategyId: Address;
60
+ token: Address;
61
+ from: Address;
62
+ to: Address;
63
+ amount: string;
64
+ amountUSD: string;
65
+ direction: "in" | "out";
66
+ timestamp: bigint;
67
+ blockNumber: bigint;
68
+ txHash: Address;
69
+ };
70
+ export type Donor = {
71
+ id: string;
72
+ strategyId: Address;
73
+ address: Address;
74
+ firstDonationAt: bigint;
75
+ lastDonationAt: bigint;
76
+ totalDonations: number;
77
+ };
78
+ export type StrategyBalance = {
79
+ id: string;
80
+ strategyId: Address;
81
+ token: Address;
82
+ balance: string;
83
+ totalReceived: string;
84
+ totalDistributed: string;
85
+ totalReceivedUSD: string;
86
+ totalDistributedUSD: string;
87
+ lastUpdatedAt: bigint;
88
+ };
89
+ export type Fork = {
90
+ id: string;
91
+ sourceStrategyId: Address;
92
+ childStrategyId: Address;
93
+ createdAt: bigint;
94
+ };
95
+ export type WarehouseBalance = {
96
+ id: string;
97
+ user: Address;
98
+ token: Address;
99
+ balance: string;
100
+ totalEarned: string;
101
+ totalClaimed: string;
102
+ totalEarnedUSD: string;
103
+ lastUpdatedAt: bigint;
104
+ };
105
+ export type YieldRedirector = {
106
+ id: Address;
107
+ owner: Address;
108
+ sourceVault: Address;
109
+ yieldRecipient: Address;
110
+ asset: Address;
111
+ name: string | null;
112
+ symbol: string | null;
113
+ principal: string;
114
+ totalHarvested: string;
115
+ totalHarvestedUSD: string;
116
+ harvestCount: number;
117
+ lastHarvestAt: bigint | null;
118
+ createdAt: bigint;
119
+ createdAtBlock: bigint;
120
+ };
121
+ export type Harvest = {
122
+ id: string;
123
+ redirectorId: Address;
124
+ amount: string;
125
+ amountUSD: string;
126
+ recipient: Address;
127
+ timestamp: bigint;
128
+ blockNumber: bigint;
129
+ txHash: Address;
130
+ };
131
+ export type Page<T> = {
132
+ items: T[];
133
+ totalCount: number;
134
+ pageInfo: {
135
+ hasNextPage: boolean;
136
+ endCursor?: string;
137
+ };
138
+ };
139
+ export type StrategyFilter = {
140
+ id?: string;
141
+ id_in?: string[];
142
+ tenantId?: string;
143
+ tenantId_in?: string[];
144
+ owner?: string;
145
+ owner_in?: string[];
146
+ sourceStrategy?: string;
147
+ sourceStrategy_in?: string[];
148
+ };
149
+ export type DistributionFilter = {
150
+ strategyId?: string;
151
+ strategyId_in?: string[];
152
+ token?: string;
153
+ token_in?: string[];
154
+ };
155
+ export type PayoutFilter = {
156
+ strategyId?: string;
157
+ strategyId_in?: string[];
158
+ distributionId?: string;
159
+ recipient?: string;
160
+ recipient_in?: string[];
161
+ token?: string;
162
+ };
163
+ export type TransferFilter = {
164
+ strategyId?: string;
165
+ strategyId_in?: string[];
166
+ token?: string;
167
+ from?: string;
168
+ to?: string;
169
+ direction?: "in" | "out";
170
+ };
171
+ export type DonorFilter = {
172
+ strategyId?: string;
173
+ strategyId_in?: string[];
174
+ address?: string;
175
+ address_in?: string[];
176
+ };
177
+ export type StrategyBalanceFilter = {
178
+ strategyId?: string;
179
+ strategyId_in?: string[];
180
+ token?: string;
181
+ token_in?: string[];
182
+ };
183
+ export type ForkFilter = {
184
+ sourceStrategyId?: string;
185
+ sourceStrategyId_in?: string[];
186
+ childStrategyId?: string;
187
+ childStrategyId_in?: string[];
188
+ };
189
+ export type WarehouseBalanceFilter = {
190
+ user?: string;
191
+ user_in?: string[];
192
+ token?: string;
193
+ token_in?: string[];
194
+ };
195
+ export type YieldRedirectorFilter = {
196
+ id?: string;
197
+ id_in?: string[];
198
+ owner?: string;
199
+ owner_in?: string[];
200
+ sourceVault?: string;
201
+ yieldRecipient?: string;
202
+ yieldRecipient_in?: string[];
203
+ };
204
+ export type HarvestFilter = {
205
+ redirectorId?: string;
206
+ redirectorId_in?: string[];
207
+ recipient?: string;
208
+ recipient_in?: string[];
209
+ };
210
+ export type QueryVariables<TFilter> = {
211
+ where?: TFilter;
212
+ orderBy?: string;
213
+ orderDirection?: "asc" | "desc";
214
+ limit?: number;
215
+ after?: string;
216
+ };
217
+ export type TrendingStrategy = Strategy & {
218
+ trendingStats: {
219
+ transferCount: number;
220
+ totalAmount: string;
221
+ };
222
+ };
223
+ export type TrendingResponse = {
224
+ data: TrendingStrategy[];
225
+ period: "24h" | "7d";
226
+ };
227
+ export type TokenTotals = {
228
+ token: Address;
229
+ totalReceived: string;
230
+ totalDistributed: string;
231
+ };
232
+ export type ProtocolStats = {
233
+ totalStrategies: number;
234
+ totalCurators: number;
235
+ totalDonors: number;
236
+ totalDistributions: number;
237
+ totalAllocatedUSD: string;
238
+ totalsByToken: TokenTotals[];
239
+ };
240
+ export type StatsResponse = {
241
+ data: ProtocolStats;
242
+ };
243
+ export type StrategyLineage = {
244
+ strategy: Address;
245
+ sourceStrategy: Address | null;
246
+ ancestors: Address[];
247
+ children: Address[];
248
+ depth: number;
249
+ };
250
+ export type LineageResponse = {
251
+ data: StrategyLineage;
252
+ };
253
+ type IndexerBase = {
254
+ client: Client;
255
+ gql: typeof gql;
256
+ baseUrl: string;
257
+ strategy: {
258
+ get: (id: Address) => Promise<Strategy | null>;
259
+ query: (variables?: QueryVariables<StrategyFilter>) => Promise<Page<Strategy> | null>;
260
+ };
261
+ distribution: {
262
+ query: (variables?: QueryVariables<DistributionFilter>) => Promise<Page<Distribution> | null>;
263
+ };
264
+ payout: {
265
+ query: (variables?: QueryVariables<PayoutFilter>) => Promise<Page<Payout> | null>;
266
+ };
267
+ donor: {
268
+ query: (variables?: QueryVariables<DonorFilter>) => Promise<Page<Donor> | null>;
269
+ };
270
+ strategyBalance: {
271
+ query: (variables?: QueryVariables<StrategyBalanceFilter>) => Promise<Page<StrategyBalance> | null>;
272
+ };
273
+ fork: {
274
+ query: (variables?: QueryVariables<ForkFilter>) => Promise<Page<Fork> | null>;
275
+ };
276
+ warehouseBalance: {
277
+ query: (variables?: QueryVariables<WarehouseBalanceFilter>) => Promise<Page<WarehouseBalance> | null>;
278
+ };
279
+ yieldRedirector: {
280
+ get: (id: Address) => Promise<YieldRedirector | null>;
281
+ query: (variables?: QueryVariables<YieldRedirectorFilter>) => Promise<Page<YieldRedirector> | null>;
282
+ };
283
+ harvest: {
284
+ query: (variables?: QueryVariables<HarvestFilter>) => Promise<Page<Harvest> | null>;
285
+ };
286
+ trending: (options?: {
287
+ period?: "24h" | "7d";
288
+ limit?: number;
289
+ }) => Promise<TrendingResponse>;
290
+ stats: () => Promise<ProtocolStats>;
291
+ lineage: (strategyAddress: Address) => Promise<StrategyLineage | null>;
292
+ };
293
+ export type Indexer = IndexerBase & {
294
+ extend<T>(extension: IndexerExtension<T>): Indexer & T;
295
+ };
296
+ export type IndexerExtension<T> = (indexer: Indexer) => T;
297
+ export declare function createIndexer(chainId: SupportedChainId): Indexer;
298
+ export {};
@@ -0,0 +1,11 @@
1
+ import { type Abi, type WalletClient } from 'viem';
2
+ /**
3
+ * Execute a transaction and extract a specific event from the logs.
4
+ */
5
+ export declare function writeAndParse<T>(wallet: WalletClient, hash: `0x${string}`, abi: Abi, eventName: string): Promise<T>;
6
+ /**
7
+ * Execute a transaction without parsing events, just wait for confirmation.
8
+ */
9
+ export declare function writeAndWait(wallet: WalletClient, hash: `0x${string}`): Promise<{
10
+ hash: `0x${string}`;
11
+ }>;
@@ -0,0 +1,16 @@
1
+ import {
2
+ encodeToCurve,
3
+ hashToCurve,
4
+ schnorr,
5
+ secp256k1,
6
+ secp256k1_hasher
7
+ } from "./chunk-5QPQJ76C.mjs";
8
+ import "./chunk-CALEUNGN.mjs";
9
+ import "./chunk-XGB3TDIC.mjs";
10
+ export {
11
+ encodeToCurve,
12
+ hashToCurve,
13
+ schnorr,
14
+ secp256k1,
15
+ secp256k1_hasher
16
+ };
@@ -0,0 +1,304 @@
1
+ import { Client, gql } from '@urql/core';
2
+ import { Address } from 'viem';
3
+
4
+ type SupportedChainId = 1 | 11155111 | 31337;
5
+ declare const ENS_DOMAIN = "support-dev.eth";
6
+ type ChainConfig = {
7
+ factory?: `0x${string}`;
8
+ warehouse?: `0x${string}`;
9
+ indexer?: string;
10
+ foreverSubnameRegistrar?: `0x${string}`;
11
+ ensUniversalResolver?: `0x${string}`;
12
+ };
13
+ declare const config: Record<SupportedChainId, ChainConfig>;
14
+
15
+ type Allocation = {
16
+ recipient: Address;
17
+ weight: string;
18
+ label?: string;
19
+ };
20
+ type Strategy = {
21
+ id: Address;
22
+ owner: Address;
23
+ sourceStrategy: Address | null;
24
+ metadataURI: string | null;
25
+ feeRecipient: Address | null;
26
+ feeBps: number;
27
+ ensLabel: string | null;
28
+ metadata: {
29
+ title: string;
30
+ description: string;
31
+ image?: string;
32
+ };
33
+ allocations: Allocation[];
34
+ allocationsVersion: number;
35
+ timesForked: number;
36
+ uniqueDonors: number;
37
+ createdAt: bigint;
38
+ createdAtBlock: bigint;
39
+ lastUpdatedAt: bigint;
40
+ lastUpdatedAtBlock: bigint;
41
+ };
42
+ type Distribution = {
43
+ id: string;
44
+ strategyId: Address;
45
+ token: Address;
46
+ totalAmount: string;
47
+ totalAmountUSD: string;
48
+ allocationsVersion: number;
49
+ allocations: Allocation[];
50
+ timestamp: bigint;
51
+ blockNumber: bigint;
52
+ txHash: Address;
53
+ };
54
+ type Payout = {
55
+ id: string;
56
+ strategyId: Address;
57
+ distributionId: string;
58
+ recipient: Address;
59
+ token: Address;
60
+ amount: string;
61
+ amountUSD: string;
62
+ timestamp: bigint;
63
+ blockNumber: bigint;
64
+ txHash: Address;
65
+ };
66
+ type Transfer = {
67
+ id: string;
68
+ strategyId: Address;
69
+ token: Address;
70
+ from: Address;
71
+ to: Address;
72
+ amount: string;
73
+ amountUSD: string;
74
+ direction: "in" | "out";
75
+ timestamp: bigint;
76
+ blockNumber: bigint;
77
+ txHash: Address;
78
+ };
79
+ type Donor = {
80
+ id: string;
81
+ strategyId: Address;
82
+ address: Address;
83
+ firstDonationAt: bigint;
84
+ lastDonationAt: bigint;
85
+ totalDonations: number;
86
+ };
87
+ type StrategyBalance = {
88
+ id: string;
89
+ strategyId: Address;
90
+ token: Address;
91
+ balance: string;
92
+ totalReceived: string;
93
+ totalDistributed: string;
94
+ totalReceivedUSD: string;
95
+ totalDistributedUSD: string;
96
+ lastUpdatedAt: bigint;
97
+ };
98
+ type Fork = {
99
+ id: string;
100
+ sourceStrategyId: Address;
101
+ childStrategyId: Address;
102
+ createdAt: bigint;
103
+ };
104
+ type WarehouseBalance = {
105
+ id: string;
106
+ user: Address;
107
+ token: Address;
108
+ balance: string;
109
+ totalEarned: string;
110
+ totalClaimed: string;
111
+ totalEarnedUSD: string;
112
+ lastUpdatedAt: bigint;
113
+ };
114
+ type YieldRedirector = {
115
+ id: Address;
116
+ owner: Address;
117
+ sourceVault: Address;
118
+ yieldRecipient: Address;
119
+ asset: Address;
120
+ principal: string;
121
+ totalHarvested: string;
122
+ totalHarvestedUSD: string;
123
+ harvestCount: number;
124
+ lastHarvestAt: bigint | null;
125
+ createdAt: bigint;
126
+ createdAtBlock: bigint;
127
+ };
128
+ type Harvest = {
129
+ id: string;
130
+ redirectorId: Address;
131
+ amount: string;
132
+ amountUSD: string;
133
+ recipient: Address;
134
+ timestamp: bigint;
135
+ blockNumber: bigint;
136
+ txHash: Address;
137
+ };
138
+ type Page<T> = {
139
+ items: T[];
140
+ totalCount: number;
141
+ pageInfo: {
142
+ hasNextPage: boolean;
143
+ endCursor?: string;
144
+ };
145
+ };
146
+ type StrategyFilter = {
147
+ id?: string;
148
+ id_in?: string[];
149
+ owner?: string;
150
+ owner_in?: string[];
151
+ sourceStrategy?: string;
152
+ sourceStrategy_in?: string[];
153
+ };
154
+ type DistributionFilter = {
155
+ strategyId?: string;
156
+ strategyId_in?: string[];
157
+ token?: string;
158
+ token_in?: string[];
159
+ };
160
+ type PayoutFilter = {
161
+ strategyId?: string;
162
+ strategyId_in?: string[];
163
+ distributionId?: string;
164
+ recipient?: string;
165
+ recipient_in?: string[];
166
+ token?: string;
167
+ };
168
+ type TransferFilter = {
169
+ strategyId?: string;
170
+ strategyId_in?: string[];
171
+ token?: string;
172
+ from?: string;
173
+ to?: string;
174
+ direction?: "in" | "out";
175
+ };
176
+ type DonorFilter = {
177
+ strategyId?: string;
178
+ strategyId_in?: string[];
179
+ address?: string;
180
+ address_in?: string[];
181
+ };
182
+ type StrategyBalanceFilter = {
183
+ strategyId?: string;
184
+ strategyId_in?: string[];
185
+ token?: string;
186
+ token_in?: string[];
187
+ };
188
+ type ForkFilter = {
189
+ sourceStrategyId?: string;
190
+ sourceStrategyId_in?: string[];
191
+ childStrategyId?: string;
192
+ childStrategyId_in?: string[];
193
+ };
194
+ type WarehouseBalanceFilter = {
195
+ user?: string;
196
+ user_in?: string[];
197
+ token?: string;
198
+ token_in?: string[];
199
+ };
200
+ type YieldRedirectorFilter = {
201
+ id?: string;
202
+ id_in?: string[];
203
+ owner?: string;
204
+ owner_in?: string[];
205
+ sourceVault?: string;
206
+ yieldRecipient?: string;
207
+ yieldRecipient_in?: string[];
208
+ };
209
+ type HarvestFilter = {
210
+ redirectorId?: string;
211
+ redirectorId_in?: string[];
212
+ recipient?: string;
213
+ recipient_in?: string[];
214
+ };
215
+ type QueryVariables<TFilter> = {
216
+ where?: TFilter;
217
+ orderBy?: string;
218
+ orderDirection?: "asc" | "desc";
219
+ limit?: number;
220
+ after?: string;
221
+ };
222
+ type TrendingStrategy = Strategy & {
223
+ trendingStats: {
224
+ transferCount: number;
225
+ totalAmount: string;
226
+ };
227
+ };
228
+ type TrendingResponse = {
229
+ data: TrendingStrategy[];
230
+ period: "24h" | "7d";
231
+ };
232
+ type TokenTotals = {
233
+ token: Address;
234
+ totalReceived: string;
235
+ totalDistributed: string;
236
+ };
237
+ type ProtocolStats = {
238
+ totalStrategies: number;
239
+ totalCurators: number;
240
+ totalDonors: number;
241
+ totalDistributions: number;
242
+ totalAllocatedUSD: string;
243
+ totalsByToken: TokenTotals[];
244
+ };
245
+ type StatsResponse = {
246
+ data: ProtocolStats;
247
+ };
248
+ type StrategyLineage = {
249
+ strategy: Address;
250
+ sourceStrategy: Address | null;
251
+ ancestors: Address[];
252
+ children: Address[];
253
+ depth: number;
254
+ };
255
+ type LineageResponse = {
256
+ data: StrategyLineage;
257
+ };
258
+ type IndexerBase = {
259
+ client: Client;
260
+ gql: typeof gql;
261
+ baseUrl: string;
262
+ strategy: {
263
+ get: (id: Address) => Promise<Strategy | null>;
264
+ query: (variables?: QueryVariables<StrategyFilter>) => Promise<Page<Strategy> | null>;
265
+ };
266
+ distribution: {
267
+ query: (variables?: QueryVariables<DistributionFilter>) => Promise<Page<Distribution> | null>;
268
+ };
269
+ payout: {
270
+ query: (variables?: QueryVariables<PayoutFilter>) => Promise<Page<Payout> | null>;
271
+ };
272
+ donor: {
273
+ query: (variables?: QueryVariables<DonorFilter>) => Promise<Page<Donor> | null>;
274
+ };
275
+ strategyBalance: {
276
+ query: (variables?: QueryVariables<StrategyBalanceFilter>) => Promise<Page<StrategyBalance> | null>;
277
+ };
278
+ fork: {
279
+ query: (variables?: QueryVariables<ForkFilter>) => Promise<Page<Fork> | null>;
280
+ };
281
+ warehouseBalance: {
282
+ query: (variables?: QueryVariables<WarehouseBalanceFilter>) => Promise<Page<WarehouseBalance> | null>;
283
+ };
284
+ yieldRedirector: {
285
+ get: (id: Address) => Promise<YieldRedirector | null>;
286
+ query: (variables?: QueryVariables<YieldRedirectorFilter>) => Promise<Page<YieldRedirector> | null>;
287
+ };
288
+ harvest: {
289
+ query: (variables?: QueryVariables<HarvestFilter>) => Promise<Page<Harvest> | null>;
290
+ };
291
+ trending: (options?: {
292
+ period?: "24h" | "7d";
293
+ limit?: number;
294
+ }) => Promise<TrendingResponse>;
295
+ stats: () => Promise<ProtocolStats>;
296
+ lineage: (strategyAddress: Address) => Promise<StrategyLineage | null>;
297
+ };
298
+ type Indexer = IndexerBase & {
299
+ extend<T>(extension: IndexerExtension<T>): Indexer & T;
300
+ };
301
+ type IndexerExtension<T> = (indexer: Indexer) => T;
302
+ declare function createIndexer(chainId: SupportedChainId): Indexer;
303
+
304
+ export { type Allocation as A, type DistributionFilter as D, ENS_DOMAIN as E, type ForkFilter as F, type HarvestFilter as H, type Indexer as I, type LineageResponse as L, type Page as P, type QueryVariables as Q, type StrategyFilter as S, type TrendingResponse as T, type WarehouseBalance as W, type YieldRedirector as Y, type Distribution as a, type DonorFilter as b, type Donor as c, type Fork as d, type Harvest as e, type PayoutFilter as f, type Payout as g, type ProtocolStats as h, type Strategy as i, type StrategyBalanceFilter as j, type StrategyBalance as k, type StrategyLineage as l, type WarehouseBalanceFilter as m, type YieldRedirectorFilter as n, type SupportedChainId as o, type IndexerExtension as p, type StatsResponse as q, type TokenTotals as r, type Transfer as s, type TransferFilter as t, type TrendingStrategy as u, config as v, createIndexer as w };
@@ -0,0 +1,3 @@
1
+ export { A as Allocation, a as Distribution, c as Donor, E as ENS_DOMAIN, d as Fork, e as Harvest, I as Indexer, g as Payout, h as ProtocolStats, i as Strategy, k as StrategyBalance, l as StrategyLineage, o as SupportedChainId, s as Transfer, u as TrendingStrategy, W as WarehouseBalance, Y as YieldRedirector, v as config, w as createIndexer } from './server-BOSsS_Jk.js';
2
+ import '@urql/core';
3
+ import 'viem';
package/dist/server.js ADDED
@@ -0,0 +1,10 @@
1
+ import {
2
+ ENS_DOMAIN,
3
+ config,
4
+ createIndexer
5
+ } from "./chunk-QEWRRW3A.js";
6
+ export {
7
+ ENS_DOMAIN,
8
+ config,
9
+ createIndexer
10
+ };