Cacaoswap: adjust swap size to pool depth
Cacaoswap is a web interface for native-asset swaps powered by Maya Protocol. Comparing the input amount with the relevant pool balances helps assess slippage. A smaller input improves the modeled output per unit at unchanged balances, while outbound fees still affect the result.
Match the amount to the correct reserve
Each Maya liquidity pool pairs a connected asset with CACAO. For sizing, compare the amount entering a pool with its reserve of that same asset. Both values must use the same units.
A swap directly into or out of CACAO uses the corresponding asset pool. Between two non-CACAO assets, the first pool converts the input into CACAO, which enters the second pool. The second sizing check therefore compares that intermediate CACAO amount with the second pool's CACAO reserve. Both conversions affect the output; the first pool's depth alone can't establish the rate for the whole swap.
How size changes the modeled rate
Maya Protocol's single-pool swap calculation is
y = (x * Y * X) / ((x + X) * (x + X))
. Here,
x
is the input amount and
X
the pool's input-asset balance. The output-asset balance is
Y
, and the calculated output is
y
. Each amount and its corresponding reserve use the same asset units.
For a positive input,
y / x
gives output per input unit. Holding both reserves fixed, this rate falls as the input-to-reserve ratio
x / X
rises. This calculation doesn't establish the final amount received after network costs or later changes in pool balances.
Checklist for comparing swap amounts
| Review stage | Evidence to inspect | Pass or revise |
|---|---|---|
| Establish trading eligibility | The trading status of every Maya pool the swap needs. | Pass only when the required pools are open for swaps after bootstrap. An asset's presence on a connected chain doesn't establish trading availability. |
| Measure the first input | The intended input amount and the first pool's reserve of that asset, in matching units. | Pass when both values are available for the comparison. Missing balances or mismatched units leave the size-to-depth assessment incomplete. |
| Assess the second pool, if needed | For two non-CACAO assets, the calculated CACAO output from the first pool and the second pool's CACAO reserve. | Pass when the second conversion is included in the estimate. This stage doesn't apply to a swap directly into or out of CACAO. |
| Compare a reduced amount | Output per input unit for the original and smaller amounts, using the same pool balances. | A better rate supports the modeled sizing benefit. If balances differ between estimates, the difference can't be attributed to size alone. |
| Reassess transaction costs | The outbound network fees and expected output for the revised amount. | Pass when the revised amount's costs are included in the assessment. Lower modeled slippage alone doesn't demonstrate a lower total cost. |
Limits on reducing or dividing the amount
Maya's outbound fee is based on recent gas costs for the destination chain. If the fee doesn't decrease by at least the same percentage as the swap amount, it takes a larger share of that trade. Pool depth therefore can't determine an acceptable amount on its own.
Reducing one swap's amount exchanges less of the original asset. Exchanging the original total through several separate swaps creates several fee-bearing swaps, so compare their combined fees before assuming manual division improves the overall result.