Increment
  • 🍀OVERVIEW
    • Background
  • 🌊Protocols
    • 💱Decentralized Exchange
      • CPAMM DEX
        • User Guidance
        • AMM 101
        • Deployment Addresses
      • Stableswap DEX
        • Introduction
        • User Guidance
        • Deployment Addresses
      • DEX Aggregator
      • Smart Contract API
      • Token Listing
      • Security
    • 🏦Decentralized Money Market
      • User Guidance
      • Deployment Addresses
      • Interest Rate Model
      • Market Parameter
      • Liquidation
      • Governance
      • Security
    • 🔮Decentralized Price Feed (Oracle)
      • Architecture
      • Deployment Addresses
      • Using Price Feeds
      • Apply as Feeder
    • 👨‍🌾Liquidity Mining (Farm)
      • Token Farm
        • Deployment Addresses
      • NFT Farm
        • Deployment Addresses
    • 💧Liquid Staking
      • User Guidance
      • Deployment Addresses
      • Use stFlow
      • Protocol Overview
        • stFlow token
        • Protocol Epoch
        • Delegation Strategy
      • FAQ
      • Node Registration
      • Security
    • ✨Points
      • 📐Rules
      • 📄Terms
  • 💦Miscs
    • 📊Metrics
    • 📚Tutorials
    • 🛡️Security Audits
    • 🐛Bug Bounty
    • 🖼️Brand Assets
    • 🕸️Decentralized Web
    • 📄Term of Service
    • 📄Privacy Policy
  • 🌐Socials
    • 🐦 Twitter
    • 🤖️ Discord
    • 📚 Medium
    • ✈️ Telegram
Powered by GitBook
On this page
  • 1. Identify FT on Flow
  • 2. Interact with FT on Flow
  • 3. CPAMM Principles
  • 4. Understanding Impermanent loss (IL)
  1. Protocols
  2. Decentralized Exchange
  3. CPAMM DEX

AMM 101

PreviousUser GuidanceNextDeployment Addresses

Last updated 1 year ago

1. Identify FT on Flow

Unlike on EVM, simply using a contract address is not enough to identify FTs on FVM. The unique identifier for FT is composed of: A.16-byte-address.name.

For example:

  • A.b19436aae4d94622.FiatToken is USDC's unique identifier on mainnet.

  • Also ceWETH and ceWBTC (Celer-Bridged wETH & wBTC from ETH) are deployed under the same address but with different identifiers: A.231cc0dbbcffc4b7.ceWETH, and A.231cc0dbbcffc4b7.ceWBTC.

2. Interact with FT on Flow

Paths

FT on FVM conforms to the FungibleToken . One specific FT is represented as a Vault resource and stored directly under the holder' account storage area.

So each FT is also associated with several used to interact with it. Check the tokenlist file for FT details on mainnet.

FT Resource Initialization

Unlike FT on EVM, one cannot 'airdrop' FT to arbitrary address without the receiver account first initializing the FT resource once (using FT.createEmptyVault() method).

  • Example transaction: init_usdc_vault.cdc

import FungibleToken from 0xf233dcee88fe0abe  // mainnet
import FiatToken from 0xb19436aae4d94622      // mainnet

transaction() {
    prepare(signer: AuthAccount) {
        let vaultPath = /storage/USDCVault
        let receiverPath = /public/USDCVaultReceiver
        let balancePath = /public/USDCVaultBalance

        if signer.borrow<&FungibleToken.Vault>(from: vaultPath) == nil {
            signer.save(<- FiatToken.createEmptyVault(), to: vaultPath)
            signer.link<&FiatToken.Vault{FungibleToken.Receiver}>(receiverPath, target: vaultPath)
            signer.link<&FiatToken.Vault{FungibleToken.Balance}>(balancePath, target: vaultPath)
        }
    }
}

The initialization only needs to be done once per holder account for one specific FT. After that any further action like: deposit / withdraw / etc. can be performed flawlessly.

*Note: FlowToken is also FT but it's the only exception that it doesn't need initialization - as the init step has been performed when the account is created.

3. CPAMM Principles

4. Understanding Impermanent loss (IL)

Check Uniswap-V2 whitepaper here:

🌊
💱
interface
paths
here
https://uniswap.org/whitepaper.pdf
Source:
https://docs.uniswap.org/protocol/V2/concepts/advanced-topics/understanding-returns