@mycelium-sdk/core 1.0.0 → 2.0.0-alpha.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 +120 -93
- package/dist/index.cjs +281 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -27
- package/dist/index.d.ts +53 -27
- package/dist/index.js +261 -39
- package/dist/index.js.map +1 -1
- package/package.json +3 -5
package/README.md
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
# MyceliumSDK
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> To get started, check: https://docs.mycelium.sh
|
|
4
4
|
|
|
5
5
|
A TypeScript-based SDK that implements wallet management via ERC-4337 smart account and access to crypto yield opportunities though integrated protocols under the hood. The SDK allows integrators to easily onboard users, manage wallets, and interact with DeFi protocols
|
|
6
6
|
|
|
7
|
+
# Table of Contents
|
|
8
|
+
|
|
9
|
+
- [Core features](#core-features)
|
|
10
|
+
- [Versions](#versions)
|
|
11
|
+
- [Cloud version](#cloud-version)
|
|
12
|
+
- [Installation](#installation)
|
|
13
|
+
- [Testing](#testing)
|
|
14
|
+
- [SDK initialization](#sdk-initialization)
|
|
15
|
+
- [Self-hosted version](#self-hosted-version)
|
|
16
|
+
- [Get started](#get-started)
|
|
17
|
+
- [Environment variables](#environment-variables)
|
|
18
|
+
- [Installation](#installation-1)
|
|
19
|
+
- [Testing](#testing-1)
|
|
20
|
+
- [SDK initialization](#sdk-initialization-1)
|
|
21
|
+
- [Protocol security config](#protocol-security-config)
|
|
22
|
+
- [Integrated protocols](#integrated-protocols)
|
|
23
|
+
- [Chain management](#chain-management)
|
|
24
|
+
- [Local development](#local-development)
|
|
25
|
+
- [Get started](#get-started)
|
|
26
|
+
- [Documentation](#documentation)
|
|
27
|
+
- [Contribution](#contribution)
|
|
28
|
+
- [License](#license)
|
|
29
|
+
|
|
7
30
|
# Core features
|
|
8
31
|
|
|
9
32
|
The Mycelium SDK simplifies on-chain interactions by creating and managing a smart wallet with an embedded wallet as a signer for blockchain related operations. Smart wallet as well as embedded wallet signer are non-custodial and only a user has a direct access to it. The embedded wallet management is delegated to [the Privy platform](https://www.privy.io/)
|
|
@@ -19,24 +42,88 @@ SDK has the following core features:
|
|
|
19
42
|
|
|
20
43
|
An integrator can define basic settings for yield opportunities that will be recommended to a end user through SDK. More about this you can find on the `Protocol security config` section
|
|
21
44
|
|
|
22
|
-
#
|
|
45
|
+
# versions
|
|
23
46
|
|
|
24
47
|
Mycelium SDK is an open-source and publicly available to anyone for the usage. Despite this, there are 2 versions of Mycelium SDK that can be used by an integrator:
|
|
25
48
|
|
|
26
|
-
1. **
|
|
27
|
-
Clone the underlying repository, provide all necessary settings for providers that are used under the hood (Privy, Coinbase, etc). Right after this, you can use an integrated to a self hosted SDK version protocol - Spark. For more protocols, you need to switch to the cloud version
|
|
28
|
-
2. **Cloud**
|
|
49
|
+
1. **Cloud**
|
|
29
50
|
This version covers everything for an integrator. You just use the API key that will be provided to you and that's all. All settings and expenses for 3d party providers Mycelium SDK will take on it. For more information, check the `Cloud version` section
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Self hosted version is available out of this repo and can be used by anyone by cloning the repo and settings up all necessary and required SDK parameters. Self hosted version has only one integrated protocol that can be used for yield opportunities recommendations - Spark. To start working with a self hosted SDK version, please refer to the `Get started` section
|
|
51
|
+
2. **Self-hosted**
|
|
52
|
+
Clone the underlying repository, provide all necessary settings for providers that are used under the hood (Privy, Coinbase, etc). Right after this, you can use an integrated to a self hosted SDK version protocol - Spark. For more protocols, you need to switch to the cloud version
|
|
34
53
|
|
|
35
54
|
## Cloud version
|
|
36
55
|
|
|
37
56
|
Cloud version is a paid (current free) version of the SDK, when everything is handled under the hood for an integrator. The only thing that you need to pass to the SDK during the initialization is an API key. All further 3d party platforms integrations will be handled under the hood by Mycelium. To start working with a self hosted SDK version, please refer to the `Get started` section
|
|
38
57
|
|
|
39
|
-
|
|
58
|
+
<div align="center">
|
|
59
|
+
<a href="https://airtable.com/appdAzctTXEwlEoYw/pagJESMXBAT2GTTRA/form" target="_blank">
|
|
60
|
+
<img src="https://img.shields.io/badge/Get_API_Key-6366F1?style=for-the-badge&logo=key&logoColor=white&labelColor=4F46E5" alt="Get API Key" />
|
|
61
|
+
</a>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
### Installation
|
|
65
|
+
|
|
66
|
+
Right after you would get an API key, you can start working with an SDK
|
|
67
|
+
|
|
68
|
+
1. Install the library:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pnpm install @mycelium-sdk/core
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
2. You're ready to use and SDK!
|
|
75
|
+
|
|
76
|
+
### Testing
|
|
77
|
+
|
|
78
|
+
To test the SDK you can use the build in CLI from the repository OR use SDK on your own project:
|
|
79
|
+
|
|
80
|
+
1. Clone the repo:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
git clone https://github.com/MyceliumSDK/mycelium-sdk.git
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
2. Go to `packages/cli` and install dependencies
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
cd packages/cli && pnpm install
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
3. Setup the CLI settings based on the [README.md](https://github.com/MyceliumSDK/mycelium-sdk/blob/main/packages/cli/README.md) file
|
|
93
|
+
|
|
94
|
+
4. Install the latest SDK version:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
pnpm install @mycelium-sdk/core
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
5. Start the CLI
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
pnpm run start
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
> In case if you want to test the SDK with a fork, you need to use `anvil` and `packages/blockchain` service. Please refer to `packages/blockchain/README.md` for more details
|
|
107
|
+
|
|
108
|
+
### SDK initialization
|
|
109
|
+
|
|
110
|
+
```javascript
|
|
111
|
+
this.sdk = await MyceliumSDK.init({
|
|
112
|
+
apiKey,
|
|
113
|
+
chainId: '8453',
|
|
114
|
+
protocolsSecurityConfig: {
|
|
115
|
+
riskLevel: 'low',
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
> To get more information about `protocolSecurityConfig` settings, please refer to the `Protocol security config` section below
|
|
121
|
+
|
|
122
|
+
## Self-hosted version
|
|
123
|
+
|
|
124
|
+
Self hosted version is available out of this repo and can be used by anyone by cloning the repo and settings up all necessary and required SDK parameters. Self hosted version has only one integrated protocol that can be used for yield opportunities recommendations - Spark. To start working with a self hosted SDK version, please refer to the `Get started` section
|
|
125
|
+
|
|
126
|
+
### Get started
|
|
40
127
|
|
|
41
128
|
Both cloud and self hosted version are required the following prerequisites:
|
|
42
129
|
|
|
@@ -44,24 +131,23 @@ Both cloud and self hosted version are required the following prerequisites:
|
|
|
44
131
|
2. node >= 22.11.0
|
|
45
132
|
3. TypeScript >= 5.0.0
|
|
46
133
|
|
|
47
|
-
|
|
134
|
+
### Environment variables
|
|
48
135
|
|
|
49
136
|
Both self hosted and cloud version are required some variables to be provided during the initialization of an SDK. The list of envs for cloud version is significant, than for a self hosted one. Here is the full list of variables:
|
|
50
137
|
|
|
51
|
-
| Variable Name | Description
|
|
52
|
-
| ----------------------------- |
|
|
53
|
-
| `PRIVY_APP_ID` | Privy wallet app id for embedded wallets
|
|
54
|
-
| `PRIVY_APP_SECRET` | Privy wallet app secret for embedded wallets
|
|
55
|
-
| `RPC_URL` | A RPC URL for a chain
|
|
56
|
-
| `BUNDLER_URL` | A bundler URL to process User Operations
|
|
57
|
-
| `COINBASE_CDP_API_KEY_ID` | Coinbase CDP Api Key ID for on/off ramp functionality
|
|
58
|
-
| `COINBASE_CDP_API_KEY_SECRET` | Coinbase CDP Api secret for on/off ramp functionality
|
|
59
|
-
| `INTEGRATOR_ID` | Unique integrator ID to track SDK usage and enable 3rd party services (e.g., Coinbase off/on-ramp)
|
|
60
|
-
| `API_KEY` | API key to run SDK with managed settings
|
|
61
|
-
| `PROTOCOL_RISK_LEVEL` | Risk level of protocol that will be used by an SDK in the configuration
|
|
62
|
-
| `CHAIN_ID` | Chain ID to work with
|
|
63
|
-
|
|
64
|
-
## Self hosted
|
|
138
|
+
| Variable Name | Description | Version | Mandatory |
|
|
139
|
+
| ----------------------------- | ----------------------------------------------------------------------------------------------------- | ------------------- | --------- |
|
|
140
|
+
| `PRIVY_APP_ID` | Privy wallet app id for embedded wallets | Self-hosted | Yes |
|
|
141
|
+
| `PRIVY_APP_SECRET` | Privy wallet app secret for embedded wallets | Self-hosted | Yes |
|
|
142
|
+
| `RPC_URL` | A RPC URL for a chain | Self-hosted | Yes |
|
|
143
|
+
| `BUNDLER_URL` | A bundler URL to process User Operations | Self-hosted | Yes |
|
|
144
|
+
| `COINBASE_CDP_API_KEY_ID` | Coinbase CDP Api Key ID for on/off ramp functionality | Self-hosted | No |
|
|
145
|
+
| `COINBASE_CDP_API_KEY_SECRET` | Coinbase CDP Api secret for on/off ramp functionality | Self-hosted | No |
|
|
146
|
+
| `INTEGRATOR_ID` | Unique integrator ID to track SDK usage and enable 3rd party services (e.g., Coinbase off/on-ramp) | Self-hosted | Yes |
|
|
147
|
+
| `API_KEY` | API key to run SDK with managed settings | Cloud | Yes |
|
|
148
|
+
| `PROTOCOL_RISK_LEVEL` | Risk level of protocol that will be used by an SDK in the configuration | Cloud & self-hosted | Yes |
|
|
149
|
+
| `CHAIN_ID` | Chain ID to work with | Cloud & self-hosted | Yes |
|
|
150
|
+
| `PAYMASTER_URL` | Pimlico paymaster URL for a provided chain in CHAIN_ID. Currently only Pimlico paymaster is available | Self-hosted | Yes |
|
|
65
151
|
|
|
66
152
|
### Installation
|
|
67
153
|
|
|
@@ -107,7 +193,7 @@ pnpm run start
|
|
|
107
193
|
|
|
108
194
|
### SDK initialization
|
|
109
195
|
|
|
110
|
-
In case of a self
|
|
196
|
+
In case of a self-hosted version, you need to define all your env variables. For more details, please refer the `Environment variables` section above. Right after you define all env variables, you can initiate the SDK:
|
|
111
197
|
|
|
112
198
|
```typescript
|
|
113
199
|
this.sdk = new MyceliumSDK({
|
|
@@ -131,6 +217,7 @@ this.sdk = new MyceliumSDK({
|
|
|
131
217
|
chainId: '...',
|
|
132
218
|
rpcUrl: '...',
|
|
133
219
|
bundlerUrl: '...',
|
|
220
|
+
paymasterUrl: '...',
|
|
134
221
|
},
|
|
135
222
|
protocolsRouterConfig: {
|
|
136
223
|
riskLevel: '...',
|
|
@@ -143,68 +230,6 @@ this.sdk = new MyceliumSDK({
|
|
|
143
230
|
});
|
|
144
231
|
```
|
|
145
232
|
|
|
146
|
-
## Cloud version
|
|
147
|
-
|
|
148
|
-
If you decided to use a ready to use library, you need to receive an API key first. For this purpose, you can contact [Mike Krupin on Telegram](https://t.me/maikyman) or you can [send an email](emailto:myceliumsdk@gmail.com) to the Mycelium mailbox
|
|
149
|
-
|
|
150
|
-
Right after you would get an API key, you can start working with an SDK
|
|
151
|
-
|
|
152
|
-
### Installation
|
|
153
|
-
|
|
154
|
-
1. Install the library:
|
|
155
|
-
|
|
156
|
-
```bash
|
|
157
|
-
pnpm install @mycelium-sdk/core
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
2. You're ready to use and SDK!
|
|
161
|
-
|
|
162
|
-
### Testing
|
|
163
|
-
|
|
164
|
-
To test the SDK you can use the build in CLI from the repository:
|
|
165
|
-
|
|
166
|
-
1. Clone the repo:
|
|
167
|
-
|
|
168
|
-
```bash
|
|
169
|
-
git clone https://github.com/MyceliumSDK/mycelium-sdk.git
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
2. Go to `packages/cli` and install dependencies
|
|
173
|
-
|
|
174
|
-
```bash
|
|
175
|
-
cd packages/cli && pnpm install
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
3. Setup the CLI settings based on the [README.md](https://github.com/MyceliumSDK/mycelium-sdk/blob/main/packages/cli/README.md) file
|
|
179
|
-
|
|
180
|
-
4. Instal the latest SDK version:
|
|
181
|
-
|
|
182
|
-
```bash
|
|
183
|
-
pnpm install @mycelium-sdk/core
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
5. Start the CLI
|
|
187
|
-
|
|
188
|
-
```bash
|
|
189
|
-
pnpm run start
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
> In case if you want to test the SDK with a fork, you need to use `anvil` and `packages/blockchain` service. Please refer to `packages/blockchain/README.md` for more details
|
|
193
|
-
|
|
194
|
-
### SDK initialization
|
|
195
|
-
|
|
196
|
-
```javascript
|
|
197
|
-
this.sdk = await MyceliumSDK.init({
|
|
198
|
-
apiKey,
|
|
199
|
-
chainId: '8453',
|
|
200
|
-
protocolsSecurityConfig: {
|
|
201
|
-
riskLevel: 'low',
|
|
202
|
-
},
|
|
203
|
-
});
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
> To get more information about `protocolSecurityConfig` settings, please refer to the `Protocol security config` section below
|
|
207
|
-
|
|
208
233
|
# Protocol security config
|
|
209
234
|
|
|
210
235
|
Current config of settings used by `Protocol router` to define:
|
|
@@ -237,7 +262,9 @@ More protocol and chains will be added soon
|
|
|
237
262
|
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
|
|
238
263
|
The example configuration above uses Base chain (chain ID: 8453), meaning all protocol operations and vault deposits will occur on the Base network
|
|
239
264
|
|
|
240
|
-
|
|
265
|
+
## Local development
|
|
266
|
+
|
|
267
|
+
### Get started
|
|
241
268
|
|
|
242
269
|
Install dependencies:
|
|
243
270
|
|
|
@@ -263,9 +290,9 @@ Run tests in watch mode:
|
|
|
263
290
|
pnpm run test:watch
|
|
264
291
|
```
|
|
265
292
|
|
|
266
|
-
|
|
293
|
+
### Documentation
|
|
267
294
|
|
|
268
|
-
The SDK should be documented and described with [TypeDoc rules](https://typedoc.org/). To get more context, check [CONTRIBUTION.md](https://github.com/
|
|
295
|
+
The SDK should be documented and described with [TypeDoc rules](https://typedoc.org/). To get more context, check [CONTRIBUTION.md](https://github.com/MyceliumSDK/mycelium-sdk/blob/main/CONTRIBUTION.md)
|
|
269
296
|
|
|
270
297
|
To generate documentation:
|
|
271
298
|
|
|
@@ -279,8 +306,8 @@ pnpm run docs:dev
|
|
|
279
306
|
|
|
280
307
|
# Contribution
|
|
281
308
|
|
|
282
|
-
Check the [CONTRIBUTION.md](https://github.com/
|
|
309
|
+
Check the [CONTRIBUTION.md](https://github.com/MyceliumSDK/mycelium-sdk/blob/main/CONTRIBUTION.md)
|
|
283
310
|
|
|
284
311
|
# License
|
|
285
312
|
|
|
286
|
-
This project is licensed under the dual license - Apache 2.0 + Commercial - see the [LICENSE](https://github.com/
|
|
313
|
+
This project is licensed under the dual license - Apache 2.0 + Commercial - see the [LICENSE](https://github.com/MyceliumSDK/mycelium-sdk/blob/main/LICENSE)
|