Logo

bodega-market

UnofficialPreliminary, reverse-engineered version published by the tx3 team for testing and exploration. It is not endorsed by the original protocol authors. Do not use in mainnet. • v0.1.0

About this Protocol

Prediction markets on Cardano with AMM pricing and licensed batcher

Parties

The participants involved in this protocol's transactions.

protocoltreasuryProtocol treasury address that collects open fees and admin fees.
predictionscriptPrediction script address holding the AMM market state UTxO.
batcherLicensed batcher operator that processes position UTxOs in batches.
userEnd user buying prediction positions or claiming rewards/refunds.
positionscriptPosition script address holding user positions awaiting batcher processing (per-market).
projectinfoscriptProject info script address holding the market configuration UTxO.

Environment

Configuration values required to execute this protocol's transactions.

batcher_policy_idBatcher license minting policy id./$defs/Bytes
bodega_policy_idMinting policy id of the BODEGA governance token./$defs/Bytes
bodega_token_nameToken name of the BODEGA governance token (hex-encoded "BODEGA")./$defs/Bytes
position_script_refReference UTxO carrying the position validator script./$defs/UtxoRef
prediction_script_refReference UTxO carrying the prediction validator script./$defs/UtxoRef
project_info_nft_tnToken name of the project info NFT (hex-encoded "PROJECT_INFO_NFT")./$defs/Bytes
project_prediction_nft_tnToken name of the project prediction NFT (hex-encoded "PROJECT_PREDICTION_NFT")./$defs/Bytes
protocol_settings_refProtocol settings UTxO used as a reference input by create_market minting./$defs/UtxoRef
psettings_nft_policy_idProtocol settings NFT policy id (gates batcher operations)./$defs/Bytes
psettings_nft_tnProtocol settings NFT token name./$defs/Bytes

Transactions

The transactions defined in this protocol, with their parameters, inputs, and outputs.

create_market

Deploy a new prediction market: mint info/prediction NFTs, lock BODEGA pledge, pay open fee.

Diagram

create_marketbodega_policy_idbodega_token_namecm_admin_fee_percentcm_amm_paramcm_authtoken_policy_idcm_authtoken_scriptcm_batcher_policy_idcm_candidate_no_namecm_candidate_yes_namecm_deadlinecm_envelope_amountcm_info_lovelacecm_info_out_idxcm_initial_no_pricecm_initial_poolcm_initial_yes_pricecm_open_feecm_oracle_policy_idcm_oracle_token_namecm_outref_idxcm_outref_txcm_owner_pkhcm_owner_stake_keycm_payment_policy_idcm_payment_token_namecm_pledge_amountcm_position_script_hashcm_pred_out_idxcm_prediction_total_lovelacecm_project_namecm_seed_outref_idxcm_seed_outref_txcm_settings_ref_idxcm_share_policy_idcm_treasury_out_idxpredictionscriptproject_info_nft_tnproject_prediction_nft_tnprojectinfoscriptprotocol_settings_refprotocoltreasuryuser user predictionscript projectinfoscript protocoltreasury user source output 2 output 1 output 3 output 4

Parameters

bodega_policy_idBytes
bodega_token_nameBytes
cm_admin_fee_percentIntDefault admin fee in base 10000.
cm_amm_paramIntAMM tuning parameter (on-chain field 14, e.g. 2885).
cm_authtoken_policy_idBytesMinting policy id of the auth token script that mints both market NFTs.
cm_authtoken_scriptBytesInline PlutusV3 auth token minting script bytes.
cm_batcher_policy_idBytesBatcher license policy id authorized for this market.
cm_candidate_no_nameBytesToken name of the NO candidate share (e.g. "B_9EE9_NO").
cm_candidate_yes_nameBytesToken name of the YES candidate share (e.g. "B_9EE9_YES").
cm_deadlineIntMarket deadline as POSIX milliseconds.
cm_envelope_amountIntPosition envelope ADA amount required per position.
cm_info_lovelaceIntMinimum ADA attached to the project info UTxO.
cm_info_out_idxIntOutput index of the project info UTxO in this tx.
cm_initial_no_priceIntInitial NO price (normalized so yes + no ~= 1_000_000).
cm_initial_poolIntInitial AMM pool size recorded in the prediction datum.
cm_initial_yes_priceIntInitial YES price (normalized so yes + no ~= 1_000_000).
cm_open_feeIntOpen fee in lovelace paid to the protocol treasury.
cm_oracle_policy_idBytesOracle NFT policy id used to resolve the market.
cm_oracle_token_nameBytesOracle NFT token name used to resolve the market.
cm_outref_idxIntProject identity outref index recorded in datums.
cm_outref_txBytesProject identity outref tx hash recorded in datums.
cm_owner_pkhBytesMarket owner's payment key hash.
cm_owner_stake_keyBytesMarket owner's stake key hash.
cm_payment_policy_idBytesPayment asset policy id accepted by this market.
cm_payment_token_nameBytesPayment asset token name accepted by this market.
cm_pledge_amountIntBODEGA pledge amount locked at the project info UTxO.
cm_position_script_hashBytesPosition validator script hash (parameterized per market).
cm_pred_out_idxIntOutput index of the prediction UTxO in this tx.
cm_prediction_total_lovelaceIntTotal lovelace locked at the initial prediction UTxO.
cm_project_nameBytesHuman-readable project name stored in the datum.
cm_seed_outref_idxIntSeed UTxO output index consumed to anchor the auth token mint.
cm_seed_outref_txBytesSeed UTxO tx hash consumed to anchor the auth token mint.
cm_settings_ref_idxIntReference input index of the protocol settings UTxO.
cm_share_policy_idBytesMinting policy id of this market's share tokens.
cm_treasury_out_idxIntOutput index of the treasury fee payment in this tx.
predictionscriptAddress
project_info_nft_tnBytes
project_prediction_nft_tnBytes
projectinfoscriptAddress
protocol_settings_refUtxoRef
protocoltreasuryAddress
userAddress

