Maya Protocol One-Stop-Shop
  • Introduction
    • 🍫What is Maya Protocol?
      • Getting Started
      • Roles
        • Liquidity Providers
        • Swappers
        • Arbitrageurs
        • Node Operators
      • Maya Protocol Native Assets
    • 🌐Maya Ecosystem
      • User interfaces & Wallets
      • Tools
    • 🍫How to buy CACAO?
    • πŸ›£οΈRoadmap 2025
  • Deep Dive
    • πŸšΆβ€β™‚οΈStep-by-Step Guides
      • Set up a MAYAChain wallet
        • Using El Dorito Club
        • Using THORWallet web APP
        • Using THORWallet Mobile APP
        • Through MAYANode cli
        • By importing Ledger hard wallet into Ctrl Wallet
      • Custom Memos
        • Swap
        • Add Liquidity
        • Withdraw Liquidity
    • πŸ› οΈHow It Works
      • Technology
      • Incentive Curve
      • Fees
      • Governance
      • Constants and Mimir
      • Security
      • Dynamic Inflation
      • Liquidity Nodes
      • Impermanent Loss Protection (ILP)
      • ELI5
        • What is Threshold Signature Scheme (TSS)?
    • πŸ’΅DeFi Products
      • Synthetics
      • Liquidity
    • πŸ”Audits
    • 🎭Maya Masks
    • ❓FAQs
  • Blockchain Explorer
    • πŸ”ŽMayaScan
      • πŸͺ™MRC-20 Tokens
      • πŸ–ΌοΈM-NFTS
  • Airdrop
    • πŸͺ‚$MAYA Airdrops Guide
  • Media
    • πŸ“½οΈAaluxx Interviews
    • 🐦Twitter Spaces
    • πŸ”—Links
  • Contribute
    • 😎Ambassador Program
    • 🎨Content Creators Guide
  • Node Docs
    • πŸ–₯️MAYANodes
      • MAYANode Overview
      • Cluster Launcher
        • Setup - Linode
        • Setup - Azure
        • Setup - Hetzner Bare Metal
        • Setup - Google Cloud
        • Setup - HCloud
        • Setup - Digital Ocean
        • Setup - AWS
      • Deploying
      • Joining
      • Managing
      • Pooled MAYANodes
      • Alerting
      • Leaving
      • πŸ›‘Emergency Procedures
      • βœ”οΈ CHECKLIST
      • Multi-node Deployment
      • Fullnode Installation Guide
    • Bonding & Unbonding Guide
    • Bare Metal Node Guides
  • MAYACHAIN DEV DOCS
    • Introduction
      • MAYAName Guide
      • Swapping Guide
        • Quickstart Guide
        • Fees and Wait Times
        • Streaming Swaps
      • Add MAYAChain to your Wallet
    • Examples
      • Tutorials
      • Typescript (XChainJS) WIP
        • Query Package
        • AMM Package
        • Client Packages
        • Packages Breakdown
        • Coding Guide
      • SwapKit SDK
    • Concepts
      • Connecting to MAYAChain
      • Querying MAYAChain
      • Transaction Memos
      • Asset Notation
      • Memo Length Reduction
      • Network Halts
      • Fees
      • Delays
      • Sending Transactions
      • Math
    • Aggregators
      • Memos
      • EVM Implementation
    • CLI
      • Multisig
      • Offline Ledger Support
    • Protocol Development
      • Adding New Chains
      • Chain Clients
        • UTXO
        • EVM Chains
        • Cosmos Chains
      • ERC-20 Tokens
      • THORChain Version Updates I
      • THORChain Version Updates II
  • White Paper
    • πŸ“–Maya Whitepaper 2.0
      • Introduction
      • 🍫Fair Launch
        • Philosophical perspective FL
        • Economic overview FL
        • Technical overview FL
      • πŸͺ™$MAYA token
        • Philosophical perspective MT
        • Economic overview MT
        • Technical overview MT
      • 🌊Liquidity Nodes
        • Philosophical perspective LN
        • Economic overview LN
        • Technical overview LN
      • πŸ”’Security Nodes
        • Philosophical perspective SN
        • Economic overview SN
        • Technical overview SN
      • πŸ”΄Aztec Chain & $AZTEC token
        • Philosophical perspective AC
        • Economic overview AC
        • Technical overview AC
      • βš–οΈStable Pools & Route Optimization
        • Philosophical perspective RO
        • Economic overview RO
        • Technical overview RO
      • πŸ‘£Roadmap. Maya 3.0
        • Philosophical perspective 3.0
        • Economic overview 3.0
        • Technical overview 3.0
  • Website
  • GitLab
  • Archive
    • Liquidity Auction
    • THORChads Airdrop
    • Add ETH, USDC, or USDT through THORWallet using Metamask + Ledger
    • $MAYA Airdrop for Maya Mask Holders
    • Maya Integration Guide
    • Roadmap 2023
