9Lives

9Lives is an Arbitrum Stylus smart contract implemented with a simple factory/pair pattern. A factory takes a list of outcomes, and creates a variable number of contracts with a minimal viable proxy pointing to share ERC20s, and a trading contract. It either supports the Dynamic Pari-Mutuel Market (DPM) model to solve liquidity issues in orderbooks, or a Constant Product Market Maker model to be totally separate.

To get started with the contract entrypoint, src/lib.rs contains the matching of features to deploy different contract facets. Testing is done with a mixture of property and mutation testing and a bespoke testing environment for ERC20 accounting and more.

Inventors create campaigns (the prediction markets) by locking up "incentive" amounts, and by picking the type of oracle they want to use. Any fees earned in the campaign are sent to the Inventor, which provides incentive to create markets. Markets must be created with a hard deadline and a Beauty Contest or a Infrastructure Market, or with a Contract Interaction type of outcome. The Inventor must communicate to the Factory which oracle they would like to use, and provide the hash of the string that must be used to determine the outcome. This will then set the correct behaviour.

flowchart TD
    Trader --> |Locks up incentive amount, sets parameters| Factory
    Factory --> |Sets start, end, description, if infra market oracle chosen| Infra[Infra market]
    Factory --> |Deploys contract. Sets parameters| Trading
    Factory --> |Configures Longtail pool| Longtail
    Factory --> |Deploys ERC20 assets for each outcome| ERC20s
    Trading --> |Disables Longtail once trading is done| Factory
    ERC20s --> |Burns and mints supply| Trading
    Infra --> |Tells Trading who won| Trading

Infra Markets are prediction markets where Staked ARB is locked up as LARB, which is used to predict the outcome of another prediction market with a commit and reveal scheme. These markets exist in an optimistic state where anyone can "call" the outcome, before being challenged with a "whinge", which begins the process of a commit and reveal system. Following this, amounts can be claimed with a slashing process based on amounts staked.

Oracle State oracles are very simple comparatively, as presumably the associated Trading contract was configured to allow early activation, so all a caller must do is activate the associated Oracle State contract. These could communicate with LayerZero to pull information from another chain, and the contract will simply check the result of the message. If it's not activated by the date that's given, then it defaults to a "DEFAULT" clause that could be "no" if a user were to try to estimate the price of something.


Diagram of the system

Roadmap

  • UX improvements (shares are more visible, smart account behaviour)
  • Mainnet is supported as well. Mainnet has disclosure that funds are locked up until the election is over.
  • Achievements and portfolio page is supported. Some socialfi elements.
    1. Users can choose their favourite achievements to display in a minified form next to their Meow Domain.
    2. Meow domains is supported in the UI.
  • Collect payoff from the campaign ending in the frontend.
  • Custom fee collection and pool configuration supported (use beauty contest with fixed date, many outcomes if they want)
  • Anyone can create pools. Custom display of pools a la Ebay customisation.
    1. A fixed fee is sent to creator of when shares are created.
    2. Behind the scenes deferring to the AMM model if more than two outcomes.
    3. Customise the UI of the frontpage for the info
    4. Stack ranking is done for automated updating of frontpage
    5. Campaign report functionality. Images are screened automatically for bad content with CSAM
    6. API to update campaign by the original sender
    7. Custom embed when sharing URL
  • Prediction market DAO. Token launch

Building contracts

make build

Updating docs (after editing markdown files)

forge doc -b

Testing

Testing must be done with no trading or contract feature enabled. Testing is only possible on the local environment, or with end to end tests with an Arbitrum node.

./tests.sh

Interrogation of the deployment in the end to end testing library could be done using the build.rs use of environment.lst, which could be in turn read with a fresh deploy (and a clean artifacts directory):

sort $(find target -name environment.lst) | uniq

You could clear the recorded environment variables the same way with a test harness:

rm $(find target -name environment.lst)

You could use this to test the code by making a debug build, which includes more information about reverts, then simulate your calldata against it using stylus-interpreter, making debugging a breeze.

Errors

The error table lives in ERRORS.md.

Deployments

Superposition mainnet

Deployment nameDeployment address
Proxy admin0x6221A9c005F6e47EB398fD867784CacfDcFFF4E7
Factory 1 implementation0x3302ac14ad6b38baf789571395cc3a54f0f65e52
Factory 2 implementation0x928b627add9c2a3578b5c178423724f4d20202ed
Lockup implementation0x99596b476d5e16e4a30bd4858dd289a763671294
Optimistic infra predict impl0xf94aeb587d332d0e7f2f1e2c87ffea1385ff0505
Trading DPM mint impl0x7b203ff48f76b163bed86b5f2cb66ce6a46d62d4
Trading DPM extras impl0x81eebeda7eb9f68c9a825c619f5e0d13a117e5f6
Trading DPM price impl0x8fc31d39edec596e8089b313920c05642e86d549
Trading DPM quotes impl0x7439ec52bd28c21f59b07a7a12a09c1f7feac7cf
Trading AMM mint impl0x2314c906ebd852a0be249ce49b98ee804078b05e
Trading AMM extras impl0x59c9660f835c1c1c5387a48b9fe8cf7d49020a64
Trading AMM price impl0x7ff05c8bac0bce55e1519015a4a86fe2b244df88
Trading AMM quotes impl0x09e99d6c0e57c2cdb715daf1dc66b98e43514fc3
Share implementation0x3e27e934344bf490457231Cb8F0c0eda7d60C362
Lockup token implementation0x70143C674A23a43Ad487D33c4035Ba1D012ac598
Infrastructure market impl0x863642e21a45e824c4f6347a5757e5dcacae11c1
Infrastructure market proxy0xc4451d8477cd6b92bfa0d3e2662ce0507a8e10b9
Lockup proxy0x20d2360706086ec9814d15a52ad2d2aec2c43caa
Lockup token proxy0x14c35ba87e8b490761f492382c9249867b82aaf4
Factory proxy0x7dfe1fa7760131140cfc48b3ea99719203d8f00b
Helper factory0x2965aF7dD96D550d63be1577feC27ae26d2C46F7
LensesV10x051648539bC4a1C247030EABCBC29cfD1887cd83
Beauty contest implementation0x3421264e413489b1e69ae84ace8c33c6cb7809ff
Beauty contest proxy0x15f4A8a0b8cD0343fAe5a7FC736cD9e0D7bE4d5C
Sarp AI Resolver0x9d73847f1edc930d2a2ee801aeadb4c4567f18e1
Helper factory0x6e95B1fcca9aBb2D94213AE3ccFCaf5BB8406E6B
Buy helper20xEBBfeAcbbD331466512A362BEa782e1f7CB45b57
SARP Signaller0xD608CeF1D7C84feaA0E1520C7a6BC4798cFC1455

Superposition testnet

Deployment nameDeployment address
Proxy admin0xfeb6034fc7df27df18a3a6bad5fb94c0d3dcb6d5
Factory 1 implementation0x9e16b693e71d0be52da2158ac6dd2c3b75fbadf0
Factory 2 implementation0xaca4f34b884969605e7922f44748b5c5a7fb2246
Lockup implementation0x9733dd5d7e1b42f39b4227e4b0b0e17ff440b3c2
Optimistic infra predict impl0xe2175ab2ef7aa29ec61657e505e641a5ff509b72
Trading DPM mint impl0x11a4b84a7d0979e906c8eaba7c16579a3bf48bf5
Trading DPM extras impl0xbd03aff1a558d0806eed2e6e6af48453daf4de40
Trading DPM quotes impl0xccf0aed8c4157cfbc41ad0cd78b23c6fd637271e
Trading DPM price impl0x3c3363a60cf654c84915495f2efdd8dd4c3439af
Trading AMM mint impl0x76c1127f1aa1b4f8b33e6137051df91c50d6eee6
Trading AMM extras impl0xbf5776e6231d511af57a87141adc1217a695f58b
Trading AMM quotes impl0x70a9500293622ff935aa9f65818b80fdbfd9157e
Trading AMM price impl0x4b78c4f0ebeaa1ba42e0d48e7f0cd3c53e1796b9
Share implementation0xC876Fc7ddd41ae072a8898445f83bBfcC903c195
Lockup token implementation0xD813030d171026B42bd9D29aE44b3a5a600cFFf7
Infrastructure market proxy0x1b508fb73912eb306f4ca29cab096c75074ceee4
Lockup proxy0x397420c66164632937a19768174ee7e21c0df3a2
Lockup token proxy0xc9ca48f56454be7ce44b929506b32b61c0c8f6d9
Factory proxy0x48b9cf07bb9dedc7eb33868693b63b28b253f282
Helper factory0x6E0fc15eFc574e17DC181753fdD5852A1c963D97
LensesV10x61F92c803177c1060Ef7B360bD631d857B1545B9
Beauty contest implementation0x40e652ce259d6de7dd4058ce5c255a44785fc4e7
Beauty contest proxy0xc3d76a0b0ca758648b56e2535712f4a9316cb709
Sarp AI Resolver0x0000000000000000000000000000000000000000
Buy helper20x491286b009F19300ac45ed5571e012F125AB9B9d
SARP Signaller0x2137B4C506f0d7eF2A562B02Be9110a4a3A93bC9