@curator-studio/sdk
v0.1.4
Published
TypeScript SDK and React hooks for the Curator Studio capital allocation protocol
Maintainers
Readme
@curator-studio/sdk
TypeScript SDK and React hooks for the Curator Studio capital allocation protocol.
Install
npm install @curator-studio/sdkPeer dependencies:
npm install viem wagmi @tanstack/react-query react sonnerQuick Start
Standalone
import { CuratorSDK } from "@curator-studio/sdk";
const sdk = new CuratorSDK(walletClient, {
tenant: "support.eth",
indexerUrl: "https://your-indexer.example.com/graphql",
});
// Create a strategy
const { strategy } = await sdk.strategy.create({
owner: "0x...",
allocations: [
{ recipient: "0xProjectA...", weight: 40n, label: "Project A" },
{ recipient: "0xProjectB...", weight: 35n, label: "Project B" },
{ recipient: "0xCurator...", weight: 5n, label: "Curator Fee" },
],
metadataURI: "https://...",
sourceStrategy: "0x0000000000000000000000000000000000000000",
});
// Distribute funds
await sdk.strategy.distribute(strategyAddress, tokenAddress);
// Withdraw from warehouse
await sdk.warehouse.withdraw(recipientAddress, tokenAddress);React
import {
CuratorProvider,
useStrategies,
useCreateStrategy,
} from "@curator-studio/sdk";
function App() {
return (
<CuratorProvider
tenant="support.eth"
indexerUrl="https://your-indexer.example.com/graphql"
>
<StrategiesList />
</CuratorProvider>
);
}
function StrategiesList() {
const { data, isPending } = useStrategies({
orderBy: "timesForked",
orderDirection: "desc",
limit: 10,
});
if (isPending) return <div>Loading...</div>;
return data?.items.map((s) => <div key={s.id}>{s.metadata?.title}</div>);
}API
CuratorSDK
const sdk = new CuratorSDK(wallet?, options?)| Option | Type | Description |
|--------|------|-------------|
| chain | SupportedChainId | Chain ID (1, 11155111, 84532, 31337) |
| tenant | string | Tenant ENS name (e.g. "support.eth") |
| indexerUrl | string | GraphQL endpoint for the indexer |
| uploadMetadata | UploadMetadataFn | Function to upload strategy metadata |
sdk.strategy
| Method | Description |
|--------|-------------|
| create(config) | Deploy a new strategy |
| getData(address) | Read on-chain strategy data |
| balanceOf(address, token) | Token balance held by a strategy |
| rebalance(address, allocations, metadata) | Update allocations (owner only) |
| distribute(address, token) | Distribute funds to recipients |
| setENSName(address, label) | Set ENS subdomain for a strategy |
sdk.warehouse
| Method | Description |
|--------|-------------|
| withdraw(owner, token) | Withdraw from SplitsWarehouse |
| balanceOf(owner, token) | Check warehouse balance |
sdk.yieldRedirector
| Method | Description |
|--------|-------------|
| create(sourceVault, yieldRecipient, owner) | Deploy a yield redirector |
| createDeterministic(sourceVault, yieldRecipient, owner, salt) | Deploy at a predictable address |
| harvest(address) | Harvest yield and distribute |
| surplus(address) | Check available yield |
| principal(address) | Check deposited principal |
| sourceVaultValue(address) | Total value in source vault |
| setYieldRecipient(address, newRecipient) | Change yield recipient |
sdk.ens
| Method | Description |
|--------|-------------|
| available(label) | Check if ENS label is available |
| register(label, owner?) | Register ENS subdomain |
| getAddress(name) | Resolve ENS name to address |
| setAddress(name, address) | Set forward resolution |
| setReverseRecord(name) | Set reverse resolution |
| registerWithAddress(label, address, owner?) | Register with forward + reverse resolution |
React Hooks
Provider
<CuratorProvider
tenant="support.eth"
defaultChain={11155111}
indexerUrl="https://..."
uploadMetadata={createUploadFn("/api/upload", secret)}
>Query Hooks
| Hook | Description |
|------|-------------|
| useCuratorSDK() | Access the SDK instance |
| useStrategies(variables?) | List strategies |
| useStrategyById(id) | Get strategy by address |
| useStrategyData(address) | On-chain strategy data |
| useStrategyBalance(address, token) | On-chain token balance |
| useDistributions(variables?) | List distributions |
| usePayouts(variables?) | List payouts |
| useDonors(variables?) | List donors |
| useStrategyBalances(variables?) | List strategy balances |
| useForks(variables?) | List forks |
| useWarehouseBalances(variables?) | List warehouse balances |
| useWarehouseBalance(user, token) | Single warehouse balance |
| useYieldRedirectors(variables?) | List yield redirectors |
| useYieldRedirectorById(id) | Get yield redirector by address |
| useHarvests(variables?) | List harvests |
| useTrendingStrategies(options?) | Trending strategies |
| useProtocolStats() | Protocol-wide stats |
| useStrategyLineage(address) | Fork tree |
| useENSGetAddress(name) | Resolve ENS name |
| useENSAvailable(label) | Check ENS availability |
Mutation Hooks
| Hook | Description |
|------|-------------|
| useCreateStrategy() | Create a strategy |
| useRebalanceStrategy() | Rebalance allocations |
| useDistributeStrategy() | Distribute funds |
| useSetENSName() | Set ENS name |
| useWithdrawFromWarehouse() | Withdraw from warehouse |
| useCreateYieldRedirector() | Create yield redirector |
| useHarvestYield() | Harvest yield |
Utility Hooks
| Hook | Description |
|------|-------------|
| useInvalidate() | Invalidate query cache keys |
| useInvalidateENS() | Invalidate ENS-related queries |
Supported Chains
| Network | Chain ID |
|---------|----------|
| Mainnet | 1 |
| Sepolia | 11155111 |
| Base Sepolia | 84532 |
| Hardhat | 31337 |
License
MIT
