@usdu-finance/usdu-core 0.0.1 → 0.0.2

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 CHANGED
@@ -1,244 +1,122 @@
1
- # Core
1
+ # USDU Finance - Core Smart Contracts
2
2
 
3
- ### Yarn Package Scripts
3
+ Core smart contract implementation for USDU Finance, a stablecoin protocol built on Ethereum. This repository contains the essential contracts for the USDU stablecoin, yield-generating vault adapters, and reward distribution system.
4
4
 
5
- ```json
6
- // yarn run <command> args...
5
+ ## Overview
7
6
 
8
- "wallet": "npx ts-node helper/wallet.info.ts",
9
- "wallet:info": "npx ts-node helper/wallet.info.ts",
7
+ **Key Components:**
10
8
 
11
- "compile": "npx hardhat compile",
12
- "test": "npx hardhat test",
13
- "coverage": "npx hardhat coverage",
9
+ - **USDU Stablecoin**: ERC20 stablecoin with role-based governance
10
+ - **Vault Adapters**: TermMax, Morpho & Curve integrations for borrow & lending market and deep liquidity
11
+ - **Reward System**: Token distribution and staking rewards
12
+ - **TermMax Integration**: Advanced yield optimization strategies
14
13
 
15
- "deploy": "npx hardhat ignition deploy",
16
- "verify": "npx hardhat verify",
14
+ ## Project Structure
17
15
 
18
- "npm:build": "tsup",
19
- "npm:publish": "npm publish --access public"
20
16
  ```
21
-
22
- ### 1. Install dependencies
23
-
24
- `yarn install`
25
-
26
- ### 2. Set Environment
27
-
28
- > See .env.example
29
-
30
- ```JSON
31
- file: .env
32
-
33
- DEPLOYER_SEED="test test test test test test test test test test test junk"
34
- DEPLOYER_SEED_INDEX=1
35
- ALCHEMY_RPC_KEY=...
36
- ETHERSCAN_API=...
17
+ contracts/
18
+ ├── stablecoin/ # USDU stablecoin core implementation
19
+ ├── vault/ # Vault adapters for yield generation
20
+ ├── morpho/ # Morpho protocol integration
21
+ ├── curve/ # Curve protocol integration
22
+ ├── reward/ # Reward distribution system
23
+ └── test/ # Test contracts and utilities
37
24
  ```
38
25
 
39
- > Create new session or re-navigate to the current directory, to make sure environment is loaded from `.env`
26
+ **Supported Networks:**
40
27
 
41
- ### 3. Develop Smart Contracts
28
+ - **Mainnet** (primary): Full protocol deployment with all contracts
29
+ - **L2s** (in discussion): Polygon, Arbitrum, Optimism, Base, Avalanche, Gnosis, Sonic
42
30
 
43
- > Develop your contracts in the `/contracts` directory and compile with:
31
+ > See `exports/address.types.ts` for complete chain configurations and `exports/address.config.ts` for deployed addresses.
44
32
 
45
- ```Bash
46
- yarn run compile # Compiles all contracts
47
- ```
33
+ ## Quick Start
48
34
 
