Automated Salary Allocation System Built on Flow
Seflow smart contracts automate salary splitting for professionals worldwide. Deposit $FLOW, set custom allocation percentages (savings, DeFi, spending), enable auto-compounding, and earn $FROTH rewards - all powered by Flow's native smart contract capabilities.
This smart contract system leverages Flow's Forte network upgrade, utilizing Actions and Workflows for automated transaction scheduling and DeFi operations.
- AutoCompoundHandler (
0x7d7f281847222367): Manages automated yield compounding with scheduled transactions - LiquidityPool: Handles DeFi yield generation and LP token management
- SeflowSalary: Core salary splitting logic and fund allocation
- FROTHRewards: Token reward system for user engagement
β Smart Salary Splitting: Automated allocation across savings, DeFi, and spending β Scheduled Auto-Compounding: Uses Flow's transaction scheduler for yield optimization β Vault Locking: 30-day lock mechanism with enhanced APY rewards β FROTH Token Rewards: Gamified reward system for consistent usage β On-chain Storage: All user preferences and state stored on Flow blockchain
Here are some essential resources to help you hit the ground running:
- Flow Documentation - The official Flow Documentation is a great starting point to start learning about building on Flow.
- Cadence Documentation - Cadence is the native language for the Flow Blockchain. It is a resource-oriented programming language that is designed for developing smart contracts. The documentation is a great place to start learning about the language.
- Visual Studio Code and the Cadence Extension - It is recommended to use the Visual Studio Code IDE with the Cadence extension installed. This will provide syntax highlighting, code completion, and other features to support Cadence development.
- Flow Clients - There are clients available in multiple languages to interact with the Flow Blockchain. You can use these clients to interact with your smart contracts, run transactions, and query data from the network.
- Block Explorers - Block explorers are tools that allow you to explore on-chain data. You can use them to view transactions, accounts, events, and other information. Flowser is a powerful block explorer for local development on the Flow Emulator.
/cadence
βββ contracts/
β βββ AutoCompoundHandler.cdc # Automated yield compounding logic
β βββ LiquidityPool.cdc # DeFi LP management
β βββ SeflowSalary.cdc # Core salary splitting
β βββ FROTHRewards.cdc # Token reward system
βββ scripts/
β βββ check_auto_compound_status.cdc # Query compound status
β βββ get_salary_split_info.cdc # Retrieve user allocations
β βββ get_froth_balance.cdc # Check reward balances
βββ transactions/
β βββ setup_salary_splitting.cdc # Initialize user account
β βββ set_split_config.cdc # Configure allocations
β βββ schedule_auto_compound.cdc # Enable auto-compounding
β βββ claim_froth_rewards.cdc # Claim reward tokens
βββ tests/
βββ salary_splitting_test.cdc # Core functionality tests
βββ auto_compound_test.cdc # Automation tests
βββ rewards_test.cdc # Token reward tests
- Purpose: Manages scheduled transaction execution for yield compounding
- Key Features:
- Integrates with Flow's transaction scheduler
- Configurable compounding intervals (daily to monthly)
- Real LP yield compounding (no mock data)
- Error handling for insufficient funds
- Purpose: Core salary allocation and management
- Key Features:
- Three-way split: Savings, DeFi, Spending
- Percentage-based allocation system
- Vault locking mechanism (30-day periods)
- Integration with Flow token standards
- Purpose: DeFi yield generation and LP token management
- Key Features:
- Automated LP token minting/burning
- Yield calculation and distribution
- Compound interest algorithms
- Pool balance management
- Purpose: Gamified token reward system
- Key Features:
- 1% base rewards for standard transactions
- 1.5% enhanced rewards for vault locking
- Token minting and distribution logic
- User engagement tracking
- Flow CLI installed and configured
- Flow testnet account with FLOW tokens
- VS Code with Cadence extension (recommended)
AutoCompoundHandler: 0x7d7f281847222367
FlowToken: 0x7e60df042a9c0868
FungibleToken: 0x9a0766d93b6608b7
flow scripts execute cadence/scripts/check_auto_compound_status.cdc --arg Address:0x[YOUR_ADDRESS]flow transactions send cadence/transactions/setup_salary_splitting.cdcflow transactions send cadence/transactions/set_split_config.cdc \
--arg UFix64:1000.0 \ # Total salary amount
--arg UInt8:50 \ # Savings percentage
--arg UInt8:30 \ # DeFi percentage
--arg UInt8:20 \ # Spending percentage
--arg Bool:true # Lock vault (30 days)flow transactions send cadence/transactions/schedule_auto_compound.cdc \
--arg UInt64:7 # Interval in days (weekly)flow scripts execute cadence/scripts/get_salary_split_info.cdc --arg Address:0x[YOUR_ADDRESS]- Initialize Account: Set up storage and capabilities
- Configure Split: Define allocation percentages (must sum to 100%)
- Enable Automation: Schedule auto-compound with desired frequency
- Monitor Status: Check compound execution and yields
- Claim Rewards: Collect FROTH tokens earned from usage
- All assets stored as Cadence resources (cannot be copied or lost)
- Strict access control with capability-based security
- Move semantics prevent double-spending attacks
- Public functions for user interactions
- Private admin functions for contract management
- Capability-based resource access for automated operations
- Time-locked vault mechanisms for enhanced security
- Comprehensive input validation
- Graceful failure modes for insufficient funds
- Transaction rollback on any operation failure
- Detailed logging for debugging and monitoring
- Scheduled Transactions: Automated compounding without manual intervention
- Workflow Composition: Reusable DeFi action patterns
- Time-based Triggers: Configurable execution intervals
- Protocol Agnostic: Works with any Flow DeFi protocol
- Efficient resource management patterns
- Batched operations to minimize transaction costs
- Lazy evaluation for expensive computations
- Optimal storage layout for frequently accessed data
// Compound interest formula implementation
pub fun calculateCompoundYield(
principal: UFix64,
rate: UFix64,
periods: UInt64
): UFix64 {
// A = P(1 + r/n)^(nt)
let compoundFactor = (1.0 + rate).power(periods)
return principal * compoundFactor - principal
}To add a new contract to your project, run the following command:
flow generate contractThis command will create a new contract file and add it to the flow.json configuration file.
To add a new script to your project, run the following command:
flow generate scriptThis command will create a new script file. Scripts are used to read data from the blockchain and do not modify state (i.e. get the current balance of an account, get a user's NFTs, etc).
You can import any of your own contracts or installed dependencies in your script file using the import keyword. For example:
import "Counter"To add a new transaction to your project you can use the following command:
flow generate transactionThis command will create a new transaction file. Transactions are used to modify the state of the blockchain (i.e purchase an NFT, transfer tokens, etc).
You can import any dependencies as you would in a script file.
To add a new test to your project you can use the following command:
flow generate testThis command will create a new test file. Tests are used to verify that your contracts, scripts, and transactions are working as expected.
If you want to use external contract dependencies (such as NonFungibleToken, FlowToken, FungibleToken, etc.) you can install them using Flow CLI Dependency Manager.
For example, to install the NonFungibleToken contract you can use the following command:
flow deps add mainnet://1d7e57aa55817448.NonFungibleTokenContracts can be found using ContractBrowser, but be sure to verify the authenticity before using third-party contracts in your project.
To verify that your project is working as expected you can run the tests using the following command:
flow testThis command will run all tests with the _test.cdc suffix (these can be found in the cadence/tests folder). You can add more tests here using the flow generate test command (or by creating them manually).
To learn more about testing in Cadence, check out the Cadence Test Framework Documentation.
β Flow Testnet (Live)
- AutoCompoundHandler:
0x7d7f281847222367 - Successfully handling real LP compounding (no mock data)
- Integrated with Flow's transaction scheduler
- Supporting scheduled auto-compound operations
# Install Flow CLI
sh -ci "$(curl -fsSL https://storage.googleapis.com/flow-cli/install.sh)"
# Create testnet account
flow accounts create --network=testnet
# Fund account with testnet FLOW
# Visit: https://testnet-faucet.onflow.org/{
"contracts": {
"AutoCompoundHandler": "./cadence/contracts/AutoCompoundHandler.cdc",
"SeflowSalary": "./cadence/contracts/SeflowSalary.cdc",
"LiquidityPool": "./cadence/contracts/LiquidityPool.cdc"
},
"deployments": {
"testnet": {
"account-1": ["AutoCompoundHandler", "SeflowSalary", "LiquidityPool"]
}
}
}# Deploy all contracts
flow project deploy --network=testnet --update
# Verify deployment
flow accounts get 0x7d7f281847222367 --network=testnet# Set up initial liquidity pool
flow transactions send cadence/transactions/initialize_pool.cdc --network=testnet
# Configure reward parameters
flow transactions send cadence/transactions/setup_rewards.cdc --network=testnetSeflow contracts are currently optimized for testnet development and hackathon demonstration. For mainnet deployment:
- Security Audit: Complete third-party security review
- Gas Optimization: Final gas cost optimizations
- Admin Controls: Multi-sig admin account setup
- Emergency Procedures: Pause/upgrade mechanisms
- Oracle Integration: Real-time price feeds for yield calculations