Inputs

sourceuserwallet

Outputs

projectinfoscriptyesno
predictionscriptyesno
protocoltreasurynono
usernono

submit_reward_yes

Lock YES share tokens as a RewardPos so the batcher can burn them and pay out the reward.

Diagram

submit_reward_yesbatcher_fee_amountcandidate_nameenvelope_amountpositionscriptproject_info_refshare_amountshare_policy_iduseruser_pkhuser_stake_key user positionscript user source output 1 output 2

Parameters

batcher_fee_amountIntBatcher processing fee in lovelace.
candidate_nameBytesToken name of the YES candidate share (e.g. "B_9EE9_YES" hex-encoded).
envelope_amountIntPosition envelope ADA carried alongside the shares.
positionscriptAddress
project_info_refUtxoRefUTxO holding the ProjectInfoDatum for this market (reference input).
share_amountIntNumber of YES shares to surrender for reward.
share_policy_idBytesMinting policy id of this market's share tokens.
userAddress
user_pkhBytesUser's payment key hash, recorded in the position datum.
user_stake_keyBytesUser's stake key hash, recorded in the position datum.

Inputs

sourceuserwallet

Outputs

positionscriptyesno
usernono

buy_position_yes

Submit a BuyPos position on the YES candidate; batcher will later mint and deliver shares.

Diagram

buy_position_yesadmin_fee_percentbatcher_fee_amountbuy_amountpositionscriptproject_info_reftotal_lovelaceunit_priceuseruser_pkhuser_stake_key user positionscript user source output 1 output 2

Parameters

admin_fee_percentIntAdmin fee in base 10000 (e.g. 200 = 2%); may differ from ProjectInfoDatum for fee tiers.
batcher_fee_amountIntBatcher processing fee in lovelace (typically 700_000).
buy_amountIntNumber of shares to buy.
positionscriptAddress
project_info_refUtxoRefUTxO holding the ProjectInfoDatum for this market (reference input).
total_lovelaceIntPre-computed total ADA for the position UTxO (tx3 lacks * and / operators).
unit_priceIntLMSR average price per share for this trade, computed off-chain.
userAddress
user_pkhBytesUser's payment key hash, recorded in the position datum.
user_stake_keyBytesUser's stake key hash, recorded in the position datum.

Inputs

sourceuserwallet

Outputs

positionscriptyesno
usernono

buy_position_no

Submit a BuyPos position on the NO candidate; batcher will later mint and deliver shares.

Diagram

buy_position_noadmin_fee_percentbatcher_fee_amountbuy_amountpositionscriptproject_info_reftotal_lovelaceunit_priceuseruser_pkhuser_stake_key user positionscript user source output 1 output 2

Parameters

admin_fee_percentIntAdmin fee in base 10000 (e.g. 200 = 2%); may differ from ProjectInfoDatum for fee tiers.
batcher_fee_amountIntBatcher processing fee in lovelace (typically 700_000).
buy_amountIntNumber of shares to buy.
positionscriptAddress
project_info_refUtxoRefUTxO holding the ProjectInfoDatum for this market (reference input).
total_lovelaceIntPre-computed total ADA for the position UTxO (tx3 lacks * and / operators).
unit_priceIntLMSR average price per share for this trade, computed off-chain.
userAddress
user_pkhBytesUser's payment key hash, recorded in the position datum.
user_stake_keyBytesUser's stake key hash, recorded in the position datum.

Inputs

sourceuserwallet

Outputs

positionscriptyesno
usernono

sell_position_yes

Submit a RefundPos (Sell Position) on YES so the batcher buys back shares at the AMM price.

Diagram

sell_position_yesadmin_fee_percentbatcher_fee_amountenvelope_amountpositionscriptproject_info_refshare_amountunit_priceuseruser_pkhuser_stake_key user positionscript user source output 1 output 2

