This PR introduces the Dividend Distribution Module, allowing token issuers to deposit XLM which is then proportionally distributed to all SoroMint token holders.
Because enumerating all token holders on-chain is computationally unfeasible, this module utilizes an O(1) Dividends-Per-Share (DPS) accumulator pattern.
- Smart Contracts (
contracts/dividend/*):- Implemented
DividendDistributorcontract. - Math uses
10^13precision scaling to safely prevent integer truncation, even when small amounts of XLM are distributed over large token supplies. - Gas-optimized:
total_supplyandholder_balanceare provided by the caller to bypass expensive cross-contract reads. - XLM transfers handle safely through
token::Clientas SEP-41 assets.
- Implemented
- Backend Integration (
server/routes/dividend-routes.js):- Added 4 REST endpoints (
/stats,/claimable/:holderAddress,/deposit,/claim). - Implemented standard project patterns (JWT auth,
express-validatorstyle assertions viaAppError, structured winston logging). - Transaction endpoints return structured data ready for Freighter XDR building on the frontend.
- Added 4 REST endpoints (
- Testing:
- 12 comprehensive test cases utilizing the
soroban-sdk22 API (register_stellar_asset_contract). - Tested proportional splits, zero balances, late joiners, and boundary limits.
- 12 comprehensive test cases utilizing the
- Workspace Integration:
- Registered
contracts/dividendin rootCargo.toml.
- Registered
- Verify the project builds via
cargo build --target wasm32-unknown-unknown --release -p soromint-dividend. - Run tests to confirm logic:
cargo test -p soromint-dividend. - Check the backend integration by spinning up the server and navigating to the
/api/dividend/statsroute.
Closes #190