Getting a Quote
After you have already fetched all tradeable pairs, you are ready to get price quotes directly from the Broker
contract. In the example below we will do so for the CELO/cUSD
exchange.
We start by importing the SDK and instantiating it on the Alfajores Celo testnet:
In order to get a quote you will need the address of the token you will provide (tokenIn
) as well as the address of the token you intend to get out (tokenOut
). In this example we will get a quote for CELO -> cUSD
using the addresses from the previous step.
We can now get a quote for how much cUSD
we can expect to receive in exchange for 1 CELO
:
Alternatively, you can also get a quote for the amount of tokens that you would need to provide in order to buy an exact amount of another desired token. For example, the amount of cUSD
needed to buy 1 CELO
:
You can find the full runnable code for this section within the mento-sdk-examples repo:
Last updated