Skip to content

Staging#9

Open
Agneskoinange wants to merge 59 commits intomainfrom
staging
Open

Staging#9
Agneskoinange wants to merge 59 commits intomainfrom
staging

Conversation

@Agneskoinange
Copy link
Collaborator

No description provided.

ZariaHallager and others added 30 commits July 26, 2025 11:55
- Set up Rust canister project structure
- Include IC CDK for canister development
- Add stable-structures for persistent storage
- Include ICRC ledger types for token integration
- Add decimal precision for financial calculations
- Define DepositType enum for tracking fee sources
- Add AssetType enum for supported tokens (icUSD, ICP, ckBTC)
- Create DepositRecord struct for transaction tracking
- Include proper Candid serialization for IC compatibility
- Implement persistent storage for deposit records and balances
- Use StableBTreeMap for deposit history that survives upgrades
- Add TreasuryConfig for controller and ledger principals
- Include pause/unpause functionality for emergency control
- Ensure all financial data persists across canister upgrades
- Implement canister initialization with controller setup
- Add pre/post upgrade hooks for seamless updates
- Include controller-only access control for sensitive operations
- Add comprehensive logging for debugging and monitoring
- Set up proper module structure for treasury functionality
- Define complete public API for treasury canister
- Include deposit/withdraw functions with proper error handling
- Add query functions for status and deposit history
- Provide admin functions for controller and pause management
- Ensure type safety with comprehensive Candid definitions
- Remove misleading placeholder comments about simplified implementation
- Clarify that inter-canister calls are real and production-ready
- Update fee handling comments to reflect actual ledger behavior
- Ensure deployer knows code is ready for mainnet without changes
- Include rumi_treasury in workspace members
- Enable shared dependency resolution across canisters
- Add rumi_treasury canister with Rust type and Candid interface
- Configure treasury initialization with controller and ledger principals
- Add XRC external canister reference for price feeds
- Include proper init args for protocol backend treasury integration
- Configure icUSD and ICP ledgers with minting accounts and fees
- Pin IC CDK and candid versions for reproducible builds
- Ensure consistent dependency versions across environments
- Test treasury initialization and configuration
- Verify deposit recording and balance updates
- Check error handling for invalid operations
- Ensure proper state management functionality
- Build and unit test verification script
- End-to-end integration testing with dfx deployment
- Verified locally - all tests pass (7/7)
- WASM builds successfully (1.1M)
- Add treasury_principal to backend initialization
- Implement fee routing functions for minting and redemption fees
- Route fees asynchronously to treasury without blocking operations
- Add treasury fee types matching treasury canister interface
- Update backend init args to use treasury: p4osj-vaaaa-aaaai-q33ea-cai
- Backend will now automatically send fees to treasury on next upgrade
- Remove controller-only restriction from deposit function
- Anyone can now deposit to treasury (backends, users, etc.)
- Only withdrawals remain controller-only (proper security)
- Update treasury integration test with correct canister ID
- Treasury now ready for production backend integration
- Add partial_repay_to_vault() function allowing users to repay any amount ≤ debt
- Add partial_liquidate_vault() function with 10% discount for liquidators
- Implement proper validation and error handling for partial operations
- Maintain atomic state updates and proper event logging
- Support liquidator payment: X icUSD → receive (X/0.9)/ICP_price ICP
- Add PartialLiquidateVault event to track partial liquidation operations
- Include vault_id, liquidator_payment, icp_to_liquidator, and liquidator fields
- Update is_vault_related() method to include new event type
- Add replay logic for PartialLiquidateVault events in state reconstruction
- Add partial_repay_to_vault() endpoint for partial debt repayments
- Add partial_liquidate_vault() endpoint for partial liquidations with 10% discount
- Include proper validation and error handling for both endpoints
- Maintain consistency with existing API patterns and security measures
- Add partialRepayToVault() method for partial debt repayments
- Add partialLiquidateVault() method for partial liquidations
- Implement proper allowance management with buffers for both operations
- Add comprehensive error handling and validation
- Support user-friendly partial repayment and liquidation workflows
Agneskoinange and others added 29 commits September 26, 2025 09:10
### Summary
Reduce the minimum icUSD amount from 5 to 0.1.
- File: `src/rumi_protocol_backend/lib.rs`
- Before: `MIN_ICUSD_AMOUNT = ICUSD::new(500_000_000)`  // 5 icUSD
- After:  `MIN_ICUSD_AMOUNT = ICUSD::new(10_000_000)`   // 0.1 icUSD
- E8S = 100_000_000

### Motivation
Enable small test mints and smoother onboarding. This lets users try the system with tiny amounts and supports micropayment use cases.

### Scope
This constant is used in three flows:
- `borrow_from_vault` (minimum mint)
- `repay_to_vault`   (minimum repay)
- `redeem_icp`       (minimum redeem)

No Candid interface changes. No data migration.

### Risks and checks
- Rounding and fees: confirm that the borrowing fee on 0.1 icUSD does not round to zero in a way that breaks math.
- Ledger fees: verify 0.1 icUSD transfers and ICP redemptions still clear with current fee settings.
- Dust: confirm accounting and UI avoid creating unpayable dust.

### QA
- Borrow 0.09 icUSD → expect `AmountTooLow` with minimum 0.1.
- Borrow 0.1 icUSD → succeeds, mints `0.1 - fee`.
- Repay 0.1 icUSD → succeeds; 0.09 rejected.
- Redeem 0.1 icUSD → succeeds; 0.09 rejected.
- Events and logs show correct values; no panics.

### Follow up (optional)
If we want different minimums for mint vs repay vs redeem, split this into:
`MIN_BORROW_ICUSD_AMOUNT`, `MIN_REPAY_ICUSD_AMOUNT`, `MIN_REDEEM_ICUSD_AMOUNT`.

### Tasks
- [ ] Update constant
- [ ] Update UI validation and copy that mentions the minimum
- [ ] Deploy backend canister
- Fix Plug wallet disconnect error by using proper window.ic.plug.disconnect() API
- Improve WalletConnector UI with enhanced popup design and better layout
- Add animated dropdown arrow and better visual hierarchy in wallet button
- Display full principal IDs without truncation for better UX
- Remove unnecessary Plug wallet installation warnings
- Enhance balance display with token logos and organized card layout
- Add proper loading states for balance refresh operations
- Improve responsive design and accessibility
- Maintain sidebar logo visibility when collapsed

Resolves wallet disconnection issues and provides professional UI/UX
…ol enhancements

Backend Improvements:
- Enhanced vault management with improved state handling
- Updated protocol guards and security mechanisms
- Refined vault operations and liquidation logic
- Updated Candid interface definitions

New Core Features:
- Complete Rumi Stability Pool implementation with monitoring
- Rumi Treasury module for protocol fund management
- Advanced liquidation monitoring and reward systems
- User deposit and withdrawal interfaces

Frontend Enhancements:
- Stability pool UI components and dashboards
- Enhanced vault details and protocol management
- Improved token service and API client architecture
- Better configuration management and PNP integration

Infrastructure:
- Updated project dependencies and canister configurations
- Enhanced dfx.json with new canister definitions (init args removed for security)
- Proper canister ID management for production deployment

This commit establishes the foundation for advanced DeFi features
including stability pool rewards, treasury management, and enhanced
liquidation mechanisms.
- Add TreasuryService and TreasuryManagementService to apiClient
- Add treasury and stability pool canister IDs to config
- Export WALLET_TYPES constant from auth service
- Add LoadingSpinner component for async operations
- Generate treasury canister declarations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants