Request form
0xSplits
  • Payments
  • Splitter
  • Protocol
Docs
Source
ChefGPT

The standard for splitting onchain income

SplitMain :
Split recipients, ownerships, and keeper fees are stored onchain as calldata & re-passed as args / validated via hashing when needed. Each split gets its own address & proxy for maximum composability with other contracts onchain. For these proxies, we extended EIP-1167 Minimal Proxy Contract to avoid `DELEGATECALL` inside `receive()` to accept hard gas-capped `sends` & `transfers`.
distributeERC20(address,address,address[],uint32[],uint32,address) :
`accounts`, `percentAllocations`, and `distributorFee` are verified by hashing & comparing to the hash in storage associated with split `split`pernicious ERC20s may cause overflow in this function inside _scaleAmountByPercentage, but results do not affect ETH & other ERC20 balances
distributeETH(address,address[],uint32[],uint32,address) :
`accounts`, `percentAllocations`, and `distributorFee` are verified by hashing & comparing to the hash in storage associated with split `split`
transferControl(address,address) :
Two-step control transfer inspired by [dharma](https://github.com/dharma-eng/dharma-smart-wallet/blob/master/contracts/helpers/TwoStepOwnable.sol)
updateAndDistributeERC20(address,address,address[],uint32[],uint32,address) :
only callable by SplitControllerpernicious ERC20s may cause overflow in this function inside _scaleAmountByPercentage, but results do not affect ETH & other ERC20 balances
updateAndDistributeETH(address,address[],uint32[],uint32,address) :
only callable by SplitController
SplitWallet :
`SplitProxy` handles `receive()` itself to avoid the gas cost with `DELEGATECALL`.
sendERC20ToMain(address,uint256) :
payable reduces gas cost; no vulnerability to accidentally lock ETH introduced since fn call is restricted to SplitMain
sendETHToMain(uint256) :
payable reduces gas cost; no vulnerability to accidentally lock ETH introduced since fn call is restricted to SplitMain
ERC20 :
Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
SafeTransferLib :
Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.
SplitMain.sol
SplitWallet.sol
ISplitMain.sol
ReverseRecords.sol
Clones.sol
ERC20.sol
SafeTransferLib.sol

108 downloads

Chains

Authors

0xSplits
  • Payments
  • Splitter
  • Protocol
Info
Docs
Source
ChefGPT
Expand
Share

Get Cookin'

108 downloads

Chains

Authors

splits-contracts

codecov

Run locally

yarn hardhat node

Metamask network config

  • Network name: Localhost
  • New RPC URL: http://{{LOCALHOST URL - ie 127.0.0.1}}:8545
  • Chain ID: 1337

Dev Setup

Make sure to have node installed, need >= 12. Can find the installation here. A node version manager can also be useful, you can read more about it here.

Install yarn: npm install --global yarn
Confirm the installation: yarn --version

Run yarn install to add packages

Follow the hardhat network setup instructions in the Metamask network config section up above. If you do not have metamask installed, you can find it here.

Add funds to your wallet, you can find the instructions below in the Commands section.

Setup your .env.local file. Copy over the .env.local.sample file and fill in the values. Message someone else to get the values.

Common Errors

If you are getting an error on the yarn hardhat node command, you may need to clear out the artifacts/cache. Run yarn hardhat clean, then try again.

Commands

// Send funds to local wallet
yarn hardhat seedAccount --network localhost {{YOUR_WALLET_ADDRESS}}

// Create split with random recipients
yarn hardhat createSplit --network localhost --size {{SIZE}}
The standard for splitting onchain income
SplitMain :
Split recipients, ownerships, and keeper fees are stored onchain as calldata & re-passed as args / validated via hashing when needed. Each split gets its own address & proxy for maximum composability with other contracts onchain. For these proxies, we extended EIP-1167 Minimal Proxy Contract to avoid `DELEGATECALL` inside `receive()` to accept hard gas-capped `sends` & `transfers`.
distributeERC20(address,address,address[],uint32[],uint32,address) :
`accounts`, `percentAllocations`, and `distributorFee` are verified by hashing & comparing to the hash in storage associated with split `split`pernicious ERC20s may cause overflow in this function inside _scaleAmountByPercentage, but results do not affect ETH & other ERC20 balances
distributeETH(address,address[],uint32[],uint32,address) :
`accounts`, `percentAllocations`, and `distributorFee` are verified by hashing & comparing to the hash in storage associated with split `split`
transferControl(address,address) :
Two-step control transfer inspired by [dharma](https://github.com/dharma-eng/dharma-smart-wallet/blob/master/contracts/helpers/TwoStepOwnable.sol)
updateAndDistributeERC20(address,address,address[],uint32[],uint32,address) :
only callable by SplitControllerpernicious ERC20s may cause overflow in this function inside _scaleAmountByPercentage, but results do not affect ETH & other ERC20 balances
updateAndDistributeETH(address,address[],uint32[],uint32,address) :
only callable by SplitController
SplitWallet :
`SplitProxy` handles `receive()` itself to avoid the gas cost with `DELEGATECALL`.
sendERC20ToMain(address,uint256) :
payable reduces gas cost; no vulnerability to accidentally lock ETH introduced since fn call is restricted to SplitMain
sendETHToMain(uint256) :
payable reduces gas cost; no vulnerability to accidentally lock ETH introduced since fn call is restricted to SplitMain
ERC20 :
Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
SafeTransferLib :
Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.
SplitMain.sol
SplitWallet.sol
ISplitMain.sol
ReverseRecords.sol
Clones.sol
ERC20.sol
SafeTransferLib.sol