logo
Builders have two methods available to generate revenue for their integration with Myriad:
  • Charging a frontend fee at their discretion, using the built-in helpers in the API (requires whitelisted API keys), or using their own means.
  • Using builder codes and the on-chain capabilities built into the smart contract.

Front-end fees

Front-end fees can be charged on top of any fees that may be charged by the Myriad smart contract, on a market-per-market basis.
The API provides a POST /markets/quote_with_fee endpoint (requires API Key whitelisting) that returns the exact calldata needed to implement this feature easily. It is compatible with wallets that support EIP-5792.

Builder codes

  • Eligible markets: all markets that have a non-zero distributor_fee property.
  • Referral amount: a portion determined by the Myriad team based on direct agreements or at the team’s discretion. The maximum amount is the value of the distributor_fee — typically 1% — multiplied by the value of the trade.
  • Eligible trades: only buy actions are eligible — sell, claim_winnings and claim_voided are not eligible.
  • Eligible builders: Builders using the referral code provided to them in their Myriad Account or organizations who can apply for whitelisting using their custom builder code.

How to apply for custom builder codes

  • Request whitelisting: Contact the Myriad team to request approval. Whitelisting is granted and canceled at Myriad’s discretion.
  • Builder code: Provide a short ASCII string that will identify your app or organization.
  • Wallet: Provide an EVM wallet address in which you’ll receive your rewards.

How to integrate

  • To check whether a market is eligible:
    • Check wether the market information returned by the API includes a non-zero value for the fees.distributor_fee property.
    • When the third element of the buyFees tuple is non-zero, in the result of calling getMarketFees(marketId) on the smart contract.
  • Call the referralBuy function instead of calling the buy function of the smart contract.
  • In addition to the normal call data you’d pass when calling buy, also pass your whitelisted builder code.
  • You can call referralBuy even on non-eligible markets. In those cases, the referral simply won’t yield any rewards.
  • This logic applies to all chains in which the Myriad Protocol is available.

How to verify

You can verify that the revenue sharing is correctly implemented directly on-chain.
  • The smart contract emits a Referral event when referralBuy is used.
  • The event contains the following information:
    • Topics
      • 0 : 0xc993f9a8447446a00c879dadbeefa69111000411f1a1a9f67cf75a12ec08a3ec
      • 1 : user : the trader’s wallet address
      • 2 : marketId : the ID of the market in which the trade occurred
    • Data
      • code : the builder code
      • action : 0 for buys
      • outcomeId : the ID of the outcome bought
      • value : the amount of the trade (market token denomination decimals apply)
      • timestamp : the UNIX timestamp of the trade
  • In the case of eligible trades, the smart contract also transfers the corresponding reward to the Distributor Fees address, which is also specified in the API responses and by calling the getMarketFees(marketId) function on the smart contract.
  • Example transaction:

How to claim

  • The Myriad Foundation pays out rewards in the first Monday of each month to builders who earned $500 or more up until the end of the previous month.
  • Payout amounts are reset once a payment is made. Builders who don’t reach the minimum threshold of $500 keep accumulating until the next payout period, and so on.
  • Payouts are made to the builder’s Myriad Account or their whitelisted wallet address.
  • Direct agreements may have different payout terms.