@surf_liquid/surf-widget 0.1.5

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,431 @@
1
+ import { default as default_2 } from 'react';
2
+ import { JSX as JSX_2 } from 'react/jsx-runtime';
3
+ import { ReactNode } from 'react';
4
+
5
+ /** Shape returned by surfliquid's client.getAgentMessages() */
6
+ export declare interface AgentMessage {
7
+ message: string;
8
+ txHash: string;
9
+ /** ISO 8601 date string e.g. "2026-04-09T11:59:13.000Z" */
10
+ timestamp: string;
11
+ /** e.g. "USER_DEPOSIT" | "USER_WITHDRAWAL" | "AGENT_REBALANCE" */
12
+ transactionType: string;
13
+ /** "USER" | "AGENT" */
14
+ executedBy: string;
15
+ /** e.g. "v4" */
16
+ vaultVersion?: string;
17
+ chainId?: number;
18
+ }
19
+
20
+ export declare function Button({ variant, size, isLoading, leftIcon, rightIcon, fullWidth, children, className, disabled, style, ...props }: ButtonProps): JSX_2.Element;
21
+
22
+ export declare interface ButtonProps extends default_2.ButtonHTMLAttributes<HTMLButtonElement> {
23
+ variant?: ButtonVariant;
24
+ size?: ButtonSize;
25
+ isLoading?: boolean;
26
+ leftIcon?: default_2.ReactNode;
27
+ rightIcon?: default_2.ReactNode;
28
+ fullWidth?: boolean;
29
+ }
30
+
31
+ export declare type ButtonSize = 'sm' | 'md' | 'lg';
32
+
33
+ export declare type ButtonVariant = 'primary' | 'outline' | 'ghost' | 'soft';
34
+
35
+ export declare interface ChainInfo {
36
+ name: string;
37
+ id: number;
38
+ }
39
+
40
+ declare interface Credentials {
41
+ appId: string;
42
+ apiSecret: string;
43
+ }
44
+
45
+ export declare function DepositModal({ isOpen, onClose, vault, onSwitchToWithdraw, }: DepositModalProps): JSX_2.Element;
46
+
47
+ export declare interface DepositModalProps {
48
+ isOpen: boolean;
49
+ onClose: () => void;
50
+ vault: VaultInfo | null;
51
+ onSwitchToWithdraw?: () => void;
52
+ }
53
+
54
+ export declare type DepositStep = {
55
+ id: 'idle';
56
+ } | {
57
+ id: 'creating_contract';
58
+ txHash?: string;
59
+ } | {
60
+ id: 'approving';
61
+ txHash?: string;
62
+ } | {
63
+ id: 'depositing';
64
+ txHash?: string;
65
+ } | {
66
+ id: 'success';
67
+ txHash: string;
68
+ amount: string;
69
+ } | {
70
+ id: 'error';
71
+ error: Error;
72
+ };
73
+
74
+ export declare interface ISurfClient {
75
+ getVault(walletAddress?: string): Promise<SurfVaultInfo>;
76
+ deployVault(): Promise<{
77
+ vaultAddress: string;
78
+ transactionHash: string;
79
+ }>;
80
+ deposit(params: {
81
+ asset: string;
82
+ amount: string;
83
+ }): Promise<{
84
+ hash: string;
85
+ wait(): Promise<unknown>;
86
+ }>;
87
+ withdraw(params: {
88
+ asset: string;
89
+ amount?: string;
90
+ }): Promise<{
91
+ hash: string;
92
+ wait(): Promise<unknown>;
93
+ }>;
94
+ getSupportedAssets(chainId?: number): Promise<SurfSupportedAsset[]>;
95
+ /** Returns wallet's raw token balance in wei (bigint) — from ERC20 balanceOf */
96
+ getTokenBalance(tokenAddress: string, owner?: string): Promise<bigint>;
97
+ /** Returns the max withdrawable amount in wei (bigint) — from vault contract */
98
+ getWithdrawableAmount(assetAddress: string, vaultAddress?: string): Promise<bigint>;
99
+ /** Returns agent activity messages for the wallet */
100
+ getAgentMessages(walletAddress?: string, page?: number, limit?: number): Promise<AgentMessage[]>;
101
+ on(event: string, handler: (data: {
102
+ txHash: string;
103
+ }) => void): void;
104
+ off(event: string, handler: (data: {
105
+ txHash: string;
106
+ }) => void): void;
107
+ }
108
+
109
+ export declare function ManageDropdown({ isOpen, onClose, onWithdraw, onViewDeposits, onViewActivities }: ManageDropdownProps): JSX_2.Element | null;
110
+
111
+ export declare interface ManageDropdownProps {
112
+ isOpen: boolean;
113
+ onClose: () => void;
114
+ onWithdraw: () => void;
115
+ onViewDeposits: () => void;
116
+ onViewActivities: () => void;
117
+ }
118
+
119
+ export declare function Modal({ isOpen, onClose, children, className }: ModalProps): JSX_2.Element | null;
120
+
121
+ export declare interface ModalProps {
122
+ isOpen: boolean;
123
+ onClose: () => void;
124
+ children: default_2.ReactNode;
125
+ className?: string;
126
+ }
127
+
128
+ export declare function RegistrationForm({ walletAddress, onSuccess }: RegistrationFormProps): JSX_2.Element;
129
+
130
+ export declare interface RegistrationFormProps {
131
+ /** Pre-fill the wallet address field (e.g. from connected wallet) */
132
+ walletAddress?: string;
133
+ /** Called when registration completes successfully */
134
+ onSuccess?: (credentials: Credentials) => void;
135
+ }
136
+
137
+ export declare interface Step {
138
+ id: string;
139
+ title: string;
140
+ description: string;
141
+ status: StepStatus;
142
+ txHash?: string;
143
+ }
144
+
145
+ export declare function StepProgress({ steps, className, baseExplorerUrl }: StepProgressProps): JSX_2.Element;
146
+
147
+ export declare interface StepProgressProps {
148
+ steps: Step[];
149
+ className?: string;
150
+ baseExplorerUrl?: string;
151
+ }
152
+
153
+ export declare type StepStatus = 'pending' | 'active' | 'completed' | 'error';
154
+
155
+ export declare interface SurfConfig {
156
+ client: ISurfClient;
157
+ walletAddress: string;
158
+ chainId?: number;
159
+ theme?: SurfTheme;
160
+ onSuccess?: (action: 'deposit' | 'withdraw', txHash: string) => void;
161
+ onError?: (action: 'deposit' | 'withdraw', error: Error) => void;
162
+ }
163
+
164
+ export declare const SurfContext: default_2.Context<SurfContextValue | null>;
165
+
166
+ export declare interface SurfContextValue {
167
+ walletAddress: string;
168
+ chainId: number;
169
+ surfClient: ISurfClient;
170
+ theme: SurfTheme;
171
+ onSuccess?: SurfConfig['onSuccess'];
172
+ onError?: SurfConfig['onError'];
173
+ }
174
+
175
+ export declare function SurfProvider({ config, containerRef, children }: SurfProviderProps): JSX_2.Element;
176
+
177
+ export declare interface SurfProviderProps {
178
+ config: SurfConfig;
179
+ containerRef: default_2.RefObject<HTMLDivElement | null>;
180
+ children: ReactNode;
181
+ }
182
+
183
+ declare interface SurfSupportedAsset {
184
+ assetAddress: string;
185
+ assetSymbol: string;
186
+ assetDecimals: number;
187
+ chainId: number;
188
+ currentAPY: number;
189
+ }
190
+
191
+ export declare interface SurfTheme {
192
+ colors?: {
193
+ primary?: string;
194
+ primaryText?: string;
195
+ background?: string;
196
+ cardBackground?: string;
197
+ text?: string;
198
+ textSecondary?: string;
199
+ apy?: string;
200
+ border?: string;
201
+ success?: string;
202
+ };
203
+ borderRadius?: string;
204
+ fontFamily?: string;
205
+ }
206
+
207
+ declare interface SurfVaultAsset {
208
+ assetAddress: string;
209
+ assetSymbol: string;
210
+ assetDecimals: number;
211
+ chainId: number;
212
+ currentValueUSD: number;
213
+ totalEarningsUSD: number;
214
+ currentAPY: number;
215
+ }
216
+
217
+ /** Shape returned by surfliquid's client.getVault() */
218
+ declare interface SurfVaultInfo {
219
+ exists: boolean;
220
+ userVaultAddress: string | null;
221
+ homeChainId: number;
222
+ totalValueUSD: number;
223
+ totalDepositedUSD: number;
224
+ earned: {
225
+ totalEarningsUSD: number;
226
+ };
227
+ apyBreakdown: {
228
+ currentAPY: number;
229
+ };
230
+ assets: SurfVaultAsset[];
231
+ }
232
+
233
+ /**
234
+ * Drop-in DeFi yield widget.
235
+ * Pass a SurfClient (from surfliquid) + walletAddress and get the full UI.
236
+ *
237
+ * @example
238
+ * const client = SurfClient.create({ appId: '...', chainId: 8453 });
239
+ * await client.connectWallet('metamask');
240
+ * await client.authenticate();
241
+ *
242
+ * <SurfWidget client={client} walletAddress={address} />
243
+ */
244
+ export declare function SurfWidget({ client, walletAddress, chainId, theme, onSuccess, onError, className }: SurfWidgetProps): JSX_2.Element;
245
+
246
+ export declare interface SurfWidgetProps {
247
+ client: ISurfClient;
248
+ walletAddress: string;
249
+ /** 8453 = Base (default), 137 = Polygon */
250
+ chainId?: number;
251
+ theme?: SurfTheme;
252
+ className?: string;
253
+ onSuccess?: (action: 'deposit' | 'withdraw', txHash: string) => void;
254
+ onError?: (action: 'deposit' | 'withdraw', error: Error) => void;
255
+ }
256
+
257
+ export declare interface Tab {
258
+ id: string;
259
+ label: string;
260
+ }
261
+
262
+ export declare function Tabs({ tabs, activeTab, onChange, className, variant }: TabsProps): JSX_2.Element;
263
+
264
+ export declare interface TabsProps {
265
+ tabs: Tab[];
266
+ activeTab: string;
267
+ onChange: (id: string) => void;
268
+ className?: string;
269
+ variant?: 'pill' | 'underline';
270
+ }
271
+
272
+ export declare function TokenIcon({ symbol, icon, size, className }: TokenIconProps): JSX_2.Element;
273
+
274
+ export declare interface TokenIconProps {
275
+ symbol: string;
276
+ icon?: string;
277
+ size?: number;
278
+ className?: string;
279
+ }
280
+
281
+ export declare interface TokenInfo {
282
+ symbol: string;
283
+ name: string;
284
+ icon?: string;
285
+ decimals: number;
286
+ address: string;
287
+ }
288
+
289
+ export declare function useAgentMessages(): UseAgentMessagesReturn;
290
+
291
+ export declare interface UseAgentMessagesReturn {
292
+ activities: VaultActivity[];
293
+ isLoading: boolean;
294
+ refetch: () => void;
295
+ }
296
+
297
+ export declare interface UseBalanceReturn {
298
+ balance: string;
299
+ isLoading: boolean;
300
+ refetch: () => void;
301
+ }
302
+
303
+ export declare function useDeposit(): UseDepositReturn;
304
+
305
+ /**
306
+ * Fetch the wallet's spendable token balance — used in the Deposit form.
307
+ * getTokenBalance returns a raw bigint (uint256 wei) from ERC20 balanceOf.
308
+ */
309
+ export declare function useDepositBalance(tokenAddress: string, decimals?: number): UseBalanceReturn;
310
+
311
+ export declare interface UseDepositReturn {
312
+ step: DepositStep;
313
+ isProcessing: boolean;
314
+ execute: (amount: string, vault: VaultInfo) => Promise<void>;
315
+ reset: () => void;
316
+ }
317
+
318
+ export declare function useSurf(): SurfContextValue;
319
+
320
+ export declare function useVault(): UseVaultReturn;
321
+
322
+ export declare interface UseVaultReturn {
323
+ vault: VaultInfo | null;
324
+ isLoading: boolean;
325
+ error: Error | null;
326
+ refetch: () => void;
327
+ }
328
+
329
+ export declare function useWithdraw(): UseWithdrawReturn;
330
+
331
+ /**
332
+ * Fetch the max withdrawable amount from the vault — used in the Withdraw form.
333
+ * getWithdrawableAmount returns a raw bigint (uint256 wei) from the vault contract.
334
+ */
335
+ export declare function useWithdrawableBalance(assetAddress: string, vaultAddress?: string, decimals?: number): UseBalanceReturn;
336
+
337
+ export declare interface UseWithdrawReturn {
338
+ step: WithdrawStep;
339
+ isProcessing: boolean;
340
+ execute: (amount: string, vault: VaultInfo) => Promise<void>;
341
+ reset: () => void;
342
+ }
343
+
344
+ export declare interface VaultActivity {
345
+ id: string;
346
+ type: 'deposit' | 'withdraw';
347
+ description: string;
348
+ protocol: string;
349
+ timestamp: number;
350
+ txHash?: string;
351
+ }
352
+
353
+ export declare function VaultActivityModal({ isOpen, onClose, initialTab, vault, onWithdraw, onDeposit, }: VaultActivityModalProps): JSX_2.Element;
354
+
355
+ export declare interface VaultActivityModalProps {
356
+ isOpen: boolean;
357
+ onClose: () => void;
358
+ initialTab?: "activities" | "deposits";
359
+ vault?: VaultInfo | null;
360
+ onWithdraw?: () => void;
361
+ onDeposit?: () => void;
362
+ }
363
+
364
+ export declare function VaultCard({ vault, onDeposit, onWithdraw, onViewDeposits, onViewActivities, isSelected, isLoading, className, }: VaultCardProps): JSX_2.Element;
365
+
366
+ export declare interface VaultCardProps {
367
+ vault: VaultInfo;
368
+ onDeposit: () => void;
369
+ onWithdraw: () => void;
370
+ onViewDeposits: () => void;
371
+ onViewActivities: () => void;
372
+ isSelected?: boolean;
373
+ isLoading?: boolean;
374
+ className?: string;
375
+ }
376
+
377
+ export declare interface VaultDeposit {
378
+ id: string;
379
+ token: {
380
+ symbol: string;
381
+ icon?: string;
382
+ };
383
+ chain: {
384
+ name: string;
385
+ id?: number;
386
+ };
387
+ amount: string;
388
+ earned: string;
389
+ vaultUrl?: string;
390
+ }
391
+
392
+ export declare interface VaultInfo {
393
+ token: TokenInfo;
394
+ chain: ChainInfo;
395
+ balance: string;
396
+ earnings: string;
397
+ apy: number;
398
+ withdrawalType: 'instant' | 'standard';
399
+ availableBalance: string;
400
+ userVaultAddress?: string;
401
+ /** Raw vault assets — used by the deposits tab in VaultActivityModal */
402
+ assets?: SurfVaultAsset[];
403
+ }
404
+
405
+ export declare function WithdrawModal({ isOpen, onClose, vault, onSwitchToDeposit, }: WithdrawModalProps): JSX_2.Element;
406
+
407
+ export declare interface WithdrawModalProps {
408
+ isOpen: boolean;
409
+ onClose: () => void;
410
+ vault: VaultInfo | null;
411
+ onSwitchToDeposit?: () => void;
412
+ }
413
+
414
+ export declare type WithdrawStep = {
415
+ id: 'idle';
416
+ } | {
417
+ id: 'closing_position';
418
+ txHash?: string;
419
+ } | {
420
+ id: 'redeeming_reward';
421
+ txHash?: string;
422
+ } | {
423
+ id: 'success';
424
+ txHash: string;
425
+ amount: string;
426
+ } | {
427
+ id: 'error';
428
+ error: Error;
429
+ };
430
+
431
+ export { }