Parameters

admin_fee_percentIntAdmin fee in base 10000 applied to the refund payout.
batcher_fee_amountIntBatcher processing fee in lovelace.
envelope_amountIntPosition envelope ADA locked at the position script.
positionscriptAddress
project_info_refUtxoRefUTxO holding the ProjectInfoDatum for this market (reference input).
share_amountIntNumber of YES shares to sell (held in user wallet, burned by batcher).
unit_priceIntAMM unit price (in lovelace) recorded at sell time for the batcher.
userAddress
user_pkhBytesUser's payment key hash, recorded in the position datum.
user_stake_keyBytesUser's stake key hash, recorded in the position datum.

Inputs

sourceuserwallet

Outputs

positionscriptyesno
usernono

submit_reward_no

Lock NO share tokens as a RewardPos so the batcher can burn them and pay out the reward.

Diagram

submit_reward_nobatcher_fee_amountcandidate_nameenvelope_amountpositionscriptproject_info_refshare_amountshare_policy_iduseruser_pkhuser_stake_key user positionscript user source output 1 output 2

Parameters

batcher_fee_amountIntBatcher processing fee in lovelace.
candidate_nameBytesToken name of the NO candidate share (e.g. "B_9EE9_NO" hex-encoded).
envelope_amountIntPosition envelope ADA carried alongside the shares.
positionscriptAddress
project_info_refUtxoRefUTxO holding the ProjectInfoDatum for this market (reference input).
share_amountIntNumber of NO shares to surrender for reward.
share_policy_idBytesMinting policy id of this market's share tokens.
userAddress
user_pkhBytesUser's payment key hash, recorded in the position datum.
user_stake_keyBytesUser's stake key hash, recorded in the position datum.

Inputs

sourceuserwallet

Outputs

positionscriptyesno
usernono

sell_position_no

Submit a RefundPos (Sell Position) on NO so the batcher buys back shares at the AMM price.

Diagram

sell_position_noadmin_fee_percentbatcher_fee_amountenvelope_amountpositionscriptproject_info_refshare_amountunit_priceuseruser_pkhuser_stake_key user positionscript user source output 1 output 2

Parameters

admin_fee_percentIntAdmin fee in base 10000 applied to the refund payout.
batcher_fee_amountIntBatcher processing fee in lovelace.
envelope_amountIntPosition envelope ADA locked at the position script.
positionscriptAddress
project_info_refUtxoRefUTxO holding the ProjectInfoDatum for this market (reference input).
share_amountIntNumber of NO shares to sell (held in user wallet, burned by batcher).
unit_priceIntAMM unit price (in lovelace) recorded at sell time for the batcher.
userAddress
user_pkhBytesUser's payment key hash, recorded in the position datum.
user_stake_keyBytesUser's stake key hash, recorded in the position datum.

Inputs

sourceuserwallet

Outputs

positionscriptyesno
usernono

Profiles

Pre-configured sets of environment and party values for different deployment targets.

mainnet
protocoltreasuryaddr1x8ru0tc0tsy23wfe34u02zazflmkat2ar8rzk8qf93f5r94gl7dv5f8n43cyguzxv2xu3vnqdynvj5nxu2yere25k4kqpuwsp0party
batcheraddr1w9puyxdnzn3upaj73mk8lq0cq85jwrlu0kt62dw8dhka4lgjvdkjsparty
projectinfoscriptaddr1x8x7nn5lch2uawxct2hjr06kgsplxu9rpm8gg9tyffv4u8agl7dv5f8n43cyguzxv2xu3vnqdynvj5nxu2yere25k4kqt4qep6party
predictionscriptaddr1xx25vyyteavkeddsueufzr4ahgsa987fafvhv032tnmvg0dgl7dv5f8n43cyguzxv2xu3vnqdynvj5nxu2yere25k4kqf0df9xparty
batcher_policy_idc7c7af0f5c08a8b9398d78f50ba24ff76ead5d19c62b1c092c534196env
bodega_policy_id5deab590a137066fef0e56f06ef1b830f21bc5d544661ba570bdd2aeenv
bodega_token_name424f44454741env
position_script_ref73cc84de3e1b056abb3e004bdc25dd2ee49f4435ba4319f1faefe2ced843e894#2env
prediction_script_ref73cc84de3e1b056abb3e004bdc25dd2ee49f4435ba4319f1faefe2ced843e894#2env
project_info_nft_tn50524f4a4543545f494e464f5f4e4654env
project_prediction_nft_tn50524f4a4543545f50524544494354494f4e5f4e4654env
protocol_settings_ref73cc84de3e1b056abb3e004bdc25dd2ee49f4435ba4319f1faefe2ced843e894#0env
psettings_nft_policy_idd2e8f0bab4bc0e62ebe9abf79b7a13280229ad60ca8e329892cb71a7env
psettings_nft_tn50524f544f434f4c5f53455454494e47535f4e4654env
Back to all Protocols