Powered by GitBook

Social Media

  • Twitter
  • Telegram
  • Discord
On this page
  • Overview
  • Terms
  • Fees Detail
  • Inbound Fee
  • Liquidity Fee
  • Affiliate Fee
  • Preferred Asset for Affiliate Fees
  • Outbound Fee
  • Fee Ordering for Swaps
  • Refunds and Minimum Swappable Amount
  • Understanding gas_rate
  • Fee Calculation by Chain
  • MAYAChain (Cacao)
  • UTXO Chains like Bitcoin
  • EVM Chains like Ethereum

Was this helpful?

Export as PDF
  1. MAYACHAIN DEV DOCS
  2. Concepts

Fees

Understanding how fees are calculated.

Overview

There are 4 different fees the user should know about.

  1. Inbound Fee (sourceChain: gasRate * txSize)

  2. Affiliate Fee (affiliateFee * swapAmount)

  3. Liquidity Fee (swapSlip * swapAmount)

  4. Outbound Fee (destinationChain: gasRate * txSize)

Terms

  • SourceChain: the chain the user is swapping from

  • DestinationChain: the chain the user is swapping to txSize: the size of the transaction in bytes (or units)

  • gasRate: the current gas rate of the external network

  • swapAmount: the amount the user is swapping swapSlip: the slip created by the

  • swapAmount, as a function of poolDepth

  • affiliateFee: optional fee set by interface in basis points

Fees Detail

Inbound Fee

This is the fee the user pays to make a transaction on the source chain, which the user pays directly themselves. The gas rate recommended to use is fast where the tx is guaranteed to be committed in the next block. Any longer and the user will be waiting a long time for their swap and their price will be invalid (thus they may get an unnecessary refund).

inboundFee=txSizeβˆ—gasRateinboundFee = txSize * gasRateinboundFee=txSizeβˆ—gasRate

Always use a "fast" or "fastest" fee, if the transaction is not confirmed in time, it could be abandoned by the network or failed due to old prices. You should allow your users to cancel or re-try with higher fees.

Liquidity Fee

This is simply the slip created by the transaction multiplied by its amount. It is priced and deducted from the destination amount automatically by the protocol.

slip=swapAmountswapAmount+poolDepthslip = \frac{swapAmount}{swapAmount + poolDepth}slip=swapAmount+poolDepthswapAmount​
fee=slipβˆ—swapAmountfee =slip * swapAmountfee=slipβˆ—swapAmount

Affiliate Fee

In the swap transaction you build for your users you can include an affiliate fee for your exchange (accepted in $CACAOor a synthetic asset, so you will need a $CACAO address).

  • The affiliate fee is in basis points (0-500) and will be deducted from the inbound swap amount from the user.

  • If the inbound swap asset is a native MAYAChain asset ($CACAO or synth) the affiliate fee amount will be deducted directly from the transaction amount.

  • If the inbound swap asset is on any other chain the network will submit a swap to $CACAO with the destination address as your affiliate fee address.

  • If the affiliate is added to an ADDLP tx, then the affiliate is included in the network as an LP.

SWAP:CHAIN.ASSET:DESTINATION:LIMIT:AFFILIATE:FEE

affliateFee=feeInBasisPointsβˆ—swapAmount10000affliateFee = \frac{feeInBasisPoints * swapAmount}{10000}affliateFee=10000feeInBasisPointsβˆ—swapAmount​

Preferred Asset for Affiliate Fees

How it Works

Configuring a Preferred Asset for a MAYAName

  1. Set your preferred asset's chain alias (the address you'll be paid out to), and your preferred asset. Note: your preferred asset must be currently supported by MAYAChain.

For example, if you wanted to be paid out in USDC you would:

  1. Post a MsgDeposit to the MAYAChain network with the appropriate memo to register your MAYAName, set your preferred asset as USDC, and set your Ethereum network address alias. Assuming the following info:

    1. MAYAChain address: maya1g8dzs4ywxhf8hynaddw4mhwzlwzjfccakkfch7

    2. MAYAName: wr

    3. ETH payout address: 0x6621d872f17109d6601c49edba526ebcfd332d5d

    The full memo would look like:

