Protocol
Contract reference
Every external function, parameter, event and revert.
Deployed at 0xC73f689442B6D61e34ba36199e23855c61b11A0b on Robinhood Chain, chain id 4663. Everything below is the deployed source, not a plan.
State changing
createPot
function createPot(
string calldata name,
address asset,
uint256 target,
uint64 deadline,
address beneficiary,
bool shared
) external returns (uint256 id)| Parameter | Rule |
|---|---|
| name | 1 to 64 bytes, otherwise BadParams. |
| asset | Any ERC-20, not the zero address. |
| target | Above zero, at most type(uint128).max. |
| deadline | Strictly greater than block.timestamp. |
| beneficiary | Zero means the caller. On a solo pot it must equal the caller. |
| shared | False restricts contribute to the creator. |
Reverts with BadParams on any rule above. Emits PotCreated and returns the new id, which is also the previous value of potCount.
contribute
function contribute(uint256 id, uint256 amount) external
Pulls amount of the pot asset from the caller with safeTransferFrom and credits whatever actually arrived. Requires an ERC-20 allowance for the Cairn contract first.
| Revert | When |
|---|---|
| NoPot | No pot at that id. |
| PotClosed | Already released or cancelled. |
| PastDeadline | block.timestamp is past the deadline. |
| SoloPot | Pot is solo and the caller is not the creator. |
| BadParams | amount is zero, or nothing was received. |
| Reentrant | Called again from inside a token callback. |
release
function release(uint256 id) external
Permissionless. Sends the entire pot balance to the beneficiary minus the fee, and the fee to the treasury. Sets released before transferring.
| Revert | When |
|---|---|
| NoPot | No pot at that id. |
| PotClosed | Already released or cancelled. |
| TargetNotMet | raised is below target. |
| Reentrant | Reentered from a token callback. |
refund
function refund(uint256 id) external
Returns the caller's own recorded share and zeroes it. Never touches anybody else's share.
| Revert | When |
|---|---|
| NoPot | No pot at that id. |
| PotClosed | The pot was released. |
| BeforeDeadline | The deadline has not passed yet. |
| TargetMet | raised is at or above target. |
| NothingToRefund | The caller has no share left. |
| Reentrant | Reentered from a token callback. |
cancel
function cancel(uint256 id) external
| Revert | When |
|---|---|
| NoPot | No pot at that id. |
| NotCreator | The caller did not create the pot. |
| PotClosed | Already released or cancelled. |
| HasStones | raised or contributors is not zero. |
Views
| Signature | Returns |
|---|---|
| owner() view returns (address) | Admin address. |
| treasury() view returns (address) | Where fees land. |
| feeBps() view returns (uint16) | Current fee, 50 means 0.50%. |
| MAX_FEE_BPS() view returns (uint16) | Constant 100. The hard ceiling. |
| feeToken() view returns (address) | $CAIRN once armed, zero until then. |
| feeWaiverBalance() view returns (uint256) | Minimum $CAIRN balance for a free release. |
| potCount() view returns (uint256) | Number of pots ever created. |
| getPot(uint256) view returns (Pot) | The full struct. |
| contributionOf(uint256,address) view returns (uint256) | One address's recorded share. |
| potsOf(address) view returns (uint256[]) | Ids that address created. |
| joinedBy(address) view returns (uint256[]) | Ids that address contributed to. |
| contributorsOf(uint256) view returns (address[]) | Every address that ever contributed. |
| listPots(uint256,uint256) view returns (uint256[],Pot[]) | A clamped page of pots. |
| quoteFee(address,uint256) view returns (uint256) | Fee a release of that size to that beneficiary would pay now. |
| feeWaived(address) view returns (bool) | Whether that address currently skips the fee. |
Admin
Owner is 0xe568F9e89F77D88399817Ec4046fa21Fc675E269. All four functions revert with NotOwnerfor anyone else. None of them can move a contributor's money.
| Signature | Effect |
|---|---|
| setFee(uint16) | Sets the fee. Reverts with FeeTooHigh above 100 bps. |
| setTreasury(address) | Changes where fees go. Reverts on the zero address. |
| setWaiver(address,uint256) | Arms or disarms the $CAIRN fee waiver. |
| transferOwnership(address) | Hands over admin. Reverts on the zero address. |
Events
event PotCreated(uint256 indexed id, address indexed creator, address indexed asset,
address beneficiary, uint256 target, uint64 deadline, bool shared, string name);
event Contributed(uint256 indexed id, address indexed from, uint256 amount, uint256 raised);
event Released(uint256 indexed id, address indexed beneficiary, uint256 amount, uint256 fee);
event Refunded(uint256 indexed id, address indexed to, uint256 amount);
event Cancelled(uint256 indexed id);
event OwnerChanged(address indexed newOwner);
event TreasuryChanged(address indexed newTreasury);
event FeeChanged(uint16 feeBps);
event WaiverChanged(address feeToken, uint256 feeWaiverBalance);Errors
error NotOwner(); error NotCreator(); error BadParams(); error NoPot(); error PotClosed(); error SoloPot(); error PastDeadline(); error BeforeDeadline(); error TargetNotMet(); error TargetMet(); error NothingToRefund(); error HasStones(); error FeeTooHigh(); error Reentrant();