DEXs work by having pools of token pairs (e.g., NEAR-USDC) that users can deposit tokens into. The ratio of tokens in the pool determines the exchange rate for a swap. Swapping means adding tokens to one side of the pool while removing tokens from the other side.
This documentation refers to Ref Finance, a community-built DEX on NEAR. Check their official docs for more information.
Query Token Exchange Rate
You can query the exchange rate of a token by calling the Ref Finance indexer:Query Whitelisted Tokens
Anyone can list tokens for sale in the DEX. To protect users, the DEX contract maintains a list of whitelisted tokens:Register in the DEX
Before using the DEX, you must register your account by paying for storage:Deposit Funds
To swap tokens, you must first deposit tokens into the DEX. Transfer the FT you want to swap to the DEX contract:Get Deposit Balances
Query your deposit balances by callingget_deposits: