@mycelium-sdk/core 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 +145 -0
- package/dist/index.cjs +2500 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1568 -0
- package/dist/index.d.ts +1568 -0
- package/dist/index.js +2481 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# MyceliumSDK
|
|
2
|
+
|
|
3
|
+
> Check documentation: https://docs.mycelium.sh
|
|
4
|
+
|
|
5
|
+
A TypeScript-based SDK that implements access to yield opportunities in web3 using a Mycelium SDK. The SDK allows integrators to easily onboard users, manage wallets, and interact with DeFi protocols via a unified interface basic knowledge of web3
|
|
6
|
+
|
|
7
|
+
## Core features
|
|
8
|
+
|
|
9
|
+
The Mycelium SDK simplifies on-chain interactions by creating and managing embedded wallets based on user information (e.g., email). Each wallet is used as a smart account to sign blockchain transactions and perform operations across supported protocols.
|
|
10
|
+
|
|
11
|
+
The SDK includes a Router Protocol, which selects the optimal farming protocol and vault based on parameters provided by the integrator (e.g., risk level, preferences, etc.). Once selected, the protocol is used internally by the SDK for subsequent user operations.
|
|
12
|
+
|
|
13
|
+
### Key capabilities
|
|
14
|
+
|
|
15
|
+
- **Create wallet** — Initializes an embedded wallet tied to user data (like email)
|
|
16
|
+
- **Fund wallet via Coinbase (soon)** — Generates a top-up link for the user to deposit funds
|
|
17
|
+
- **Earn command** — Allocates deposited assets into a protocol or vault recommended by the SDK
|
|
18
|
+
- **Withdraw** — Allows withdrawing part or all of the user's funds from the protocol
|
|
19
|
+
- **Get balance** — Retrieves the balance and performance of assets held within protocols
|
|
20
|
+
- **Router protocol** — Determines the best protocol and vault to use based on the integrator's strategy and risk preferences
|
|
21
|
+
|
|
22
|
+
## Requirements & installation
|
|
23
|
+
|
|
24
|
+
### Prerequisites
|
|
25
|
+
|
|
26
|
+
1. pnpm >= 10.9.0
|
|
27
|
+
2. node >= 22.11.0
|
|
28
|
+
3. TypeScript >= 5.0.0
|
|
29
|
+
|
|
30
|
+
### Installation
|
|
31
|
+
|
|
32
|
+
Install dependencies:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pnpm install
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Build the SDK:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pnpm run build
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The built SDK can then be used in your application or imported as a local library
|
|
45
|
+
|
|
46
|
+
## Initialization Example
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
this.sdk = new MyceliumSDK({
|
|
50
|
+
walletsConfig: {
|
|
51
|
+
embeddedWalletConfig: {
|
|
52
|
+
provider: {
|
|
53
|
+
type: 'privy',
|
|
54
|
+
providerConfig: {
|
|
55
|
+
appId: process.env.NEXT_PUBLIC_PRIVY_APP_ID!,
|
|
56
|
+
appSecret: process.env.NEXT_PUBLIC_PRIVY_APP_SECRET!,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
smartWalletConfig: {
|
|
61
|
+
provider: {
|
|
62
|
+
type: 'default',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
chain: {
|
|
67
|
+
chainId: parseInt(process.env.NEXT_PUBLIC_CHAIN_ID!) as any,
|
|
68
|
+
rpcUrl: process.env.NEXT_PUBLIC_RPC_URL!,
|
|
69
|
+
bundlerUrl: process.env.NEXT_PUBLIC_BUNDLER_URL!,
|
|
70
|
+
},
|
|
71
|
+
protocolsRouterConfig: {
|
|
72
|
+
riskLevel: 'medium',
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
> To get more information about what protocols and chains are available for SDK, refer to the `Protocol router` section below
|
|
78
|
+
|
|
79
|
+
## Local development
|
|
80
|
+
|
|
81
|
+
Install dependencies:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pnpm install
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Build the SDK in watch mode:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
pnpm run watch
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Run tests:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pnpm run test
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Run tests in watch mode:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
pnpm run test:watch
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Documentation
|
|
106
|
+
|
|
107
|
+
The SDK should be documented and described with [TypeDoc rules](https://typedoc.org/). To get more context, check [CONTRIBUTION.md](https://github.com/0xdeval/mycelium-sdk/blob/main/CONTRIBUTION.md)
|
|
108
|
+
|
|
109
|
+
To generate documentation:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Generate public documentation
|
|
113
|
+
pnpm run docs:public
|
|
114
|
+
|
|
115
|
+
# Generate development documentation
|
|
116
|
+
pnpm run docs:dev
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Chain management
|
|
120
|
+
|
|
121
|
+
The chain configuration provided during SDK initialization defines where on-chain activities will take place. Currently, only one chain is supported for the `earn` functionality, with multi-chain support coming soon
|
|
122
|
+
The example configuration above uses Base chain (chain ID: 8453), meaning all protocol operations and vault deposits will occur on the Base network
|
|
123
|
+
|
|
124
|
+
## Protocol router
|
|
125
|
+
|
|
126
|
+
Protocol router is the key component of the SDK that helps an integrator (app/web2 product) to select the best protocol and vault to deposit user's funds.
|
|
127
|
+
The only requirement from an integrator is to define a high-level settings for protocols, e.g. min APY, protocol risk level, etc
|
|
128
|
+
|
|
129
|
+
The SDK will use settings and find the best protocol and vault under the hood. No one, including integrator, will need to care about this part
|
|
130
|
+
|
|
131
|
+
The full list of protocol and chains along with they can be used is the following:
|
|
132
|
+
|
|
133
|
+
| Protocol | Chain | ChainId |
|
|
134
|
+
| -------------------------- | ----- | ------- |
|
|
135
|
+
| [Spark](https://spark.fi/) | Base | 8453 |
|
|
136
|
+
|
|
137
|
+
More protocol and chains will be added soon
|
|
138
|
+
|
|
139
|
+
## Contribution
|
|
140
|
+
|
|
141
|
+
Check the [CONTRIBUTION.md](https://github.com/0xdeval/mycelium-sdk/blob/main/CONTRIBUTION.md)
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
This project is licensed under the dual license - Apache 2.0 + Commercial - see the [LICENSE](https://github.com/0xdeval/mycelium-sdk/blob/main/LICENSE.md)
|