~:wr:ETH:0x6621d872f17109d6601c49edba526ebcfd332d5d:maya1g8dzs4ywxhf8hynaddw4mhwzlwzjfccakkfch7:ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48

You will also need a MAYA alias set to collect affiliate fees. Use another MsgDeposit with memo: ~:<mayaname>:MAYA:<mayachain-address> to set your MAYA alias. Your MAYA alias address can be the same as your owner address, but won't be used for anything if a preferred asset is set.

You can also set one or more subaffiliates to share revenue from affiliate fees. Use another MsgDeposits with memos:

~:wr:500:SUBA1:2000

~:wr:500:SUBA2:1000

The response should look like:

{
  "name": "wr",
  "expire_block_height": 22061405,
  "owner": "maya1g8dzs4ywxhf8hynaddw4mhwzlwzjfccakkfch7",
  "preferred_asset": "ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48",
  "affiliate_collector_cacao": "0",
  "aliases": [
    {
      "address": "0x6621d872f17109d6601c49edba526ebcfd332d5d",
      "chain": "ETH"
    },
    {
      "address": "maya1v7gqc98d7d2sugsw5p4pshv0mm24mfmzgmj64n",
      "chain": "MAYA"
    }
  ],
  "affiliate_bps": 150
  "subaffiliates": [
    {
      "name": "SUBA1",
      "bps": 2000
    },
    {
      "name": "SUBA2",
      "bps": 1000
    }
  ]  
}

Your MAYAName is now properly configured and any affiliate fees will begin accruing in the AffiliateCollector module. You can verify that fees are being collected by checking the affiliate_collector_rune value of the above endpoint.

Outbound Fee

This is the fee the Network pays on behalf of the user to send the outbound transaction. To adequately pay for network resources (TSS, compute, state storage) the fee is marked up from what nodes actually pay on-chain by an "Outbound Fee Multiplier" (OFM).

outboundFee=txSizeβˆ—gasRateβˆ—OFMoutboundFee = txSize * gasRate * OFMoutboundFee=txSizeβˆ—gasRateβˆ—OFM

The minimum Outbound Layer1 Fee the network will charge is on /mayachain/mimir and is priced in USD (based on MAYAChain's USD pool prices). This means really cheap chains still pay their fair share. It is currently set to 10000000000 = $1.00

Fee Ordering for Swaps

Fees are taken in the following order when conducting a swap.

  1. Inbound Fee (user wallet controlled, not MAYAChain controlled)

  2. Affiliate Fee (if any) - skimmed from the input.

  3. Swap Fee (denoted in output asset)

  4. Outbound Fee (taken from the swap output)

To work out the total fees, fees should be converted to a common asset (e.g. CACAO or USD) then added up. Total fees should be less than the input else it is likely to result in a refund.

Refunds and Minimum Swappable Amount

If a transaction fails, it is refunded, thus it will pay the outboundFee for the SourceChain not the DestinationChain. Thus devs should always swap an amount that is a maximum of the following, multiplier by a buffer of at least 4x to allow for sudden gas spikes:

  1. The Destination Chain outbound_fee

  2. The Source Chain outbound_fee

  3. $1.00 (the minimum)

Remember, if the swap limit is not met or the swap is otherwise refunded the outbound_fee of the Source Chain will be deducted from the input amount, so give your users enough room.

Understanding gas_rate

{
		"address": "0x87a8d8abd8086173e2f15a90a1938d8077e02ecb",
		"chain": "ETH",
		"chain_lp_actions_paused": false,
		"chain_trading_paused": false,
		"gas_rate": "130",
		"gas_rate_units": "gwei",
		"global_trading_paused": false,
		"halted": false,
		"outbound_fee": "1080000",
		"outbound_tx_size": "80000",
		"pub_key": "mayapub1addwnpepqvz6vkw4nzcp5sl9ktx63kz7v0n754r99uehfnzv42eauc644yzgvmuun3k",
		"router": "0xe3985E6b61b814F7Cdb188766562ba71b446B46d"
	},

The gas_rate property can be used to estimate network fees for each chain the swap interacts with. For example, if the swap is BTC -> ETH the swap will incur fees on the bitcoin network and Ethereum network. The gas_rate property works differently on each chain "type" (e.g. EVM, UTXO, COSMOS).

The gas_rate_units explain what the rate is for chain, as a prompt to the developer.

The outbound_tx_size is what MAYAChain internally budgets as a typical transaction size for each chain.

Fee Calculation by Chain

MAYAChain (Cacao)

CACAO is the only asset expressed in 1e10 format. All other asset are expressed in 1e8 format.

UTXO Chains like Bitcoin

For UXTO chains link Bitcoin, gas_rateis denoted in Satoshis. The gas_rate is calculated by looking at the average previous block fee seen by the MAYANodes.

All MAYAChain transactions use BECH32 so a standard tx size of 250 bytes can be used. The standard UTXO fee is then gas_rate* 250.

EVM Chains like Ethereum

For EVM chains like Ethereum, gas_rateis denoted in GWEI. The gas_rate is calculated by looking at the average previous block fee seen by the MAYANodes

An Ether Tx fee is: gasRate * 10^9 (GWEI) * 21000 (units).

An ERC20 Tx is larger: gasRate * 10^9 (GWEI) * 70000 (units)

PreviousNetwork HaltsNextDelays

Last updated 6 months ago

Was this helpful?

MAYAChain calculates and posts fee rates at

Read for more information.

Affiliates can collect their fees in the asset of their choice (choosing from the assets that have a pool on MAYAChain). In order to collect fees in a preferred asset, affiliates must use a in their swap .

If an affiliate's MAYAName has the proper preferred asset configuration set, the network will begin collecting their affiliate fees in $CACAO in the AffiliateCollector module. Once the accrued CACAO in the module is greater than * outbound_fee of the preferred asset's chain, the network initiates a swap from $CACAO -> Preferred Asset on behalf of the affiliate. At the time of writing, PreferredAssetOutboundFeeMultiplier is set to 100, so the preferred asset swap happens when the outbound fee is 1% of the accrued $CACAO.

if not done already. This is done with a MsgDeposit posted to the MAYAChain network.

Grab the full USDC name from the endpoint: ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48

You can use to post a MsgDeposit with a custom memo. Load your wallet, then open your MAYAChain wallet page > Deposit > Custom.

Once you successfully post your MsgDeposit you can verify that your MAYAName is configured properly. View your MAYAName info from MAYANode at the following endpoint:

The OFM moves between a MaxOutboundFeeMultiplier and a MinOutboundFeeMultiplier(defined as ), based on the network's current outbound fee "surplus" in relation to a "target surplus". The outbound fee "surplus" is the cumulative difference (in $CACAO) between what the users are charged for outbound fees and what the nodes actually pay. As the network books a "surplus" the OFM slowly decreases from the Max to the Min. Current values for the OFM can be found on the .

See for more information.

The outbound_fee for each chain is returned on the endpoint, priced in the gas asset.

It is strongly recommended to use the recommended_min_amount_in value that is included on the endpoint, which is the calculation described above. This value is priced in the inbound asset of the quote request (in 1e8). This should be the minimum-allowed swap amount for the requested quote.

MAYANode keeps track of current gas prices. Access these at the /inbound_addresses endpoint of the . The response is an array of objects like this:

The outbound_fee is gas_rate * outbound_tx_size * OFM and developers can use this to budget for the fee to be charged to the user. The current Outbound Fee Multiplier (OFM) can be found on the .

Keep in mind the outbound_fee is priced in the gas asset of each chain. For chains with tokens, be sure to convert the outbound_fee to the outbound token to determine how much will be taken from the outbound amount. To do this, use the getValueOfAsset1InAsset2 formula described in the section.

The MAYAChain blockchain has a set 0.5 CACAO fee. This is set within the MAYAChain by NativeTransactionFee. As MAYAChain is 1e10, 5000000000 TOR = 0.5 CACAO

MAYAChain calculates and posts gas fee rates at

https://mayanode.mayachain.info/mayachain/inbound_addresses
https://medium.com/thorchain/affiliate-fees-on-thorchain-17cbc176a11b
PreferredAssetOutboundFeeMultiplier
Pools
Asgardex
https://mayanode.mayachain.info/mayachain/mayaname/wr
Mimir Values
Network Endpoint
Inbound Addresses
Swap Quote
MAYANode API
Network Endpoint
Math
Mimir
https://mayanode.mayachain.info/mayachain/inbound_addresses
MAYAName
memos
Register a MAYAName
Outbound Fee