feat: Treasury Storage, Fee Collection & Allocation Logic#325
Merged
Olowodarey merged 1 commit intoDevsol-01:mainfrom Mar 24, 2026
Merged
feat: Treasury Storage, Fee Collection & Allocation Logic#325Olowodarey merged 1 commit intoDevsol-01:mainfrom
Olowodarey merged 1 commit intoDevsol-01:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@Folex1275 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: Treasury Storage, Fee Collection & Allocation Logic
Closes #321, Closes #322, Closes #323
Description
This PR implements the core treasury infrastructure for the Nestera savings protocol, covering three interconnected features:
Treasury Storage Structure ([contract] Treasury Storage Structure #321): Defines a persistent on-chain
Treasurystruct to track protocol funds, includingtotal_fees_collected,total_yield_earned,reserve_balance,treasury_balance,rewards_balance, andoperations_balance. The treasury is initialized with zero values duringinitialize_config.Fee Collection Mechanism ([contract] Fee Collection Mechanism #322): Replaces the single
protocol_fee_bps/PlatformFeeconfiguration with three independently configurable fees:deposit_fee_bps— deducted on deposits (flexi, goal)withdrawal_fee_bps— deducted on withdrawals (flexi, goal)performance_fee_bps— deducted on strategy yield harvestEach fee collection point now emits a
FeeCollectedevent and records the fee into theTreasurystruct viatreasury::record_fee().Treasury Allocation Logic ([contract] Treasury Allocation Logic #323): Implements
allocate_treasury()which splits the unallocatedtreasury_balanceinto three buckets:reserve_balancerewards_balanceoperations_balanceAllocation percentages are provided in basis points and must sum to exactly 10,000 (100%). Invalid configs are rejected. Operations receives the remainder to avoid rounding dust.
Files Changed
New Files
contracts/src/treasury/mod.rsget_treasury,initialize_treasury,record_fee,record_yield,allocate_treasurycontracts/src/treasury/types.rsTreasurystruct,AllocationConfigstructModified Files
contracts/src/storage_types.rsDataKey::Treasury→DataKey::TreasuryAddress; addedDataKey::Treasury(struct),DataKey::AllocationConfig,DataKey::DepositFeeBps,DataKey::WithdrawalFeeBps,DataKey::PerformanceFeeBps; removedDataKey::PlatformFeecontracts/src/config.rsConfigstruct now hasdeposit_fee_bps,withdrawal_fee_bps,performance_fee_bps;initialize_configaccepts 3 fee params and callsinitialize_treasury;set_feesreplacesset_protocol_feecontracts/src/lib.rsget_treasury,allocate_treasury,set_fees; removedset_protocol_fee,set_protocol_fee_bps,get_protocol_fee_bpscontracts/src/flexi.rsDepositFeeBps/WithdrawalFeeBps; callstreasury::record_feecontracts/src/goal.rsDepositFeeBps/WithdrawalFeeBps; callstreasury::record_feecontracts/src/strategy/routing.rsperformance_fee_bpsfrom Config; callstreasury::record_feeandtreasury::record_yieldcontracts/src/config_tests.rscontracts/tests/strategy_integration_test.rsinitialize_configsignature.gitignorecontracts/test_snapshots/Acceptance Criteria
Treasurystruct stored on-chain with correct fieldsinitialize_configdeposit_fee,withdrawal_fee,performance_feerecord_feeFeeCollectedevent emitted on every fee collectionallocate_treasury()splits funds into reserves, rewards, and operationsTesting