InvestreContract is a smart contract system that enables automated token purchases triggered by social interactions on Farcaster, with intelligent routing across multiple Uniswap versions (V2, V3, V4).
The protocol allows users to set up automated token purchases that are triggered by social interactions (likes, recasts) on Farcaster. Users pre-approve USDC spending, and authorized backends monitor social activity to execute purchases on their behalf, with purchased tokens held in the user's account within the contract.
- Social-Triggered Auto-Buys: Automatic token purchases triggered by Farcaster likes and recasts
- Multi-Router Support: Smart routing across Uniswap V4, V3, and V2 for optimal execution
- Backend Authorization: Authorized backends can execute trades on behalf of users
- User-Controlled Limits: Users set their own spending limits and social interaction amounts
- Fee Structure: 1% fee on all transactions goes to fee recipient
- Earned Token Management: Users can swap their earned tokens using smart routing
- Option A Design: Backends call functions on behalf of users (current implementation)
- Smart Routing: V4-first with V3/V2 fallback for optimal swap execution
- User Funds: USDC remains in user wallets, contract approved for spending
- Earned Tokens: Purchased tokens stored in contract, withdrawable by users
The main contract AutoBuyContract is built with:
- Solidity 0.8.26
- OpenZeppelin security standards
- Uniswap V2/V3/V4 integration
- ReentrancyGuard protection
- Foundry testing framework
executeFarcasterAutoBuy()- Execute social-triggered purchasessmartAutoBuy()- Intelligent multi-router token swappingwithdrawUserTokens()- Withdraw earned tokenssetUserBuyLimitSelf()- Set personal spending limitssetSocialAmounts()- Configure like/recast amounts
This project uses Foundry for development and testing.
- Foundry
- Git
git clone <repository-url>
cd extwall
forge installforge buildRun all tests:
forge testRun specific test suites:
# Integration tests
forge test --match-contract AutoBuyIntegration -vv
# Advanced functionality tests
forge test --match-contract AutoBuyAdvanced -vv
# Gas optimization tests
forge test --match-contract AutoBuyGas -vvforge fmtforge snapshotFor Base mainnet deployment, see DEPLOY_BASE.md for detailed instructions.
Quick deployment:
forge script script/DeployBase.s.sol:DeployBase --rpc-url base --broadcast --verifyStart local node:
anvilDeploy locally:
forge script script/Counter.s.sol:CounterScript --rpc-url http://localhost:8545 --private-key <anvil_private_key>The project includes comprehensive test suites:
- Integration Tests (
AutoBuyIntegration.t.sol): Multi-user scenarios, social interactions, backend management - Advanced Tests (
AutoBuyAdvanced.t.sol): Smart routing, fallback logic, V4 swaps, fuzz testing - Gas Tests (
AutoBuyGas.t.sol): Gas optimization validation - Invariant Tests (
AutoBuyInvariant.t.sol): Property-based testing
- ✅ Social auto-buy execution
- ✅ Multi-router fallback logic
- ✅ User limit enforcement
- ✅ Backend authorization
- ✅ Fee collection
- ✅ Token withdrawal
- ✅ Emergency scenarios
MIT License - see LICENSE file for details.
- Fork the repository
- Create a feature branch
- Add comprehensive tests
- Run
forge testandforge fmt - Submit a pull request
For questions and support, please open an issue in the repository.