Mento Protocol
  • Mento Protocol
    • Home
    • What, why, who Mento?
    • Quick Links
  • HOW TO SOURCE MENTO STABLES
    • Overview
    • CEXs, DEXs, Pools
    • From other Chains
    • On-ramp Providers
    • Automation via MATE
  • Protocol Concepts
    • Stability
    • Reserve
    • Asset exchanges
      • Broker
      • Trading Limits
      • Exchange Providers
      • BiPoolManager
    • Oracles
    • On-Chain Circuit Breaker
    • Governance
      • Verification
  • Developers
    • Repository Overview
    • Integrate Mento Stables
    • Smart Contracts
      • Broker
      • TradingLimits
      • BiPoolManager
      • Pricing Modules
      • SortedOracles
      • BreakerBox
      • Reserve
      • StableToken
      • Audits
    • Deployments
      • Addresses
      • Verification
      • Parameters
    • Mento SDK
      • Installation
      • Guides
        • Getting Exchange Pairs
        • Getting a Quote
        • Initiating a Swap
    • Oracles
      • Oracle Client
        • Price Sources
      • Becoming an Oracle Provider
  • Economics
    • Stability
    • Risks
    • Research
  • Governance & Token
    • Overview
    • Governance Components
    • Governance Scope
    • MENTO Token
      • Listing information
    • Airdrop
    • Governance Watchdogs
Powered by GitBook
On this page
Edit on GitHub
  1. Developers
  2. Mento SDK
  3. Guides

Getting Exchange Pairs

PreviousGuidesNextGetting a Quote

Last updated 1 year ago

This guide will walk you through an example code snippet for instantiating the SDK and getting all tradeable pairs from exchanges configured in the broker contract within the Alfajores Celo testnet.

After installing the SDK, we can import it alongside Ethers:

import { Mento } from "@mento-protocol/mento-sdk";
import { providers } from "ethers";

To instantiate the Mento class we will need to pass an Ethers provider or signer object. This example will use a JsonRpcProvider connected to , a public hosted node service operated by cLabs.

const provider = new providers.JsonRpcProvider(
  "https://alfajores-forno.celo-testnet.org"
);
const mento = await Mento.create(provider);

Now that the Mento class is instantiated, we can fetch all the pairs by calling the getTradeablePairs method:

const pairs = await mento.getTradeablePairs();
console.log(pairs);

Which will output the list of pairs alongside their token addresses and symbols in an array format:

[
  [
    {
      address: '0x874069Fa1Eb16D44d622F2e0Ca25eeA172369bC1',
      symbol: 'cUSD'
    },
    {
      address: '0xF194afDf50B03e69Bd7D057c1Aa9e10c9954E4C9',
      symbol: 'CELO'
    }
  ],
  [
    {
      address: '0x10c892A6EC43a53E45D0B916B4b7D383B1b78C0F',
      symbol: 'cEUR'
    },
    {
      address: '0xF194afDf50B03e69Bd7D057c1Aa9e10c9954E4C9',
      symbol: 'CELO'
    }
  ],
  ...
]

You can find the full runnable code for this section within the repo:

forno
mento-sdk-examples
https://github.com/mento-protocol/mento-sdk-examples/blob/main/src/discovery.tsgithub.com