Skip to content

Repository files navigation

BorinFi

A smart contract for structured savings on EVM chains. Users deposit stablecoins into a personal stash, then allocate funds across vaults with different withdrawal rules.

Built with Solidity 0.8.20, OpenZeppelin, and Hardhat.

How it works

Stash — your main balance inside the contract. Deposit stablecoins in, request withdrawals out. Withdrawals have a 24-hour cooldown period to protect against impulsive spending (that's the point — it's a savings tool).

Vaults — sub-accounts you create from your stash. Each vault has a name and a lock type:

  • Nolock — withdraw anytime, no restrictions
  • Timelock — locked until a specific date (e.g., "don't touch until December")
  • Targetlock — locked until the vault reaches a target amount (e.g., "save $1,000 before I can withdraw")

Funds move: wallet → stash → vault → stash → wallet. Vaults pull from and return to the stash. Only the stash interacts with the outside world.

Fee structure

1% on deposit, 1% on withdrawal. Fees go to a configurable fee collector address.

Contract architecture

BorinFi.sol
├── Stash (per user)
│   ├── depositToStash()        — deposit stablecoin, 1% fee taken
│   ├── requestWithdrawal()     — start 24hr cooldown
│   ├── cancelWithdrawal()      — cancel and return funds to stash
│   └── finalizeWithdrawal()    — withdraw after cooldown, 1% fee taken
│
└── Vaults (per user, unlimited)
    ├── createVault()            — create with name + lock type
    ├── fundVault()              — move funds from stash → vault
    ├── withdrawFromVault()      — move funds from vault → stash (if unlocked)
    └── getUserVaults()          — view all vaults for an address

Quick start

git clone https://github.com/bigchiano/borinfi.git
cd borinfi
npm install

Compile

npx hardhat compile

Test

npx hardhat test

Deploy

npx hardhat run scripts/deploy.js --network <network>

Constructor takes two arguments:

  • _token — address of the ERC20 stablecoin (USDT, USDC, etc.)
  • _feeCollector — address that receives fees

Dependencies

Security notes

  • Uses OpenZeppelin's ReentrancyGuard on all external token transfer functions
  • 24-hour withdrawal cooldown acts as a time-delayed safety mechanism
  • Vault lock conditions are enforced on-chain — no admin override
  • Each user's vaults are isolated — no cross-user access
  • This contract has not been formally audited. Use at your own risk.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages