Testnet on Base Sepolia: 1 ZRO here is 0.0001 test ETH.
Docs · Contract reference

Docs · For builders

Contract reference

Every public function, constant and error in contracts/src, by contract. Amounts are in wei unless a row says otherwise, and shares are in basis points, where 10,000 is 100%.

IVenue

The shape every market has, so the router, limit orders and agents can treat them all alike. A venue that can't serve a token quotes 0 instead of reverting.

solidity
interface IVenue {
    function quoteBuy(address token, uint256 zroIn) external view returns (uint256 tokensOut);
    function quoteSell(address token, uint256 tokensIn) external view returns (uint256 zroOut);
    function buy(address token, uint256 minOut, address recipient, uint256 deadline) external payable returns (uint256 tokensOut);
    function sell(address token, uint256 tokensIn, uint256 minOut, address recipient, uint256 deadline) external returns (uint256 zroOut);
}

Launchpad

Launches tokens and runs one constant-product curve per token, with virtual reserves. Every token sells 80% of its supply on the curve for 6,000 ZRO, then the raised ZRO and the other 20% open a pool on PancakeSwap Infinity whose liquidity can never be removed. Ownable2Step and ReentrancyGuard.

Constants

ConstantValueMeaning
SUPPLY1,000,000,000 tokensDefault supply, for a launch that doesn't choose
CURVE_SUPPLY / LP_SUPPLY80% / 20%Of the default supply. Any other supply splits the same way
VIRTUAL_TOKENSsupply × 16 / 15The token side of the virtual reserve
VIRTUAL_ZRO2,000 ZROThe ZRO side of the virtual reserve
RAISE_TARGET6,000 ZROReal ZRO raised at which the token graduates
MIN_WHOLE_SUPPLY / MAX_WHOLE_SUPPLY10⁹ / 10¹⁵ whole tokensThe supply a creator may choose
BPS10,000100%
BASE_FEE_BPS100The 1% base every token pays on every trade, on its curve and on its pool
PROTOCOL_BPS40Of each trade, Submarine's part of the base: 0.4%, less a trader's rank discount
CREATOR_BASE_BPS60Of each trade, the creator's part of the base: 0.6%
MAX_DEV_FEE_BPS1,000The most a creator may add on top of the base: 10%
MAX_LAUNCH_FEE40 ZROThe most the owner can ever charge to launch
REFERRAL_BPS4,000Of Submarine's cut of a referred trade, 40% goes to Referrals, after any partner's part
PARTNER_BPS3,000Of Submarine's cut of a trade through a partner, 30% goes to the router for the partner, before any referral
MIN_MAX_WALLET_BPS / MAX_MAX_WALLET_BPS100 / 500A max wallet is 1% to 5% of the supply
MIN_MAX_WALLET_SECS / MAX_MAX_WALLET_SECS900 / 86,400A max wallet lasts 15 minutes to a day from launch
SNIPE_START_BPS / SNIPE_SECONDS5,000 / 60Anti-snipe: a buy pays 50% at launch, falling to the token's fee over 60 s
DEAD0x…dEaDWhere burned tokens go

Storage you can read: launchFee, router, treasury, pools, referrals, creatorFees(address), protocolFees, notEarningSet and curves(token). The base fee and its split are constants, so nothing in storage can change them. A token's own fee, in feeBps, only its creator can change, and only down.

curves(token) returns
struct Curve {
    address creator;
    uint40  createdAt;
    bool    graduated;
    uint16  feeBps;       // what a trader without a rank pays now: 100 + the own fee, 100 to 1,100. Only ever lowered
    uint16  holdersBps;   // of the creator's own fee only
    uint16  burnBps;      // of the creator's own fee only
    bool    antiSnipe;
    uint128 raised;       // real ZRO in the curve
    uint128 sold;         // tokens sold, net of sales
    uint128 supply;
    uint16  protocolBps;  // Submarine's cut before a rank discount, always 40
}

Functions

FunctionWhoWhat it does
launch(name, symbol, uri, minTokensOut)Anyone, payableLaunches on the default terms: 1 billion supply, no own fee (1% in all), no anti-snipe. ZRO sent beyond the launch fee is the creator's first buy, in the same transaction
launch(name, symbol, uri, minTokensOut, wholeSupply, devFeeBps, holdersBps, burnBps, antiSnipe)Anyone, payableLaunches on the creator's terms. devFeeBps is the own fee on top of the base, 0 to 1,000, which can later only be lowered. holdersBps and burnBps are shares of that own fee, 10,000 or less together; the creator gets the rest. With devFeeBps 0 both must be 0
launch(…, antiSnipe, maxWalletBps, maxWalletSecs)Anyone, payableThe same, with a max wallet: 100 to 500 basis points of the supply for 900 to 86,400 seconds, or both 0 for none. The creator's first buy has to fit under it. Emits MaxWalletSet
lowerFee(token, devFeeBps)The token's creatorLowers the own fee to devFeeBps, which must be below what it is now. The split stays. On a graduated token it runs distribute first, then lowers the pool's fee to match. Returns the whole fee now. Emits FeeLowered
buy(token, minOut, recipient, deadline)Anyone, payableBuys on the curve. Through the router, the trader's rank discount comes off the fee. The buy that fills the curve only pays for what is left, refunds the rest, and graduates the token
sell(token, tokensIn, minOut, recipient, deadline)AnyoneSells on the curve, with the same discount through the router. Reverts once the token has graduated
quoteBuy(token, zroIn) / quoteSell(token, tokensIn)ViewWhat a trade would get right now for a trader without a rank, fee included. 0 for an unknown or graduated token
priceOf(token)ViewSpot price in wei per whole token
buyFeeBps(token)ViewWhat a buy pays right now without a rank. Differs from feeBps only during anti-snipe
buyFeeBpsFor(token, trader)ViewThe same for one trader through the router, with their rank discount taken off
isToken(token), tokensCount(), tokenAt(i)ViewWhether a token is from here, and the list of every token
claimCreatorFees()CreatorSends the caller's creator fees
collectProtocolFees()AnyonePushes the treasury's fees to the treasury
payFromPool(token)ZroInfinityPools onlyA graduated token's fee from its pool, less the burn the hook already made, paid to its holders and creator
payProtocolFromPool(token, trader)ZroInfinityPools onlySubmarine's 0.4% of pool trades, which the hook took. Sends a partner's 30% to the router and the trader's referral share, exactly as on the curve, and adds the rest to protocolFees
setLaunchFee(launchFee)OwnerThe fee to launch, capped at 40 ZRO. The only setting the owner has here: the trading fees can't change
setRouter(router), setNotEarning(list)Owner, onceWiring at deployment

Limits on a launch

A name of 1 to 64 bytes, a symbol of 1 to 16 bytes, and a uri of at most 512 bytes. Anything else reverts with BadMetadata.

Errors

UnknownToken, AlreadyGraduated, Expired, Slippage, ZeroAmount, BadMetadata, BadConfig, BadTerms (also a max wallet out of range), WrongLaunchFee, TransferFailed, NotPools, NotCreator, FeeNotLower.

Rounding always favours the curve. Fees round up and token amounts round down, so the curve's real ZRO can never fall short of what sellers are owed.

LaunchToken and HolderToken

A plain ERC-20 with a fixed supply minted once to the launchpad, a metadataURI, no owner and no way to mint more. A token whose creator gave its holders a share is a HolderToken instead, which adds rewards in ZRO. Neither takes anything from a transfer.

Both inherit HoldsOneBlock: a wallet that got coins from the market (the launchpad's curve, Infinity's Vault or ZroInfinityVenue) can't send any of that token until the next block, and a transfer from it in the same block reverts with BoughtThisBlock. boughtInBlock(wallet) is the block it last got coins from the market in. Coins sent by another wallet don't mark the one that gets them, and the market itself is never marked, so it keeps trading with everyone in the same block. A sandwich can't close in the block it opened.

They also treat the launchpad, the router and the router's forwarders (LimitOrders and CopyVault) as approved: allowance answers the most there is for them, and they move coins without an approve first. Each of those is set once and only ever takes coins from whoever calls it, so this lets nobody move anyone else's coins, and a first sale or order is one transaction instead of two. Any other spender needs an approval as usual. The launchpad answers which spenders it trusts with trusts(spender). The tokens are deployed by TokenFactory, which only the launchpad can use, so their code doesn't count toward the launchpad's size.

