@compass-labs/widgets 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.
- package/README.md +138 -0
- package/dist/index.d.mts +910 -0
- package/dist/index.d.ts +910 -0
- package/dist/index.js +3330 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3299 -0
- package/dist/index.mjs.map +1 -0
- package/dist/server/index.d.mts +56 -0
- package/dist/server/index.d.ts +56 -0
- package/dist/server/index.js +253 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/index.mjs +251 -0
- package/dist/server/index.mjs.map +1 -0
- package/dist/styles.css +166 -0
- package/package.json +76 -0
package/README.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# @compass-labs/widgets
|
|
2
|
+
|
|
3
|
+
Embeddable DeFi widgets for React applications, powered by Compass Labs.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @compass-labs/widgets
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { CompassProvider, VaultsList } from '@compass-labs/widgets';
|
|
15
|
+
import '@compass-labs/widgets/styles.css';
|
|
16
|
+
|
|
17
|
+
function App() {
|
|
18
|
+
return (
|
|
19
|
+
<CompassProvider
|
|
20
|
+
apiKey="your-compass-api-key"
|
|
21
|
+
defaultChain="base"
|
|
22
|
+
>
|
|
23
|
+
<VaultsList
|
|
24
|
+
onDeposit={(vault, amount, txHash) => {
|
|
25
|
+
console.log('Deposited:', amount, 'to', vault.name);
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
</CompassProvider>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Components
|
|
34
|
+
|
|
35
|
+
### VaultsList
|
|
36
|
+
|
|
37
|
+
Display yield-bearing vaults from protocols like Morpho.
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
<VaultsList
|
|
41
|
+
showApy={true}
|
|
42
|
+
showTvl={true}
|
|
43
|
+
showUserPosition={true}
|
|
44
|
+
assetFilter={['USDC', 'ETH', 'WBTC']}
|
|
45
|
+
onVaultSelect={(vault) => console.log('Selected:', vault)}
|
|
46
|
+
onDeposit={(vault, amount, txHash) => console.log('Deposited')}
|
|
47
|
+
onWithdraw={(vault, amount, txHash) => console.log('Withdrew')}
|
|
48
|
+
/>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### AaveMarketsList
|
|
52
|
+
|
|
53
|
+
Display Aave V3 lending markets.
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
<AaveMarketsList
|
|
57
|
+
showApy={true}
|
|
58
|
+
showUserPosition={true}
|
|
59
|
+
onMarketSelect={(market) => console.log('Selected:', market)}
|
|
60
|
+
onSupply={(market, amount, txHash) => console.log('Supplied')}
|
|
61
|
+
onWithdraw={(market, amount, txHash) => console.log('Withdrew')}
|
|
62
|
+
/>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### PendleMarketsList
|
|
66
|
+
|
|
67
|
+
Display Pendle fixed-yield markets.
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
<PendleMarketsList
|
|
71
|
+
showApy={true}
|
|
72
|
+
showExpiry={true}
|
|
73
|
+
showTvl={true}
|
|
74
|
+
onMarketSelect={(market) => console.log('Selected:', market)}
|
|
75
|
+
onDeposit={(market, amount, txHash) => console.log('Deposited')}
|
|
76
|
+
onWithdraw={(market, amount, txHash) => console.log('Withdrew')}
|
|
77
|
+
/>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Theming
|
|
81
|
+
|
|
82
|
+
Customize the look by providing a theme object:
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
<CompassProvider
|
|
86
|
+
apiKey="your-api-key"
|
|
87
|
+
defaultChain="base"
|
|
88
|
+
theme={{
|
|
89
|
+
colors: {
|
|
90
|
+
primary: '#6366f1',
|
|
91
|
+
background: '#0a0a0f',
|
|
92
|
+
surface: '#1a1a24',
|
|
93
|
+
border: '#2a2a3a',
|
|
94
|
+
text: {
|
|
95
|
+
primary: '#ffffff',
|
|
96
|
+
secondary: '#a0a0a0',
|
|
97
|
+
tertiary: '#666666',
|
|
98
|
+
},
|
|
99
|
+
success: '#22c55e',
|
|
100
|
+
warning: '#eab308',
|
|
101
|
+
error: '#ef4444',
|
|
102
|
+
},
|
|
103
|
+
borderRadius: '12px',
|
|
104
|
+
fontFamily: 'Inter, system-ui, sans-serif',
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
{/* widgets */}
|
|
108
|
+
</CompassProvider>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Or use CSS variables directly:
|
|
112
|
+
|
|
113
|
+
```css
|
|
114
|
+
.compass-widget {
|
|
115
|
+
--compass-color-primary: #6366f1;
|
|
116
|
+
--compass-color-background: #0a0a0f;
|
|
117
|
+
--compass-color-surface: #1a1a24;
|
|
118
|
+
--compass-color-border: #2a2a3a;
|
|
119
|
+
--compass-color-text-primary: #ffffff;
|
|
120
|
+
--compass-color-text-secondary: #a0a0a0;
|
|
121
|
+
--compass-border-radius: 12px;
|
|
122
|
+
--compass-font-family: 'Inter', system-ui, sans-serif;
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Requirements
|
|
127
|
+
|
|
128
|
+
- React 18+ or 19+
|
|
129
|
+
- `@privy-io/react-auth` for wallet connection
|
|
130
|
+
- `@tanstack/react-query` for data fetching
|
|
131
|
+
|
|
132
|
+
## Documentation
|
|
133
|
+
|
|
134
|
+
Full documentation available at [docs.compasslabs.ai](https://docs.compasslabs.ai/v2/Products/Widgets).
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
MIT
|