Nabla Docs
  • Nabla Finance
    • The problem Nabla solves
    • Benefits of using Nabla
  • Protocol Overview
    • Swap Algorithm
    • Liquidity Pools
      • Swap Pools
      • Backstop Pool
    • Oracle Details
      • Architecture
      • Pyth
      • Chainlink
      • EV:GO
  • Roadmap
  • Protocol-owned Liquidity (POL)
    • Trading Fees and LP Incentives
    • Nabla as an autonomous protocol
  • Security
    • Audits
    • Bug Bounty Program
  • Mainnet Alpha
    • Risks and Benefits of being a Mainnet Alpha LP
  • Monad Testnet
    • Add Monad Testnet to Metamask
    • Get Monad Test Tokens
    • Monad Testnet Tasks
  • Testnet Beta
    • Connect Wallet to Base Sepolia
    • Testnet Beta Tasks
    • Obtaining Base Sepolia Ether for Gas
    • Test Assets
    • Connect Wallet to Base Sepolia Testnet
    • Performing a Swap
    • Managing Swap Pool Liquidity
    • Redeem Swap Pool Shares via Backstop Pool
    • Managing Backstop Pool Liquidity
    • Withdraw Backstop Pool Liquidity via Excess Swap Pool
  • Testnet Alpha
    • Testnet Alpha Results
    • Whitelisting for testnet
      • Whitelist Campaigns List
      • $PYTH Stakers Whitelist
    • Connect Wallet to Sepolia Testnet
    • Requesting Testnet Gas
    • How to contribute to testing
    • Performing a Swap
    • Managing Swap Pool Liquidity
    • How to swap into a swap pool that is depleted
    • Managing Backstop Pool Liquidity
    • Redeem Swap Pool Shares via Backstop Pool
    • Withdraw Backstop Pool Liquidity via Excess Swap Pool
  • Liquidity Provision
  • $NABLA
    • $sNABLA Token Utility
    • Staking Mechanism
    • Fee Distribution
    • Tokenomics
    • Token Utility Summary
    • Governance
      • Initial Governance Implementation
      • Governance structure
      • Discussion and Proposal process
      • Voting process
      • Transparency and record-keeping
      • Code of conduct
      • Amendments to the Governance Framework
      • Template for a vote
  • $AMBER Onchain Points Program
    • Mainnet Alpha Rewards
      • Arbitrum-Mainnet Alpha Rewards
      • Base-Mainnet Alpha Rewards
    • $AMBER FAQ
  • 💻Developers
    • Integration Guide
    • NablaPortal
    • NablaRouter
    • SwapPool
    • GenericPool
    • NablaBackstopPool
    • PythAdapter
    • ISlippageCurve
    • Contract addresses
      • Arbitrum One
      • Base
      • Monad Testnet
    • Contract errors
  • Community
    • Linktree
    • Twitter
    • Discord
    • Telegram
  • Whitepaper
  • Legal
    • Privacy Policy
    • Terms of Service
Powered by GitBook
On this page
  • oracleAdapter
  • poolByAsset
  • swapExactTokensForTokens
  • getAmountOut
  1. Developers

NablaRouter

oracleAdapter

contract IPriceOracleGetter oracleAdapter

poolByAsset

mapping(address => contract ISwapPoolPermissioned) poolByAsset

swapExactTokensForTokens

function swapExactTokensForTokens(
    uint256 _amountIn, 
    uint256 _amountOutMin, 
    address[] _tokenInOut, 
    address _to, 
    uint256 _deadline, 
    bytes[] _priceUpdateData
) external payable returns (uint256[] amounts_)

Swap some _fromToken tokens for _toToken tokens, ensures _amountOutMin and _deadline, sends funds to _to address msg.sender needs to grant the router contract a sufficient allowance beforehand

By calling this function the price feed gets be updated (IPriceOracleAdapter.updatePriceFeeds)

Parameters

Name
Type
Description

_amountIn

uint256

The amount of input tokens to swap

_amountOutMin

uint256

The minimum amount of output token that the user will accept

_tokenInOut

address[]

Array of size two, indicating the in and out token

_to

address

The recipient of the output tokens

_deadline

uint256

Unix timestamp after which the transaction will revert

_priceUpdateData

bytes[]

Array of price update data

Return Values

Name
Type
Description

amounts_

uint256[]

Array of size two, containing

the input and output amount


getAmountOut

function getAmountOut(
    uint256 _amountIn, 
    address[] _tokenInOut, 
    uint256[] _tokenPrices
) external view returns (uint256 amountOut_, uint256 swapFee_)

Get a quote for how many _toToken tokens _amountIn many tokenIn tokens can currently be swapped for.

Parameters

Name
Type
Description

_amountIn

uint256

The amount of input tokens to swap

_tokenInOut

address[]

Array of size two, indicating the in and out token

_tokenPrices

uint256[]

Array of size two, indicating the in and out token prices fetched off-chain

Return Values

Name
Type
Description

amountOut_

uint256

Number of _toToken tokens that such a swap would yield right now

swapFee_

uint256

The fee that is charged for the swap (in _toToken tokens)

PreviousNablaPortalNextSwapPool

Last updated 1 month ago

💻