Integration Options

Magicswap v2 can be integrated in games through two paths:

  1. Via TDK integration (recommended!)
  2. Self-serve integration via contracts

Best Practices

Trading in Magicswap can result in remainders which are rounded down, with the remainders staying in the LP pool as LP fees. This behaviour may be unexpected (and possibly harm users) in cases when rounded amounts are large in dollar terms.

When integrating Magicswap, consider the following:

Swap Safety Recommendations

Swaps that accidentally burn items

Warn when traders input something that attempts to buy fractional amounts of an NFT (which are rounded down to zero and effectively burnt)

  • e.g., swapping 15 Bridgeworld Metabolic Boosters for 0.7 of a Beacon Pet, which is rounded down to 0, burning the Boosters.

Swaps that result in significant rounding (in $ terms)

Warn if swap results in significant rounding errors (above say $5)

  • Teams should be careful about creating pools around rare, low supply, valuable NFTs (which are more susceptible to larger rounding errors in $ terms). - The most appropriate items for pooling are high supply, cheap NFT items that users are likely to buy in large batch quantities where a rounding error of ±1 item is a fraction of a cent.

In summary:

NFT → ERC-20 swaps

Safe; user specifies exact amount of input NFT and output ERC-20 is divisible

ERC-20 → NFT swaps

Safe; user specifies exact amount of input NFT and output ERC-20 is divisible

NFT → NFT swaps

Check for swaps that accidentally burn, and swaps with significant rounding

LPing Behavior

ℹ️ Provide info in the LPing screen:

  • When withdrawing liquidity positions from NFT-ERC-20 pools, remainders are returned to the liquidity provider either as vault token or swapped to the ERC-20 token. The choice can be made by the implementing project or presented as a choice to the user.
  • e.g. Suppose a user LPs in a SMOL/MAGIC pool and deposits exactly 4 Smols NFTs, and 6400 MAGIC. When they want to withdraw sometime later, their LP position is 4.2 Smols, 6080 MAGIC. The user has options to withdraw either
    • (a) 4 SmolBrains + 6080 MAGIC + X MAGIC (resulting from converting the extra 0.2 Smol into MAGIC in the pool), or
    • (b) 4 SmolBrains + 6080 MAGIC + 0.2 SmolBrainsVault

NFT Purchases and Rarity

  • ⚠️ Warn that when you provide liquidity in an NFT pool, you can select the specific token IDs to add to the pool, but you are not guaranteed to receive the same exact token IDs when withdrawing from the pool. This applies to all NFT vaults that will accept multiple token IDs, but is of most importance for ERC-721 collections.
    • e.g., User provides liquidity with Smol Brains #1337 and 600 MAGIC. Through the normal course of swaps, #1337 may be obtained by another trader. When the liquidity provider withdraws their position, they will have a chance to select which Smol Brains to withdraw, but #1337 may no longer be an option.
  • The pricing of a NFT pool should therefore reflect the floors of a collection.
    • ⚠️ Teams using Magicswap NFT pools should warn users against putting rare token IDs into a pool. Users should only deposit specific NFT token IDs they are willing to part with.