feat: Add Merkle distributor, PnL engine, CSV export & referral system#131
Merged
edehvictor merged 1 commit intoedehvictor:mainfrom Mar 30, 2026
Conversation
Implements four features for the StellarYield platform: ## Merkle Tree Airdrop Distributor (edehvictor#106) - Soroban smart contract with SHA256 Merkle proof verification - Bitmap-based claim tracking with epoch support for root updates - Node.js Merkle tree generator with comprehensive test suite - React ClaimRewards component with wallet integration - 12 contract tests + 32 backend tests passing ## PnL Tracking Engine (edehvictor#107) - Time-Weighted Return (TWR) calculator with daily snapshot generation - Share price cron job running at 00:00 UTC via node-cron - REST API endpoint GET /api/users/:address/pnl - Recharts-based PnL visualization component - Prisma models: SharePriceSnapshot, UserTransaction ## CSV Export for Tax Reporting (edehvictor#113) - In-memory and streaming CSV generators with batched processing - Rate-limited export endpoint (5 req/15min) GET /api/users/:address/export - Support for transaction_history and pnl_summary report types - TaxExport React component with download functionality - Prisma model: ExportJob ## Referral & Affiliate System (edehvictor#115) - On-chain referral tracking in yield_vault contract - Configurable fee (default 500bps, max 1000bps) with admin controls - Referral reward accrual on deposits, claimable by referrers - ReferralDashboard component with link sharing and reward claiming - 17 contract tests covering registration, deposits, rewards, and edge cases - Prisma model: Referral All tests passing: 108 total across contracts, server, and backend packages.
|
@Akanimoh12 is attempting to deploy a commit to the Edeh Victor's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Akanimoh12 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: Add Merkle Distributor, PnL Engine, CSV Export & Referral System
Summary
This PR implements four new features for the StellarYield platform, spanning smart contracts, backend services, and frontend components with comprehensive test coverage.
Closes #106, Closes #107, Closes #113, Closes #115
Changes
1. Merkle Tree Airdrop Distributor (Issue #106)
Smart Contract (
contracts/merkle_distributor/)set_merkle_rootwith automatic epoch incrementAlreadyClaimed,InvalidProof,ZeroAmount,InsufficientBalance, etc.Backend (
backend/rewards/)MerkleTreeclass with sorted-pair SHA256 hashing (matches on-chain logic)generateTreeutility for building trees from address/amount pairsFrontend (
client/src/features/rewards/ClaimRewards.tsx)Tests: 12 contract tests + 32 backend tests
2. PnL Tracking Engine (Issue #107)
Backend Services (
server/src/services/pnl_engine/)calculatePnLaggregating deposits, withdrawals, and unrealized gainsInfrastructure
sharePriceSnapshotcron job running daily at 00:00 UTC (server/src/jobs/)GET /api/users/:address/pnl(server/src/routes/pnl.ts)SharePriceSnapshot,UserTransactionFrontend (
client/src/features/pnl/PnLChart.tsx)Tests: 15 test cases covering calculations, edge cases, and error handling
3. CSV Export for Tax Reporting (Issue #113)
Backend Services (
server/src/services/export/)transaction_history,pnl_summarycreateExportFilenamewith timestamp-based namingInfrastructure
GET /api/users/:address/export(5 requests per 15 minutes)ExportJobfor tracking export historyFrontend (
client/src/features/taxes/TaxExport.tsx)Tests: 14 test cases covering generation, streaming, and edge cases
4. Referral & Affiliate System (Issue #115)
Smart Contract (
contracts/yield_vault/src/referrals.rs)deposit_with_referralclaim_referral_rewardswith token transfer to referrerFrontend (
client/src/features/referrals/ReferralDashboard.tsx)Tests: 17 contract tests covering registration, deposits, reward accrual/claiming, fee management, admin controls, and edge cases
Files Changed
New Files (62)
contracts/merkle_distributor/- Complete Soroban merkle distributor contractcontracts/yield_vault/src/referrals.rs- Referral system modulebackend/rewards/- Merkle tree generator packageserver/src/services/pnl_engine/- PnL calculation servicesserver/src/services/export/- CSV export servicesserver/src/jobs/sharePriceSnapshot.ts- Daily cron jobserver/src/routes/{pnl,export}.ts- API endpointsserver/src/__tests__/{pnlCalculator,csvExport}.test.ts- Server testsclient/src/features/{rewards,pnl,taxes,referrals}/- UI componentsModified Files (7)
contracts/Cargo.toml- Addedmerkle_distributorto workspacecontracts/Cargo.lock- Updated dependenciescontracts/yield_vault/src/lib.rs- Added referral module + wrapper functions + testsserver/prisma/schema.prisma- Added 4 new modelsserver/src/app.ts- Registered new routesserver/src/index.ts- Added cron job startupclient/src/App.tsx- Added routes and navigationTesting
contracts/merkle_distributorcontracts/yield_vault(referral)contracts/yield_vault(existing)server(PnL + CSV)backend/rewards(Merkle)All code passes
cargo clippy --all-targets -- -D warningsandcargo fmt --check.Architecture Decisions
implfunctions inreferrals.rscalled by wrapper methods in the main#[contractimpl]block, avoiding multiplecontractimplconflicts (consistent with existingflashloan.rspattern)u128words for gas-efficient on-chain storage of claim status