Only this pageAll pages
Powered by GitBook
1 of 37

Trading Post

General Information

Loading...

Loading...

PRODUCTS

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

FAQ

Loading...

Developer

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Integration

Loading...

Loading...

LEGAL

Loading...

Loading...

Why Trading Post?

Trade

Instantly swap tokens: no registration or account needed.

Low fees

Why pay more? Trading Post runs on CAMP, a blockchain with much lower transaction costs than Ethereum or Bitcoin.

Trading fees are lower than other top decentralized exchanges too, so that's a double win for you!

Decentralized

Trade directly from your wallet.

Unlike centralized exchanges like Binance or Coinbase. Trading Post doesn't hold your funds when you trade: you have 100% ownership of your own crypto. Your keys your crypto.

Earn

Earn TP and other tokens for free by participating in the protocol

Earn tokens with Staking TP

Stake TP, earn free tokens. It's really that simple.

Earn TP with Yield Farms

Stake LP tokens, earn TP.

Earn Trading Fees

You can earn trading fees when you stake your tokens in Liquidity Pools (LPs).

Trading Post Intro

Welcome to Trading Post!

Trading Post is a native social-first DEX built on Camp. Trading Post is the home for the teams and tokens built on Camp to provide them with a venue to trade their tokens. Allowing both users and the builders to leverage our trading venue for the best trading experience. Liquidity provider tools are also essential for Trading Post and allow for better yield capture for LPs.

Why Camp?

Camp Network is the user identity layer across blockchains. Camp aggregates online user data, enabling users to own and monetize their identity while helping teams like us Trading Post better understand user behavior.

This allows us to bring in social aspects to the trading experience that had previously been an isolated experience.

Fees and Routes

In Exchange V3, on default, Trading Post Smart Router will utilize liquidity from V3, V2, StableSwap, and the AMM or market makers, to execute trades and find the best price for traders.

However, users are always able to customize their trade by choosing which liquidity sources the router shall utilize, and enable or disable multihops and split routing.

Multihops allow tokens to swap through multiple hops between several liquidity pools to achieve the best deal. Turning it off will restrict trades to direct swaps, which may cause higher slippage or even fund loss.

Split routing enables tokens swaps to be broken into multiple routes to achieve the best deal. Turning it off will restrict trades from being executed with a single route, which may result in low efficiency or higher slippage.

When your trade can not be executed due to a customized trading configuration, a warning will appear, you can click "Check your settings" to quickly bring up the "Customize Routing" interface. Or choose "Reset to default" to quickly reset your configuration back to default.

StableSwap

StableSwap on Trading Post is a feature to trade stable pairs with a lower slippage based on an invariant curve slippage function. It is designed to swap specific assets that are usually priced closely - such as stablecoins or liquidity-staking tokens.

The StableSwap is an implementation of Curve Finance's AMM on Trading Post. It adds a linear invariant constant sum curve (x+y=K) on top of the constant product formula (x*y=k) to keep prices more equal as long as the liquidity pool is not extremely unbalanced. As a result, since StableSwaps are restricted to similarly priced assets, the impermanent loss is not as much of a concern (except in extreme depeg cases) and the slippage is lower than normal AMM which just uses the constant product formula.

When you conduct a Swap (trade) on the StableSwap you will pay lower trading fees, than the usual 0.25% on Exchange V2 AMM.

StableSwap Fees

Fees for each pair are broken down per trading pair.

The team will gradually roll out StableSwap pairs and revise the fees to test and improve the experience further.

Why should I use the StableSwap instead of the normal AMM?

  • Swap your stablecoins or other pairs with similar asset prices more efficiently with the same trade steps

  • With the StableSwap function, the trading pair slippage is lower than normal AMM

  • The StableSwap trading fees are lower compared to the normal AMM

Smart Router

Trading Post Smart Router is a routing algorithm that links the AMM and stableswap, and the AMM to market makers, to provide better liquidity and pricing. It uses a smart order routing algorithm that executes trades across multiple pools to find the best price for traders.

Why should I use the Smart Router for my AMM swaps?

  • Swap your stablecoins or other pairs with similar asset prices more efficiently with the same trade steps.

  • Swap against market makers, who may provide better execution on trades than the normal Trading Post AMM.

  • With the StableSwap function, the trading slippage is lower than normal AMM

  • The StableSwap trading fees are lower compared to the normal AMM

Yield Farming

Yield Farms allow users to earn TP while supporting Trading Post by staking LP Tokens.

Reward Calculations

Yield Farm APR calculations include both:

  • LP rewards APR earned through providing liquidity and;

  • Farm base rewards APR earned through staking LP tokens in the Farm.

Why? Because when you stake your LP tokens in a farm to earn TP, you're still providing liquidity to the liquidity pool, so you earn LP rewards as well!

Calculating Farm Base Reward APR

The Farm Base APR is calculated according to the farm multiplier and the total amount of liquidity in the farm - this is the amount of TP distributed to the farm.

Calculating LP Reward APR

On top of that, farmers receive LP Rewards for providing liquidity. Here's an example of calculating LP Rewards:

To calculate the yearly fees

  • Use the 24H volume to calculate the fee share of liquidity providers in the pool

  • Use the Fee share to estimate the projected yearly fees earned by the pool (based on the current 24h volume)

  • We can now use the yearly fees to calculate the LP rewards APR: That's yearly fees divided by liquidity equals LP reward APR.

veTP

Stake TP, Earn TP, and much more!

veTP stands for vote-escrowed TP. veTP tokens serve a crucial role in Trading Post's governance, enabling you to actively participate in Trading Post's governance proposals and Gauges voting system. This allows you to vote on broader governance proposals and influence the allocation of TP emissions within liquidity pools.

Gauges Voting empowers veTP holders to shape the distribution of TP emissions across essential products like Farms. By leveraging veTP, users directly influence how TP emissions are allocated within each pool, impacting specific liquidity pools and projects. The more veTP a pool accumulates through Gauge Voting, the higher the TP emissions allocated, leading to increased rewards for liquidity providers (LPs) during the subsequent 14-day epochs.

Lock TP for any duration from 1 week to 4 years to get veTP. Your veTP amount is based on the number of your locked TP and the duration you locked them for.

What is veTP?

Here are the guides for how to get veTP, by creating a new position.

How to get veTP?

Token Swaps

Token Swaps on Trading Post are a simple way to trade one token for another via automated liquidity pools.

When you make a token swap (trade) on Trading Post, you will pay trading fees according to the type of liquidity pool your trade is being routed through. You may check the route details by clicking the magnifier icon on the "Route" section.

For Exchange V3 liquidity pools, there are currently four different fee tiers: 0.01%, 0.05%, 0.25%, and 1%.

For StableSwap liquidity pools, the fee rate depends on the individual pool configurations. Please check the "Fee" section for more details.

For Exchange V2 liquidity pools, a fixed 0.25% trading fee is applied

General FAQ

Explore FAQs on Trading Post for quick answers related to providing liquidity, swap fees, earnings, and how to use the protocol.

Privacy Policy

Trading Post V2

API

Indexing data from Trading Post contracts

Please refer to Github repo for the latest version

Code:

  1. Blocks: Tracks all blocks on CAMP

  2. Exchange V2: Tracks all Trading Post V2 Exchange data with price, volume, liquidity,...

  3. Pairs: Tracks all Trading Post Pairs and Tokens

Terms of Use

Smart Contracts

This page providees links or locations for Trading Post's smart contracts on CAMP Network

Main contracts

The following links will take you to the explorer page for Trading Post's main smart contracts

  • Trading Post: Main Staking Contract / MasterChef v3

Trading Post V3

Liquidity Pools

Exchange V3

In the Exchange V3, liquidity will be managed in the form of a non-fungible position. You will still earn a share in the fees while providing liquidity.

When you add your token to a Liquidity Pool you will receive a Liquidity Provider NFT token and share in the fees.

Token Whitelist & Integration Guide for Partners

Token Whitelist

If you want to get your token whitelisted on the Trading Post front-end, please go through this link and follow the instructions there:

Token Hyperlink

Exchange

Overview

Trading Post is an Automated Market Maker (AMM), and the Exchange is at the heart of TradingPost. Trading Post is the designated home AMM on the CAMP network!

The Trading Post offers several features that support decentralized trading:

