@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,81 @@
1
+ import { type Address, type WalletClient, type PublicClient } from "viem";
2
+ export type Allocation = {
3
+ recipient: Address;
4
+ weight: bigint;
5
+ label?: string;
6
+ };
7
+ /**
8
+ * Strategy configuration for creation
9
+ * Note: Fee is handled as the first allocation by convention
10
+ */
11
+ export type StrategyConfig = {
12
+ owner: Address;
13
+ sourceStrategy: Address;
14
+ allocations: Allocation[];
15
+ metadataURI: string;
16
+ ensLabel: string;
17
+ };
18
+ /**
19
+ * Strategy data returned from contract
20
+ * Note: Fee is calculated from first allocation
21
+ */
22
+ export type StrategyData = {
23
+ owner: Address;
24
+ sourceStrategy: Address;
25
+ allocations: Allocation[];
26
+ totalWeight: bigint;
27
+ metadataURI: string;
28
+ };
29
+ type ChainDeployments = {
30
+ Strategy: {
31
+ abi: unknown;
32
+ };
33
+ StrategyFactory: {
34
+ abi: unknown;
35
+ address: string;
36
+ };
37
+ };
38
+ export declare function createStrategyMethods(wallet: WalletClient | undefined, publicClient: PublicClient, deployments: ChainDeployments): {
39
+ /**
40
+ * Create a new strategy with optional ENS subdomain
41
+ * @param config Strategy configuration
42
+ * @param label ENS subdomain label (e.g., "mystrategy") - pass "" or omit to skip ENS
43
+ */
44
+ create: (config: StrategyConfig) => Promise<{
45
+ strategy: Address;
46
+ config: StrategyConfig;
47
+ }>;
48
+ /**
49
+ * Get strategy data including owner, allocations, and metadata
50
+ * Note: Fee is the first allocation by convention
51
+ */
52
+ getData: (strategyAddress: Address) => Promise<StrategyData>;
53
+ /**
54
+ * Get the balance of a token held by the strategy
55
+ */
56
+ balanceOf: (strategyAddress: Address, token: Address) => Promise<bigint>;
57
+ /**
58
+ * Update the allocation configuration and metadata (owner only)
59
+ */
60
+ rebalance: (strategyAddress: Address, allocations: Allocation[], metadataURI: string) => Promise<{
61
+ hash: `0x${string}`;
62
+ }>;
63
+ /**
64
+ * Distribute the strategy's token balance to recipients according to allocations
65
+ */
66
+ distribute: (strategyAddress: Address, token: Address) => Promise<{
67
+ hash: `0x${string}`;
68
+ }>;
69
+ /**
70
+ * Set ENS subdomain name for an existing strategy
71
+ * @param strategyAddress The strategy address to set ENS name for
72
+ * @param label ENS subdomain label (e.g., "mystrategy")
73
+ * @dev Automatically handles two cases:
74
+ * 1. If factory doesn't own the name: registers it via ENS registrar
75
+ * 2. If factory owns the name: connects pre-registered name
76
+ */
77
+ setENSName: (strategyAddress: Address, label: string) => Promise<{
78
+ hash: `0x${string}`;
79
+ }>;
80
+ };
81
+ export {};
@@ -0,0 +1,34 @@
1
+ import { type Address } from "viem";
2
+ export type TokenConfig = {
3
+ address: Address;
4
+ symbol: string;
5
+ name: string;
6
+ decimals: number;
7
+ logoURI?: string;
8
+ };
9
+ /**
10
+ * Native ETH address per ERC-7528 standard
11
+ * Used throughout the system to represent native ETH
12
+ */
13
+ export declare const NATIVE_TOKEN = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
14
+ export declare const isNativeToken: (token?: string) => boolean;
15
+ /**
16
+ * Native ETH token config
17
+ */
18
+ export declare const ETH_TOKEN: TokenConfig;
19
+ /**
20
+ * Get all available tokens for a chain
21
+ */
22
+ export declare function getTokens(chainId: number): TokenConfig[];
23
+ /**
24
+ * Get a token by symbol for a chain
25
+ */
26
+ export declare function getToken(chainId: number, symbol: string): TokenConfig | undefined;
27
+ /**
28
+ * Get a token by address for a chain
29
+ */
30
+ export declare function getTokenByAddress(chainId: number, address: Address): TokenConfig | undefined;
31
+ /**
32
+ * Get token addresses for a chain (useful for indexer)
33
+ */
34
+ export declare function getTokenAddresses(chainId: number): Address[];
@@ -0,0 +1,19 @@
1
+ import { type Address } from "viem";
2
+ export type VaultConfig = {
3
+ address: Address;
4
+ name: string;
5
+ symbol: string;
6
+ asset: Address;
7
+ };
8
+ /**
9
+ * Get all available vaults for a chain
10
+ */
11
+ export declare function getVaults(chainId: number): VaultConfig[];
12
+ /**
13
+ * Get a vault by address for a chain
14
+ */
15
+ export declare function getVaultByAddress(chainId: number, address: Address): VaultConfig | undefined;
16
+ /**
17
+ * Get vault addresses for a chain
18
+ */
19
+ export declare function getVaultAddresses(chainId: number): Address[];
@@ -0,0 +1,24 @@
1
+ import { type Address, type WalletClient, type PublicClient } from "viem";
2
+ import { type SupportedChainId } from "./config";
3
+ type ChainDeployments = {
4
+ SplitsWarehouse: {
5
+ abi: unknown;
6
+ };
7
+ };
8
+ export declare function createWarehouseMethods(wallet: WalletClient | undefined, publicClient: PublicClient, chainId: SupportedChainId, deployments: ChainDeployments): {
9
+ /**
10
+ * Withdraw tokens from the SplitsWarehouse
11
+ * @param owner Address to withdraw for (usually msg.sender)
12
+ * @param token Token address to withdraw
13
+ */
14
+ withdraw: (owner: Address, token: Address) => Promise<{
15
+ hash: `0x${string}`;
16
+ }>;
17
+ /**
18
+ * Get warehouse balance for a user/token
19
+ * @param owner Address to check balance for
20
+ * @param token Token address
21
+ */
22
+ balanceOf: (owner: Address, token: Address) => Promise<bigint>;
23
+ };
24
+ export {};
@@ -0,0 +1,68 @@
1
+ import { type Address, type WalletClient, type PublicClient } from "viem";
2
+ type ChainDeployments = {
3
+ YieldRedirectorFactory: {
4
+ abi: unknown;
5
+ address: string;
6
+ };
7
+ YieldRedirector4626: {
8
+ abi: unknown;
9
+ };
10
+ };
11
+ export declare function createYieldRedirectorMethods(wallet: WalletClient | undefined, publicClient: PublicClient, deployments: ChainDeployments): {
12
+ /**
13
+ * Create a new yield redirector
14
+ * @param sourceVault ERC-4626 vault address that generates yield
15
+ * @param yieldRecipient Address to receive harvested yield (typically a Strategy)
16
+ * @param owner Address that can update yield recipient
17
+ */
18
+ create: (sourceVault: Address, yieldRecipient: Address, owner: Address) => Promise<{
19
+ redirector: Address;
20
+ sourceVault: Address;
21
+ yieldRecipient: Address;
22
+ owner: Address;
23
+ }>;
24
+ /**
25
+ * Create a new yield redirector with deterministic address
26
+ * @param sourceVault ERC-4626 vault address that generates yield
27
+ * @param yieldRecipient Address to receive harvested yield (typically a Strategy)
28
+ * @param owner Address that can update yield recipient
29
+ * @param salt Bytes32 salt for deterministic address generation
30
+ */
31
+ createDeterministic: (sourceVault: Address, yieldRecipient: Address, owner: Address, salt: `0x${string}`) => Promise<{
32
+ redirector: Address;
33
+ sourceVault: Address;
34
+ yieldRecipient: Address;
35
+ owner: Address;
36
+ }>;
37
+ /**
38
+ * Harvest yield from a redirector and send to recipient
39
+ * @param redirectorAddress The yield redirector contract address
40
+ */
41
+ harvest: (redirectorAddress: Address) => Promise<{
42
+ hash: `0x${string}`;
43
+ }>;
44
+ /**
45
+ * Get the current surplus (harvestable yield) from a redirector
46
+ * @param redirectorAddress The yield redirector contract address
47
+ */
48
+ surplus: (redirectorAddress: Address) => Promise<bigint>;
49
+ /**
50
+ * Get the principal deposited in a redirector
51
+ * @param redirectorAddress The yield redirector contract address
52
+ */
53
+ principal: (redirectorAddress: Address) => Promise<bigint>;
54
+ /**
55
+ * Get the total value in the source vault (principal + yield)
56
+ * @param redirectorAddress The yield redirector contract address
57
+ */
58
+ sourceVaultValue: (redirectorAddress: Address) => Promise<bigint>;
59
+ /**
60
+ * Update the yield recipient (owner only)
61
+ * @param redirectorAddress The yield redirector contract address
62
+ * @param newRecipient New address to receive harvested yield
63
+ */
64
+ setYieldRecipient: (redirectorAddress: Address, newRecipient: Address) => Promise<{
65
+ hash: `0x${string}`;
66
+ }>;
67
+ };
68
+ export {};
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@curator-studio/sdk",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "types": "./dist/index.d.ts",
16
+ "dependencies": {
17
+ "@ensdomains/ensjs": "^4.2.2",
18
+ "@urql/core": "^6.0.1",
19
+ "@vercel/blob": "^2.2.0",
20
+ "@curator-studio/contracts": "1.0.0"
21
+ },
22
+ "peerDependencies": {
23
+ "@tanstack/react-query": ">=5.0.0",
24
+ "react": "^19.2.4",
25
+ "sonner": ">=1.0.0",
26
+ "typescript": ">=4.5.0",
27
+ "viem": "^2.45.1",
28
+ "wagmi": ">=2.0.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/react": "^19.2.13",
32
+ "@types/react-dom": "^19.2.3",
33
+ "tsup": "^8.5.1",
34
+ "vitest": "^4.0.18"
35
+ },
36
+ "scripts": {
37
+ "build": "tsup src/index.ts --format esm --dts",
38
+ "dev": "tsup src/index.ts --watch --format esm --dts",
39
+ "check-types": "tsc --noEmit",
40
+ "test": "vitest run",
41
+ "test:watch": "vitest"
42
+ }
43
+ }