Mento Protocol
  • Overview
    • Getting Started
      • What Is Mento?
      • Quick Start Guides
      • Analytics & Dashboards
    • Core Concepts
      • Stability Mechanisms
      • The Reserve
      • Oracles & Price Feeds
      • Trading Limits & Circuit Breakers
      • The Broker & Virtual AMMs
      • Fixed-Price Market Makers (FPMMs)
      • Research & Economics
    • Governance & the MENTO Token
      • Understanding Mento Governance
      • Participating in Governance
        • veMENTO & Voting Power
        • Creating Proposals
        • Voting Process
      • MENTO Tokenomics
      • Watchdogs & Safety
    • Security & Risk
      • Overview
      • Audit Reports
  • Build On Mento
    • Integration Overview
      • Integrate Stables
      • Integrate the Broker
      • Integrate Oracles
    • Mento SDK
      • Installation
      • Guides
        • Getting Exchange Pairs
        • Getting a Quote
        • Initiating a Swap
    • Smart Contracts
      • Broker
      • TradingLimits
      • BiPoolManager
      • Pricing Modules
      • SortedOracles
      • BreakerBox
      • Reserve
      • StableToken
      • Audits
    • Deployments
      • Addresses
      • Verification
  • Use Mento
    • Getting Mento Stables
      • On Celo
      • On Mobile
      • From Other Chains
      • Via Centralized Exchanges
Powered by GitBook
On this page
Edit on GitHub
  1. Build On Mento
  2. Mento SDK
  3. Guides

Getting Exchange Pairs

PreviousGuidesNextGetting a Quote

Last updated 1 year ago

CtrlK

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 forno, 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 mento-sdk-examples repo:

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