49
- ### 4. Testing
35
+ ```bash
36
+ # Setup
37
+ yarn install
38
+ cp .env.example .env # Configure your environment
50
39
 
51
- > All test files are located in /test directory. Run tests using:
40
+ # Development
41
+ yarn compile # Compile contracts
42
+ yarn test # Run tests
43
+ yarn coverage # Test coverage
52
44
 
53
- ```Bash
54
- yarn run test # Run all tests
55
- yarn run test test/Membership.ts # Run specific test file
56
- yarn run coverage # Generate test coverage report
57
- ```
58
-
59
- ### 5. Write Deployment Scripts (via ignition deploy and verify)
60
-
61
- - Create new `/ignition/params/[file].ts` for type conform deployment params
62
- - Create new `/ignition/module/[file].ts` for workflow of deployment
45
+ # Deployment
46
+ yarn deploy ignition/modules/StablecoinModule.ts --network mainnet --verify
63
47
 
64
- > Deployment modules are located in `/ignition/modules`. Deploy your contracts:
65
-
66
- ```Bash
67
- yarn run deploy ignition/modules/MembershipFactory.ts --network polygon --verify --deployment-id Membership01
68
-
69
- --> increase: deployment-id
48
+ # Package
49
+ yarn npm:build # Build for npm
50
+ yarn npm:publish # Publish package
70
51
  ```
71
52
 
72
- This will:
73
-
74
- - Compile and deploy contracts
75
- - Verify on Etherscan and Sourcify
76
- - Generate deployment artifacts in `/ignition/deployments`
77
-
78
- Verify:
79
-
80
- - verifies contract on etherscan
81
- - verifies contract on sourcify
82
-
83
- Key deployment files:
84
-
85
- - deployed_addresses.json: Contains contract addresses
86
- - journal.json: Detailed deployment logs
87
-
88
- - creates deployment artifacts in /ignition`/deployments` directory
89
- - creates ./ignition/deployments/[deployment]/`deployed_addresses.json`
90
- - creates ./ignition/deployments/[deployment]/`journal.jsonl`
91
- - creates constructor-args in /ignition`/constructor-args` directory, as JS module export
92
-
93
- ### 5.1 Example
94
-
95
- ```Bash
96
- ✔ Confirm deploy to network polygon (137)? … yes
97
- {
98
- message: 'Config Info: Deploying Module with accounts',
99
- admin: '0xb687FE7E47774B22F10Ca5E747496d81827167E3',
100
- executor: '0xBdae8D35EDe5bc5174E805DcBe3F7714d142DAAb',
101
- member: '0x2ACf17C04F1d8BE7E9D5529894DCee86bf2fcdC3'
102
- }
103
- Constructor Args
104
- [
105
- '0xb687FE7E47774B22F10Ca5E747496d81827167E3',
106
- '0xBdae8D35EDe5bc5174E805DcBe3F7714d142DAAb',
107
- '0x2ACf17C04F1d8BE7E9D5529894DCee86bf2fcdC3'
108
- ]
109
- Hardhat Ignition 🚀
110
-
111
- Deploying [ MembershipModule ]
112
-
113
- Batch #1
114
- Executed MembershipModule#Membership
115
-
116
- Batch #2
117
- Executed MembershipModule#Storage
118
-
119
- [ MembershipModule ] successfully deployed 🚀
120
-
121
- Deployed Addresses
53
+ ## Development Workflow
122
54
 
123
- MembershipModule#Membership - 0x72950A0A9689fCA941Ddc9E1a58dcD3fb792E3D2
124
- MembershipModule#Storage - 0x8A7e8091e71cCB7D1EbDd773C26AD82AAd323328
55
+ ### Environment Setup
125
56
 
126
- Verifying deployed contracts
57
+ Create `.env` file (see `.env.example`):
127
58
 
128
- Verifying contract "contracts/Membership.sol:Membership" for network polygon...
129
- Contract contracts/Membership.sol:Membership already verified on network polygon:
130
- - https://polygonscan.com/address/0x72950A0A9689fCA941Ddc9E1a58dcD3fb792E3D2#code
131
-
132
- Verifying contract "contracts/Storage.sol:Storage" for network polygon...
133
- Contract contracts/Storage.sol:Storage already verified on network polygon:
134
- - https://polygonscan.com/address/0x8A7e8091e71cCB7D1EbDd773C26AD82AAd323328#code
135
-
136
- ✨ Done in 69.96s.
59
+ ```bash
60
+ DEPLOYER_SEED="your mnemonic here"
61
+ DEPLOYER_SEED_INDEX=0
62
+ ALCHEMY_RPC_KEY=your_api_key
63
+ ETHERSCAN_API=your_api_key
137
64
  ```
138
65
 
139
- ### 5.2 Manual Verify
140
-
141
- `npx hardhat verify --network polygon --constructor-args ./ignition/constructor-args/$FILE.js $ADDRESS`
142
-
143
- or manually include unrelated contracts by creating or using `/ignition/constructor-args/[file].js`
144
-
145
- `npx hardhat ignition verify $DEPLOYMENT --include-unrelated-contracts`
146
-
147
- ### 6 Prepare NPM Package Support
66
+ ### Testing & Building
148
67
 
149
- - [x] Export ready to use TypeScript ABIs
150
- - [x] Export ready to use TypeScript deployed address config
151
- - [ ] ...
152
-
153
- ### 6.1 TypeScript ABIs
154
-
155
- Export contract ABIs for npm package usage by copying the JSON into dedicated TypeScript files:
156
-
157
- ```TS
158
- file: exports/abis/...
159
-
160
- export const StorageABI = [
161
- ...
162
- JSON
163
- ...
164
- ] as const;
68
+ ```bash
69
+ yarn test # All tests
70
+ yarn test test/Stablecoin.ts # Specific test
71
+ yarn coverage # Coverage report
165
72
  ```
166
73
 
167
- ### 6.2 TypeScript Address Config
168
-
169
- Provides a mapping of contract addresses for the Membership and Storage contracts deployed on different blockchain networks.
170
-
171
- The `ADDRESS` object contains the contract addresses for the `mainnet` and `polygon` networks, with the network ID as the key.
172
- The `zeroAddress` is used as a placeholder for the `mainnet` network, as the contracts have not been deployed there yet.
74
+ ### Deployment
173
75
 
174
- ```TS
175
- file: exports/address.config.ts
76
+ Create deployment modules in `/ignition/modules/` and parameter files in `/ignition/params/`:
176
77
 
