@curator-studio/sdk 0.1.0 → 0.1.2
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/README.md +204 -0
- package/dist/index.js +24345 -53
- package/package.json +28 -6
package/README.md
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# @curator-studio/sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK and React hooks for the [Curator Studio](https://github.com/carlbarrdahl/curator-studio) capital allocation protocol.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @curator-studio/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install viem wagmi @tanstack/react-query react sonner
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
### Standalone
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { CuratorSDK } from "@curator-studio/sdk";
|
|
23
|
+
|
|
24
|
+
const sdk = new CuratorSDK(walletClient, {
|
|
25
|
+
tenant: "support.eth",
|
|
26
|
+
indexerUrl: "https://your-indexer.example.com/graphql",
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Create a strategy
|
|
30
|
+
const { strategy } = await sdk.strategy.create({
|
|
31
|
+
owner: "0x...",
|
|
32
|
+
allocations: [
|
|
33
|
+
{ recipient: "0xProjectA...", weight: 40n, label: "Project A" },
|
|
34
|
+
{ recipient: "0xProjectB...", weight: 35n, label: "Project B" },
|
|
35
|
+
{ recipient: "0xCurator...", weight: 5n, label: "Curator Fee" },
|
|
36
|
+
],
|
|
37
|
+
metadataURI: "https://...",
|
|
38
|
+
sourceStrategy: "0x0000000000000000000000000000000000000000",
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Distribute funds
|
|
42
|
+
await sdk.strategy.distribute(strategyAddress, tokenAddress);
|
|
43
|
+
|
|
44
|
+
// Withdraw from warehouse
|
|
45
|
+
await sdk.warehouse.withdraw(recipientAddress, tokenAddress);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### React
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
import {
|
|
52
|
+
CuratorProvider,
|
|
53
|
+
useStrategies,
|
|
54
|
+
useCreateStrategy,
|
|
55
|
+
} from "@curator-studio/sdk";
|
|
56
|
+
|
|
57
|
+
function App() {
|
|
58
|
+
return (
|
|
59
|
+
<CuratorProvider
|
|
60
|
+
tenant="support.eth"
|
|
61
|
+
indexerUrl="https://your-indexer.example.com/graphql"
|
|
62
|
+
>
|
|
63
|
+
<StrategiesList />
|
|
64
|
+
</CuratorProvider>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function StrategiesList() {
|
|
69
|
+
const { data, isPending } = useStrategies({
|
|
70
|
+
orderBy: "timesForked",
|
|
71
|
+
orderDirection: "desc",
|
|
72
|
+
limit: 10,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
if (isPending) return <div>Loading...</div>;
|
|
76
|
+
return data?.items.map((s) => <div key={s.id}>{s.metadata?.title}</div>);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## API
|
|
81
|
+
|
|
82
|
+
### CuratorSDK
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
const sdk = new CuratorSDK(wallet?, options?)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
| Option | Type | Description |
|
|
89
|
+
|--------|------|-------------|
|
|
90
|
+
| `chain` | `SupportedChainId` | Chain ID (`1`, `11155111`, `84532`, `31337`) |
|
|
91
|
+
| `tenant` | `string` | Tenant ENS name (e.g. `"support.eth"`) |
|
|
92
|
+
| `indexerUrl` | `string` | GraphQL endpoint for the indexer |
|
|
93
|
+
| `uploadMetadata` | `UploadMetadataFn` | Function to upload strategy metadata |
|
|
94
|
+
|
|
95
|
+
### sdk.strategy
|
|
96
|
+
|
|
97
|
+
| Method | Description |
|
|
98
|
+
|--------|-------------|
|
|
99
|
+
| `create(config)` | Deploy a new strategy |
|
|
100
|
+
| `getData(address)` | Read on-chain strategy data |
|
|
101
|
+
| `balanceOf(address, token)` | Token balance held by a strategy |
|
|
102
|
+
| `rebalance(address, allocations, metadata)` | Update allocations (owner only) |
|
|
103
|
+
| `distribute(address, token)` | Distribute funds to recipients |
|
|
104
|
+
| `setENSName(address, label)` | Set ENS subdomain for a strategy |
|
|
105
|
+
|
|
106
|
+
### sdk.warehouse
|
|
107
|
+
|
|
108
|
+
| Method | Description |
|
|
109
|
+
|--------|-------------|
|
|
110
|
+
| `withdraw(owner, token)` | Withdraw from SplitsWarehouse |
|
|
111
|
+
| `balanceOf(owner, token)` | Check warehouse balance |
|
|
112
|
+
|
|
113
|
+
### sdk.yieldRedirector
|
|
114
|
+
|
|
115
|
+
| Method | Description |
|
|
116
|
+
|--------|-------------|
|
|
117
|
+
| `create(sourceVault, yieldRecipient, owner)` | Deploy a yield redirector |
|
|
118
|
+
| `createDeterministic(sourceVault, yieldRecipient, owner, salt)` | Deploy at a predictable address |
|
|
119
|
+
| `harvest(address)` | Harvest yield and distribute |
|
|
120
|
+
| `surplus(address)` | Check available yield |
|
|
121
|
+
| `principal(address)` | Check deposited principal |
|
|
122
|
+
| `sourceVaultValue(address)` | Total value in source vault |
|
|
123
|
+
| `setYieldRecipient(address, newRecipient)` | Change yield recipient |
|
|
124
|
+
|
|
125
|
+
### sdk.ens
|
|
126
|
+
|
|
127
|
+
| Method | Description |
|
|
128
|
+
|--------|-------------|
|
|
129
|
+
| `available(label)` | Check if ENS label is available |
|
|
130
|
+
| `register(label, owner?)` | Register ENS subdomain |
|
|
131
|
+
| `getAddress(name)` | Resolve ENS name to address |
|
|
132
|
+
| `setAddress(name, address)` | Set forward resolution |
|
|
133
|
+
| `setReverseRecord(name)` | Set reverse resolution |
|
|
134
|
+
| `registerWithAddress(label, address, owner?)` | Register with forward + reverse resolution |
|
|
135
|
+
|
|
136
|
+
### React Hooks
|
|
137
|
+
|
|
138
|
+
#### Provider
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
<CuratorProvider
|
|
142
|
+
tenant="support.eth"
|
|
143
|
+
defaultChain={11155111}
|
|
144
|
+
indexerUrl="https://..."
|
|
145
|
+
uploadMetadata={createUploadFn("/api/upload", secret)}
|
|
146
|
+
>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
#### Query Hooks
|
|
150
|
+
|
|
151
|
+
| Hook | Description |
|
|
152
|
+
|------|-------------|
|
|
153
|
+
| `useCuratorSDK()` | Access the SDK instance |
|
|
154
|
+
| `useStrategies(variables?)` | List strategies |
|
|
155
|
+
| `useStrategyById(id)` | Get strategy by address |
|
|
156
|
+
| `useStrategyData(address)` | On-chain strategy data |
|
|
157
|
+
| `useStrategyBalance(address, token)` | On-chain token balance |
|
|
158
|
+
| `useDistributions(variables?)` | List distributions |
|
|
159
|
+
| `usePayouts(variables?)` | List payouts |
|
|
160
|
+
| `useDonors(variables?)` | List donors |
|
|
161
|
+
| `useStrategyBalances(variables?)` | List strategy balances |
|
|
162
|
+
| `useForks(variables?)` | List forks |
|
|
163
|
+
| `useWarehouseBalances(variables?)` | List warehouse balances |
|
|
164
|
+
| `useWarehouseBalance(user, token)` | Single warehouse balance |
|
|
165
|
+
| `useYieldRedirectors(variables?)` | List yield redirectors |
|
|
166
|
+
| `useYieldRedirectorById(id)` | Get yield redirector by address |
|
|
167
|
+
| `useHarvests(variables?)` | List harvests |
|
|
168
|
+
| `useTrendingStrategies(options?)` | Trending strategies |
|
|
169
|
+
| `useProtocolStats()` | Protocol-wide stats |
|
|
170
|
+
| `useStrategyLineage(address)` | Fork tree |
|
|
171
|
+
| `useENSGetAddress(name)` | Resolve ENS name |
|
|
172
|
+
| `useENSAvailable(label)` | Check ENS availability |
|
|
173
|
+
|
|
174
|
+
#### Mutation Hooks
|
|
175
|
+
|
|
176
|
+
| Hook | Description |
|
|
177
|
+
|------|-------------|
|
|
178
|
+
| `useCreateStrategy()` | Create a strategy |
|
|
179
|
+
| `useRebalanceStrategy()` | Rebalance allocations |
|
|
180
|
+
| `useDistributeStrategy()` | Distribute funds |
|
|
181
|
+
| `useSetENSName()` | Set ENS name |
|
|
182
|
+
| `useWithdrawFromWarehouse()` | Withdraw from warehouse |
|
|
183
|
+
| `useCreateYieldRedirector()` | Create yield redirector |
|
|
184
|
+
| `useHarvestYield()` | Harvest yield |
|
|
185
|
+
|
|
186
|
+
#### Utility Hooks
|
|
187
|
+
|
|
188
|
+
| Hook | Description |
|
|
189
|
+
|------|-------------|
|
|
190
|
+
| `useInvalidate()` | Invalidate query cache keys |
|
|
191
|
+
| `useInvalidateENS()` | Invalidate ENS-related queries |
|
|
192
|
+
|
|
193
|
+
## Supported Chains
|
|
194
|
+
|
|
195
|
+
| Network | Chain ID |
|
|
196
|
+
|---------|----------|
|
|
197
|
+
| Mainnet | `1` |
|
|
198
|
+
| Sepolia | `11155111` |
|
|
199
|
+
| Base Sepolia | `84532` |
|
|
200
|
+
| Hardhat | `31337` |
|
|
201
|
+
|
|
202
|
+
## License
|
|
203
|
+
|
|
204
|
+
MIT
|