Links

DEX and Lending Market

In building DApps, you may wish to leverage Canto's Free Public Infrastructure, such as its native DEX or lending market. This page provides an overview of how these primitives are designed and how you can interact with them.

Canto DEX

The Canto DEX is built around three contracts: BaseV1Factory, BaseV1Pair, and BaseV1Router01. Each liquidity pool is represented by a unique BaseV1Pair contract generated by the BaseV1Factory.
For most use cases, BaseV1Router01 offers sufficient functionality. Key methods include:
Method
Description
pairFor
Calculates the address for a pair
isPair
Checks if an address is a valid pair
getReserves
Fetches and sorts the reserves for a pair
getAmountOut
Calculates amount out for a specified pair
addLiquidity
Adds liquidity to a pair
removeLiquidity
Removes liquidity from a pair
swapExactTokensforTokensSimple
Swaps one token for another directly
swapExactTokensforTokens
Swaps one token for another using a specified route
getUnderlyingPrice
Gets underlying asset price as a mantissa
For $CANTO-specific and other methods, refer to the contract source code.

Canto Lending Market

The Canto Lending Market is an adaptation of Compound v2. Its functional design is unchanged in that the primary means of interacting with the lending market is the CToken, an ERC20 representation of a supplied asset.
Key methods on CToken contracts include:
Method
Description
mint
Deposits a token and mints the corresponding CToken
redeem
Redeems a specified amount of CToken tokens for the underlying token
redeemUnderlying
Redeems CToken tokens for a specified amount of the underlying token
borrow
Borrows the underlying token
repayBorrow
Repays a borrow of the underlying token
For more information on the Canto Lending Market's design, see the Compound v2 docs.