177
- import { mainnet, polygon } from 'viem/chains';
178
- import { Address, zeroAddress } from 'viem';
179
-
180
- export interface ChainAddress {
181
- membership: Address;
182
- storage: Address;
183
- }
184
-
185
- export const ADDRESS: Record<number, ChainAddress> = {
186
- [mainnet.id]: {
187
- membership: zeroAddress,
188
- storage: zeroAddress,
189
- },
190
- [polygon.id]: {
191
- membership: '0x72950A0A9689fCA941Ddc9E1a58dcD3fb792E3D2',
192
- storage: '0x8A7e8091e71cCB7D1EbDd773C26AD82AAd323328',
193
- },
194
- };
78
+ ```bash
79
+ yarn deploy ignition/modules/StablecoinModule.ts --network mainnet --verify --deployment-id USDU01
195
80
  ```
196
81
 
197
- # 7. TSUP and npm package
198
-
199
- ### 7.1 TSUP
200
-
201
- > Config: /tsup.config.ts
202
-
203
- TSUP bundles TypeScript code into optimized JavaScript packages. This package uses TSUP to create production-ready builds.
82
+ This compiles, deploys, and verifies contracts on Etherscan/Sourcify. Artifacts are saved to `/ignition/deployments/`.
204
83
 
205
- `yarn run build`
84
+ **Manual Verification:**
206
85
 
207
- ### 7.2 NPM Package
208
-
209
- > **Increase Version:** Update version number in package.json using semantic versioning (e.g. 0.0.1 -> 0.0.2) before publishing new changes.
210
-
211
- ```
212
- file: /package.json
213
-
214
- "name": "@wrytlabs/core-template",
215
- "version": "0.0.1", <-- HERE
86
+ ```bash
87
+ npx hardhat verify --network mainnet --constructor-args ./ignition/constructor-args/$FILE.js $ADDRESS
88
+ npx hardhat ignition verify $DEPLOYMENT --include-unrelated-contracts
216
89
  ```
217
90
 
218
- Login to your NPM account
91
+ ## NPM Package
219
92
 
220
- `npm login`
93
+ The package exports TypeScript ABIs and address configurations:
221
94
 
222
- This will publish your package to NPM with public access, making it **available for anyone to install and use**.
95
+ **ABIs:** `exports/abis/` - Contract ABIs as TypeScript constants
96
+ **Addresses:** `exports/address.config.ts` - Deployed contract addresses by chain
97
+ **Types:** `exports/address.types.ts` - Chain configurations and type definitions
223
98
 
224
- `yarn run publish`
99
+ ```typescript
100
+ import { ADDRESS, StablecoinABI, MorphoAdapterV1ABI } from '@usdu-finance/usdu-core';
225
101
 
226
- To publish new version. `publish: "npm publish --access public"`
102
+ // Get mainnet addresses
103
+ const { usduStable, usduMorphoAdapterV1_2 } = ADDRESS[1];
227
104
 
228
- > **Note**: During npm package publishing, the command may execute twice. The second execution will fail with a version conflict since the package is already published. This is expected behavior and the first publish will have succeeded.
105
+ // Use ABIs with contract instances
106
+ const stablecoin = new Contract(usduStable, StablecoinABI, provider);
107
+ ```
229
108
 
230
- ### 7.3 How to transpile package into bundled apps
109
+ ### Package Publishing
231
110
 
232
- (not needed, since its already a true JS bundled module)
111
+ 1. **Update version** in `package.json` (semantic versioning)
112
+ 2. **Build package:** `yarn npm:build` (uses tsup config)
113
+ 3. **Publish:** `yarn npm:publish` (requires `npm login`)
233
114
 
234
- E.g. for `NextJs` using the `next.config.js` in root of project.
115
+ **Next.js Integration:**
235
116
 
236
117
  ```js
237
- /** @type {import('next').NextConfig} */
238
- const nextConfig = {
239
- reactStrictMode: true,
240
- transpilePackages: ['@wrtylabs/core', '@wrytelabs/api'],
118
+ // next.config.js
119
+ module.exports = {
120
+ transpilePackages: ['@usdu-finance/usdu-core'],
241
121
  };
242
-
243
- module.exports = nextConfig;
244
122
  ```