Limit Orders and TWAP

Limit Orders

Allow you to get your swaps at desired prices by leaving instructions how to fill buy or sell orders at specific prices. The trade will only be executed if the price on Trading Post reaches your limit price (or better).

TWAP (Time-weighted Average Price)

What is veTP?

What is veTP?

veTP stands for vote-escrowed TP. It is not transferable, and the only way to acquire veTP is by staking TP. The maximum lock time is 4 years; the longer you lock your TP, the more veTP you'll receive.

What is the purpose of veTP?

Trading Post: Factory v3
  • Trading Post: Router v3

  • Trading Post: Main Staking Contract / MasterChef v2

  • Trading Post: Factory v2

  • Trading Post: Router v2

  • Farm Contracts

  • Liquidity pool contract

    Each liquidity pool created by Trading Post has its own smart contract. Follow the steps below to view the LP (Liquidity pool) token's smart contract on a specific farm.

    1. Go to the Trading Post Farms page and click the row of the farm you want to see the contract for

    2. When the details section expands out, click the View Contract link on the left to open the contract in the explorer.

    Non-fungible liquidity positions

    In V3, liquidity providers have more control over what price range they want to deploy their liquidity. So, when you add your token to a Liquidity Pool in V3, you will create a new non-fungible liquidity position with its unique settings.

    Therefore, in V3, liquidity positions are NFTs. Please note that these NFTs are transferable, and they represent the ownership of the underlying assets and the trading fees they earned.

    In V3, trading fees will no longer be automatically compounded in the position. You can manually claim them on each of the position detail pages.

    You can redeem your funds at any time by removing your liquidity.

    Active liquidity and price ranges

    In V3, liquidity providers can configure their positions to only provide liquidity when the price is within a certain range. If the trading price moves out of the range, the position will consist of only one type of token in the pair and become inactive.

    Inactive liquidity positions will not participate in trading or earn any trading fees.

    Concentrated liquidity

    In V3, because of liquidity providers can concentrate their token deposits to provide liquidity only within a specific price range. With the same amount of underlying assets, V3 can support a much bigger trade.

    It results in a much higher relative liquidity level when compared to V2. Liquidity providers can earn more trading fees with the same amount of capital.

    Earning TP

    To make being a liquidity provider even more worthwhile, you can also put your liquidity positions to work inside of the TP Farms, while still earning the base trading fee rewards.

    Exchange V2

    LP Tokens

    As an example, if you deposited TP and CAMP into a Liquidity Pool, you'd receive TP-CAMP LP tokens.

    The number of LP tokens you receive represents your portion of the TP-CAMP Liquidity Pool.

    You can also redeem your funds at any time by removing your liquidity.

    Earning trading fees

    Whenever someone trades on Trading Post, for each hop (swap) in each Exchange V2 liquidity pool, the trader pays a fixed 0.25% fee.

    Earning TP

    Similar to Echange V3, you will be able to deposit some of the LP tokens into farms to earn additional TP on top of the base trading fees.

    Impermanent Loss

    Providing liquidity is not without risk, as you may be exposed to impermanent loss.

    To create a hyperlink for your token or desired liquidity pair on Trading post, please follow this URL format:

    Swap

    URL format: app.tradingpost.finance/?token1={addres1}&token2={address2}

    Parameters:

    • address1 and 2 are replaced with their respective token address

    Adding Liquidity

    URL format: app.tradingpost.finance/add?token1={address1}&token2={address2}&poolVersion={version}&fee={fee}&minTick={}&maxTick={}

    Parameters

    • address1 and 2 are replaced with their respective token addresses

    • version: V2 or V3

    • fee:

      • v2 fee: 0.003 or 0.01

      • v3 fee: 0.0005, 0.003, or 0.01

    • minPrice/maxPrice: only for V3 (optional)

    Swapping/Trading

    Trading Post lets users trade without the need to go through a Centralized Exchange. Everything you do on Trading Post is routed directly through your own wallet, there is no need to trust a custodian!

    Liquidity Pools

    You can swap tokens on TradingPost if there is enough liquidity for those tokens. If nobody has added liquidity for the token or tokens you want to swap, it will be difficult, expensive, or impossible to do so.

    Providing liquidity will get you LP tokens, which will earn you rewards in the form of trading fees for making sure there's always liquidity for the exchange to use.

    Yield Farming

    Yield farming lets users that are providing liquidity earn TP rewards by locking their LP tokens into a smart contract. The incentive is to balance out the risk of impermanent loss that comes along with locking in your liquidity.

    Is a common order type that breaks an order into smaller trade sizes and executes them at regular intervals. The main goal of a TWAP order is to reduce the order's price impact and get the best execution.

    Powered by Orbs

    The Limit Orders and TWAP feature is developed by Orbs and powered by Orbs' L3 technology.

    veTP tokens serve a crucial role in Trading Post's governance, enabling you to actively participate in Trading Post's governance proposals and Gauges Voting system. This allows you to vote on broader governance proposals and influence the allocation of TP emissions within liquidity pools.

    What are the benefits of holding veTP?

    Weekly Rewards: Claim TP rewards regularly through TP Staking and Revenue Sharing.

    Gauges Voting Participation: Influence and boost TP emissions in your preferred pools, by engaging in Gauges Voting every 2 weeks, with results applied bi-weekly. Adjust your voting preferences for each gauge at intervales less frequent than 10 days.

    Vote Incentives: Access additional incentives by claiming bribes from our veTP Managers

    Governance: Vote on governance proposals for matters related to gauge approvals, protocol changes, emission adjustments, etc.

    Liquidity Rewards: Amplify TP rewards when providing liquidity to v3, v2, StableSwap, or position managers sequentially.

    Addresses
    Technical Overview
    https://docs.campnetwork.xyz/docs.campnetwork.xyz

    Gauges Voting

    Use your veTP to vote and decide how TP emissions is to be distributed

    What is a gauge?

    To understand gauges voting, you may think of any products that require TP emissions as a series of gauges. This includes farms, TP weekly reward pool, position manager vaults, etc.

    veTP holders can now use their veTP as votes to decide how much % of TP goes to which product. The more veTP a gauge accumulates through Gaguges Voting, the more TP emissions will be allocated to the underlying liquidity pool / position manager vault.

    Gauge Types

    There are two types of gauges - 'core' and 'non-core'. TP emissions to the former are controlled by the Team, while the community influences emissions to 'non-core' pools by voting with veTP.

    1. 'Core' gauges include pairs with major tokens and stablecoins - the Team will make sure these pairs receive sufficient TP rewards as they contribute significantly to the protocol's revenue.

    2. 'Non-core' gauges represent all other gauges not classified as 'core' gauges

    How to Vote?

    1 - Understand the voting schedule

    Gauges weight voting is conducted every two weeks. The beginning of an epoch, just like revenue sharing, is at 00:00 UTC every even Thursdays.

    In the above example:

    • Epoch 1 is starting at 00:00 UTC, 1st, Thursday on Week 1.

    • Epoch 1 is ending 2 weeks later, at 00:00 UTC, 15th, Thursday on Week 3.

    • Users can vote during 00:00 UTC from 1st to 14th.

    • NO votes can be cast during 00:00 UTC from 14th to 15th as votes are being adjusted and tallied.

    2 - Become eligible

    Since veTP is gradually decreasing according to the remaining lock time, voting results will be taken via a snapshot at the end of every epoch. This incldues the number of total veTP, and the veTP each user has.

    In the above example:

    • Results for Epoch 1, will be based on the veTP balances at 00:00 UTC, 15th.

    • Users whose veTP position is unlocking before or equal to the 15th, will have 0 veTP balance at the snapshot time. Therefore they have no voting power for Epoch 1.

    Therefore, to become eligible, you must obtain an active veTP position, which unlocks AFTER the end/ snapshot time of the current epoch.

    In the above eample:

    • If you want to vote in epoch 1, you must have veTP position which unlocks on the 21st or later than the 21st, or Thursday on week 3.

    3 - Check the current voting results

    Head to "TP staking", scroll down and look for the "Gauges Voting" section, then click "Check Gauges".

    At the top-left section. You may find:

    • Your veTP

    • Snapshot time and voting end time for the current epoch.

    • The total number of TP rewards to be distributed in the next epoch based on the voting results from the current epoch.

    • The total amount of veTP votes casted.

    At the top-right, you may find a pie chart representing the % of each gauge received.

    At the bottom, there is a complete list of every voting gauges. With the number of votes they received and the expected % weight, they are gaining in the current epoch. There is also a "boost" and "caps" field, detailing two important gauge characteristics. Continue reading for more details.

    Gauge Boost and Emission Caps

    To ensure TP rewards go to the most productive gauges. Each gauge can be applied with a boost and/or an emission cap. Two of the characteristics can both exist at the same time.

    Gauge Boost is a multiplier applied to the number of votes a gauge receives, ranging from 1x to 2.5x (gauges for V3 pools are capped at 2x). This is to encourage votes and liquidity for important trading pairs.

    Emission cap is a maximum cap on the % weight a gauge can receive, ranging from 2% to 20%. This is to promote fairness in allocation and prevent abuse of the gauge system.

    For example:

    • A gauge has 10 votes, 2x boost and 15% cap. The total vote is 100.

    • After applying the boost, this gauge will have 20 votes, 20% weight against the total (100).

    • However, since it has a 15% cap, the final % of TP rewards this gauge receives in the next epoch will be adjusted to 15%.

    How are Gauge Boost and Emission Caps determined?

    During the process of a gauge application, we ask applicants to propose the value of the boost multiplier and emissions cap % they wish to assign to the gauge. These have to be voted on by veTP holders, along with the entire gauge application.

    The default option for all gauges is 1.00x multiplier and 5% emission cap. They can be changed with future proposals.

    4 - Add gauges to vote

    To vote on a gauge, scroll down and look for "My Votes" section. Click "Add Gauge".

    In the pop-up window, you may add gauges to your list of votes by clicking the blue "+" icon. You may find the current voting results in the list, along with boost and caps.

    To quickly locate a gauge, you can use filtering to filter gauges by blockchains, fee tiers and liquidity types. Or type in the token ticker into the search field.

    5 - Select how much % veTP to vote on each gauge

    Once you have added the gauges, you may select how much % of your veTP goes to each of the gauges.

    This is because:

    • veTP gradually decreases with the remaining lock time. It is impractical to estimate and calculate how many exact veTP to vote.

    • It is troublesome to re-vote in every upcoming epoch. Therefore, gauge voting is designed to carry your voting decisions throughout the upcoming epoch until you cast a new one.

    6 - Update your votes

    Once your vote is submitted, you may see your votes being updated to "Current Votes". And the remaining veTP gets updated.

    Please note that the voting decision for each gauge can only be updated every 10 days. Once you submit a vote request, all voted gauges will be applied a 10-day cooldown period before you can submit another request for updates.

    To update your vote decision, change the % percentage and submit again.

    Please note that after gaining more veTP by adding TP or extending lock time. You need to manually update every gauge by re-submitting the vote request. The 10-day cooldown period still applies regardless if you changed your % decisions.

    Addresses

    Core

    Mainnet

    Contract
    Address

    PancakeV3Factory

    PancakeV3PoolDeployer

    Testnet

    Contract
    Address

    Periphery

    Mainnet

    Contract
    Address

    Testnet

    Contract
    Address

    Smart Router

    Able to route to v3, v2, and stable pool

    Mainnet

    Contract
    Address

    Testnet

    Contract
    Address

    MastchefV3

    Mainnet

    Contract
    Address

    Testnet

    Contract
    Address

    Voting results will be snapshotted at 00:00 UTC on the 15th. The end of Epoch 1.

  • Voting results will be applied within 72 hrs after an epoch is closed.

  • MixedRouteQuoterV1

    TokenValidator

    MixedRouteQuoterV1

    TokenValidator

    PancakeV3Factory

    PancakeV3PoolDeployer

    SwapRouter (v3)

    V3Migrator

    NonfungiblePositionManager

    QuoterV2

    TickLens

    TradingPostInterfaceMulticall

    SwapRouter (v3)

    V3Migrator

    NonfungiblePositionManager

    QuoterV2

    TickLens

    TradingPostInterfaceMulticall

    Smart Router

    Smart Router

    Masterchef V3

    Masterchef V3

    Technical Overview

    How to get veTP?

    Simply lock TP for a period of time!

    Go to the TP staking page

    Choose the lock amount and duration

    • Input the amount of TP you wish to lock

    • Select the amount of time you wish to lock

    There is no minimum amount to lock and the minimum duration to lock is 1 week with a maximum of 4 years.

    Approve TP spend and start locking

    Once confirmed, click "Lock TP" to proceed. A loading modal will appear and your wallet should prompt you to confirm TP spending. Confirm the transaction in the wallet to continue.

    After the TP spend approval transaction is executed. Another wallet pop-up should appear. Confirm that transaction to lock TP and receive veTP.

    Congratulations!

    Once confirmed, you should see your veTP staking position details on the left, with the amount of TP locked and the unlock time. Then most importantly - your veTP number.

    Scroll down to check on all the veTP benefits!

    SmartRouter

    V3SwapRouter

    Solidity API

    SwapCallbackData

    pancakeV3SwapCallback

    Called to msg.sender after executing a swap via ITradingPostV3Pool#swap.

    In the implementation you must pay the pool tokens owed for the swap. The caller of this method must be checked to be a TradingPostV3Pool deployed by the canonical TradingPostV3Factory. amount0Delta and amount1Delta can both be 0 if no tokens were swapped.

    Parameters

    Name
    Type
    Description

    amount0Delta

    int256

    The amount of token0 that was sent (negative) or must be received (positive) by the pool by the end of the swap. If positive, the callback must send that amount of token0 to the pool.

    amount1Delta

    int256

    The amount of token1 that was sent (negative) or must be received (positive) by the pool by the end of the swap. If positive, the callback must send that amount of token1 to the pool.

    _data

    bytes

    exactInputSingle

    Swaps amountIn of one token for as much as possible of another token

    Setting amountIn to 0 will cause the contract to look up its own balance, and swap the entire amount, enabling contracts to send tokens before calling this function.

    Parameters

    Name
    Type
    Description

    params

    struct IV3SwapRouter.ExactInputSingleParams

    The parameters necessary for the swap, encoded as ExactInputSingleParams in calldata

    Return Values

    Name
    Type
    Description

    amountOut

    uint256

    The amount of the received token

    exactInput

    Swaps amountIn of one token for as much as possible of another along the specified path

    Setting amountIn to 0 will cause the contract to look up its own balance, and swap the entire amount, enabling contracts to send tokens before calling this function.

    Parameters

    Name
    Type
    Description

    params

    struct IV3SwapRouter.ExactInputParams

    The parameters necessary for the multi-hop swap, encoded as ExactInputParams in calldata

    Return Values

    Name
    Type
    Description

    amountOut

    uint256

    The amount of the received token

    exactOutputSingle

    Swaps as little as possible of one token for amountOut of another token that may remain in the router after the swap.

    Parameters

    Name
    Type
    Description

    params

    struct IV3SwapRouter.ExactOutputSingleParams

    The parameters necessary for the swap, encoded as ExactOutputSingleParams in calldata

    Return Values

    Name
    Type
    Description

    amountIn

    uint256

    The amount of the input token

    exactOutput

    Swaps as little as possible of one token for amountOut of another along the specified path (reversed) that may remain in the router after the swap.

    Parameters

    Name
    Type
    Description

    params

    struct IV3SwapRouter.ExactOutputParams

    The parameters necessary for the multi-hop swap, encoded as ExactOutputParams in calldata

    Return Values

    Name
    Type
    Description

    amountIn

    uint256

    The amount of the input token

    V2SwapRouter

    Solidty API

    swapExactTokensForTokens

    Swaps amountIn of one token for as much as possible of another token

    Setting amountIn to 0 will cause the contract to look up its own balance, and swap the entire amount, enabling contracts to send tokens before calling this function.

    Parameters

    Name
    Type
    Description

    amountIn

    uint256

    The amount of token to swap

    amountOutMin

    uint256

    The minimum amount of output that must be received

    path

    address[]

    The ordered list of tokens to swap through

    to

    address

    The recipient address

    Return Values

    Name
    Type
    Description

    amountOut

    uint256

    The amount of the received token

    swapTokensForExactTokens

    Swaps as little as possible of one token for an exact amount of another token

    Parameters

    Name
    Type
    Description

    amountOut

    uint256

    The amount of token to swap for

    amountInMax

    uint256

    The maximum amount of input that the caller will pay

    path

    address[]

    The ordered list of tokens to swap through

    to

    address

    The recipient address

    Return Values

    Name
    Type
    Description

    amountIn

    uint256

    The amount of token to pay

    StableSwapRouter

    Solidity API

    stableSwapFactory

    stableSwapInfo

    SetStableSwap

    constructor

    setStableSwap

    Set Trading Post Stable Swap Factory and Info

    Only callable by contract owner

    exactInputStableSwap

    Parameters

    Name
    Type
    Description

    path

    address[]

    flag

    uint256[]

    token amount in a stable swap pool. 2 for 2pool, 3 for 3pool

    amountIn

    uint256

    amountOutMin

    uint256

    exactOutputStableSwap

    Parameters

    Name
    Type
    Description

    path

    address[]

    flag

    uint256[]

    token amount in a stable swap pool. 2 for 2pool, 3 for 3pool

    amountOut

    uint256

    amountInMax

    uint256

    NonfungiblePositionManager

    Contract Info

    Contract name: NonfungiblePositionManager

    Contract address

    Solidity API

    Position

    constructor

    positions

    Returns the position information associated with a given token ID.

    Throws if the token ID is not valid.

    Parameters

    Name
    Type
    Description

    Return Values

    Name
    Type
    Description

    mint

    Creates a new position wrapped in a NFT

    Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized a method does not exist, i.e. the pool is assumed to be initialized.

    Parameters

    Name
    Type
    Description

    Return Values

    Name
    Type
    Description

    isAuthorizedForToken

    tokenURI

    baseURI

    _Returns the base URI set via {setBaseURI}. This will be automatically added as a prefix in {tokenURI} to each token's URI, or to the token ID if no specific URI is set for that token ID.

    increaseLiquidity

    Increases the amount of liquidity in a position, with tokens paid by the msg.sender

    Parameters

    Name
    Type
    Description

    Return Values

    Name
    Type
    Description

    decreaseLiquidity

    Decreases the amount of liquidity in a position and accounts it to the position

    Parameters

    Name
    Type
    Description

    Return Values

    Name
    Type
    Description

    collect

    Collects up to a maximum amount of fees owed to a specific position to the recipient

    Parameters

    Name
    Type
    Description

    Return Values

    Name
    Type
    Description

    burn

    Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens must be collected first.

    Parameters

    Name
    Type
    Description

    _getAndIncrementNonce

    Gets the current nonce for a token ID and then increments it, returning the original value

    getApproved

    _Returns the account approved for tokenId token.

    Requirements:

    • tokenId must exist._

    _approve

    _Overrides approve to use the operator in the position, which is packed with the position permit nonce

    struct SwapCallbackData {
    bytes path;
    address payer;
    }
    function pancakeV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes _data) external
    
    function exactInputSingle(struct IV3SwapRouter.ExactInputSingleParams params) external payable returns (uint256 amountOut)
    function exactInput(struct IV3SwapRouter.ExactInputParams params) external payable returns (uint256 amountOut)
    function exactOutputSingle(struct IV3SwapRouter.ExactOutputSingleParams params) external payable returns (uint256 amountIn)
    function exactOutput(struct IV3SwapRouter.ExactOutputParams params) external payable returns (uint256 amountIn)
    function swapExactTokensForTokens(uint256 amountIn, uint256 amountOutMin, address[] path, address to) external payable returns (uint256 amountOut)
    function swapTokensForExactTokens(uint256 amountOut, uint256 amountInMax, address[] path, address to) external payable returns (uint256 amountIn)
    address stableSwapFactory
    address stableSwapInfo
    event SetStableSwap(address factory, address info)
    constructor(address _stableSwapFactory, address _stableSwapInfo) internal
    function setStableSwap(address _factory, address _info) external
    function exactInputStableSwap(address[] path, uint256[] flag, uint256 amountIn, uint256 amountOutMin, address to) external payable returns (uint256 amountOut)
    function exactOutputStableSwap(address[] path, uint256[] flag, uint256 amountOut, uint256 amountInMax, address to) external payable returns (uint256 amountIn)

    to

    address

    to

    address

    fee

    uint24

    The fee associated with the pool

    tickLower

    int24

    The lower end of the tick range for the position

    tickUpper

    int24

    The higher end of the tick range for the position

    liquidity

    uint128

    The liquidity of the position

    feeGrowthInside0LastX128

    uint256

    The fee growth of token0 as of the last action on the individual position

    feeGrowthInside1LastX128

    uint256

    The fee growth of token1 as of the last action on the individual position

    tokensOwed0

    uint128

    The uncollected amount of token0 owed to the position as of the last computation

    tokensOwed1

    uint128

    The uncollected amount of token1 owed to the position as of the last computation

    tokenId

    uint256

    The ID of the token that represents the position

    nonce

    uint96

    The nonce for permits

    operator

    address

    The address that is approved for spending

    token0

    address

    The address of the token0 for a specific pool

    token1

    address

    The address of the token1 for a specific pool

    params

    struct INonfungiblePositionManager.MintParams

    The params necessary to mint a position, encoded as MintParams in calldata

    tokenId

    uint256

    The ID of the token that represents the minted position

    liquidity

    uint128

    The amount of liquidity for this position

    amount0

    uint256

    The amount of token0

    amount1

    uint256

    The amount of token1

    params

    struct INonfungiblePositionManager.IncreaseLiquidityParams

    tokenId The ID of the token for which liquidity is being increased, amount0Desired The desired amount of token0 to be spent, amount1Desired The desired amount of token1 to be spent, amount0Min The minimum amount of token0 to spend, which serves as a slippage check, amount1Min The minimum amount of token1 to spend, which serves as a slippage check, deadline The time by which the transaction must be included to effect the change

    liquidity

    uint128

    The new liquidity amount as a result of the increase

    amount0

    uint256

    The amount of token0 to achieve resulting liquidity

    amount1

    uint256

    The amount of token1 to achieve resulting liquidity

    params

    struct INonfungiblePositionManager.DecreaseLiquidityParams

    tokenId The ID of the token for which liquidity is being decreased, amount The amount by which liquidity will be decreased, amount0Min The minimum amount of token0 that should be accounted for the burned liquidity, amount1Min The minimum amount of token1 that should be accounted for the burned liquidity, deadline The time by which the transaction must be included to effect the change

    amount0

    uint256

    The amount of token0 accounted to the position's tokens owed

    amount1

    uint256

    The amount of token1 accounted to the position's tokens owed

    params

    struct INonfungiblePositionManager.CollectParams

    tokenId The ID of the NFT for which tokens are being collected, recipient The account that should receive the tokens, amount0Max The maximum amount of token0 to collect, amount1Max The maximum amount of token1 to collect

    amount0

    uint256

    The amount of fees collected in token0

    amount1

    uint256

    The amount of fees collected in token1

    tokenId

    uint256

    The ID of the token that is being burned

    struct Position {
      uint96 nonce;
      address operator;
      uint80 poolId;
      int24 tickLower;
      int24 tickUpper;
      uint128 liquidity;
      uint256 feeGrowthInside0LastX128;
      uint256 feeGrowthInside1LastX128;
      uint128 tokensOwed0;
      uint128 tokensOwed1;
    }
    constructor(address _deployer, address _factory, address _WETH9, address _tokenDescriptor_) public
    function positions(uint256 tokenId) external view returns (uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1)
    function mint(struct INonfungiblePositionManager.MintParams params) external payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1)
    modifier isAuthorizedForToken(uint256 tokenId)
    function tokenURI(uint256 tokenId) public view returns (string)
    function baseURI() public pure returns (string)
    function increaseLiquidity(struct INonfungiblePositionManager.IncreaseLiquidityParams params) external payable returns (uint128 liquidity, uint256 amount0, uint256 amount1)
    function decreaseLiquidity(struct INonfungiblePositionManager.DecreaseLiquidityParams params) external payable returns (uint256 amount0, uint256 amount1)
    function collect(struct INonfungiblePositionManager.CollectParams params) external payable returns (uint256 amount0, uint256 amount1)
    function burn(uint256 tokenId) external payable
    function _getAndIncrementNonce(uint256 tokenId) internal returns (uint256)
    function getApproved(uint256 tokenId) public view returns (address)
    function _approve(address to, uint256 tokenId) internal

    Integrating Trading Post Router / Swaps

    Integrating Trading Post's routers and swaps remains very similar to integrating Uniswap or PancakeSwap's routers and swaps. Developers familiar with this should have relative ease with integrations, though users should reference Uniswap's or PancakeSwap's documentation if you're seeking more information please contact Trading Post's contributors in our Discord if you have specific questions.

    TradingPostV3Pool

    Solidity API

    factory

    The contract that deployed the pool, which must adhere to the ITradingPostV3Factory interface

    Return Values

    token0

    The first of the two tokens of the pool, sorted by address

    Return Values

    token1

    The second of the two tokens of the pool, sorted by address

    Return Values

    fee

    The pool's fee in hundredths of a bip, i.e. 1e-6

    Return Values

    tickSpacing

    The pool tick spacing

    Ticks can only be used at multiples of this value, minimum of 1 and always positive e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ... This value is an int24 to avoid casting even though it is always positive.

    Return Values

    maxLiquidityPerTick

    The maximum amount of position liquidity that can use any tick in the range

    This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool

    Return Values

    PROTOCOL_FEE_SP

    PROTOCOL_FEE_DENOMINATOR

    Slot0

    slot0

    The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas when accessed externally.

    Return Values

    feeGrowthGlobal0X128

    The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool

    This value can overflow the uint256

    feeGrowthGlobal1X128

    The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool

    This value can overflow the uint256

    ProtocolFees

    protocolFees

    The amounts of token0 and token1 that are owed to the protocol

    Protocol fees will never exceed uint128 max in either token

    liquidity

    The currently in range liquidity available to the pool

    This value has no relationship to the total liquidity across all ticks

    ticks

    Look up information about a specific tick in the pool

    ParametersReturn Values

    tickBitmap

    Returns 256 packed tick initialized boolean values. See TickBitmap for more information

    positions

    Returns the information about a position by the position's key

    ParametersReturn Values

    observations

    Returns data about a specific observation index

    You most likely want to use #observe() instead of this method to get an observation as of some amount of time ago, rather than at a specific index in the array.

    ParametersReturn Values

    lmPool

    SetLmPoolEvent

    lock

    Mutually exclusive reentrancy protection into the pool to/from a method. This method also prevents entrance to a function before the pool is initialized. The reentrancy guard is required throughout the contract because we use balance checks to determine the payment status of interactions such as mint, swap and flash.

    onlyFactoryOwner

    Prevents calling a function from anyone except the address returned by ITradingPostV3Factory#owner()

    constructor

    _blockTimestamp

    Returns the block timestamp truncated to 32 bits, i.e. mod 2**32. This method is overridden in tests.

    snapshotCumulativesInside

    Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range

    Snapshots must only be compared to other snapshots, taken over a period for which a position existed. I.e., snapshots cannot be compared if a position is not held for the entire period between when the first snapshot is taken and the second snapshot is taken.

    Parameters

    Name
    Type
    Description

    Return Values

    Name
    Type
    Description

    observe

    Returns the cumulative tick and liquidity as of each timestamp secondsAgo from the current block timestamp

    To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick, you must call it with secondsAgos = [3600, 0]. The time weighted average tick represents the geometric time weighted average price of the pool, in log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.

    Parameters

    Name
    Type
    Description

    Return Values

    Name
    Type
    Description

    increaseObservationCardinalityNext

    Increase the maximum number of price and liquidity observations that this pool will store

    This method is no-op if the pool already has an observationCardinalityNext greater than or equal to the input observationCardinalityNext.

    Parameters

    Name
    Type
    Description

    initialize

    Sets the initial price for the pool

    not locked because it initializes unlocked

    Parameters

    Name
    Type
    Description

    ModifyPositionParams

    mint

    Adds liquidity for the given recipient/tickLower/tickUpper position

    _noDelegateCall is applied indirectly via modifyPosition

    Parameters

    Name
    Type
    Description

    Return Values

    Name
    Type
    Description

    collect

    Collects tokens owed to a position

    Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.

    Parameters

    Name
    Type
    Description

    Return Values

    Name
    Type
    Description

    burn

    Burn liquidity from the sender and account tokens owed for the liquidity to the position

    _noDelegateCall is applied indirectly via modifyPosition

    Parameters

    Name
    Type
    Description

    Return Values

    Name
    Type
    Description

    SwapCache

    SwapState

    StepComputations

    swap

    Swap token0 for token1, or token1 for token0

    The caller of this method receives a callback in the form of ITradingPostV3SwapCallback#tradingPostV3SwapCallback

    Parameters

    Name
    Type
    Description

    Return Values

    Name
    Type
    Description

    flash

    Receive token0 and/or token1 and pay it back, plus a fee, in the callback

    The caller of this method receives a callback in the form of ITradingPostV3FlashCallback#tradingpostV3FlashCallback Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling with 0 amount{0,1} and sending the donation amount(s) from the callback

    Parameters

    Name
    Type
    Description

    setFeeProtocol

    Set the denominator of the protocol's % share of the fees

    Parameters

    Name
    Type
    Description

    collectProtocol

    Collect the protocol fee accrued to the pool

    Parameters

    Name
    Type
    Description

    Return Values

    Name
    Type
    Description

    setLmPool

    address factory

    data

    bytes

    Any data that should be passed through to the callback

    amount1Requested

    uint128

    How much token1 should be withdrawn from the fees owed

    data

    bytes

    Any data to be passed through to the callback

    tickLower

    int24

    The lower tick of the range

    tickUpper

    int24

    The upper tick of the range

    tickCumulativeInside

    int56

    The snapshot of the tick accumulator for the range

    secondsPerLiquidityInsideX128

    uint160

    The snapshot of seconds per liquidity for the range

    secondsInside

    uint32

    The snapshot of seconds per liquidity for the range

    secondsAgos

    uint32[]

    From how long ago each cumulative tick and liquidity value should be returned

    tickCumulatives

    int56[]

    Cumulative tick values as of each secondsAgos from the current block timestamp

    secondsPerLiquidityCumulativeX128s

    uint160[]

    Cumulative seconds per liquidity-in-range value as of each secondsAgos from the current block timestamp

    observationCardinalityNext

    uint16

    The desired minimum number of observations for the pool to store

    sqrtPriceX96

    uint160

    the initial sqrt price of the pool as a Q64.96

    recipient

    address

    The address for which the liquidity will be created

    tickLower

    int24

    The lower tick of the position in which to add liquidity

    tickUpper

    int24

    The upper tick of the position in which to add liquidity

    amount

    uint128

    The amount of liquidity to mint

    amount0

    uint256

    The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback

    amount1

    uint256

    The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback

    recipient

    address

    The address which should receive the fees collected

    tickLower

    int24

    The lower tick of the position for which to collect fees

    tickUpper

    int24

    The upper tick of the position for which to collect fees

    amount0Requested

    uint128

    How much token0 should be withdrawn from the fees owed

    amount0

    uint128

    The amount of fees collected in token0

    amount1

    uint128

    The amount of fees collected in token1

    tickLower

    int24

    The lower tick of the position for which to burn liquidity

    tickUpper

    int24

    The upper tick of the position for which to burn liquidity

    amount

    uint128

    How much liquidity to burn

    amount0

    uint256

    The amount of token0 sent to the recipient

    amount1

    uint256

    The amount of token1 sent to the recipient

    recipient

    address

    The address to receive the output of the swap

    zeroForOne

    bool

    The direction of the swap, true for token0 to token1, false for token1 to token0

    amountSpecified

    int256

    The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)

    sqrtPriceLimitX96

    uint160

    The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this value after the swap. If one for zero, the price cannot be greater than this value after the swap

    amount0

    int256

    The delta of the balance of token0 of the pool, exact when negative, minimum when positive

    amount1

    int256

    The delta of the balance of token1 of the pool, exact when negative, minimum when positive

    recipient

    address

    The address which will receive the token0 and token1 amounts

    amount0

    uint256

    The amount of token0 to send

    amount1

    uint256

    The amount of token1 to send

    data

    bytes

    Any data to be passed through to the callback

    feeProtocol0

    uint32

    new protocol fee for token0 of the pool

    feeProtocol1

    uint32

    new protocol fee for token1 of the pool

    recipient

    address

    The address to which collected protocol fees should be sent

    amount0Requested

    uint128

    The maximum amount of token0 to send, can be 0 to collect fees in only token1

    amount1Requested

    uint128

    The maximum amount of token1 to send, can be 0 to collect fees in only token0

    amount0

    uint128

    The protocol fee collected in token0

    amount1

    uint128

    The protocol fee collected in token1

    address token0
    address token1
    uint24 fee
    int24 tickSpacing
    uint128 maxLiquidityPerTick
    uint32 PROTOCOL_FEE_SP
    uint256 PROTOCOL_FEE_DENOMINATOR
    struct Slot0 {
      uint160 sqrtPriceX96;  
      int24 tick;  
      uint16 observationIndex;  
      uint16 observationCardinality;  
      uint16 observationCardinalityNext;  
      uint32 feeProtocol;  
      bool unlocked;
    }
    struct TradingPostV3Pool.Slot0 slot0
    uint256 feeGrowthGlobal0X128
    uint256 feeGrowthGlobal1X128
    struct ProtocolFees {
      uint128 token0;
      uint128 token1;
    }
    struct TradingPostV3Pool.ProtocolFees protocolFees
    uint128 liquidity
    mapping(int24 => struct Tick.Info) ticks
    mapping(int16 => uint256) tickBitmap
    mapping(bytes32 => struct Position.Info) positions
    struct Oracle.Observation[65535] observations
    contract ITradingPostV3LmPool lmPool
    event SetLmPoolEvent(address addr)
    modifier lock()
    modifier onlyFactoryOwner()
    constructor() public
    function _blockTimestamp() internal view virtual returns (uint32)
    function snapshotCumulativesInside(int24 tickLower, int24 tickUpper) external view returns (int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside)
    function observe(uint32[] secondsAgos) external view returns (int56[] tickCumulatives, uint160[] secondsPerLiquidityCumulativeX128s)
    function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external
    function initialize(uint160 sqrtPriceX96) external
    struct ModifyPositionParams {
      address owner;
      int24 tickLower;
      int24 tickUpper;
      int128 liquidityDelta;
    }
    function mint(address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes data) external returns (uint256 amount0, uint256 amount1)
    function collect(address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested) external returns (uint128 amount0, uint128 amount1)
    function burn(int24 tickLower, int24 tickUpper, uint128 amount) external returns (uint256 amount0, uint256 amount1)
    struct SwapCache {
      uint32 feeProtocol;
      uint128 liquidityStart;  
      uint32 blockTimestamp;  
      int56 tickCumulative;  
      uint160 secondsPerLiquidityCumulativeX128;  
      bool computedLatestObservation;
    }
    struct SwapState {
      int256 amountSpecifiedRemaining;
      int256 amountCalculated;  
      uint160 sqrtPriceX96;  
      int24 tick;  
      uint256 feeGrowthGlobalX128;  
      uint128 protocolFee;  
      uint128 liquidity;
    }
    struct StepComputations {
      uint160 sqrtPriceStartX96;  
      int24 tickNext;  
      bool initialized;  
      uint160 sqrtPriceNextX96;  
      uint256 amountIn;  
      uint256 amountOut;  
      uint256 feeAmount;
    }
    function swap(address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes data) external returns (int256 amount0, int256 amount1)
    function flash(address recipient, uint256 amount0, uint256 amount1, bytes data) external
    function setFeeProtocol(uint32 feeProtocol0, uint32 feeProtocol1) external
    function collectProtocol(address recipient, uint128 amount0Requested, uint128 amount1Requested) external returns (uint128 amount0, uint128 amount1)
    function setLmPool(contract ITradingPostV3LmPool _lmPool) external

    FactoryV2

    TradingPost is based on Uniswap v2. Read the Uniswap v2 documentation. For more in-depth information on the core contract logic, read the Uniswap v2 Core whitepaper.

    Contract info

    Contract name: TradingPostFactory

    View TradingPostFactory on Github

    Contract address

    Read functions

    getPair

    function getPair(address tokenA, address tokenB) external view returns (address pair);

    Address for tokenA and address for tokenB return address of pair contract (where one exists).

    tokenA and tokenB order is interchangeable.

    Returns 0x0000000000000000000000000000000000000000 as address where no pair exists.

    allPairs

    function allPairs(uint) external view returns (address pair);

    Returns the address of the nth pair (0-indexed) created through the Factory contract.

    Returns 0x0000000000000000000000000000000000000000 where pair has not yet been created.

    Begins at 0 for first created pair.

    allPairsLength

    function allPairsLength() external view returns (uint);

    Displays the current number of pairs created through the Factory contract as an integer.

    feeTo

    function feeTo() external view returns (address);

    The address to where non-LP-holder fees are sent.

    feeToSetter

    function feeToSetter() external view returns (address);

    The address with permission to set the feeTo address.

    Write functions

    createPair

    function createPair(address tokenA, address tokenB) external returns (address pair);

    Creates a pair for tokenA and tokenB where a pair doesn't already exist.

    tokenA and tokenB order is interchangeable.

    Emits PairCreated (see Events).

    setFeeTo

    Sets address for feeTo.

    setFeeToSetter

    Sets address for permission to adjust feeTo.

    Events

    PairCreated

    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    Emitted whenever a createPair creates a new pair.

    token0 will appear before token1 in sort order.

    The final uint log value will be 1 for the first pair created, 2 for the second, etc.

    Interface

    TradingPostV3Factory

    Contract name: TradingPostFactory

    Contract address

    Solidity API

    Deploys TradingPost V3 pools and manages ownership and control over pool protocol fees

    owner

    Returns the current owner of the factory

    Can be changed by the current owner via setOwner

    poolDeployer

    Returns the current pool deployer

    feeAmountTickSpacing

    Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled

    A fee amount can never be removed, so this value should be hard coded or cached in the calling context

    getPool

    Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist

    tokenA and tokenB may be passed in either token0/token1 or token1/token0 order

    feeAmountTickSpacingExtraInfo

    Returns the tick spacing extra info

    A fee amount can never be removed, so this value should be hard coded or cached in the calling context

    constructor

    createPool

    Creates a pool for the given two tokens and fee

    tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments are invalid.

    Parameters

    Name
    Type
    Description

    Return Values

    Name
    Type
    Description

    setOwner

    Updates the owner of the factory

    Must be called by the current owner

    Parameters

    Name
    Type
    Description

    enableFeeAmount

    Enables a fee amount with the given tickSpacing

    Fee amounts may never be removed once enabled

    Parameters

    Name
    Type
    Description

    setWhiteListAddress

    Set an address into white list

    Address can be updated by owner with boolean value false

    Parameters

    Name
    Type
    Description

    setFeeAmountExtraInfo

    Set a fee amount extra info

    Fee amounts can be updated by owner with extra info

    Parameters

    Name
    Type
    Description

    tokenA

    address

    One of the two tokens in the desired pool

    tokenB

    address

    The other of the two tokens in the desired pool

    fee

    uint24

    The desired fee for the pool

    pool

    address

    The address of the newly created pool

    _owner

    address

    The new owner of the factory

    fee

    uint24

    The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)

    tickSpacing

    int24

    The spacing between ticks to be enforced for all pools created with the given fee amount

    user

    address

    The user address that add into white list

    verified

    bool

    fee

    uint24

    whitelistRequested

    bool

    The flag whether should be created by owner only

    enabled

    bool

    The flag is the fee is enabled or not

    import '@uniswap/v2-core/contracts/interfaces/IPancakeFactory.sol';
    pragma solidity =0.5.16;  
    
    interface IPancakeFactory {
        event PairCreated(address indexed token0, address indexed token1, address pair, uint);
         
         function feeTo() external view returns (address);    
         function feeToSetter() external view returns (address);     
         function getPair(address tokenA, address tokenB) external view returns (address pair);    
         
         function allPairs(uint) external view returns (address pair);    
         function allPairsLength() external view returns (uint);     
         function createPair(address tokenA, address tokenB) external returns (address pair);     
         
         function setFeeTo(address) external;    
         function setFeeToSetter(address) external;
    }
    address owner
    address poolDeployer
    mapping(uint24 => int24) feeAmountTickSpacing
    mapping(address => mapping(address => mapping(uint24 => address))) getPool
    mapping(uint24 => struct IPancakeV3Factory.TickSpacingExtraInfo) feeAmountTickSpacingExtraInfo
    constructor(address _poolDeployer) public
    function createPool(address tokenA, address tokenB, uint24 fee) external returns (address pool)
    function setOwner(address _owner) external
    function enableFeeAmount(uint24 fee, int24 tickSpacing) public
    function setWhiteListAddress(address user, bool verified) public
    function setFeeAmountExtraInfo(uint24 fee, bool whitelistRequested, bool enabled) public

    RouterV2

    TradingPostSwap is based on Uniswap v2. Read the Uniswap v2 documentation. For more in-depth information on the core contract logic, read the Uniswap v2 Core whitepaper.

    Contract info

    Contract name: TradingPostRouter

    View on Github

    Contract Address

    Read functions

    WETH

    function WETH() external pure returns (address);

    Returns the canonical address for CAMP: WETH (WETH being a vestige from Ethereum network origins).

    factory

    function factory() external pure returns (address);

    Returns the canonical address for TradingPostFactory

    For explanations of the following, view the .

    getAmountOut

    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut);

    getAmountIn

    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn);

    getAmountsOut

    function getAmountsOut(uint amountIn, address[] memory path) internal view returns (uint[] memory amounts);

    getAmountsIn

    function getAmountsIn(uint amountOut, address[] memory path) internal view returns (uint[] memory amounts);

    quote

    function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB);

    Write functions

    addLiquidity

    Adds liquidity to a BEP20⇄BEP20 pool.

    Name
    Type
    Description

    addLiquidityETH

    Name
    Type

    removeLiquidity

    Name
    Type

    removeLiquidityETH

    Name
    Type

    removeLiquidityETHSupportingFeeOnTransferTokens

    Name
    Type

    removeLiquidityETHWithPermit

    Name
    Type

    removeLiquidityETHWithPermitSupportingFeeOnTransferTokens

    Name
    Type

    removeLiquidityWithPermit

    Name
    Type

    swapETHForExactTokens

    Name
    Type

    swapExactETHForTokens

    Name
    Type

    swapExactETHForTokensSupportingFeeOnTransferTokens

    Name
    Type

    swapExactTokensForETH

    Name
    Type

    swapExactTokensForETHSupportingFeeOnTransferTokens

    Name
    Type

    swapExactTokensForTokens

    Receive as many output tokens as possible for an exact amount of input tokens.

    Name
    Type

    swapExactTokensForTokensSupportingFeeOnTransferTokens

    Receive as many output tokens as possible for an exact amount of input tokens. Supports tokens that take a fee on transfer.

    Name
    Type

    swapTokensForExactETH

    Receive an exact amount of ETH for as few input tokens as possible.

    Name
    Type

    swapTokensForExactTokens

    Receive an exact amount of output tokens for as few input tokens as possible.

    Name
    Type

    Interface

    amountAMin

    uint

    The minimum amount of tokenA to provide (slippage impact).

    amountBMin

    uint

    The minimum amount of tokenB to provide (slippage impact).

    to

    address

    Address of LP Token recipient.

    deadline

    uint

    Unix timestamp deadline by which the transaction must confirm.

    amountETHMin

    uint

    The minimum amount of ETH to provide (slippage impact).

    to

    address

    Address of LP Token recipient.

    deadline

    uint

    Unix timestamp deadline by which the transaction must confirm.

    amountBMin

    uint

    The minimum amount of tokenB to remove (slippage impact).

    to

    address

    Address of LP Token recipient.

    deadline

    uint

    Unix timestamp deadline by which the transaction must confirm.

    to

    address

    Address of LP Token recipient.

    deadline

    uint

    Unix timestamp deadline by which the transaction must confirm.

    to

    address

    Address of LP Token recipient.

    deadline

    uint

    Unix timestamp deadline by which the transaction must confirm.

    to

    address

    Address of LP Token recipient.

    deadline

    uint

    Unix timestamp deadline by which the transaction must confirm.

    approveMax

    bool

    Whether or not the approval amount in the signature is for liquidity or uint(-1).

    v

    uint8

    The v component of the permit signature.

    r

    bytes32

    The r component of the permit signature.

    s

    bytes32

    The s component of the permit signature.

    to

    address

    Address of LP Token recipient.

    deadline

    uint

    Unix timestamp deadline by which the transaction must confirm.

    approveMax

    bool

    Whether or not the approval amount in the signature is for liquidity or uint(-1).

    v

    uint8

    The v component of the permit signature.

    r

    bytes32

    The r component of the permit signature.

    s

    bytes32

    The s component of the permit signature.

    amountETHMin

    uint

    The minimum amount of ETH to remove (slippage impact).

    to

    address

    Address of LP Token recipient.

    deadline

    uint

    Unix timestamp deadline by which the transaction must confirm.

    approveMax

    bool

    Whether or not the approval amount in the signature is for liquidity or uint(-1).

    v

    uint8

    The v component of the permit signature.

    r

    bytes32

    The r component of the permit signature.

    s

    bytes32

    The s component of the permit signature.

    deadline

    uint

    Unix timestamp deadline by which the transaction must confirm.

    deadline

    uint

    Unix timestamp deadline by which the transaction must confirm.

    deadline

    uint

    Unix timestamp deadline by which the transaction must confirm.

    deadline

    uint

    Unix timestamp deadline by which the transaction must confirm.

    deadline

    uint

    Unix timestamp deadline by which the transaction must confirm.

    deadline

    uint

    Unix timestamp deadline by which the transaction must confirm.

    deadline

    uint

    Unix timestamp deadline by which the transaction must confirm.

    deadline

    uint

    Unix timestamp deadline by which the transaction must confirm.

    deadline

    uint

    Unix timestamp deadline by which the transaction must confirm.

    tokenA

    address

    The contract address of one token from your liquidity pair.

    tokenB

    address

    The contract address of the other token from your liquidity pair.

    amountADesired

    uint

    The amount of tokenA you'd like to provide as liquidity.

    amountBDesired

    uint

    The amount of tokenA you'd like to provide as liquidity.

    addLiquidityETH

    uint

    The payable amount in ETH.

    token

    address

    The contract address of the token to add liquidity.

    amountTokenDesired

    uint

    The amount of the token you'd like to provide as liquidity.

    amountTokenMin

    uint

    The minimum amount of the token to provide (slippage impact).

    tokenA

    address

    The contract address of one token from your liquidity pair.

    tokenB

    address

    The contract address of the other token from your liquidity pair.

    liquidity

    uint

    The amount of LP Tokens to remove.

    amountAMin

    uint

    The minimum amount of tokenA to remove (slippage impact).

    token

    address

    The contract address of the token to remove liquidity.

    liquidity

    uint

    The amount of LP Tokens to remove.

    amountTokenMin

    uint

    The minimum amount of the token to remove (slippage impact).

    amountETHMin

    uint

    The minimum amount of ETH to remove (slippage impact).

    token

    address

    The contract address of the token to remove liquidity.

    liquidity

    uint

    The amount of LP Tokens to remove.

    amountTokenMin

    uint

    The minimum amount of the token to remove (slippage impact).

    amountETHMin

    uint

    The minimum amount of ETH to remove (slippage impact).

    token

    address

    The contract address of the token to remove liquidity.

    liquidity

    uint

    The amount of LP Tokens to remove.

    amountTokenMin

    uint

    The minimum amount of the token to remove (slippage impact).

    amountETHMin

    uint

    The minimum amount of ETH to remove (slippage impact).

    token

    address

    The contract address of the token to remove liquidity.

    liquidity

    uint

    The amount of LP Tokens to remove.

    amountTokenMin

    uint

    The minimum amount of the token to remove (slippage impact).

    amountETHMin

    uint

    The minimum amount of ETH to remove (slippage impact).

    tokenA

    address

    The contract address of one token from your liquidity pair.

    tokenB

    address

    The contract address of the other token from your liquidity pair.

    liquidity

    uint

    The amount of LP Tokens to remove.

    amountTokenMin

    uint

    The minimum amount of the token to remove (slippage impact).

    swapETHForExactTokens

    uint

    Payable ETH amount.

    amountOut

    uint

    The amount tokens to receive.

    path (address[])

    address

    An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

    to

    address

    Address of recipient.

    swapExactETHForTokens

    uint

    Payable ETH amount.

    amountOutMin

    uint

    The minimum amount tokens to receive.

    path (address[])

    address

    An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

    to

    address

    Address of recipient.

    swapExactETHForTokensSupportingFeeOnTransferTokens

    uint

    Payable ETH amount.

    amountOutMin

    uint

    The minimum amount tokens to receive.

    path (address[])

    address

    An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

    to

    address

    Address of recipient.

    amountIn

    uint

    Payable amount of input tokens.

    amountOutMin

    uint

    The minimum amount tokens to receive.

    path (address[])

    address

    An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

    to

    address

    Address of recipient.

    amountIn

    uint

    Payable amount of input tokens.

    amountOutMin

    uint

    The minimum amount tokens to receive.

    path (address[])

    address

    An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

    to

    address

    Address of recipient.

    amountIn

    uint

    Payable amount of input tokens.

    amountOutMin

    uint

    The minimum amount tokens to receive.

    path (address[])

    address

    An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

    to

    address

    Address of recipient.

    amountIn

    uint

    Payable amount of input tokens.

    amountOutMin

    uint

    The minimum amount tokens to receive.

    path (address[])

    address

    An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

    to

    address

    Address of recipient.

    amountOut

    uint

    Payable amount of input tokens.

    amountInMax

    uint

    The minimum amount tokens to input.

    path (address[])

    address

    An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

    to

    address

    Address of recipient.

    amountOut

    uint

    Payable amount of input tokens.

    amountInMax

    uint

    The maximum amount tokens to input.

    path (address[])

    address

    An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

    to

    address

    Address of recipient.

    Uniswap v2 Internal Functions documentation
    function addLiquidity(  address tokenA,  address tokenB,  uint amountADesired,  uint amountBDesired,  uint amountAMin,  uint amountBMin,  address to,  uint deadline) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(  address token,  uint amountTokenDesired,  uint amountTokenMin,  uint amountETHMin,  address to,  uint deadline) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(  address tokenA,  address tokenB,  uint liquidity,  uint amountAMin,  uint amountBMin,  address to,  uint deadline) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(  address token,  uint liquidity,  uint amountTokenMin,  uint amountETHMin,  address to,  uint deadline) external returns (uint amountToken, uint amountETH);
    function removeLiquidityETHSupportingFeeOnTransferTokens(  address token,  uint liquidity,  uint amountTokenMin,  uint amountETHMin,  address to,  uint deadline) external returns (uint amountETH);
    function removeLiquidityETHWithPermit(  address token,  uint liquidity,  uint amountTokenMin,  uint amountETHMin,  address to,  uint deadline,  bool approveMax, uint8 v, bytes32 r, bytes32 s) external returns (uint amountToken, uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(  address token,  uint liquidity,  uint amountTokenMin,  uint amountETHMin,  address to,  uint deadline,  bool approveMax, uint8 v, bytes32 r, bytes32 s) external returns (uint amountETH);
    function removeLiquidityWithPermit(  address tokenA,  address tokenB,  uint liquidity,  uint amountAMin,  uint amountBMin,  address to,  uint deadline,  bool approveMax, uint8 v, bytes32 r, bytes32 s) external returns (uint amountA, uint amountB);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)  external  payable  returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)  external  payable  returns (uint[] memory amounts);
    function swapExactETHForTokensSupportingFeeOnTransferTokens(  uint amountOutMin,  address[] calldata path,  address to,  uint deadline) external payable;
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)  external  returns (uint[] memory amounts);
    function swapExactTokensForETHSupportingFeeOnTransferTokens(  uint amountIn,  uint amountOutMin,  address[] calldata path,  address to,  uint deadline) external;
    function swapExactTokensForTokens(  uint amountIn,  uint amountOutMin,  address[] calldata path,  address to,  uint deadline) external returns (uint[] memory amounts);
    function swapExactTokensForTokensSupportingFeeOnTransferTokens(  uint amountIn,  uint amountOutMin,  address[] calldata path,  address to,  uint deadline) external;
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)  external  returns (uint[] memory amounts);
    function swapTokensForExactTokens(  uint amountOut,  uint amountInMax,  address[] calldata path,  address to,  uint deadline) external returns (uint[] memory amounts);
    import '@uniswap/v2-core/contracts/interfaces/ITradingPostRouter.sol';
    pragma solidity >=0.6.2; 
    
    interface ITradingPostRouter01 {
        function factory() external pure returns (address);
        function WETH() external pure returns (address);     
        function addLiquidity(
                address tokenA,        
                address tokenB,        
                uint amountADesired,        
                uint amountBDesired,        
                uint amountAMin,        
                uint amountBMin,        
                address to,        
                uint deadline
        ) external returns (uint amountA, uint amountB, uint liquidity);
        function addLiquidityETH(
                address token,        
                uint amountTokenDesired,        
                uint amountTokenMin,        
                uint amountETHMin,        
                address to,        
                uint deadline    
        ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
        function removeLiquidity(
                address tokenA,        
                address tokenB,        
                uint liquidity,        
                uint amountAMin,        
                uint amountBMin,        
                address to,        
                uint deadline
        ) external returns (uint amountA, uint amountB);    
        function removeLiquidityETH(
                address token,        
                uint liquidity,        
                uint amountTokenMin,        
                uint amountETHMin,        
                address to,        
                uint deadline
       ) external returns (uint amountToken, uint amountETH);    
       function removeLiquidityWithPermit(
               address tokenA,
               address tokenB,        
               uint liquidity,        
               uint amountAMin,        
               uint amountBMin,        
               address to,        
               uint deadline,        
               bool approveMax, uint8 v, bytes32 r, bytes32 s
       ) external returns (uint amountA, uint amountB);    
       function removeLiquidityETHWithPermit(
               address token,        
               uint liquidity,        
               uint amountTokenMin,        
               uint amountETHMin,        
               address to,        
               uint deadline,        
               bool approveMax, uint8 v, bytes32 r, bytes32 s
       ) external returns (uint amountToken, uint amountETH);    
       function swapExactTokensForTokens(        
               uint amountIn,        
               uint amountOutMin,        
               address[] calldata path,        
               address to,        
               uint deadline
       ) external returns (uint[] memory amounts);    
       function swapTokensForExactTokens(
               uint amountOut,        
               uint amountInMax,        
               address[] calldata path,        
               address to,        
               uint deadline
       ) external returns (uint[] memory amounts);    
       function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)        
               external        
               payable        
               returns (uint[] memory amounts);
       function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)        
                external        
                returns (uint[] memory amounts);    
       function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
                 external        
                 returns (uint[] memory amounts);    
       function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)        
                  external        
                  payable        
                  returns (uint[] memory amounts);     
       function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);    
       function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);    
       function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);    
       function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);    
       function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);} 
       
     // File: contracts\interfaces\ITradingPostRouter02.sol pragma solidity >=0.6.2;
     
    interface ITradingPostRouter02 is ITradingPostRouter01 {    
            function removeLiquidityETHSupportingFeeOnTransferTokens(
                    address token,        
                    uint liquidity,        
                    uint amountTokenMin,        
                    uint amountETHMin,        
                    address to,        
                    uint deadline
            ) external returns (uint amountETH);
            function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(                                
                    address token,        
                    uint liquidity,        
                    uint amountTokenMin,        
                    uint amountETHMin,        
                    address to,        
                    uint deadline,        
                    bool approveMax, uint8 v, bytes32 r, bytes32 s    
            ) external returns (uint amountETH);     
            function swapExactTokensForTokensSupportingFeeOnTransferTokens(
                    uint amountIn,        
                    uint amountOutMin,        
                    address[] calldata path,        
                    address to,        
                    uint deadline
            ) external;    
            function swapExactETHForTokensSupportingFeeOnTransferTokens(
                    uint amountOutMin,        
                    address[] calldata path,        
                    address to,        
                    uint deadline
            ) external payable;    
            function swapExactTokensForETHSupportingFeeOnTransferTokens(
                    uint amountIn,        
                    uint amountOutMin,        
                    address[] calldata path,        
                    address to,        
                    uint deadline
            ) external;
    }