FunctionWhoWhat it does
addRewards()Anyone, payableAdds ZRO for holders, split by balance. Waits while less than MIN_EARNING (1 token) is held by earning wallets
rewardOf(holder)ViewZRO this holder can claim now
claim()HolderSends the caller's rewards
claimFor(holder)AnyoneSends a holder's rewards to that holder. Anyone may pay the gas, the money only goes to the holder
perShare, earningSupply, waiting, notEarning(addr), claimedBy(addr)ViewThe bookkeeping behind rewardOf
maxWallet, maxWalletUntilViewBoth kinds. The max wallet in wei of the token and when it ends, both 0 for none
walletCap()ViewBoth kinds. The max wallet now: 0 when there is none or it has ended
maxWalletExempt(addr)ViewBoth kinds. Submarine's contracts the max wallet doesn't apply to

While a max wallet lasts, a transfer that leaves the receiving wallet above maxWallet reverts with MaxWallet. It is checked after the balances move, on the receiver only, so a sale is never blocked. The market is never capped (the launchpad, Infinity's Vault, ZroInfinityVenue and ZroInfinityPools), nor is the exempt list: the not-earning list below and the dead address.

Not earning: the launchpad, ZroInfinityPools, the dead address, and the Router, LimitOrders, BuybackVault, CopyVault, ZroInfinityVenue, Staking and Infinity's Vault, which holds every pool's tokens. Tokens in those contracts earn nothing, so their share goes to people who hold. Errors: BoughtThisBlock, MaxWallet, and on a HolderToken NothingToClaim and TransferFailed.

ZroInfinityPools

The hook of every graduated token's pool on PancakeSwap Infinity, and the launchpad's migrator. At graduation it opens a ZRO/token pool on Infinity's CLPoolManager at the price the curve ended on, and puts the 6,000 ZRO and 20% of the supply in as one position over the whole price range. It owns that position and has no way to remove it. As the hook it refuses liquidity from anyone else and every removal, so the position is the pool's only liquidity, for good. It doesn't trade itself: trades come through ZroInfinityVenue or straight through Infinity. GPL-2.0-or-later, Ownable and ReentrancyGuard. Rebasing tokens are not supported.

ConstantValueMeaning
TICK_SPACING200The whole range is one position, so any spacing works. A wide one keeps a swap to few steps
LP_FEE0No LP fee. The token's fee comes through the hook instead
BURN_PRICE_STEP9,747Of 10,000, on the square-root price: one burn moves the price at most about 5%
HOOK_BITMAP3,285 (0x0CD5)Bits 0, 2, 4, 6, 7, 10 and 11: beforeInitialize, beforeAddLiquidity, beforeRemoveLiquidity, beforeSwap, afterSwap, and both swap return deltas
PROTOCOL_BPS40Submarine's 0.4% of every pool trade, less the trader's rank discount when it comes through ZroInfinityVenue
DEAD0x…dEaDWhere burned tokens go
earnersBps(token)feeBps − 40A graduated token's fee for its earners on the ZRO side of every trade: the creator's 0.6% and the own fee, set when its pool opens and only ever lowered after, with the creator's fee. At most 1,060. Submarine's 0.4% is taken on top
burnBps(token)own × burn ÷ (60 + own)Of that fee, the part that buys the token back from its pool and burns it: the launch burn share, restated as a share of the whole earners' fee
FunctionWhoWhat it does
seed(token, tokenAmount, earnersBps, burnBps)Launchpad only, payableOpens a graduated token's pool at the curve's last price and puts all of the ZRO and tokens in as the one locked position. The few wei the liquidity maths rounds off stay in this contract
distribute(token)AnyonePays out the fees a pool has collected: the burn share buys the token back from its pool and sends it to the dead address, the rest goes to the launchpad for holders and the creator, and Submarine's cut goes to the launchpad's payProtocolFromPool. ZroInfinityVenue runs it after each of its trades
pools(token)View(reserveZro, reserveToken, totalShares): the ZRO and tokens the position is worth at the current price, and its liquidity, for readers built for constant-product pools. Zeros with no pool
priceOf(token)ViewZRO per whole token, in wei, before any fee. 0 with no pool
quoteBuy(token, zroIn) / quoteSell(token, tokensIn)ViewWhat a trade would get, after the token's whole fee, for a trader without a rank. Exact while the locked position is the only liquidity, which the hook makes sure of, and while Infinity's protocol fee is off
poolKeyOf(token)ViewThe pool's Infinity key: ZRO (native) as currency0, the token as currency1, this hook, fee 0, tick spacing 200. What a wallet or another router needs to trade it on Infinity directly
pending(token), pendingProtocol(token)ViewThe earners' fees and Submarine's cut collected and not yet paid out, held as claims on Infinity's vault
tokenOf(poolId), vault, poolManager, launchpadViewWhich token a pool id trades, and the wiring
beforeInitialize, beforeAddLiquidity, beforeRemoveLiquidity, beforeSwap, afterSwapPool manager onlyThe hook. Only this contract may open a pool with this hook or add to it, nobody may remove liquidity, and every trade pays the fee and is reported as a Swap
lockAcquired(data)Infinity vault onlyDoes the opening deposit and the payouts inside the vault's lock
lowerFee(token, earnersBps, burnBps)Launchpad onlyA creator lowered their fee: the pool takes the new, lower fee from the next trade. Reverts unless earnersBps is below today's. Emits FeeLowered(token, earnersBps, burnBps)
setLaunchpad(launchpad)Owner, onceWiring. The only thing the owner can do here

How the fee is taken

When a trade names its ZRO amount, a buy with exact ZRO in or a sale for exact ZRO out, beforeSwap takes earnersBps plus PROTOCOL_BPS of it. When it names the token amount, afterSwap takes the same of the ZRO the swap moved. For a trade through ZroInfinityVenue the hook asks launchpad.router() for currentTrader() and discountOf, and takes the rank discount off Submarine's part. Either way the fee is recorded as a claim on Infinity's vault (ERC-6909) and added to pending(token) and pendingProtocol(token), because in the middle of a swap the vault may hold less ZRO than the fee. distribute turns the claims into ZRO and pays them out.

Infinity never calls a hook for a swap the hook makes itself, so the burns pay no fee and aren't reported as trades. That is also why trades come through a separate venue. A burn buys until the price has moved about 5% (BURN_PRICE_STEP); what it can't spend within that goes to the launchpad with the rest of the fee, for holders and the creator.

Errors: NotLaunchpad (a seed from anyone else, or a pool with this hook opened by anyone else), Locked (liquidity added by anyone else, or any removal), NotVault, NotPoolManager, PoolExists, ZeroAmount, BadConfig (also every hook callback it didn't register), NoPool, TransferFailed.

ZroInfinityVenue

The router's way into the pools, listed as "Submarine Pools" with a router fee of 0, fixed for good, since the hook already takes Submarine's 0.4%. It buys and sells through Infinity's vault, then runs distribute so the fee is paid out in the same transaction. It is a contract of its own because Infinity skips a pool's hook when the hook itself swaps, and the venue's trades have to pay the fee like anyone else's. It names the trade's recipient in the hook data, so the pool's Swap event shows the trader and not the venue. Holds nothing between calls. GPL-2.0-or-later.

FunctionWhoWhat it does
buy(token, minOut, recipient, deadline)Anyone, payableIVenue. Exact ZRO in. The fee is paid out before the buyer holds the tokens, so nobody earns holder rewards from their own buy. ZRO a swap couldn't spend goes back to the recipient
sell(token, tokensIn, minOut, recipient, deadline)AnyoneIVenue. Exact tokens in. The ZRO goes straight to the recipient, then the fee is paid out
quoteBuy / quoteSellViewZroInfinityPools' quotes
vault, poolManager, poolsViewThe wiring, fixed at deployment
lockAcquired(data)Infinity vault onlyMakes the swap inside the vault's lock

Errors: NoPool, Slippage, Expired, ZeroAmount, NotVault, TransferFailed.

Infinity core

contracts/lib/infinity-core is PancakeSwap Infinity's core, unmodified, from pancakeswap/infinity-core-bsc-base at commit 7c04695, under GPL-2.0-or-later. Submarine deploys two of its contracts on Zero: the Vault, which holds every pool's ZRO and tokens, and the CLPoolManager, which runs the pools and is the only app registered on the vault. Both are owned by Submarine's deployer. What that owner can do is on Risks.

Router

One entry point for every venue. It asks each listed venue for a quote, trades on the best, and passes over a venue that quotes well and then fails. It holds nothing between calls and is itself an IVenue.

ConstantValueMeaning
MAX_FEE_BPS100A venue's router fee is at most 1%
MAX_VENUES16Venues listed at once
LISTING_DELAY2 daysA new venue waits this long in public after setup
QUOTE_GAS300,000Gas a venue gets to answer a quote. More reads as no quote
REFERRAL_BPS4,000Of the router fee on a referred trade, 40% goes to Referrals, after any partner's part
RANKS5Ranks above the first, which every wallet starts at
PARTNER_BPS3,000Of Submarine's cut of a partner trade, 30% goes to the partner
PARTNER_CALL / PARTNER_BUILDER1 / 2The kinds of partner: a call, and a builder
FEE_FREE_GAS100,000Gas the staking contract gets to answer isFeeFree. More, or a failure, reads as not fee-free

The deploy lists the Launchpad and ZroInfinityVenue, both with a router fee of 0, since the curve and the hook each take Submarine's 0.4% themselves. A router fee only matters for any other venue listed later.

Volume ranks

volumeOf(wallet) is the ZRO a wallet has traded through the router, buys and sales, for good. It never goes down. Trades sent straight to a venue or to Infinity don't count. The marks are fixed in the code:

rankNameFromoffBpsSubmarine's cut
0Starter0 ZRO00.40%
1Trader2,000 ZRO50.35%
2Regular10,000 ZRO100.30%
3Pro40,000 ZRO150.25%
4Whale200,000 ZRO200.20%
5Legend1,000,000 ZRO250.15%

On the curve and on the pool, the launchpad and the hook take the discount off Submarine's cut, never more than 40. On any other venue it comes off the router's fee. Volume is added after each trade, so a new rank counts from the next one. The names are the site's; the contract only knows the numbers.

Functions

FunctionWhoWhat it does
buy(token, minOut, recipient, deadline)Anyone, payableTakes the venue's router fee, less the recipient's rank discount, from msg.value, buys on the best venue, and checks what really arrived at the recipient against minOut. The trade is the recipient's: their volume, rank and referrer
sell(token, tokensIn, minOut, recipient, deadline)AnyonePulls the tokens, sells on the best venue, takes the router fee less the seller's discount from the ZRO and sends the rest. The trade is the seller's, whoever the recipient is
buyFor(token, minOut, recipient, deadline, trader)Forwarders only, payableA buy LimitOrders or CopyVault makes for a user. It counts for trader: volume, rank discount, referrer. Records no activity. Anyone else gets NotForwarder
sellFor(token, tokensIn, minOut, recipient, deadline, trader)Forwarders onlyThe same for a sale. The tokens come from the forwarder
isForwarder(addr), feeFixed(venue)ViewTrue for LimitOrders and CopyVault; true for the venues listed at deployment, whose router fee stays 0
volumeOf(wallet)ViewZRO traded through here, in wei
rankAt(rank)PureThe volume a rank starts at and its discount: (volume, offBps)
buyPartner(token, minOut, recipient, deadline, partner, kind)Anyone, payableA buy that came through a partner: kind 1 a call, 2 a builder. The trader pays exactly what buy costs, and the partner gets 30% of Submarine's cut, after the trade. The partner can't be the trader, the router or zero
sellPartner(token, tokensIn, minOut, recipient, deadline, partner, kind)AnyoneA sale through a partner, the same way
rankOf(trader), discountOf(trader)ViewA wallet's rank, 0 to 5, and its discount in basis points of a trade: its rank's, or 100 for a fee-free wallet, which the curve and pool cap at their 40
isFeeFree(trader), stakingViewWhether the staking contract says this wallet trades with no Submarine cut right now, and that contract. False until it is set
currentPartner(), payPartner()View; our curve and pool during a tradeThe partner of the trade in progress, and where the curve and pool send its part of their cut
bestBuy(token, zroIn) / bestSell(token, tokensIn)ViewThe winning venue's index and its quote after the router fee
quoteBuy / quoteSellViewThe best quote anywhere
venuesCount(), venueAt(i)ViewAddress, fee and name of each venue
activityOf(wallet, token)ViewA wallet's latest buy and sale of a token through here. CopyVault copies from this
currentTrader()ViewWho the trade in progress is for, from transient storage. Zero outside a trade
queueVenue, cancelQueuedVenue, listVenueOwnerAnnounce a venue, then list it after LISTING_DELAY
setVenueFee(index, feeBps)OwnerAnother launchpad's router fee, capped at 1%. Submarine's own curve and pools were listed at deployment with 0 and keep it for good (feeFixed), and can't be listed again with a fee
setForwarders(list)Owner, onceThe contracts that may trade in a user's name: LimitOrders and CopyVault, set at deployment
setStaking(staking)Owner, onceThe staking contract whose fee-free wallets pay no Submarine cut, set at deployment
removeVenue(index)OwnerInstant, because it is the emergency action
finishSetup()OwnerCloses free listing for good
activityOf(wallet, token) returns
struct Activity {
    uint40  buyBlock;
    uint40  sellBlock;
    uint16  soldBps;    // share of its holding the latest sale let go
    uint128 buyZro;     // ZRO the latest buy spent, fee included
    uint128 buyTokens;
    uint128 sellZro;    // ZRO the latest sale brought, after the fee
    uint128 sellTokens;
}

A buy only counts as activity when the wallet bought for itself (recipient equals sender), so nobody can make a wallet look like it bought. Trades made through buyFor and sellFor record no activity, so copy trading only ever follows a leader's own trades. With no venue left, a trade reverts with the last venue's own reason, such as MaxWallet, or NoRoute when none was tried. Every partner trade emits Partner, with an amount of 0 when there was no cut to share. Errors: NoRoute, Expired, Slippage, BadConfig, NotReady, NotForwarder, TransferFailed, StrayZro, BadPartner, NotInTrade.

LimitOrders

Orders that wait for a condition. A buy escrows ZRO, a sale escrows tokens, and every order names the least it must get, which no condition overrides. Fills go through the router and anyone may make them. See Limit orders and automation for the trader's view.

ConstantValueMeaning
feeBps0 (max 100)Fee on top of the router's. None by default
runFee0.04 ZRO (max 0.4)Paid to whoever fills, per whole order, shared across its parts
MAX_LEGS5Legs in one sale group
MAX_SLICES100Most DCA parts. The least is 2
LIMIT, STOP, TRAILING, ON_GRADUATION, ON_DEV_SELL, DCA0 to 5Order kinds
FunctionWhoWhat it does
placeBuy(token, minOut, expiry)Anyone, payableA limit buy. msg.value must be more than twice the run fee
placeBuyIf(token, minOut, expiry, kind, interval, slices)Anyone, payableLIMIT, ON_GRADUATION or DCA
placeSell(token, amount, minOut, expiry)AnyoneA limit sale
placeSellLegs(token, amount, expiry, legs[])AnyoneOne escrow, up to 5 ways out. Returns the first leg's id
fill(id, part)AnyoneFills part of an order, or closes and refunds it if expired. Reverts if the condition or minimum isn't met
fillBatch(ids[], parts[])AnyoneFills many. One that can't fill is skipped
poke(ids[])AnyoneRaises each trailing stop's high to what its tokens would fetch now
cancel(id)Owner of the orderRefunds what is left. Cancelling a leg ends its whole group
withdraw(to)Anyone with creditSends ZRO the caller's wallet refused when an order paid out
getOrder(id), available(id), openIds(from, count), ordersCount()ViewFor keepers and the site
setConfig(feeBps, runFee)OwnerCapped. An open order keeps the fees it was placed under
A leg of a sale group
struct Leg {
    uint8   kind;      // LIMIT, STOP, TRAILING, ON_GRADUATION or ON_DEV_SELL
    uint128 share;     // tokens this leg may sell, of the group's
    uint128 minOut;    // least ZRO for the whole share
    uint128 trigger;   // STOP: ZRO for the whole share at which it fires
    uint16  trailBps;  // TRAILING: the drop that fires it. ON_DEV_SELL: share the creator must sell
}

The run fee and the minimum both scale with the part being filled, rounded up, so splitting an order into many small fills pays the filler no more and never lets a part fill below its share. Errors: Busy, BadOrder, NotYours, NotOpen, NotYet.

CopyVault

Copy trading that runs with the browser closed. A follower deposits ZRO and sets rules per leader. Anyone may run a copy and earn the run fee, but only of a trade the leader really made through the router in the last 30 blocks, and only inside the rules. See Copy trading.

ConstantValueMeaning
WINDOW30 blocks, about 30 seconds at Zero's 1 second blocksA copy may run this long after the leader's trade
RUN_FEE_BPS100A runner gets 1% of a copy, or of what a copied sale or exit brought
MIN_RUN_FEE / RUN_FEE0.01 / 0.1 ZROThe least and the most one run pays
MIN_COPY0.1 ZROThe smallest copy that runs
MAX_COPY_FEE_BPS100The copy fee to the treasury is at most 1% of each copied buy
MAX_SLIPPAGE_BPS5,000Slippage in a rule or an exit is at most 50%
Rules and Exit
struct Rules {
    uint128 perTrade;     // most ZRO one copied buy may spend (must be > 0)
    uint128 perToken;     // most ZRO copied into one token over time
    uint128 perDay;       // most ZRO copied from this leader in a UTC day
    uint16  sizeBps;      // the leader's size times this. 10,000 copies the same size
    uint16  slippageBps;  // from the quote at the moment of copying
    uint16  chaseBps;     // how much worse than the leader's own price it may still go in or out
    uint16  minSellBps;   // a copied sale never fetches less than this share of cost
    bool    buyOnce;      // only the first buy of each token
    bool    copySells;    // sell along with the leader
    uint32  maxAge;       // only tokens younger than this many seconds, 0 for any
}

struct Exit {
    uint16 takeProfitBps; // 5,000 sells everything at +50%. 0 for none
    uint16 stopLossBps;   // 3,000 sells everything at -30%. 0 for none
    uint16 slippageBps;
}
FunctionWhoWhat it does
deposit()Follower, payableAdds ZRO to the caller's balance
withdraw(amount, to)FollowerTakes ZRO out, at any time
follow(leader, rules) / unfollow(leader)FollowerStarts, changes or stops copying a leader. follow fixes the copy fee for this follow at feeBps as it stands
setExit(exit)FollowerTake profit and stop loss over every position
sell(token, tokens, minOut)FollowerSells part of the caller's own position
withdrawTokens(token, tokens, to)FollowerTakes tokens out, with their share of the cost
copyBuy(follower, leader, token)AnyoneCopies the leader's latest buy within the rules and the token's max wallet, pays the caller the run fee and the treasury the follow's copy fee
copySell(follower, leader, token)AnyoneSells the share the leader sold, if copySells is on
exit(follower, token)AnyoneSells the whole position once take profit or stop loss is reached
collectRunnerCredit(to)RunnerRun fees a runner's address refused when they were paid
runFeeFor(size)Pure1% of size, between 0.01 and 0.1 ZRO
pause()Guardian or ownerStops copyBuy and copySell. Deposits, withdrawals, the follower's own sales, withdrawTokens and exit keep working
unpause()OwnerResumes copies
setGuardian(guardian)OwnerWho may pause. It starts as the owner
setFee(feeBps)OwnerThe copy fee for follows from now on, at most 100. A follow keeps the fee it was made under
balanceOf(f), positions(f, token), copied(f, leader, token), exits(f), followOf(f, leader), runnerCredit(r)ViewEverything above, readable. followOf includes the follow's feeBps
paused, guardian, feeBps, treasuryViewThe switches, and where the copy fee goes

The owner and the guardian can't move anyone's ZRO or tokens: there is no function that would. Errors: BadRules, NotFollowing, NothingToCopy, NotYet, TooLittle, TransferFailed, StrayZro, Paused, NotAllowed, MaxWallet.

BuybackVault

The treasury. Every Submarine fee lands here, and the only ways out are buying one token and sending it to the dead address, and funding that token's stakers through the staking contract. There is no withdraw function for anyone.

ConstantValueMeaning
MAX_SPEND_BPS1,000A buyback, or a funding of stakers, spends at most 10% of the balance
MIN_INTERVAL1 hourBetween buybacks, and between fundings, counted apart
FunctionWhoWhat it does
buyback(zroAmount, minOut)Keeper or ownerBuys buybackToken through the router and sends it to the dead address
setBuybackToken(token)Owner, onceThe one token it may ever buy. Until set, fees only accumulate
setRouter(router)Owner, onceWiring
fundStaking(zroAmount)Keeper or ownerSends ZRO to the staking contract's fund, which streams it to stakers over seven days
setStaking(staking)Owner, onceThe staking contract it may fund, set at deployment
setKeeper(keeper)OwnerWho may run buybacks and fundings
buybackToken, keeper, lastBuyback, totalSpent, totalBurned, staking, lastFund, totalFundedViewState

Errors: NotKeeper, BadConfig, AlreadySet, NoToken, TooSoon, TooMuch, NoStaking.

Staking

Staking of the platform token, the Submarine token. No lockup. Rewards in ZRO come in through fund, and each deposit streams out over the next seven days together with whatever was still streaming, to the stakers of each second by stake. While nobody stakes the stream waits. It also answers who trades with no Submarine cut. Ownable2Step and ReentrancyGuard. See Staking.

ConstantValueMeaning
DURATION7 daysHow long each deposit streams for
FunctionWhoWhat it does
stake(amount)AnyoneStakes the token, which needs an approval first. Counts what really arrived
unstake(amount)StakerAny amount, any time. What it earned stays to be claimed
claim() / claimFor(staker)AnyonePays a staker what they earned. The ZRO only ever goes to the staker
fund()Anyone, payableAdds ZRO to the rewards: rate becomes (this + what was left) over 7 days. The treasury calls it through fundStaking
isFeeFree(wallet)ViewTrue when threshold is above 0 and the wallet has at least threshold staked, or staked and in its wallet together
earnedOf(staker), stakedOf(staker)ViewZRO claimable now, and the stake
ratePerDay(), fundedWeek()ViewZRO streaming per day now, and ZRO funded today and on the six UTC days before
token, threshold, totalStaked, totalFunded, totalPaid, finish, perShare, rate, last, fundedOn(day)ViewState
setToken(token)Owner, onceThe token that can be staked
setThreshold(threshold)OwnerHow much makes a wallet fee-free, in wei of the token. 0 turns it off

The owner can't move anyone's stake or the ZRO waiting to be paid out. Rounding is always down. Errors: AlreadySet, NoToken, ZeroAmount, TooMuch, NothingToClaim, BadConfig, TransferFailed.

Referrals

Who brought whom. Nothing in it can be changed by anyone, and it only holds what it was sent to pay out.

ConstantValueMeaning
REFERRER_BPS7,500Of each credit, 75% to the referrer and 25% back to the trader
FunctionWhoWhat it does
link(referrer)Trader, onceLinks the caller for good. Not to themselves, and not to someone they referred
credit(trader)Anyone, payableSplits what is sent between the trader's referrer and the trader
claim()Anyone with earningsSends the caller's earnings
referrerOf(t), earned(a), referredCount(a)ViewState

Errors: BadReferrer, AlreadyLinked, NothingToClaim, TransferFailed.

ExitProbe

Never deployed. The site hands this contract's code to the node for a single eth_call, which buys through the router and sells straight back, to learn what a sale right after a buy would return. A token that taxes or refuses a sale shows up before anyone has spent anything. It is used for other launchpads' tokens. A token launched on Submarine holds bought coins for one block, so the probe would always fail on it; for those the site works the round trip out from their fees instead.

solidity
function probe(address venue, bytes calldata buyData, address token, bytes calldata sellHead, bytes calldata sellTail)
    external payable returns (uint256 bought, uint256 back, bool sold);
Source of truth. This page is written from contracts/src. Where it and the code disagree, the code wins. The events each contract emits are on Events to index.