2

I am trying to use erdpy to find the address of the pair EGLD-MEX on the testnet Maiar Exchange.

I am using this call:

erdpy --verbose contract query erd1qqqqqqqqqqqqqpgqum3tp4paqxt3snyfj3a5qj37tr9umv970n4s0kv06c --proxy https://testnet-gateway.elrond.com --function=getPair --arguments 0x5745474C442D663634336438 0x4D45582D633735316436

where

erd1qqqqqqqqqqqqqpgqum3tp4paqxt3snyfj3a5qj37tr9umv970n4s0kv06c is the address of the router smart contract on the testnet. I found it when performing a swap in https://testnet.maiar.exchange/ as shown in the picture UI when performing a swap on the exchange that displays the address of the router smart contract

0x5745474C442D663634336438 is WEGLD-f643d8 in hexadecimal

0x4D45582D633735316436 is MEX-c751d6 in hexadecimal

The response from this call is empty.

What did I do wrong?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199

1 Answers1

1

The address you are using is not the router address as you assumed, but the address of the pair itself.

You can also easily check that via the graphql api. https://testnet-exchange-graph.elrond.com/graphql

With the following query:

{factory{address}, pairs{address, firstToken{identifier}, secondToken{identifier}}}

You will receive the following output:

{
  "data": {
    "factory": {
      "address": "erd1qqqqqqqqqqqqqpgq4axqc749vuqr27snr8d8qgvlmz44chsr0n4sm4a72g"
    },
    "pairs": [
      {
        "address": "erd1qqqqqqqqqqqqqpgqum3tp4paqxt3snyfj3a5qj37tr9umv970n4s0kv06c",
        "firstToken": {
          "identifier": "WEGLD-f643d8"
        },
        "secondToken": {
          "identifier": "MEX-c751d6"
        }
      },
      {
        "address": "erd1qqqqqqqqqqqqqpgqmzjpcyra47d0k8xualwcs6k2gzkdrdap0n4sdj0nu6",
        "firstToken": {
          "identifier": "WEGLD-f643d8"
        },
        "secondToken": {
          "identifier": "USDC-72a225"
        }
      },
      {
        "address": "erd1qqqqqqqqqqqqqpgq3cpwrvmextk986e6z6akeewq8feukuj90n4sf2aa2n",
        "firstToken": {
          "identifier": "WEGLD-f643d8"
        },
        "secondToken": {
          "identifier": "RIDE-ae50f0"
        }
      }
    ]
  }
}

Where the factory address is the proxy, and the pair addresses should be self explanatory.

Martin W
  • 733
  • 4
  • 12
  • Hey, thank you so much. This graphql api is godsent. I don't know how I missed it. I was poking around blindly and now I finally have some kind of documentation about the API. – baptiste00001 Dec 25 '21 at 02:19
  • Two questions though: 1. What is the mainnet equivalent to https://testnet-exchange-graph.elrond.com/graphql? (I will need to send calls to the mainnet eventually) 2. So the factory is like the Router Smart Contract in the API right? – baptiste00001 Dec 25 '21 at 02:50
  • 1
    1. The address on mainnet would be: https://graph.maiar.exchange/graphql 2. Yes, the factory is the address for the router/proxy smart contract :) – Martin W Dec 25 '21 at 15:12
  • 1
    Awesome. Thank you for the precise and detailed answers. Greatly appreciated! – baptiste00001 Dec 26 '21 at 05:53