# Welcome

GnoSwap is the first decentralized exchange (DEX) built using [Gnolang](https://gno.land/gnolang) – an interpreted variation of the widely-used Go programming language (Golang) that powers the Gnoland blockchain ecosystem. As an automated market maker (AMM) protocol, GnoSwap features an innovative [concentrated liquidity mechanism](/core-concepts/amm/concentrated-liquidity). This mechanism empowers GnoSwap to offer deeper liquidity for trading pairs, resulting in lower slippage and better trading prices for traders, while also generating more fees for liquidity providers.

Enter the most user-friendly and simple decentralized finance (DeFi) experience where you can seamlessly swap and earn on the most capital-efficient liquidity layer of Gnoland.

<figure><img src="/files/BZyzJ5nvIhW7ql9LSw4p" alt=""><figcaption></figcaption></figure>

**For traders,** GnoSwap provides a quality trading experience powered by the performance it inherits from Gnoland and a trader-centric interface designed to deliver valuable insights into the market. Furthermore, GnoSwap offers an opportunity to become the earliest adopter of aspiring projects building on Gnoland, which we believe has the potential to become one of the most widely adopted smart contracts platforms in the world with its developer-oriented design philosophy. Lastly, GnoSwap is built with interoperability in mind to remove any friction involved in exchanging bridged tokens from external ecosystems.

<figure><img src="/files/GqKYxDVbl4FyuMV213si" alt=""><figcaption></figcaption></figure>

**For liquidity providers,** the concentrated liquidity mechanism of GnoSwap enhances the capital efficiency of tokens in pools to amplify their earnings with higher trading fee rewards. GnoSwap introduces a novel liquidity mining model that incorporates [Warm-up Periods](/core-concepts/liquidity-mining#warm-up-periods), a concept for rewarding long-term position stakers for their staking commitment, while also offering flexibility to unstake their positions at any time to adjust price range for higher concentration. As a whole, GnoSwap emerges as the optimal platform for liquidity providers to maximize the potential of their capital.

<figure><img src="/files/NgipJGO9SyNr6wy5w9aJ" alt=""><figcaption></figcaption></figure>

**For dApps,** GnoSwap is a non-custodial and secure liquidity infrastructure powered by the secure Gnolang, devoid of a single point of failure risks of centralized exchanges. Deployment of liquidity pools is permissionless on GnoSwap to allow any project to provide its community with a place to trade tokens instantly upon launch. The interactive launchpad feature of GnoSwap also allows nascent teams to build a strong potential user base while gaining full exposure across the Gnoland ecosystem.


# Why GnoSwap?

GnoSwap is committed to bringing censorship-resistant, non-custodial, and secure financial infrastructure to Gnoland, a performant, developer-friendly layer 1 powered by the [GnoVM](https://github.com/gnolang/gno/tree/master/gnovm) and [Tendermint2](https://github.com/gnolang/gno/tree/master/tm2), poised to serve as a secure hub for smart contracts. As its first DEX, GnoSwap specializes in seamless liquidity sourcing and exchange of tokens on Gnoland, offering the following key value propositions:

### **Deep Liquidity**

The AMM of GnoSwap adopts[ concentrated liquidity](/core-concepts/amm/concentrated-liquidity), which enables liquidity providers to select a price range only in which their liquidity will be active. This allows for higher capital efficiency – up to a [maximum of 20,000x](https://blog.uniswap.org/uniswap-v3#capital-efficiency) compared to traditional AMMs such as the [Constant Product Market Maker (CPMM)](/core-concepts/amm/constant-product-market-maker), resulting in significantly more liquid markets for traders. Multiple incentivization schemes exist on GnoSwap including liquidity mining and external rewards to ensure continuous liquidity provision.

### **Gnoland-Native**

GnoSwap is native to Gnoland, built from the ground up in [Gnolang](https://gno.land/gnolang). This implies that GnoSwap fully benefits from the advantages of Gnoland such as high performance, transparency, interoperability, and simplicity – all of which are vital to building a reliable decentralized financial infrastructure. In addition, smart contracts that power GnoSwap are seamlessly composable with other DeFi applications on Gnoland, opening up possibilities for other projects to leverage or build upon the liquidity of Gnoswap.

### **Intuitive & User-Centric Interface**

GnoSwap is designed to streamline the user experience by abstracting away the complexity involved in liquidity provision and staking. Each element of the web application has been carefully shaped to make the interface as intuitive and informative as possible. Additionally, to facilitate a simple onboarding experience for new users, GnoSwap provides step-by-step visual guides that cover everything users need to know in order to maximize the protocol's potential. For advanced traders, GnoSwap provides an extensive and comprehensive pool of real-time information about behaviors and stats of tokens and pools to help analyze the market.

### **Flexible & Customizable**

GnoSwap is designed to offer flexibility to both traders and liquidity providers. Swaps on GnoSwap are automatically routed through multiple pools, removing the need for traders to manually perform multiple swaps to obtain the desired token as the output. Liquidity pools on GnoSwap allow liquidity providers to customize the fee tier and the price range, enabling the optimization of pool configurations based on the expected behavior of assets within each pool.

### **Non-Custodial**

GnoSwap aims to provide a secure exchange protocol for anyone. Unlike centralized exchanges, none of the tokens on GnoSwap are stored in a wallet controlled by a single entity. Instead, GnoSwap is completely non-custodial, where tokens for providing liquidity are kept in smart contracts which only the depositor has access to, and the balance of traders always remains in their own wallets. Furthermore, GnoSwap is a decentralized protocol, meaning that it is owned and governed by xGNS holders who earn their share of the protocol by staking $GNS.

### **Vision Driven**

GnoSwap was launched with a vision to achieve complete decentralization of finance by harnessing the power of Gnoland. As a part of our commitment, we are building the GnoSwap AMM as the base layer that will serve as the de facto liquidity infrastructure of Gnoland, and expanding upon that foundation to build advanced features that will bring advanced financial primitives such as leveraged trading and perpetual futures, inviting anyone to own and operate customizable liquidity pools with any tokens.


# Disclaimer


# General Disclaimer

#### 1. Overview

Please read this section carefully. The following information is provided for informational purposes only and is not intended as legal, financial, business, or tax advice. You should consult your own professional advisors before participating in any activities related to the GnoSwap project or GNS tokens. Neither the company issuing GNS tokens (hereafter referred to as "the Company"), any team members who contributed to the development of GnoSwap (the "GnoSwap Team"), nor any affiliated vendors or service providers shall be held liable for any damages or losses arising from access to this document, the website at[ http://gnoswap.io/](http://gnoswap.io/), or any related materials. Users must perform their own due diligence and independently verify the accuracy and completeness of all information provided in this document and on the website. You must read and agree to our [Terms of Use](https://gnoswap.io/terms) and [Privacy Policy](https://gnoswap.io/privacy), available on the website, before using GnoSwap.

#### 2. Project Purpose

By acquiring GNS tokens, you agree to participate in the GnoSwap ecosystem and utilize its services. The Company and its affiliates contribute to the underlying source code of GnoSwap. However, the Company acts solely as a facilitator in the distribution of GNS tokens and does not provide financial advice or assume any fiduciary responsibility in connection with the token distribution. The Company's role is limited to the facilitation of the token distribution and the maintenance of technical infrastructure. It assumes no responsibility for financial outcomes or governance decisions.

#### 3. Decentralized Governance

GnoSwap is governed by GNS token holders through a decentralized governance model. The Company and its team do not control the day-to-day operations, decisions, or outcomes of the GnoSwap platform. Governance decisions are determined by the GNS community, and such decisions may be beyond the Company’s control. The Company disclaims any responsibility for the outcomes of decisions made by GNS token holders. The Company expressly renounces any authority or ability to override or influence governance decisions made by the GNS community.

#### 4. Nature of this Document

This document, along with any content on the associated website, is intended for informational purposes only and does not constitute an offer of securities, investment solicitation, or any contractual relationship. The Company reserves the right to update or amend this content at any time without prior notice. While the Company reserves the right to update or amend this content at any time, users will be notified of material updates through the website or other appropriate channels.

#### 5. Token Documentation

Nothing in this document or on the website constitutes an offer to sell GNS tokens. Any decision to acquire GNS tokens is subject to the [Terms ](https://gnoswap.io/terms)[of Use](https://gnoswap.io/terms) applicable to all GnoSwap platform users. The Terms of Use govern the relationship between the Company, the platform, and GNS token holders, and should be reviewed carefully before acquiring GNS tokens. In the event of any conflict between this document and the Terms of Use, the Terms of Use shall prevail.

#### 6. User Responsibility

By using the GnoSwap platform and acquiring GNS tokens, you acknowledge that you are solely responsible for your decisions. It is your responsibility to fully understand the risks, functionalities, and applicable legal frameworks related to GnoSwap and any associated digital assets. The Company disclaims responsibility for the consequences of any user decisions. The Company disclaims liability for all consequences arising from user decisions, including but not limited to errors, misunderstandings, or negligence on the part of the user. Users agree to indemnify and hold harmless the Company, its affiliates, and its team members from any claims, damages, or losses arising from their use of the platform or acquisition of GNS tokens.

#### 7. Market Risks

Digital assets, including GNS tokens, are subject to significant market volatility and risk. There is no guarantee of liquidity, stability, or the future value of GNS tokens. The Company makes no representations or assurances regarding the current or future value of GNS tokens. Any statements or promotional materials regarding GNS tokens are for informational purposes only and should not be construed as guarantees of performance, value, or liquidity.

#### 8. Smart Contract Risks

The GnoSwap platform operates through smart contracts deployed on the gno.land blockchain. These smart contracts may carry inherent technical risks, including bugs, vulnerabilities, or unintended behaviors. While the GnoSwap Team conducts audits and security reviews of its smart contracts, the Company cannot be held liable for losses arising from exploits, errors, or failures within these contracts. While the GnoSwap Team conducts audits and testing, no guarantee is made regarding the completeness or effectiveness of such reviews.

#### 9. Compliance with Local Laws

It is the responsibility of users to ensure that their participation in the GnoSwap platform complies with all applicable laws and regulations in their respective jurisdictions. It is the user's sole responsibility to verify the legality of their participation. The Company reserves the right to restrict access or services to users from jurisdictions where participation is prohibited or restricted. The Company assumes no liability for any legal or regulatory consequences that may arise from users’ activities on the platform or their acquisition of GNS tokens.

#### 10. Acknowledgments

By accessing this document or the website, you acknowledge that:

* You are not relying on any statements made in this document for your decision to acquire GNS tokens.
* GNS tokens may have no intrinsic value, and there is no guarantee of their future value or liquidity.
* Participation in the token distribution is restricted for residents of certain jurisdictions, including but not limited to the United States and China, where such activities are regulated or prohibited.
* No promises are made regarding the future performance or liquidity of GNS tokens.

#### 11. Forward-Looking Statements

This document and related materials may contain forward-looking statements that involve risks and uncertainties. Forward-looking statements reflect current expectations but are subject to significant uncertainties, and no guarantees are made as to their accuracy or realization. These statements are based on current expectations and are subject to change as circumstances evolve. The Company assumes no obligation to update or revise any forward-looking information.

#### 12. Translations and Conflicts

This document may be translated into other languages for reference purposes. In the event of any discrepancies between the English version and any translated version, the English version shall prevail. In case of discrepancies, the English version shall govern, particularly for legal and technical terms that may have no direct equivalent in other languages.<br>


# Risk and Security

#### 1. Overview

All participants who read this guidance are deemed to have understood and agreed to its contents. GnoSwap is a decentralized application (DApp) built on the gno.land blockchain. Users of GnoSwap can access various functions, including cryptocurrency exchanges, liquidity provision, staking, and governance participation. Users must carefully review the GnoSwap documentation and ensure they understand the operational procedures before accessing the platform.

#### 2. Asset Send and Receive Risks

GnoSwap is a decentralized platform, which means GnoSwap Labs Inc. does not have access to or control over users’ assets or transaction processes. Users must verify and double-check all details before sending assets, as blockchain transactions are irreversible once signed. Users must utilize compatible wallets that support gno.land blockchain assets and ensure they have sufficient native tokens to cover gas fees. Tokens from other blockchains must be properly bridged into gno.land-compatible assets before use. Users acknowledge and accept all risks associated with asset transfers, including potential loss during bridging processes due to delays, errors, or malfunctions.

#### 3. Transaction Signing Risks

Users must verify transaction details before signing any transactions. Signing a transaction through GnoSwap involves authorizing irreversible actions on the blockchain, such as swaps, liquidity provision, staking, and more. GnoSwap Labs Inc. advises users to only sign transactions from trusted sources, as malicious phishing attempts may seek to compromise user wallets. Users are solely responsible for verifying the authenticity of transaction sources and should exercise caution before interacting with any contracts or platforms.

#### 4. Risk of Impermanent Loss

Users providing liquidity to GnoSwap acknowledge the potential for impermanent loss, which occurs when the value of tokens deposited into a liquidity pool changes relative to their initial price. Users should carefully assess their risk tolerance before providing liquidity, as impermanent loss could result in a reduction—or total loss—of assets over time.

#### 5. Risk of Staking and Delegating

Users should be aware of the risks involved in staking or delegating tokens for rewards. Staking may offer benefits, but it also involves risks, including the potential loss of principal and the fluctuation of token values. When users stake or delegate GNS tokens on GnoSwap, their assets are locked in the protocol for a designated period. During this time, market volatility could impact the value of staked assets, and early withdrawal may incur penalties. Additionally, rewards are not guaranteed and may be affected by network conditions, platform performance, or unforeseen issues with the gno.land blockchain. Users are responsible for understanding these risks before staking or delegating.

#### 6. Governance Risks

The GnoSwap platform operates under decentralized governance, controlled by GNS token holders. While this system offers community participation, it also exposes users to governance-related risks. Governance decisions or proposals may not always align with the best interests of all users, and malicious actors could attempt to influence proposals for harmful purposes. Users participating in governance must carefully evaluate proposals and recognize that governance changes could impact the platform’s security, functionality, and financial stability.

#### 7. Risks in Other Features

GnoSwap offers additional features, such as:

* Incentivize Pool: A permissionless incentivization program where users can add incentives for specific pools. Users should note that rewards may fluctuate or become unsustainable due to project failure, platform issues, market conditions, or other unforeseen factors.
* Launchpad: A feature to support gno.land-based projects by allowing users to deposit GNS tokens. Launchpad carries risks, including potential project failure, fraudulent activities, and market volatility affecting the future value of tokens from supported projects. GnoSwap does not guarantee the success or profitability of any project listed on its Launchpad. Users are advised to conduct thorough research before participating.

#### 8. Limitation of Liability

Users must carefully assess the risks of each transaction within GnoSwap, proceeding at their own discretion. GnoSwap provides information to assist users but does not offer investment advice.

* No Liability for Losses: GnoSwap Labs Inc. is not liable for any losses or damages resulting from security vulnerabilities, asset theft, hacking, or exploits, including flash loan attacks.
* Third-Party Services: GnoSwap Labs Inc. is not responsible for issues arising from third-party services or platforms, including the gno.land blockchain and any integrated third-party services. Service interruptions or errors from these entities are beyond the control of GnoSwap Labs Inc.
* No Developer Liability: No developer or entity involved in the creation or maintenance of GnoSwap is liable for damages or claims related to user transactions on the platform.


# Getting Started


# Create an Account


# Adena Wallet

The standard way to connect to GnoSwap is using Adena, the flagship wallet of Gnoland. This process involves downloading a third-party Chrome extension app and creating a new account on the Gnoland blockchain. Follow the guide below to learn how to set up an account in Adena wallet.

## Installing Adena

### **1. Visit the official Adena website**

Click on [this link](https://adena.app/) to visit the official download section on the Adena website. Click on the download link for your browser.

<figure><img src="/files/X1wroc9W7iCRwoDXvKtJ" alt=""><figcaption></figcaption></figure>

### **2. Download the Chrome extension**

Once the official download page for the Adena extension app on the Chrome Webstore opens up, click on **Add to Chrome**.

<figure><img src="/files/rfvMoPcvRhi7OrcJ4ZXd" alt=""><figcaption></figcaption></figure>

### **3. Confirm the installation**

A pop-up that asks you to confirm the installation will appear. Click on **Add extension** to proceed.

<figure><img src="/files/syYmgo9NmCaAhshHtlxT" alt=""><figcaption></figcaption></figure>

## Signing In

Adena supports multiple sign-in methods. Choose an option that best fits you, and click on its link from the list below to visit the official Adena documentation page for a detailed guide on how to set up an account.

* [Sign In With Google](https://docs.adena.app/user-guide/sign-in/advanced-options/sign-in-with-google)
* [Create New Wallet](https://docs.adena.app/user-guide/sign-in/advanced-options/create-new-wallet)
* [Import Wallet](https://docs.adena.app/user-guide/sign-in/advanced-options/import-wallet)
* [Connect Ledger](https://docs.adena.app/user-guide/sign-in/connect-hardware-wallet/ledger)

Once your account is set up, you're all set to get started!


# Social Login

{% hint style="warning" %}
**Important Notice**

Social login methods provide a convenient way to use GnoSwap, simplifying the complex wallet creation process. However, this method limits wallet functionalities to basic actions, such as viewing and transferring assets or signing transactions. To access the full range of functionalities, such as exporting your key or changing networks, you need to install [Adena](/user-guide/getting-started/create-an-account/adena-wallet) and log in with the same social. We recommend **keeping only a small amount of tokens in accounts accessed via social login** until you have securely saved your key in a safe location. We recommend **using Adena or other wallets to fully own and use your account.**
{% endhint %}

{% hint style="info" %}
**How does this work?**

GnoSwap has integrated with Web3Auth, a key management infrastructure provider that relies on multi-party computation (MPC). Simply put, Web3Auth splits your keys between its nodes and lets you retrieve them with your Social Account. The Web3Auth Social Login is a non-custodial service, meaning that no single party ever has access to your keys. If you'd like to learn more about Web3Auth, visit their [website](https://web3auth.io/).
{% endhint %}

The convenient way to create an account is by using the Social Login feature available directly on the GnoSwap Web Application.

By default, GnoSwap allows you to sign in using your Google account or your X (Twitter) account. Clicking on either option will prompt you to continue on their websites to sign in. Once you successfully sign in, you will be instantly connected to GnoSwap with your newly created Gnoland account bound to your social login credentials.

<figure><img src="/files/lF8vh4irUcSrTLOGuPSc" alt=""><figcaption></figcaption></figure>

Alternatively, you can sign in using any other email provider you're using. Manually enter your email address and click on the arrow button to continue.

<figure><img src="/files/J9vuKAth19dPSP1mZVmG" alt=""><figcaption></figcaption></figure>

You will be prompted to enter a 6-digit code sent to your inbox. Once you enter the code, you'll be signed in and connected to GnoSwap.

<figure><img src="/files/3qbNdFtfhmZK9xVJN1FP" alt=""><figcaption></figcaption></figure>


# Connect to GnoSwap

Once your account is set up, visit the official GnoSwap Web Application.

### **1. Click on Connect Wallet**

Locate the header and click on the **Connect Wallet** button to connect your wallet.

<figure><img src="/files/I3AQm25jAMzzuP5eMjdL" alt=""><figcaption></figcaption></figure>

### **2. Choose a wallet**

A pop-up that allows you to choose a wallet will appear. Click on the one you'd like to continue with. If you're signing in using your Social Login account, complete the login process in the popups and skip to Step 4.

<figure><img src="/files/mt6RAnbJcUzUYsqwv9F5" alt=""><figcaption></figcaption></figure>

### **3. Approve the connection**

Once you click on Adena from the list, Adena will open up a web page requesting your approval on a new window. Click on **Connect** to continue.

{% hint style="warning" %}
**Beware of fake websites!**

We're seeing an increase in scammers deceiving users to connect to a fake website to steal funds. Adena lets you confirm the legitimacy of the website by displaying the domain of the website you're connecting to below the logo. Make sure that you're connecting to **gnoswap.io** before clicking on **Connect**.
{% endhint %}

<figure><img src="/files/ZUNT0iSoeeZJwTD6NCaT" alt=""><figcaption></figcaption></figure>

### **4. Confirm your connection**

Once you successfully connect your Adena account to GnoSwap, your account address will be displayed in the top right corner.

<figure><img src="/files/wjvio1ehqNR9NcJ9tSWr" alt=""><figcaption></figcaption></figure>

### **5.** **Manage your connected account**

Click on the **Down Arrow** in your connected wallet section to manage your account. The expanded wallet section will allow you to copy your address, view your account on Gnoscan, or disconnect from GnoSwap. You may also switch to day mode if you prefer lighter backgrounds.

<figure><img src="/files/aiN1pLKV6piMcRjMNAaE" alt=""><figcaption></figcaption></figure>


# Quick Tour

Once you're connected, let's take a brief tour of GnoSwap to help you get familiar with where to find what you're looking for.

### **1. Main page**

The Main page is where you land once you connect to the GnoSwap website. Discover trending tokens, the most profitable pools, and the platform statistics. Further below, find a full list of tokens on Gnoland.

<figure><img src="/files/wjvio1ehqNR9NcJ9tSWr" alt=""><figcaption></figcaption></figure>

### **2. Swap**

Seamlessly trade tokens in the Swap menu. GnoSwap's Auto Router optimizes your trade by running calculations through all available liquidity pools to help you find the best quote.

To learn more about the GnoSwap AMM, check out [this session](/core-concepts/amm/concentrated-liquidity).

<figure><img src="/files/DuIoF0pLSxB4kZrWqh0e" alt=""><figcaption></figcaption></figure>

### **3. Earn**

Keep track of your positions and all of the liquidity pools available on GnoSwap. Earn swap fees by providing liquidity, and maximize your rewards by staking your positions. The cards highlighted with a blue border indicate your staked positions under **My Positions** and the pools in which you staked positions under **Incentivized Pools**. Additionally, if you're a project builder, you can create your own liquidity pool with any GRC20 tokens and incentivize it to bootstrap liquidity.

Check out our [Positions ](/core-concepts/positions)and [Liquidity Mining](/core-concepts/liquidity-mining) pages to learn more about the Earn activities.

<figure><img src="/files/JNwXcfbxqM3ZMIXIIsM5" alt=""><figcaption></figcaption></figure>

### **4. Portfolio**

Managing your assets at a glance. A detailed breakdown of your balance helps you keep track of your holdings. Deposit or withdraw tokens with a simple interface.

<figure><img src="/files/1SEJ9pEEzBZLKz8mL7cT" alt=""><figcaption></figcaption></figure>

### **5. Explore**

Discover the key statistics of Gnoswap including Total Value Locked (TVL), total trading volume, latest transactions, and more.

<figure><img src="/files/PK5sd2Wult1YQlI9byKv" alt=""><figcaption></figcaption></figure>

### **6. Launchpad**

Tap into the "lossless" token launch experience on GnoSwap, powered by its innovative yield-redirection mechanism leveraging the Protocol Fees earned from the xGNS Staking Contract.

To learn more about Launchpad, check out [this session](/core-concepts/launchpad).

<figure><img src="/files/SyL1E8AJLFpKtwsgSOgQ" alt=""><figcaption></figcaption></figure>

### **7. Governance**

Delegate your $GNS to earn xGNS, which gives you voting power in GnoSwap Governance and a share of Protocol Fees. You may also help shape the future of GnoSwap by creating or voting on governance proposals.

To learn more about Governance, check out [this session](/core-concepts/governance).

<figure><img src="/files/Cs6wy0Ge0anx2MMhGOwx" alt=""><figcaption></figcaption></figure>


# Trading


# Swap Tokens

### **1. Locate the Swap menu**

Click on **Swap** on the header to visit the **Swap** page.

<figure><img src="/files/Fs7JkIhjxhTr0VBIoFM7" alt=""><figcaption></figcaption></figure>

### **2. Set up your swap**

Choose the pair you wish to swap and specify the amount of tokens to sell or buy. Once you enter a valid amount, details of the swap will appear at the bottom of the screen. Note that the recent price action of each token and latest swaps will appear on the right side.

{% hint style="info" %}
**Purchasing the exact desired amount**

You may sometimes end up with fewer tokens compared to the amount displayed in the modal due to price fluctuations. You can specify the number of tokens to purchase by manually editing the bottom side of the modal. This will automatically calculate the number of tokens you need to sell to obtain your desired amount.
{% endhint %}

{% hint style="info" %}
**Sharing a swap link**

Generate a link to the Swap page with the selected token(s) by clicking on the link icon on the top right of the Swap modal. This allows project owners to share a link that takes users directly to the Swap page with their tokens selected.
{% endhint %}

<figure><img src="/files/DuIoF0pLSxB4kZrWqh0e" alt=""><figcaption></figcaption></figure>

### **3. Set your slippage tolerance**

Click on the **Settings Icon** to configure your slippage limit to avoid unexpected price swings. Then, click on **Swap** to proceed.

{% hint style="info" %}
**What does slippage mean?**

Trades on GnoSwap are executed on-chain, meaning that it takes a few seconds for the Gnoland blockchain to process your trade after you submit your swap transaction. During a volatile market, the actual amount of tokens you end up receiving may vary due to price fluctuations. This phenomenon is known as **slippage**. You can prevent this by manually setting your slippage tolerance.
{% endhint %}

<figure><img src="/files/xKJtduB6p2lFYi0ejKUc" alt=""><figcaption></figcaption></figure>

### **4. Confirm your swap**

Carefully review the details of your swap to ensure that all of the displayed information is correct. Then, click on **Confirm Swap** to continue.

<figure><img src="/files/l50or4dp8QdctSJRrTE0" alt=""><figcaption></figcaption></figure>

### **5. Approve the transaction on Adena**

A pop-up from Adena will appear in a new window, prompting you to approve the transaction. Click on **Approve** to proceed.

<figure><img src="/files/JleaagohnYh7hWoobxLV" alt=""><figcaption></figcaption></figure>

### **6. Review your swap**

Wait a few seconds for your transaction to be broadcast to the blockchain. A notification will appear once it's complete. You can either return to the **Swap** menu by clicking on **Close** or view details of the transaction on Gnoscan by clicking on **View transaction**.

<figure><img src="/files/jj6ZRQjQxy2SAx5499tD" alt=""><figcaption></figcaption></figure>


# Swap With Details

### **1. Visit the Token Details page**

Click on any token on the Main page to visit the **Token Details** page.

<figure><img src="/files/8zSuyQtoyzo2opOKGtVf" alt=""><figcaption></figcaption></figure>

### **2. Explore the page**

Discover detailed information about the featured token, including a price chart, its recent price performance, market insights, and information about the project.

<figure><img src="/files/uz3z9vdowz8aGIO5Almq" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/yyw8w4lcVFAsT34g5TM5" alt=""><figcaption></figcaption></figure>

### **3. Swap the featured token**

Use the Swap modal on the top right to swap the token. If you change the featured token to another, you will be redirected to the page of the newly selected token.

<figure><img src="/files/W0wuZRZPZTOed65Y9y5E" alt=""><figcaption></figcaption></figure>


# Providing Liquidity


# Create a Pool

### **1. Click on New Position**

Navigate to the Earn menu and click on **New Position** on the top right side of the page.

<figure><img src="/files/JNwXcfbxqM3ZMIXIIsM5" alt=""><figcaption></figcaption></figure>

### **2. Select a pair**

Select a pair of tokens. Customize your pool by selecting one of the four fee tiers available.

<figure><img src="/files/OMggtYpUThr4gLhX9Ccj" alt=""><figcaption></figcaption></figure>

### **3. Enter a starting price**

Enter a starting price for your pool. Choosing a reasonable price similar to the market rates is important to avoid capital loss caused by arbitrageurs.

{% hint style="info" %}
**How does an unreasonable starting price result in capital loss?**

The starting price will decide the ratio of tokens to be deposited in the pool. If the price of a token is much higher than the market rates, arbitrageurs will purchase the tokens from external sources and sell them in your pool for profit. This is equivalent to you purchasing the token at an unreasonably high price, which may result in a net loss of your position's value.
{% endhint %}

<figure><img src="/files/dpKgQwd6E0CtiuAF0Gfh" alt=""><figcaption></figcaption></figure>

### **4. Set a price range**

Enter the **Min Price** and the **Max Price** for your price range. Note that the pool will be available for trading only if the starting price is placed within the price range. If you want your pool to be available for trading at all times, click on the Full Price Range button below to provide liquidity to the entire price range from 0 to ∞.

<figure><img src="/files/rHk8gXbxoAFoqcmk5pgj" alt=""><figcaption></figcaption></figure>

### **5. Enter amounts**

Enter the amount of tokens you'd like to deposit. Filling out one side of the pair will automatically calculate the amount of the opposite side, based on the current price of the pool and your price range.

<figure><img src="/files/94185QfwPOICKigR4sWZ" alt=""><figcaption></figcaption></figure>

### **6. Preview your transaction**

Review your transaction to ensure that all of the displayed information is correct. A pool creation fee of 100 $GNS exists for spam prevention purposes.

<figure><img src="/files/G37ATdpwIEiRfuSAu4Xr" alt=""><figcaption></figcaption></figure>

### **7. Approve the transaction on Adena**

A pop-up from Adena will appear in a new window, prompting you to approve the transaction. Click on **Approve** to proceed.

<figure><img src="/files/scHk9un7PW0P2TqbcvRv" alt=""><figcaption></figcaption></figure>

### **8. Check your pool**

Once your transaction is complete, use the search feature in the header to find your newly created pool.

{% hint style="info" %}
**Displaying Price Information**

GnoSwap only displays price information about tokens that meet the TWAP criteria. Until then, all of the price-related data will be displayed as `-` . Learn more about the TWAP criteria in [this section](/references/twap).
{% endhint %}

<figure><img src="/files/vJFL2PrHfnFwdz3xWtE2" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/zHf6dC7xq3mHDyha8IlG" alt=""><figcaption></figcaption></figure>


# Create a Position

### **1. Click on New Position**

In the **Earn** menu, click on **New Position** at the top right side of the page. Alternatively, you can click on one of the pools from the list or the cards below to skip to Step 3.

<figure><img src="/files/JNwXcfbxqM3ZMIXIIsM5" alt=""><figcaption></figcaption></figure>

### **2. Select a pool**

Select a pair of tokens and the fee tier of the pool that you will add liquidity in.

<figure><img src="/files/kHmXj5cDwW9OnRcqQAzn" alt=""><figcaption></figcaption></figure>

### **3. Set a price range**

GnoSwap offers three options for liquidity providers:

* **Active**: An aggressive range of \[-10% \~ +10%] for higher risks & returns.
* **Passive**: A passive range of \[-50% \~ +100%] for moderate risks & returns.
* **Custom**: A customizable price range that enables you to select a Min Price and a Max Price.

{% hint style="info" %}
**How do price ranges work?**

GnoSwap offers concentrated liquidity, which allows liquidity providers (LPs) to select a specific price range in which their tokens become available for trading. Experienced LPs will select a price range where trading activities are most active to maximize their trading fee rewards. GnoSwap offers a set of pre-configured ranges to help beginners who aren't experienced in building their own strategies.

For more information about price ranges and concentrated liquidity, visit [this section ](https://docs.gnoswap.io/concepts/amm/concentrated-liquidity)to learn about the mechanism.
{% endhint %}

<figure><img src="/files/CzsdfepwkxbSSce2Uo4D" alt=""><figcaption></figcaption></figure>

### **4. Enter amounts**

Enter the amount of tokens you'd like to deposit. Filling out one side of the pair will automatically calculate the amount of the opposite side, based on the current price of the pool and your price range.

<figure><img src="/files/Y5Wl36UxZMiqBd0cGYAM" alt=""><figcaption></figcaption></figure>

### **5. Preview your transaction**

Review your transaction to ensure that all of the displayed information is correct.

<figure><img src="/files/ijzb5nMjG5rAQODw5fxH" alt=""><figcaption></figcaption></figure>

### **6. Approve the transaction on Adena**

A pop-up from Adena will appear in a new window, prompting you to approve the transaction. Click on **Approve** to proceed.

<figure><img src="/files/BFybwvr4clEZMG6X7252" alt=""><figcaption></figcaption></figure>

### **7. Check your new position**

Once your transaction is complete, return to the **Earn** menu and find your new position under **My Positions**.

<figure><img src="/files/sFshCEQibxQ5V80syEHB" alt=""><figcaption></figcaption></figure>


# Remove a Position

### **1. Find the pool**

Visit the **Pool Details** page by clicking on the pool to remove a position.

<figure><img src="/files/Cv8xIQrkTKoxXk8Z28rz" alt=""><figcaption></figcaption></figure>

### **2. Click on Remove Position**

Click on the **Remove Position** button on the right side of the page.

<figure><img src="/files/wnus6UapwxFqPVkj6JHS" alt=""><figcaption></figcaption></figure>

### **3. Select positions**

From the list of your positions in the pool, select the ones you'd like to remove and click on **Remove Position**. Note that you may only remove unstaked positions. To remove staked positions, you must first unstake them.

<figure><img src="/files/hcb3xG4HA8y1Kr7UYiyU" alt=""><figcaption></figcaption></figure>

### **4. Preview your transaction**

A breakdown of the selected position will appear. Review the details and click on **Confirm Remove Position**.

<figure><img src="/files/z4FlD9sv6IdpOlvMd6nW" alt=""><figcaption></figcaption></figure>

### **5. Approve your transaction**

A pop-up from Adena will appear in a new window, prompting you to approve the transaction. Click on **Approve** to proceed.

<figure><img src="/files/HJiWhDffOaGPEvmmE1ej" alt=""><figcaption></figcaption></figure>

### **6. Check your closed position**

Once your transaction is complete, return to the **Pool Details** page and find your closed position by activating the **Show closed positions** toggle.

<figure><img src="/files/RZZ3LsNVRaj7TWga1Up3" alt=""><figcaption></figcaption></figure>


# Reposition

{% hint style="info" %}
**How repositioning works**

Repositioning allows you to re-adjust the price range of your position without creating a new position in a 3-step process:

1. All tokens are removed from the position.
2. Removed tokens are swapped in a ratio that matches the newly selected range.
3. The Min/Max Prices of the position are modified, and the swapped tokens are added to the position.

This feature comes in handy when your position is pushed out of range.
{% endhint %}

### **1. Click on your position**

Under **My Positions**, select a position to adjust the price range. This will take you to the pool details page.

<figure><img src="/files/guZn4NW94mKrMkZnWrjn" alt=""><figcaption></figcaption></figure>

### **2. Click on Reposition**

Once you land on your position card, expand the **Manage** dropdown and click on **Reposition**.

<figure><img src="/files/okTBvM8TPMK9nO4ZDPfq" alt=""><figcaption></figcaption></figure>

### **3. Select a new range**

Select a new range for the position. Your New Balance will be calculated based on the expected swap results from the Auto Router. Click on **Reposition** to proceed.

<figure><img src="/files/GjyGJATUjqy8kNnSkvJL" alt=""><figcaption></figcaption></figure>

### **4. Preview your transaction**

Review the details of your position and click on **Confirm Reposition**.

<figure><img src="/files/4jjYgDTXCG2K4N5hGKbO" alt=""><figcaption></figcaption></figure>

### **6. Approve 3 consecutive transactions**

Repositioning involves a 3-step process. Each step requires approval for each transaction. Approve the transactions consecutively to complete the reposition.

{% hint style="warning" %}
**Important Notice**

Your swap may occasionally fail due to market fluctuations. In this case, your position will be closed but your tokens will remain in your wallet.
{% endhint %}

<figure><img src="/files/llbVjvNga9dGVzmlaIFQ" alt=""><figcaption></figcaption></figure>

### **6. Check your new position balance**

Return to your position and check your new balance. You can also expand the **Position History** to double-check your transaction.

<figure><img src="/files/TQ36RlAAltz1HGwDyYf1" alt=""><figcaption></figcaption></figure>


# Increase Liquidity

{% hint style="info" %}
**Increasing Liquidity in Your Position**

Add tokens to an existing position to provide more liquidity without creating a new position with an identical price range.
{% endhint %}

### **1. Click on your position**

Under **My Positions**, select a position to increase liquidity.

<figure><img src="/files/JNwXcfbxqM3ZMIXIIsM5" alt=""><figcaption></figcaption></figure>

### **2. Click on Increase Liquidity**

Once you land on your position card, expand the **Manage** dropdown and click on **Increase Liquidity**.

<figure><img src="/files/uiJIfmFZjnsofwbYcJGn" alt=""><figcaption></figcaption></figure>

### **3. Enter amounts**

Enter the number of tokens to add to your position. Filling out one side of the pair will automatically calculate the amount of the opposite side, based on the current price of the pool and the price range of your position.

<figure><img src="/files/AdfmCw54Y2TrcaargEhq" alt=""><figcaption></figcaption></figure>

### **4. Preview your transaction**

Review the details of your transaction and click on **Confirm Increase Liquidity**.

<figure><img src="/files/dA7ASRKxJJwNu0xtJPHI" alt=""><figcaption></figcaption></figure>

### **5. Approve your transaction**

A pop-up from Adena will appear in a new window, prompting you to approve the transaction. Click on **Approve** to proceed.

<figure><img src="/files/9dkfIty5m0OjnfJArX00" alt=""><figcaption></figcaption></figure>

### **6. Check your new position balance**

Return to your position and check your new balance. You can also expand the **Position History** to double-check your transaction.

<figure><img src="/files/4JhDTJg14BuuO7ZNUQ2i" alt=""><figcaption></figcaption></figure>


# Decrease Liquidity

{% hint style="info" %}
**Decrease Liquidity in Your Position**

You may partially remove tokens from your existing position to decrease liquidity without closing it.
{% endhint %}

### **1. Click on your position**

Under **My Positions**, select a position to decrease liquidity from.

<figure><img src="/files/JNwXcfbxqM3ZMIXIIsM5" alt=""><figcaption></figcaption></figure>

### **2. Click on Decrease Liquidity**

Once you land on your position card, expand the **Manage** dropdown and click on **Decrease Liquidity**.

<figure><img src="/files/VFJtWugH9K5FAg8fWGrW" alt=""><figcaption></figcaption></figure>

### **3. Select a percentage**

Select a percentage of liquidity to decrease from your position. The exact amount of tokens to be decreased will be displayed at the bottom. Selecting 100% will close your position. Click on **Decrease Liquidity** to proceed.

<figure><img src="/files/xWS8DfBDoYJHsjaNdqVO" alt=""><figcaption></figcaption></figure>

### **4. Preview your transaction**

A breakdown of the selected position will appear. Review the details and click on **Confirm Decrease Liquidity**.

<figure><img src="/files/TdRS027XxqCzP2i4Nx5e" alt=""><figcaption></figcaption></figure>

### **5. Approve your transaction**

A pop-up from Adena will appear in a new window, prompting you to approve the transaction. Click on **Approve** to proceed.

<figure><img src="/files/a9Fbfw1nRt67suXoEuOU" alt=""><figcaption></figcaption></figure>

### **6. Check your new position balance**

Return to your position and check your new balance. You can also expand the **Position History** to double-check your transaction.

<figure><img src="/files/9tA4EF2M83oomTq8UvTS" alt=""><figcaption></figcaption></figure>


# Staking


# Stake Positions

### **1. Select a pool**

Select a pool under **Incentivized Pools** to stake your position. The token logos on the top right side of the pool indicate the rewards.

<figure><img src="/files/nQnCydIhqP24Uxakc8kH" alt=""><figcaption></figcaption></figure>

### **2. Click on Stake Position**

Scroll down to the Staking section and click on **Stake Position**.

<figure><img src="/files/i4nGbneDrShrmt1HwuFS" alt=""><figcaption></figcaption></figure>

### **3. Select positions**

Select the position(s) to stake and click on **Stake Position**.

{% hint style="info" %}
**Staking APR Range**

The Staking APR is displayed as a variable range based on the multiplier applied from Warm-up Periods, which gradually increases your rewards the longer you stake your positions. Visit [this section](/references/warm-up-periods) to learn more about how Warm-up Periods work.
{% endhint %}

<figure><img src="/files/DY3WaPc2P23H6oIxtG60" alt=""><figcaption></figcaption></figure>

### **4. Preview your transaction**

Review the details of your transaction and click on **Confirm Stake Position**.

<figure><img src="/files/NbgBVtd7XC1wSCbfn5Pv" alt=""><figcaption></figcaption></figure>

### **5. Approve your transaction**

A pop-up from Adena will appear in a new window, prompting you to approve the transaction. Click on **Approve** to proceed.

<figure><img src="/files/vtyMoTgNCswiFuyvaszK" alt=""><figcaption></figcaption></figure>

### **6. Check your staked position**

Return to your position. The **Staked** label will appear on your card and staking rewards will start accruing to your position. You can also expand the **Position History** to double-check your transaction.

<figure><img src="/files/mIVpdySUMvZobbKmiTSz" alt=""><figcaption></figcaption></figure>


# Claim Rewards

{% tabs %}
{% tab title="Claim Rewards by Pool" %}
**1. Select a pool**

Select a pool to claim your rewards from.

<figure><img src="/files/nQnCydIhqP24Uxakc8kH" alt=""><figcaption></figcaption></figure>

### **2. Check your rewards**

Hover over the **Total Claimable Rewards** under **My Positions** to check your rewards, broken down into three categories: Swap Fees, Internal Rewards, and External Rewards.

<figure><img src="/files/zlRYNApyv501IqCqvrZD" alt=""><figcaption></figcaption></figure>

### **3. Click on Claim All**

To claim all of the rewards earned from the pool, click on Claim All.

<figure><img src="/files/zAEi6R54UoEb9N47s1Ud" alt=""><figcaption></figcaption></figure>

### **4. Approve your transaction**

A pop-up from Adena will appear in a new window, prompting you to approve the transaction. Click on **Approve** to proceed.<br>

<figure><img src="/files/Y5OupfPIRJFfEIfi83lA" alt=""><figcaption></figcaption></figure>

### **5. Check your new balance**

Your **Claimable Rewards** will be reset to $0, and your wallet balance will include the claimed rewards.

<figure><img src="/files/6ehZonESEamDJxFGPRyx" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Claim All Rewards" %}

### **1. Click on Claim All**

To claim all your rewards at once, click on **Claim All** inside the Earn menu.

<figure><img src="/files/zZt8Ue0dgzA593lyEc8o" alt=""><figcaption></figcaption></figure>

### **2. Approve the transaction**

A pop-up from Adena will appear in a new window, prompting you to approve the transaction. Click on **Approve** to proceed.<br>

<figure><img src="/files/QzzVwYzQTc8J8Ll0nrHO" alt=""><figcaption></figcaption></figure>

### **3. Check your new balance**

Your **Claimable Rewards** will be reset to $0, and your new Total Balance will include the claimed rewards.

<figure><img src="/files/MTFVLyYuDYJ4T1OQrWpu" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}


# Unstake Positions

### **1. Select a position**

Select a position under **My Positions** to unstake.

<figure><img src="/files/JNwXcfbxqM3ZMIXIIsM5" alt=""><figcaption></figcaption></figure>

### **2. Click on Unstake Position**

Once you land on the **Pool Details** page of the pool containing your position, scroll down to the Staking section and click on **Unstake Position**.

<figure><img src="/files/i4nGbneDrShrmt1HwuFS" alt=""><figcaption></figcaption></figure>

### **3. Select positions**

Select the position(s) to unstake. A breakdown of your position will be displayed at the bottom of the screen. Note that any unclaimed rewards from your position will be claimed when you unstake your position.

<figure><img src="/files/69iiXr8ct3otu9Y3y6ec" alt=""><figcaption></figcaption></figure>

### **4. Preview your transaction**

Review the details of your transaction and click on **Confirm Unstake Position**.

{% hint style="warning" %}
**Warm-up Period Reset**

Unstaking will reset the multiplier earned from the Warm-up Period for that position. You will stop earning staking rewards and a full penalty will be applied once you re-stake your position. Visit [this section](/references/warm-up-periods) to learn more about how Warm-up Periods work.
{% endhint %}

<figure><img src="/files/jWYayOSoWEzoqCLkjxuH" alt=""><figcaption></figcaption></figure>

### **5. Approve your transaction**

A pop-up from Adena will appear in a new window, prompting you to approve the transaction. Click on **Approve** to proceed.

<figure><img src="/files/tCzIK6W2y8HpjvzDD09J" alt=""><figcaption></figcaption></figure>

### **6. Check your unstaked position**

Return to your position. The **Staked** label will be removed from your card. You can also expand the **Position History** to double-check your transaction.

<figure><img src="/files/YPcwyF486hccgxgCG4VD" alt=""><figcaption></figcaption></figure>


# Add Incentives

### **1. Click on Incentivize Pool**

In the **Earn** menu, click **Incentivize Pool** under the **Incentivized Pools** section.

<figure><img src="/files/XZji3maHQuiB405x4MET" alt=""><figcaption></figcaption></figure>

### **2. Select a pool**

Select a pool to add incentives to.

<figure><img src="/files/F4sB63wcc1VEQoOCBvQF" alt=""><figcaption></figcaption></figure>

### **3. Select the distribution period**

Select a range of dates during which your incentives will be distributed. Choose the starting date inside the calendar, and specify a total duration from three options: 90 days, 180 days, or 365 days.

{% hint style="warning" %}
**Distribution Period**

Rewards are evenly distributed on a per-block basis, meaning that the exact time it takes to disperse your rewards fully may differ from the selected dates due to the network conditions of the blockchain. For a precise schedule, please refer to the block heights after the distribution begins.
{% endhint %}

{% hint style="warning" %}
**Warm-up Periods**

Incentives are distributed with[ warm-up period](/references/warm-up-periods), a distribution mechanism that applies a dynamic multiplier to each staked position based on its total duration staked in range, which is considered when calculating the staking reward. This mechanism is designed to encourage long-term liquidity provision while offering flexibility for those who often need to adjust their price range to remain active due to liquidity concentration.

The undistributed rewards from the warm-up periods are sent to the incentive provider's wallet at the end of the distribution period set by the incentive provider.

Before providing incentives, make sure you check out [the warm-up period](/references/warm-up-periods) page and understand how it works.
{% endhint %}

<figure><img src="/files/HqPFC7NTx17idu1dVcRe" alt=""><figcaption></figcaption></figure>

### **4. Set the reward amount**

Select the token and the amount to be distributed as incentives. The bottom of the modal will display detailed information about your incentive distribution plan. Click on **Incentivize Pool** to proceed.

{% hint style="info" %}
**Accepted Incentives**

To prevent users from receiving harmful tokens from unknown sources, there is a limit on which tokens can be added as incentives: $GNOT, $GNS, and the pair of the pool.
{% endhint %}

<figure><img src="/files/rT8e0rVpKeqObSnUYV72" alt=""><figcaption></figcaption></figure>

### **5. Preview your transaction**

Review the details of your transaction and click on **Confirm Incentivize Pool**.

<figure><img src="/files/fNNOLZ0uIv1ipgfDACnL" alt=""><figcaption></figcaption></figure>

### **6. Approve your transaction**

A pop-up from Adena will appear in a new window, prompting you to approve the transaction. Click on **Approve** to proceed.

<figure><img src="/files/6Y6aS4jDMHwdAyfHCwGO" alt=""><figcaption></figcaption></figure>

### **7. Check the incentives**

Once your transaction is complete, your pool will now appear under **Incentivized Pools**. Visit the Staking section of your pool and hover over the APR to check the details of your incentives.

<figure><img src="/files/iqYUV6hBSTc3uEoVBNYd" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/f84GZzNI53Ej5dJdQ8PS" alt=""><figcaption></figcaption></figure>


# Launchpad


# Participate in Launches

{% hint style="info" %}
**How GnoSwap Launchpad Works**

GnoSwap Launchpad allows you to acquire newly launched tokens without any payment, simply by staking $GNS tokens for a fixed period. Over the staking period, the **Protocol Fee rewards are re-directed** towards the project owners, while the stakers of the pool earn a fixed supply of project tokens pro-rata based on their share.

At the end of the staking period, the principal (in terms of the amount of $GNS staked) is returned to the staker, creating a **"lossless"** token launch experience.

To learn about the core concepts of GnoSwap Launchpad, visit the [Launchpad](/core-concepts/launchpad) page.
{% endhint %}

### **1. Locate the Launchpad menu**

Click on **Launchpad** in the header to visit the **Launchpad** page.

<figure><img src="/files/SyL1E8AJLFpKtwsgSOgQ" alt=""><figcaption></figcaption></figure>

### **2. Search for Active Projects**

Scroll down to find a list of Active Projects. The list includes upcoming or ongoing projects on GnoSwap Launchpad. Click on a project of your choice to proceed.

<figure><img src="/files/IG67uhBO66yMeEvbOOmx" alt=""><figcaption></figcaption></figure>

### **3. Select a pool**

GnoSwap Launchpad offers three different types of pools by staking period: 1 Month, 3 Months, and 6 Months. Each pool comes with different allocations - typically longer staking periods will offer higher rewards.

{% hint style="warning" %}
**Important Notes On Participating in Launchpad Pools**

* The $GNS tokens you deposit are automatically staked to the [xGNS](/gnoswap-token/xgns) [Governance](/core-concepts/governance) Contract to start earning [Protocol Fee](/core-concepts/fees#protocol-fees) rewards, which are re-directed to the project owner.
* You will only receive the Launchpad project token as rewards during your Launchpad participation.
* You CANNOT withdraw your deposit before the End Date of your pool.
* No governance power will be attributed to the $xGNS tokens staked via Launchpad Pools.
  {% endhint %}

<figure><img src="/files/IwMTWTHClqVs1ACqiTg8" alt=""><figcaption></figcaption></figure>

Detailed information about the project including its overview, the realm path of the token, and official links can be found at the bottom of the page.

<figure><img src="/files/W6k3T2FIuGCzbj4pHMXa" alt=""><figcaption></figcaption></figure>

### **4. Review your participation**

Once you select a pool and enter your amount, a confirmation pop-up will appear, allowing you to review your deposit. Carefully note the End Date and the Claim Availability Date, and click on Confirm to complete your deposit.

<figure><img src="/files/Q3F9CBgccJb1HokGgilh" alt=""><figcaption></figcaption></figure>

### **5. Claim your rewards**

A full list of your participations will appear at the bottom right side of the page.

Your claimable rewards will be updated on a per-block basis. Note that the amount you receive will be proportional to your share of the pool. The accrued rewards can be claimed at any time, provided that the Claimable Date has passed.

<figure><img src="/files/yfK5dqjWg0IcLeaman0B" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
**Withdrawing Your Deposit**

Your tokens are automatically unstaked at the end of the staking period. To redeem your principal, click on Claim All to withdraw your $GNS along with any unclaimed rewards.
{% endhint %}


# Governance


# Delegate

To learn about the core concepts of GnoSwap Governance, visit the [Governance](/core-concepts/governance) page.

### **1. Locate the Governance menu**

Hover your cursor on the arrow icon to expand the menu and click on **Governance** in the header to visit the **Governance** page.

<figure><img src="/files/xBzL6jWbH4ytA5qkISeO" alt=""><figcaption></figcaption></figure>

### **2. Click on Delegate**

Click on **Delegate** on the right side of the **My Delegation** section.

<figure><img src="/files/yIU6MEvxy49q2vE5Skgi" alt=""><figcaption></figcaption></figure>

### **3. Select your delegate**

Select a delegate who will inherit your voting power. Detailed information about the delegates such as their current voting power, wallet address, a short description, and their website can be found below. Alternatively, you may manually enter a wallet address of the delegate of your choice.

<figure><img src="/files/fB80nwEJpHWC6H23A5nx" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
**What are delegates?**

Delegates are representatives of GnoSwap Governance who inherit the voting power of xGNS holders who delegate their tokens to them. The delegate you choose can ONLY vote on your behalf. Rest assured, they CANNOT sell or undelegate your tokens.
{% endhint %}

### **4. Enter $GNS amount**

Enter the amount of $GNS you would like to delegate. Note that there is no minimum amount of $GNS that you must delegate.

{% hint style="warning" %}
**Acknowledge the undelegation period before you proceed!**

To retrieve your delegated $GNS tokens, you must first undelegate them. Be sure to understand that there is an undelegation period of 7 days during which you cannot receive any protocol fee rewards and your voting power becomes inactive.
{% endhint %}

<figure><img src="/files/rjODBF5N8drWguUB77VJ" alt=""><figcaption></figcaption></figure>

### **5. Review your delegation**

A preview of your delegation will be displayed at the bottom of the modal. Be sure to throroughly review them before you proceed.

<figure><img src="/files/70esmNgxmqo8yFGbV82q" alt=""><figcaption></figcaption></figure>

### **6. Approve your transaction**

Once you click on **Delegate GNS,** a pop-up from Adena will appear in a new window, prompting you to approve the transaction. Click on **Approve** to proceed.

<figure><img src="/files/WHOr9WZeifvNabIdyK54" alt=""><figcaption></figcaption></figure>

### **7. Check your xGNS balance**

Your new xGNS balance will be updated under **Voting Weight**. Hover over the value to check a breakdown of your current delegations by each delegate.

<figure><img src="/files/3xGHnXk7DdOR2sbVLvfZ" alt=""><figcaption></figcaption></figure>

### **8. Claim your rewards**

Your delegated xGNS will start earning protocol fees. You can check your rewards under **Claimable Rewards**. These rewards are claimable at any time. Click on Claim All to receive all of your accrued rewards in your wallet.

<figure><img src="/files/BOqjbwoAB15s2VbPS4dP" alt=""><figcaption></figcaption></figure>


# Undelegate

To learn about the core concepts of GnoSwap Governance, visit the [Governance](/core-concepts/governance) page.

### **1. Locate the Governance menu**

Hover your cursor on the arrow icon to expand the menu and click on **Governance** in the header to visit the **Governance** page.

<figure><img src="/files/xBzL6jWbH4ytA5qkISeO" alt=""><figcaption></figcaption></figure>

### **2. Click on Undelegate**

Click on **Undelegate** on the right side of the **My Delegation** section.

<figure><img src="/files/8QHe3tRmfEqFm74d1tzc" alt=""><figcaption></figcaption></figure>

### **3. Select your delegate**

Select a delegate to undelegate your $GNS from. Click on the delegate to activate a drop down of a full list of your delegates.

<figure><img src="/files/PdrYuoj8VI4brZW6fzD2" alt=""><figcaption></figcaption></figure>

### **4. Enter $GNS amount**

Enter the amount of $GNS tokens you would like to undelegate. Carefully read the notes below to understand the effects of undelegating your tokens.

{% hint style="warning" %}
**Understand the effects of undelegating your tokens!**

* Your tokens will be **locked for 7 days**.
* You **CANNOT cancel** the undelegation once you complete this step.
* During this period, you will receive **NO protocol fee rewards**.
* Your undelegating xGNS tokens will have **NO voting power**.
  {% endhint %}

<figure><img src="/files/F9aaEsu2u8RaFD6U2gf7" alt=""><figcaption></figcaption></figure>

### **5. Review your undelegation**

A preview of your undelegation will be displayed at the bottom of the modal. Be sure to throroughly review them before you proceed.

<figure><img src="/files/A18BapwnlqwQMffG7mbP" alt=""><figcaption></figcaption></figure>

### **6. Approve your transaction**

Once you click on **Undelegate GNS,** a pop-up from Adena will appear in a new window, prompting you to approve the transaction. Click on **Approve** to proceed.

<figure><img src="/files/ZhpxI2NMnE3Dyo6tsk3g" alt=""><figcaption></figcaption></figure>

### **7. Check your undelegation balance**

Check your $GNS tokens in undelegation period under **Undelegation**. Hover over the value to activate a pop-up which will display a full list of your undelegations including detailed information such as the delegate, amount, and the unlock date.

Upon reaching the unlock date, you can claim the principal $GNS tokens you previously delegated.

<figure><img src="/files/hFK6BaPkLUfTBYVbYfA1" alt=""><figcaption></figcaption></figure>


# Create a Proposal

To learn about the core concepts of GnoSwap Governance, visit the [Governance](/core-concepts/governance) page.

### **1. Locate the Governance menu**

Hover your cursor on the arrow icon to expand the menu and click on **Governance** in the header to visit the **Governance** page.

<figure><img src="/files/xBzL6jWbH4ytA5qkISeO" alt=""><figcaption></figcaption></figure>

### **2. Click on Create Proposal**

Click on **Create Proposal** on the right side of the **Proposals** section.

<figure><img src="/files/0RipeJeOTmgJ4u5V6DAF" alt=""><figcaption></figcaption></figure>

### **3. Select the Proposal Type**

Choose one of three types of proposals supported on GnoSwap Governance.

* **Text Proposal:** Proposals in simple text form containing future upgrade plans, surveys, or statements. Text proposals have no direct effect on the contracts of GnoSwap.
* **Community Pool Spend:** Proposals that request to spend funds from the Community Pool. Once passed and executed, the request amount of tokens will be sent to the recipient's wallet address.
* **Parameter Change:** Proposals that request to change the current parameters of GnoSwap's contracts such as the quorum, emissions, voting periods, etc. Once passed and executed, the parameters will be updated on-chain.

<figure><img src="/files/gBEaaNKVSi2os1QPXSRK" alt=""><figcaption></figcaption></figure>

### **4. Fill out the details**

Enter the title and the description of the proposal. Note that the description field supports markdown formatting to allow you to better structure your description. Be sure to use a professional tone and check the grammar of your description.

<figure><img src="/files/4paLMb0iuNbb5zvaD0TP" alt=""><figcaption></figcaption></figure>

### **5. Set variables**

If you're creating a **Community Pool Spend** or a **Parameter Change** proposal, you must be sure to enter valid variables, as they will have direct effects to GnoSwap's community pool or the contracts.

**Community Pool Spend Variables**

* **Recipient Address:** Enter the address to receive the $GNS tokens.
* **$GNS Amount:** Enter the amount of $GNS tokens to spend from the community pool.

<figure><img src="/files/b7fqZzfBfef9jRYxgKVa" alt=""><figcaption></figcaption></figure>

**Parameter Change Variables**

* **Realm:** Click on the **Select Realm** input to activate a drop down of realms available to update via governance.
* **Function:** Enter the name of the function.
* **Arguments:** Enter the argument(s) of the function. Arguments should be separated by commas.

<figure><img src="/files/S0jNI1A0klHMBSlYcI9h" alt=""><figcaption></figcaption></figure>

### **6. Approve your transaction**

{% hint style="info" %}
**Minimum xGNS Holdings**

The **Submit** button is only active if your wallet meets the minimum xGNS holdings requirement. This mechanism exists to prevent spam and to ensure that only those who are truly aligned with GnoSwap can create proposals. This value is subject to change, and can be found at the bottom of the Create Proposal modal.
{% endhint %}

Once you click on **Submit**, a pop-up from Adena will appear in a new window, prompting you to approve the transaction. Click on **Approve** to proceed.

<figure><img src="/files/FtGXJg8BIqZmz4zOAtJE" alt=""><figcaption></figcaption></figure>

### **7. Check your proposal**

Under **Proposals**, your newly uploaded proposal will be displayed. Click on the proposal for its details and the current voting results.

<figure><img src="/files/bmfWCNBmf2cgXPWfagMF" alt=""><figcaption></figcaption></figure>

### **8. (Optional) Cancel your proposal**

If you discover an error or a critical typo in your proposal, you may cancel it. Click on **Cancel Proposal** on the right side of the proposal card. Note that only the creator of the proposal may cancel it.

{% hint style="info" %}
**When can I cancel proposals?**

Proposals can only be cancelled during the **Voting Start Delay** period of 1 day (modifiable via GnoSwap Governance), if an error is detected. Once the voting begins, there is no way to cancel the proposal. There are no penalties for canceling a proposal.
{% endhint %}

<figure><img src="/files/Vyowb1hpqshjJcXiPB4k" alt=""><figcaption></figcaption></figure>


# Vote

To learn about the core concepts of GnoSwap Governance, visit the [Governance](/core-concepts/governance) page.

### **1. Locate the Governance menu**

Hover your cursor on the arrow icon to expand the menu and click on **Governance** in the header to visit the **Governance** page.

<figure><img src="/files/xBzL6jWbH4ytA5qkISeO" alt=""><figcaption></figcaption></figure>

### **2. Click on a proposal to vote on**

Under the list of proposals, click on a proposal in an **Active** state.

{% hint style="info" %}
**Various states of proposals**

Proposals exist in various state based on its stage and outcome

* **Upcoming:** The proposal has been uploaded, but the voting period has not yet begun.
* **Active:** The proposal is available for voting.
* **Passed:** The proposal has reached the quorum and 50% or more voters have voted **Yes**.
* **Rejected:** The proposal has failed to reached the quorum or less than 50% of voters have voted **Yes**.
* **Cancelled:** The creator of the proposal has cancelled the proposal.
  {% endhint %}

<figure><img src="/files/rcZLWtEfe00Qc0VGWN0g" alt=""><figcaption></figcaption></figure>

### **3. Vote on the proposal**

Carefully read the proposal and cast your vote. You may choose **Yes** to indicate that you support the proposal, or choose **No** to indicate that you're against the proposal. Each xGNS you own translates to 1 vote. Once you've made your decision, click on **Vote** to proceed.

{% hint style="warning" %}
**Your votes are irreversible!**

You CANNOT change your vote once you complete your transaction. Be sure to thoroughly read the descriptions and understand the outcome of the proposal before you cast your vote.
{% endhint %}

<figure><img src="/files/X6bOzAfQ2yy1LYyqr8jK" alt=""><figcaption></figcaption></figure>

### **4. Approve your transaction**

Once you click on **Vote**, a pop-up from Adena will appear in a new window, prompting you to approve the transaction. Click on **Approve** to proceed.

<figure><img src="/files/ogujfIcYXRThEgI4jja8" alt=""><figcaption></figcaption></figure>

### **5. Check your vote**

Return to the proposal to confirm your vote. The option you've chosen will be tagged with the Voted label.

<figure><img src="/files/MOAVI771Na7dJzCPVD0B" alt=""><figcaption></figcaption></figure>

### **6. (Optional) Execute the proposal**

Once the proposal passes, a separate transaction must be created to execute it. This can be done by anyone. To do so, click on the **Execute Proposal** button on the right side of the passed proposal card. Once the proposal is executed, the button will disappear.

<figure><img src="/files/8Mm7lSDO7GHOVtUnTpej" alt=""><figcaption></figcaption></figure>


# AMM

## Automated Market Makers

An **Automated Market Maker (AMM)** is a protocol consisting of a set of smart contracts that enables automatic price discovery and exchange of tokens, designed to power decentralized exchanges (DEXs).

Unlike traditional exchanges that leverage the order book design, AMMs adopt a unique structure called **liquidity pools** for matching and executing trades. Liquidity pools are reserves of both tokens in each trading pair that allow traders to exchange tokens from the pool at a deterministic price, based on mathematical formulas. Liquidity pools are funded by **liquidity providers (LPs)** who deposit tokens at a given rate. The pool creation and liquidity provision are fully permissionless, which allows for automatic price discovery and listing of any token on Gnoland.

<figure><img src="/files/sJt2XfpwENQqTFPXbUNJ" alt=""><figcaption></figcaption></figure>

## LP Tokens

Once liquidity providers deposit tokens into a pool, they receive newly minted **Liquidity Pool Tokens (LP Tokens)** as a certificate of their deposit. The LP Tokens represent the liquidity provider's share of the pool, and their underlying tokens change dynamically as the quantities of tokens in a liquidity pool fluctuate with each trade.

LP Tokens are designed to automatically capture swap fees of the pool. Liquidity pools charge swap fees by extracting a pre-determined portion from the output of each trade.

When liquidity providers wish to redeem the deposit, they must submit their LP Tokens to the liquidity pool contract, which returns tokens in the pool proportional to the share of the submitted LP Tokens. The LP Tokens get burnt upon redemption of the deposit. As LP Tokens are transferrable, they can be traded in secondary markets or used as collateral to borrow assets. it's important to keep the LP Tokens safe, as there is no way to recover your deposit without submitting them.

## Impermanent Loss

**Impermanent loss (IL)** refers to a decrease in the net worth of LP Tokens relative to the initial deposit. As the AMM is designed to hold the equal value of both tokens in a pool, the pool is left with more amount of tokens that have decreased in price relative to the opposite side of the pair and less amount of tokens that have increased in price. Swap fees and liquidity staking rewards exist to mitigate the impermanent loss of liquidity providers.

The greater the change in price, the higher the impermanent loss a liquidity provider will experience. The change in total equity value can be plotted on a graph, as shown below.

<figure><img src="/files/OshyvzCeDLzCrMHzsyex" alt=""><figcaption></figcaption></figure>


# Constant Product Market Maker

Liquidity pools on GnoSwap utilize the **Constant Product Formula** to achieve deterministic pricing of any token in a pool, ensuring that trades can occur at any price within the range of (0, ∞). Liquidity pools maintain a constant ***k*** value, which is the product of ***x*** and ***y***, representing the quantity of **token x** and **token y** in the pool, respectively. This mechanism results in the following formula:

$$
x \*y=k
$$

When a trade occurs in a pool, the values of ***x*** and ***y*** change. Let's assume that **∆** represents the change in the quantity of a token. If a trader sells **∆*****x*** amount of **token x**, the pool receives **∆*****x*** amount of **token x** and pays out **∆*****y*** amount of ***token*****&#x20;y** (minus the swap fee) as the output in a way that satisfies the equation below:

$$
(x+∆x)(y-∆y)=k
$$

Based on the above formula, we can plot a graph that illustrates changes in token reserves in a pool after a trade.

<figure><img src="/files/YF5FrGRvv9QyBgpJ89Ba" alt=""><figcaption></figcaption></figure>

To illustrate this concept, let's consider a scenario where Pool A holds 10 $GNOT and 10,000 $USDC. If Alice wishes to exchange 1 $GNOT for $USDC in Pool A, an equation reflecting the current reserves and **∆x** (change in $GNOT) is set up as follows:

$$
k = 10\*10,000 = 100,000 = (10+1)(10,000-∆y)
$$

Solving for ∆y, we get:

$$
∆y = 10,000-(100,000/11) = 909.090909...
$$

Therefore, we can expect Alice would receive 909.090909... $USDC if she were to sell 1 $GNOT in Pool A.

When adding liquidity to an existing pool, liquidity providers must deposit an amount of **token x** and **token y** that is proportional to the current ***x : y*** ratio in the pool. Once liquidity is added, the value of ***k*** adjusts to the new values of ***x*** and ***y***.

As ***k*** is proportional to the liquidity of the pool, this structure can be seen as a virtual order book where liquidity is evenly distributed across the entire price range.

<figure><img src="/files/bTn5FFUlg3DhgLiZRaI2" alt=""><figcaption></figcaption></figure>


# Problem: Lazy Liquidity

Although the [Constant Product Market Maker (CPMM)](/core-concepts/amm/constant-product-market-maker) is effective for pools containing tokens with highly volatile prices, traders tend to experience slippages and low capital efficiency due to **lazy liquidity**. Lazy liquidity refers to tokens in a liquidity pool that are excluded from their usual price range, resulting in a lower trading volume and higher slippage.

The price of a pool is determined by the ratio of token reserves in the pool, defined as ***y/x*** (the number of quote tokens divided by the number of base tokens). If we define the usual price range of the pool as ***(Pa, Pb)***, we can plot a graph that displays the lazy liquidity of a pool as shown below:

<figure><img src="/files/sbFsjGv9my5pDtH0gM7d" alt=""><figcaption></figcaption></figure>

For pools containing tokens that are relatively stable in price (e.g., stablecoins pegged to the same asset or a token paired with its liquid staking token), lazy liquidity becomes a severe issue. Assuming a usual price range of (0.99, 1.01), which is a common scenario in the aforementioned pools, [99.5% of total tokens in the pool are wasted as lazy liquidity](https://uniswap.org/blog/uniswap-v3).

Minimizing lazy liquidity is important for improving the efficiency of liquidity pools and reducing the slippage for traders. This can be solved by managing the price range of a pool and incentivizing liquidity providers to supply tokens that fall within that range, which will increase capital efficiency and provide a better trading experience for all users. There are various techniques and strategies for minimizing lazy liquidity, and Gnoswap is committed to exploring and implementing the most effective approaches for our users.


# Concentrated Liquidity

To address the [lazy liquidity problem](/core-concepts/amm/problem-lazy-liquidity), GnoSwap leverages a novel architecture called **Concentrated Liquidity Pools (CLPs).** CLPs allow liquidity providers to set a minimum and maximum price range, in which their liquidity will be active. This ensures that liquidity is concentrated around a specific price range, improving capital efficiency and reducing slippage for traders.

As liquidity in CLPs only requires each amount of ***x*** and ***y*** within the designated range ***(Pa, Pb)***, its behavior can be plotted into a graph as the following:

<figure><img src="/files/N1Tzx7Ctohg9Nf9ee7fU" alt=""><figcaption></figcaption></figure>

The **real reserve curve** is a parallel translation of the **virtual reserve curve** by the number of x tokens in price b (***xb***) towards the y-axis and the number of y tokens in price a (***ya***) towards the x-axis, giving the following equation:

$$
k = (x+x\_b)(y+y\_a)
$$

Although the real reserve curve represents the actual amount of tokens deposited by a liquidity provider, the liquidity pool must track two values to compute the virtual reserve curve that the pool behaves as: liquidity ***L*** and the square root of price ***√P***.

We define ***L*** as ***√k***, a geometric mean of the quantity of two tokens in a pool, and also a constant that reflects the liquidity of the pool. We can solve for ***L*** using ***k = xy***:

$$
L = \sqrt{k} = \sqrt{xy}
$$

Similarly, we can solve for ***√P*** by simply square-rooting the price equation:

$$
\sqrt{P} = \sqrt{y/x}
$$

Using the above formulas, we can compute the virtual reserves by solving for ***x*** and ***y*** respectively:

Solving for ***x***:

$$
\sqrt{x}=\sqrt{y/P}
$$

$$
x=\sqrt{xy}/\sqrt{P}=L/\sqrt{P}
$$

Solving for ***y***:

$$
\sqrt{y}=\sqrt{Px}
$$

$$
y=\sqrt{xy}*\sqrt{P}=L*\sqrt{P}
$$

If we substitute these values for ***xb*** and ***ya*** for the initial formula, we arrive at **the concentrated liquidity formula** (the real reserve curve):

$$
k = L^2 = (x+L/\sqrt{P\_b})(y+L\sqrt{P\_a})
$$

### Output Calculation

Based on the formulas derived in the previous section, we can calculate the output of a swap.

When trading y for x (calculating ***∆x*** with ***∆y***), we first calculate **∆*****√P*** using the first equation, then use the value to calculate ***∆x:***

$$
∆√P = ∆y /L
$$

$$
∆x=∆(1/\sqrt{P})\*L
$$

Similarly, we can also calculate ***∆y*** when we trade x for y:

$$
∆(1/\sqrt{P})=∆x/L
$$

$$
∆y=∆\sqrt{P}\*L
$$

### Price Tick

Since the price range of each LP Token in a pool is unique, we need a mechanism to uniformly divide the price units of a pool to merge the liquidity of tokens provided at the same price within a single liquidity pool. The boundaries that partition the range are called **ticks**. The default tick spacing for pools is 1 basis point, meaning that liquidity is divided into intervals of 0.01%.

The pricing mechanism and the fee distribution mechanism remain the same as regular CPMM pools within a single tick. After a tick's liquidity is drained, the remaining input rolls over to the following tick to be swapped at a different rate.

Price at tick ***i*** can be expressed as the following formula:

$$
p(i)=1.0001^i
$$

Since prices are stored as a square root in GnoSwap's contracts, we use the following formula to calculate the square root of the price at tick ***i***:

$$
\sqrt{p}(i)=1.0001^{i/2}
$$

As the logarithmic calculation to derive ***i*** from a select price doesn't always end up as an integer, once a user inputs a value as a price, the contract automatically finds the nearest tick out of lower ones. For example, the exact value of the price at a tick index of 50,000, can be calculated as:

$$
1.0001^{50,000} = 148.376062923
$$

As the next highest tick (50,001) would result in a value of 148.383481541, a lower price range of 148.37 would translate into a lower tick of 50,000.


# Positions

As each LP Token on GnoSwap is unique based on its price range and liquidity, **LP Tokens are minted as NFTs,** called **Positions,** due to their uninterchangeable nature. To ensure that the underlying tokens and fees due are always derivable, position contracts store the following values:

* **User:** The owner's account address.
* **Lower & upper bound:** The price range in ticks.
* **Liquidity:** The geometric mean of underlying tokens.
* **Collected fees:** Accrued fees per liquidity unit.

Within a single pool, the liquidity of positions with overlapping pricing ranges are merged within the same tick, which results in a liquidity distribution that looks like the following graph:

<figure><img src="/files/XBSXLWUAAd09A9ItyLwe" alt=""><figcaption></figcaption></figure>

As a result, LP tokens are not fungible and represent a unique position in the pool, allowing for finer control over liquidity provisioning and better capital efficiency.


# Liquidity Mining

**Liquidity mining**, often referred to as yield farming, is a mechanism where liquidity providers earn token rewards in return for the liquidity they offer to the platform. Liquidity mining serves to create an additional revenue stream for liquidity providers, offsetting the potential for impermanent loss (IL). Furthermore, implementing liquidity mining also helps nascent platforms bootstrap initial liquidity, which attracts traders with less slippage. Onboarding more traders is essential as it leads to higher swap fees that are distributed to liquidity providers, generating higher returns on their deposits.

Liquidity providers may engage in liquidity mining by staking their positions in a dedicated liquidity staking pool. It is important to note that a position can earn swap fees and staking rewards while **it is active**, meaning that the current price of the pool is within its price range.

GnoSwap distributes liquidity staking rewards with [Warm-up Periods](/references/warm-up-periods), a reward distribution mechanism that applies a dynamic multiplier to each staked position based on its total duration staked in range. This mechanism is designed to encourage **long-term liquidity provision while offering flexibility** for those who often need to adjust their price range to remain active due to liquidity concentration.

GnoSwap offers two types of liquidity mining incentives for its liquidity staking pools:

#### 1) Internal Reward

GnoSwap distributes newly minted $GNS tokens to incentivized pools on a per-block basis, with further details available in the [Emission](/gnoswap-token/emission) section. These incentivized pools are **categorized into three tiers** based on their importance to the platform, with **higher-tier pools receiving a greater share of internal GNS rewards** to ensure key liquidity is well-supported. The GnoSwap Governance will select these incentivized pools and determine their appropriate tier from among the pools that hold tokens essential to the GnoSwap platform. More details about the calculation logic can be found [here](https://github.com/gnoswap-labs/gnoswap/tree/main/contract/r/gnoswap/staker#internal-reward).

#### 2) External Reward

GnoSwap enables third-party projects to inject tokens as rewards to liquidity staking pools to incentivize liquidity providers. The incentive provider must specify the type of the token, its quantity, and a period for the staking contract to automatically distribute rewards to position stakers in a pool selected by the incentive provider.

GnoSwap offers this functionality to help new, low-capital projects that lack credibility or reputation become an incentivized pool to bootstrap liquidity for growth. For more details, check out [this session](/user-guide/staking/add-incentives).


# Fees

### **Swap Fees**

Swap fees are paid to liquidity providers from traders by taking a portion of the output of trades. Unlike regular CPMMs, concentrated liquidity pools hold swap fees instead of automatically re-investing them into the pool, as positions are non-fungible. Instead, the liquidity pool contracts track claimable fees, allowing liquidity providers to claim fees at any time without removing liquidity.

### **Fee Tiers**

Due to the high capital efficiency of concentrated liquidity pools, lowering swap fee rates has become a viable option for liquidity providers to attract more traders to engage in the pool to increase the trading volume.

By default, GnoSwap allows 4 different fee tiers:

* **0.01%:** Best for very stable pairs with low volatility and IL, such as stablecoins.
* **0.05%:** Best for stable pairs with relatively low volatility and IL, such as stablecoins and liquid staking tokens.
* **0.3%:** A generic tier that works best for most pairs.
* **1%:** For exotic pairs with high volatility and IL, such as meme tokens.

While having multiple fee tiers can lead to liquidity fragmentation, we expect rational liquidity providers and traders to eventually agree on a single pool that works best for each pair to utilize. The characteristics of concentrated liquidity will also mitigate liquidity fragmentation by sharply reducing lazy liquidity. In addition, the Auto Router feature can split a single trade across multiple pools to ensure the maximum output.

### **Protocol Fees**

**A Protocol Fee** is charged on core interactions on GnoSwap. This fee is sent directly to the Protocol Fee Contract, which then distributes 100% to the [xGNS](/gnoswap-token/xgns) holders (GNS stakers). The interactions and the applied fee rates are as follows:

* **Swap Router Fee:** `0.15%` of the total swap amount, only applied when executed through the GnoSwap Router.
* **Pool Creation Fee:** `100 GNS` when creating a pool
* **Withdrawal Fee:** `1%` of liquidity provider's fees claimed
* **Unstaking Fee:** `1%` of staking rewards claimed

<figure><img src="/files/6xCqXbRaTol5YTqEYdvX" alt=""><figcaption></figcaption></figure>


# Governance

### How Does GnoSwap Governance Work? <a href="#voting-process" id="voting-process"></a>

GnoSwap is a decentralized protocol governed by [xGNS](/gnoswap-token/xgns) holders. Anyone can participate in the decision-making process in GnoSwap by staking $GNS tokens to obtain xGNS, which enables its holders to create or vote on proposals. The voting system regards 1 xGNS as 1 vote.

The core governance realms are available on [GitHub](https://github.com/gnoswap-labs/governance) for any project to customize and implement to their project.

### Proposal Life Cycle <a href="#scope-of-proposals" id="scope-of-proposals"></a>

#### 1. Stake & Delegate $GNS Tokens <a href="#scope-of-proposals" id="scope-of-proposals"></a>

To participate in the GnoSwap Governance, you must first obtain xGNS by staking your $GNS tokens. To stake your tokens, visit the [**Governance**](https://gnoswap.io/governance) menu. You will receive 1 xGNS for 1 $GNS staked.

While you stake your tokens, you must delegate your voting power to an address. You may delegate to yourself, or any public delegates that you support. Delegation only transfers your voting powers, while ensuring you retain all of your rewards. You may select multiple delegates to split your voting power.

{% hint style="warning" %}
**Unstaking Period**

A lock-up period of 7 days is applied once you unstake your xGNS. During this period, the locked xGNS tokens will be ineligible to receive staking rewards and have no voting powers. This mechanism exists to ensure that xGNS stakers are aligned with the long-term benefits of the GnoSwap protocol.
{% endhint %}

#### 2. Create a Proposal <a href="#scope-of-proposals" id="scope-of-proposals"></a>

A proposal refers to a request for permission to execute a set of calls that will affect the configurations of GnoSwap's realms. To create a proposal, visit the **Governance** menu. Be sure to concisely describe your proposal and select the correct parameters and values to modify.

{% hint style="info" %}
**Proposal Topic Examples**

Below is a non-exhaustive list of parameters that can be changed with a proposal:

* **Protocol Fee:** The percentage of the Protocol Fee taken from swaps, withdrawals, and unstaking.
* **Emission Direction:** The pools to be included in the $GNS token emission.
* **Voting Period:** The duration of the voting period.
* **Vote Quorum:** The threshold of the percentage of total voting power required to cause the proposal to become valid.
  {% endhint %}

#### 3. Vote <a href="#scope-of-proposals" id="scope-of-proposals"></a>

Once the proposal is created, it enters a voting period after the Voting Start Delay has passed. All delegates are given the option to either vote `Yes` or `No`. At the end of the voting period, all votes are consolidated and the results are determined. A proposal only passes if the Quorum has been reached and the total `Yes` voting power strictly exceeds the total `No` voting power. Tied votes do not pass.

{% hint style="info" %}
**When can I cancel proposals?**

Proposals can only be cancelled during the **Voting Start Delay** period of 1 day (modifiable via GnoSwap Governance), if an error is detected. Once the voting begins, there is no way to cancel the proposal. There are no penalties for canceling a proposal.
{% endhint %}

#### 4. Execute a Proposal <a href="#scope-of-proposals" id="scope-of-proposals"></a>

If a proposal passes, it can be executed within the Execution Window of 30 days. The `execute` function must be called for the changes proposed to take effect on the realms.

### Configuration Parameters <a href="#scope-of-proposals" id="scope-of-proposals"></a>

Below are the initial configuration parameters of the GnoSwap governance. All of the parameters can be modified via proposals.

* **Voting Start Delay**: 1 day (= 86400 seconds)
  * *The time delay, in seconds, before voting begins after a proposal is created.*
* **Voting Period**: 7 days (= 604800 seconds)
  * *The duration, in seconds, during which votes can be submitted.*
* **Voting Weight Smoothing Duration**: 1 day (= 86400 seconds)
  * *The time period, in seconds, over which the voting weight is averaged for proposal voting and creation/cancellation.*
* **Quorum**: 50% of the total supply of xGNS tokens when a proposal is created (with 6 decimals)
  * *The total number of votes required for the proposal to be considered valid.*
* **Proposal Creation Threshold**: 1,000 xGNS (with 6 decimals)
  * *The minimum holding of xGNS tokens required to create a proposal.*
* **Execution Delay**: 1 day (= 86400 seconds)
  * *The time period, in seconds, that must pass after the voting period ends before the proposal can be executed.*
* **Execution Window**: 30 days (= 2592000 seconds)
  * *The window of time, in seconds, after the execution delay during which the proposal may be executed (any user can execute it).*


# Launchpad

### What is GnoSwap Launchpad?

GnoSwap Launchpad is a user-friendly token launch platform designed for "lossless" exposure to early-stage projects. This innovative feature enables users to acquire project tokens by depositing $GNS for a fixed duration. The yield generated from the deposited $GNS, sourced from [protocol fees](/core-concepts/fees#protocol-fees), is redirected to support project teams. Meanwhile, participants retain their principal $GNS amount, making it a secure and risk-minimized way to engage in token launches.

{% hint style="warning" %}
**Important Notes On Participating in Launchpad Pools**

* The $GNS tokens you deposit are automatically staked to the [xGNS](/gnoswap-token/xgns) [Governance](/core-concepts/governance) Contract.
* The yield generated from the deposited $GNS, sourced from [protocol fees](/core-concepts/fees#protocol-fees), is redirected to support project teams.
* You will only receive the Launchpad project token as rewards during your Launchpad participation.
* You CANNOT withdraw your deposit before the End Date of your pool.
* No governance power will be attributed to the $xGNS tokens staked via Launchpad Pools.
  {% endhint %}

### Key Concepts

#### "Lossless" Exposure to Early-Stage Projects

GnoSwap Launchpad enables $GNS holders to obtain early-stage project tokens while maintaining their principal $GNS amount, creating a "lossless" token launch participation experience.

In GnoSwap Launchpad, users who deposit and lock their $GNS tokens for a pre-defined period are rewarded with newly launching tokens, while their base capital (in terms of the amount of $GNS tokens) remains staked safely inside the xGNS Governance Contract. While the pool is active, project tokens are distributed to the users pro-rata to their share of the pool.

At the end of the maturity period - regardless of the lock-up period chosen by the user or the price action of the project token - GnoSwap Launchpad returns the same amount of $GNS tokens to the user. Importantly, no $GNS tokens are directly spent in the process of users acquiring the project tokens.

{% hint style="warning" %}
**Important Note On Depositing $GNS Tokens**

Once you deposit your $GNS tokens in a Launchpad Pool, your tokens are LOCKED until the respective maturity date of the pool. The launchpad contract automatically deposits your tokens to the [xGNS](/gnoswap-token/xgns) [Governance](/core-concepts/governance) Contract for a fixed duration. You may only withdraw your tokens after the pool reaches its maturity period.
{% endhint %}

#### Pool Diversity

Each project comes with three different types of pools to accommodate various risk-reward preferences based on users' approaches. $GNS tokens are locked over a varying amount of time for each pool. Unlike the deposit, rewards accumulated are liquid and can be claimed at any time. Below are the pool types available in GnoSwap Launchpad:

* **1 Month**: Requires shorter commitment with moderate rewards. Ideal for users who trade and adjust their portfolio frequently.
* **3 Months**: Balanced duration and reward allocation.
* **6 Months**: Requires longer commitment, which is compensated by higher token rewards. Recommended for long-term $GNS holders who are also highly optimistic about the underlying project in the pool.

#### Yield-Redirection-Based Funding

The "lossless" token rewards are made possible thanks to the unique yield-redirection mechanism of GnoSwap Launchpad, creating a flow that looks like the following chart:

<figure><img src="/files/Dsw81sVtjkOrhLYSjIxB" alt=""><figcaption></figcaption></figure>

All of the $GNS tokens deposited by users into the Launchpad Pools are automatically staked into the xGNS Governance Contract, instantly starting to earn Protocol Fee Rewards. These rewards, however, are not distributed back to the users. Instead, they're **redirected to the Project Owner** in return for the project token rewards they supply to the Launchpad Pools - hence the term **"yield redirection"**.

### Example Use Case

Let's assume that Alice is participating in the $FOO token launch under the following settings:

* xGNS Governance Contract APR: **24%**
* Total $GNS Staked in the 3-month pool: **100,000 $GNS**
* Alice's $GNS Staked in the 3-month pool: **10,000 $GNS (10% share)**
* Total $FOO Rewards in the 3-month pool: **500,000 $FOO**

Over 3 months, Alice's Protocol Fee reward of **600 $GNS** (= 10,000 $GNS \* 24% APR / 12 months in a year \* 3 months) will be **redirected** to the Project Owner of $FOO tokens, and Alice will earn **50,000 $FOO** (= 500,000 \* 10% share) in Launchpad Rewards.

But most importantly, at the end of the staking period, Alice receives the principal amount of **10,000 $GNS**, making this token acquisition process **lossless**.

### Enter GnoSwap Launchpad <a href="#enter-pylon-gateway" id="enter-pylon-gateway"></a>

**For users,** GnoSwap Launchpad offers an opportunity to scale into promising early-stage project tokens while eliminating the risk of losing their $GNS tokens. This allows $GNS holders to support and profit from the growth of the broader the gno.land ecosystem without reducing their exposure to GnoSwap.

**For project owners,** GnoSwap Launchpad is a reliable token launch platform where you can seamlessly build a strong community of supporters by distributing your tokens to loyal $GNS holders, aligning your project's success with them. This opens up possibilities for your token's liquidity pools to be voted to receive $GNS Emissions via GnoSwap Governance, which adds a layer of incentives to further enhance your project's liquidity. Additionally, the redirected yield from the staked $GNS tokens in the pool provides a stable funding source over a fixed duration.

Join GnoSwap Launchpad today to seamlessly support or launch trailblazing decentralized application projects on gno.land. If you are a member of a project team interested in launching your project on GnoSwap, please let us know by filling out this form: \[google form link to be added]


# What's GNS?

**GnoSwap** **Token ($GNS)** serves as the utility token that forms the foundation of the GnoSwap ecosystem. Its primary role lies in facilitating the coordination and alignment of stakeholders' interests to promote sustainable liquidity incentivization and uphold the long-term vision of the GnoSwap protocol.

<table><thead><tr><th width="262">Item</th><th>Value</th></tr></thead><tbody><tr><td>Name</td><td>GnoSwap Token</td></tr><tr><td>Symbol</td><td>GNS</td></tr><tr><td>Token Standard</td><td>GRC-20</td></tr><tr><td>Realm Path</td><td>gno.land/r/gnoswap/gns</td></tr><tr><td>Total Supply</td><td>1,000,000,000 GNS</td></tr></tbody></table>

#### **Use cases**

* **The Primary Quote Currency:** Paired with most tokens available on GnoSwap, $GNS serves as the primary quote currency across GnoSwap, meaning that it can facilitate trades of tokens without having direct pools.
* **Position Staking Incentives:** $GNS block [emissions](/gnoswap-token/emission) are directed towards position staking pools as incentives for LPs. These rewards are designed to offset the impermanent loss that LPs may experience, while also attracting them to contribute liquidity, ensuring the deep liquidity of the protocol.
* **Governance:** $GNS can be staked into the governance staking pool to become [xGNS](/gnoswap-token/xgns), which grants voting power on proposals submitted to GnoSwap [Governance](broken://pages/5JUWfeqdPPncRkhQPI5w), enabling community members to actively participate in the governance of the GnoSwap protocol.
* **Protocol Fees:** Users are required to pay fees in $GNS on core interactions on GnoSwap. All protocol fees are distributed to xGNS holders. Details can be found in the [Fee](/core-concepts/fees#protocol-fees) section.
* **Participation in Launchpad:** Users holding $GNS will have the opportunity to gain exposure to new projects launching on GnoSwap. By staking their $GNS, they receive tokens from a Launchpad project without any loss of their principal $GNS.


# Genesis Supply

Upon launch, the genesis supply of 100 million $GNS will be issued, divided into two categories:

<figure><img src="/files/dNDJ7nOSCeSTuZ1dC5q4" alt=""><figcaption></figcaption></figure>

#### **1. Airdrop (50%)**

A total of 50 million $GNS, representing 50% of the genesis supply, will be distributed through an airdrop. Details of the airdrop are TBA.

#### **2. Ecosystem Growth Reserve (50%)**

A total of 50 million $GNS, representing 50% of the genesis supply, will be reserved to sustain the core protocol and foster the success of the GnoSwap and the Gnoland ecosystems.

The tokens in the Ecosystem Growth Reserve will be utilized to provide initial liquidity for a smooth trading experience from launch day, bootstrap new GnoSwap features, fund public goods on Gnoland, and make strategic investments to drive the growth of the ecosystem.

Ultimately, this reserve will aim to be utilized to capture the long-term value of $GNS for the $GNS holders, who are the backbone of the protocol's long-term success.


# Emission

Following the genesis supply of 100 million $GNS, additional tokens are issued on a per-block basis based on a biennial halving schedule, which reduces the total annual token emission by half every two years. The halving occurs for four cycles, after which the emission rate remains constant until the total supply of 1 billion $GNS is reached.

The newly minted tokens will be split into three different categories, and after +12 years from Genesis, the distribution will be as follows:

<figure><img src="/files/Vvc3mMngAoWWcbLvcwkD" alt=""><figcaption></figcaption></figure>

<table><thead><tr><th width="224">Category</th><th width="159">Amount ($GNS)</th><th>Emission Pct.</th><th>Total Supply Pct.</th></tr></thead><tbody><tr><td>Liquidity Staking Pools</td><td>675,000,000</td><td>75%</td><td>67.5%</td></tr><tr><td>DevOps</td><td>180,000,000</td><td>20%</td><td>18%</td></tr><tr><td>Community Pool</td><td>45,000,000</td><td>5%</td><td>4.5%</td></tr><tr><td><strong>Total</strong></td><td><strong>900,000,000</strong></td><td><strong>100%</strong></td><td><strong>90%</strong></td></tr></tbody></table>

#### 1. Liquidity Staking Pools

75% of newly minted tokens will be distributed to the liquidity staking pools to reward long-term liquidity providers who stake their positions. This ensures that GnoSwap's direction aligns with the interests of active contributors, promoting sustainability, liquidity growth, and fostering participation in the ecosystem.

#### 2. Development & Operations

20% of newly minted tokens per block will be distributed to the GnoSwap Team for development and operations. This prevents excessive concentration of power by the team while incentivizing continuous contributions by aligning interests fairly and transparently.

The GnoSwap Team considers the Development & Operations allocation as a vital element in securing the long-term viability, stability, and enhancement of the GnoSwap protocol. As part of our ongoing effort to embrace decentralization, we recognize the importance of meticulous planning and developing a robust ecosystem to achieve full decentralization. We are dedicated to iterating and evolving as we progress toward decentralization while maintaining the stability and growth of the GnoSwap protocol.

#### 3. Community Pool

5% of newly minted tokens will be distributed to the Community Pool, a treasury managed by the GnoSwap [Governance](/core-concepts/governance). This empowers the community and provides resources for community-driven initiatives such as funding community projects, grants and scholarships, liquidity provision, governance incentives, and emergency funds.

These requests will be thoroughly reviewed and evaluated by the GnoSwap community and governance to ensure they align with the long-term goals of the protocol.


# Release Schedule

The genesis supply of 100 million $GNS and the emissions based on four biennial halvings will be gradually released until the total supply reaches 1 billion $GNS, as illustrated in the graph below. The graph depicts the projected distribution timeline for the entire supply of $GNS tokens:

<figure><img src="/files/BFxB13izLWiKQrH7j15Z" alt=""><figcaption></figcaption></figure>

To further illustrate the token distribution, see the charts below for a comparison between the token distributions at Genesis and after +12 years from Genesis.

<figure><img src="/files/dNDJ7nOSCeSTuZ1dC5q4" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/10qm7uJHxWT6Tx2vuLUs" alt=""><figcaption></figcaption></figure>


# xGNS

### What is xGNS?

[Governance](/core-concepts/governance) in GnoSwap is powered by xGNS, a non-transferable governance token exclusively issued to users who stake $GNS into a single token staking pool. This staking pool functions as voting-power-escrow contracts for the GnoSwap Governance. **The issuing ratio for xGNS:$GNS is 1:1**, meaning the amount of xGNS a user receives equals the amount of $GNS they stake.

{% hint style="warning" %}
**Unstaking Period**

A lock-up period of 7 days is triggered once you unstake your xGNS. During this period, the locked xGNS tokens will be ineligible to receive staking rewards and have no voting powers. The unstaking mechanism exists to ensure that the $GNS tokens from which voting power originates are exposed to the full effect of the proposal, adding a layer of "skin in the game".
{% endhint %}

### How to Use xGNS

1. Stake $GNS in the governance staking pool via the [GnoSwap Governance Page.](/user-guide/governance/delegate)
2. Receive xGNS corresponding to the amount of $GNS you staked **at a 1:1 ratio.**
3. As soon as you receive xGNS, **you become eligible to vote in governance and start earning rewards from** [**Protocol Fees**](/core-concepts/fees#protocol-fees).
4. Once you unstake your xGNS, **a 7-day lock-up period is applied**. During this time, **your tokens will become inactive**, meaning **you can't participate in governance or earn protocol rewards.**
5. After the 7-day lock-up period, you can claim the principal $GNS you previously staked via the [GnoSwap Governance Page.](https://docs.gnoswap.io/gnoswap-token/pages/mW3A3UFkXbUDfdfxW85w#id-7.-check-your-undelegation-balance) (You can claim protocol rewards at any time regardless of this lock-up.)

The staking mechanism in GnoSwap is designed to incentivize the $GNS holders with the greatest commitment to the protocol's long-term success by granting them governance power. This enables active participation in voting on proposals and influencing the direction of the GnoSwap protocol.


# Overview

Welcome to the GnoSwap Realm (smart contracts in Gno) documentation. This section contains technical documentation for the realms that compose the GnoSwap Protocol. Use these guides to learn how each contract interacts within GnoSwap or to integrate GnoSwap into your product.

### Contract Structure

Here’s a quick look at the primary contracts and their purposes:

* **Pool Contract**: Handles liquidity management, including creating new liquidity positions and withdrawing liquidity.
* **Position Contract**: Manages user-specific assets and liquidity, allowing users to define their asset boundaries and manage their exposure.
* **Staker Contract**: Rewards users who provide liquidity or hold specific assets, managing incentives and emission rates.
* **Router Contract**: Connects different pools for seamless token swaps.
* **Governance Contract**: Manages protocol governance, allowing GNS holders to vote on proposals and enact protocol changes.
* **Launchpad Contract**: Manages project creation and reward distribution, enabling users to participate with GNS and allowing projects to distribute tokens and receive funding via yield redirection.

Each contract section provides detailed explanations of functions, parameters, and expected outputs.

### Resources

* [GnoSwap Contracts](https://github.com/gnoswap-labs/gnoswap/tree/main): A GitHub repository containing the GnoSwap Contracts' source code.
* [README](https://github.com/gnoswap-labs/gnoswap/blob/main/README.md): Setup and installation instructions.
* [License](https://github.com/gnoswap-labs/gnoswap/blob/main/LICENSE): Licensing information for using GnoSwap.


# Errors

## Errors Overview

This section provides a comprehensive list of error codes encountered using the GnoSwap contracts. Error codes are organized by contract, making it easier to troubleshoot issues specific to different components of the system.

Each error entry includes:

* **Code**: A unique identifier for the error.
* **Message**: A description of the error and the conditions under which it occurs.


# Pool

The following table outlines potential errors that may occur during interactions with the pool contract in GnoSwap:

| Code             | Error                                           | Description                                                                                                                          |
| ---------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| GNOSWAP-POOL-001 | Unsupported fee tier                            | Occurs when an unsupported fee tier is specified for pool operations.                                                                |
| GNOSWAP-POOL-002 | Pool already created                            | Occurs when there is an attempt to create a pool that already exists with the same token pair and fee tier.                          |
| GNOSWAP-POOL-003 | Out of range for numeric value                  | Occurs when a numeric input exceeds the allowed range for liquidity or token amounts.                                                |
| GNOSWAP-POOL-004 | Invalid input data                              | Occurs when input data does not meet the expected format or parameters, making the operation invalid.                                |
| GNOSWAP-POOL-005 | Requested data not found                        | Occurs when the system is unable to locate the requested data for the operation, such as a specific pool or liquidity position.      |
| GNOSWAP-POOL-006 | Invalid liquidity calculated                    | Occurs when the calculated liquidity value is incorrect, possibly due to invalid inputs or calculation errors.                       |
| GNOSWAP-POOL-007 | Zero liquidity                                  | Occurs when an operation that requires positive liquidity is attempted with zero liquidity.                                          |
| GNOSWAP-POOL-008 | Same token used in single pool                  | Occurs when the same token is used twice in a single pool, which is invalid in a pool configuration.                                 |
| GNOSWAP-POOL-009 | TickLower is invalid                            | Occurs when request tickLower does not match to the tickSpacing.                                                                     |
| GNOSWAP-POOL-010 | TickUpper is invalid                            | Occurs when request tickUpper does not match to the tickSpacing.                                                                     |
| GNOSWAP-POOL-011 | Invalid swap amount                             | Occurs when the swap amount provided is invalid, such as a negative value or an amount that exceeds available liquidity.             |
| GNOSWAP-POOL-012 | Invalid protocol fee percentage                 | Occurs when an invalid protocol fee percentage is provided, such as a value outside the acceptable range.                            |
| GNOSWAP-POOL-013 | Invalid withdrawal fee percentage               | Occurs when the withdrawal fee percentage is outside the allowed range or is otherwise invalid.                                      |
| GNOSWAP-POOL-014 | Cannot swap while pool is locked                | Occurs when a user attempts to perform a swap operation while the pool is locked, making swaps temporarily unavailable.              |
| GNOSWAP-POOL-015 | Swap price out of range                         | Occurs when the specified swap price falls outside the acceptable range defined by the pool's parameters.                            |
| GNOSWAP-POOL-016 | Token transfer failed                           | Occurs when a token transfer fails due to issues such as insufficient gas, network issues, or restrictions on the token itself.      |
| GNOSWAP-POOL-017 | Invalid tick and tick spacing requested         | Occurs when an invalid tick value or tick spacing is provided, which does not align with the pool's tick configuration requirements. |
| GNOSWAP-POOL-018 | TickLower is greater than or equal to tickUpper | Occurs when tickLower is equal or greater than tickUpper while it should be always less.                                             |
| GNOSWAP-POOL-019 | Underflow                                       | Occurs when mathematical results underflow numeric range.                                                                            |
| GNOSWAP-POOL-020 | Overflow                                        | Occurs when mathematical results overflow numeric range.                                                                             |
| GNOSWAP-POOL-021 | Balance update failed                           | Occurs when token transfer succeeds, but pool's balance did not update.                                                              |
| GNOSWAP-POOL-022 | Invalid payer                                   | Occurs when the payer address is invalid or unauthorized.                                                                            |
| GNOSWAP-POOL-023 | Not access EOA                                  | Occurs when the caller is not an externally owned account (EOA).                                                                     |
| GNOSWAP-POOL-024 | Insufficient payment                            | Occurs when the payment amount is insufficient for the operation.                                                                    |
| GNOSWAP-POOL-025 | Not initialized observation                     | Occurs when an observation has not been initialized.                                                                                 |
| GNOSWAP-POOL-026 | Target timestamp before oldest observation      | Occurs when the target timestamp is before the oldest available observation.                                                         |


# Position

The following table outlines potential errors that may occur during interactions with the position contract in GnoSwap:

| Code                 | Error                                        | Description                                                                                                             |
| -------------------- | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| GNOSWAP-POSITION-001 | Caller has no permission                     | Occurs when a user without the necessary permissions attempts an action that requires authorization.                    |
| GNOSWAP-POSITION-002 | Slippage failed                              | Occurs when the actual execution price deviates beyond the allowed slippage tolerance specified by the user.            |
| GNOSWAP-POSITION-003 | Wrap, unwrap failed                          | Occurs when an attempt to wrap or unwrap tokens fails, potentially due to invalid inputs or insufficient token balance. |
| GNOSWAP-POSITION-004 | Invalid input data                           | Occurs when input data does not meet the expected format or values, making the operation invalid.                       |
| GNOSWAP-POSITION-005 | Requested data not found                     | Occurs when the system is unable to locate the requested data related to a specific position.                           |
| GNOSWAP-POSITION-006 | Transaction expired                          | Occurs when a transaction is attempted after its designated expiration time, making it invalid.                         |
| GNOSWAP-POSITION-007 | Cannot wrap less than minimum amount         | Occurs when the user attempts to wrap an amount below the minimum allowed, which is not permissible.                    |
| GNOSWAP-POSITION-008 | Position is not clear                        | Occurs when a position is not in a finalized state, preventing certain operations from proceeding.                      |
| GNOSWAP-POSITION-009 | Zero liquidity                               | Occurs when an operation that requires positive liquidity is attempted with zero liquidity.                             |
| GNOSWAP-POSITION-010 | Position with same positionId already exists | Occurs when user mints a new position, but positionId did not update.                                                   |
| GNOSWAP-POSITION-011 | Invalid address                              | Occurs when requested address is invalid.                                                                               |
| GNOSWAP-POSITION-012 | Position does not exist                      | Occurs when request position does not exist.                                                                            |
| GNOSWAP-POSITION-013 | No UGNOTs were sent                          | Occurs when user mints a new position with ugnot, but did not send any.                                                 |
| GNOSWAP-POSITION-014 | Insufficient UGNOT provided                  | Occurs when user mints a new position with ugnot, but did not send with requested amount.                               |
| GNOSWAP-POSITION-015 | Invalid token address                        | Occurs when request token path is invalid.                                                                              |
| GNOSWAP-POSITION-016 | Underflow                                    | Occurs when mathematical results underflow numeric range.                                                               |
| GNOSWAP-POSITION-017 | Overflow                                     | Occurs when mathematical results overflow numeric range.                                                                |
| GNOSWAP-POSITION-018 | Invalid liquidity                            | Occurs when handling liquidity more than position has.                                                                  |


# Router

The following table outlines potential errors that may occur during interactions with the router contract in GnoSwap:

| Code               | Error                                | Description                                                                                                               |
| ------------------ | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
| GNOSWAP-ROUTER-001 | Slippage check failed                | Occurs when the execution price deviates beyond the user's specified slippage tolerance, causing the transaction to fail. |
| GNOSWAP-ROUTER-002 | Invalid routes and quotes            | Occurs when requested routes and quote does not match length.                                                             |
| GNOSWAP-ROUTER-003 | Transaction expired                  | Occurs when transaction failed due to expiration.                                                                         |
| GNOSWAP-ROUTER-004 | Invalid input data                   | Occurs when input data does not match the expected format or parameters, making the operation invalid.                    |
| GNOSWAP-ROUTER-005 | Invalid pool fee tier                | Occurs when the pool fee tier specified in the transaction is not valid for pool.                                         |
| GNOSWAP-ROUTER-006 | Invalid swap fee                     | Occurs when the swap fee specified in the transaction is not valid for the operation or pool.                             |
| GNOSWAP-ROUTER-007 | Invalid swap type                    | Occurs when an unsupported or incorrect swap type is specified, causing the transaction to fail.                          |
| GNOSWAP-ROUTER-008 | Invalid pool path                    | Occurs when an invalid or non-existent pool path is referenced in the transaction.                                        |
| GNOSWAP-ROUTER-009 | Cannot wrap less than minimum amount | Occurs when the amount provided for an operation is below the minimum allowed for wugnot tokens.                          |
| GNOSWAP-ROUTER-010 | Number of hops must be 1\~3          | Occurs when single path has unsupported number of hops.                                                                   |
| GNOSWAP-ROUTER-011 | Cannot swap same token               | Occurs when an attempt is made to swap the same token as input and output.                                                |
| GNOSWAP-ROUTER-012 | Overflow                             | Occurs when mathematical results overflow numeric range.                                                                  |
| GNOSWAP-ROUTER-013 | Invalid route path                   | Occurs when the route path is invalid or malformed.                                                                       |
| GNOSWAP-ROUTER-014 | Invalid route first token            | Occurs when the first token in the route does not match expected input token.                                             |
| GNOSWAP-ROUTER-015 | Invalid route last token             | Occurs when the last token in the route does not match expected output token.                                             |
| GNOSWAP-ROUTER-016 | Invalid swap amount                  | Occurs when the swap amount is invalid or out of acceptable range.                                                        |
| GNOSWAP-ROUTER-017 | Unauthorized caller                  | Occurs when the caller does not have permission to execute the operation.                                                 |


# Staker

The following table outlines potential errors that may occur during interactions with the staker contract in GnoSwap:

| Code               | Error                                | Description                                                                                                        |
| ------------------ | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------ |
| GNOSWAP-STAKER-001 | Caller has no permission             | Occurs when a user without the necessary permissions attempts an action restricted to authorized callers.          |
| GNOSWAP-STAKER-002 | Pool not found                       | Occurs when non incentivized pool is used.                                                                         |
| GNOSWAP-STAKER-003 | Cannot wrap less than minimum amount | Occurs when the user attempts to wrap an amount below the minimum allowed, which is not permissible.               |
| GNOSWAP-STAKER-004 | Invalid input data                   | Occurs when input data does not meet the required format or values for a staking operation.                        |
| GNOSWAP-STAKER-005 | Invalid unstaking fee                | Occurs when an invalid unstaking fee is specified, such as a fee outside the acceptable range.                     |
| GNOSWAP-STAKER-006 | Already staked position              | Occurs when an attempt is made to stake a position that is already staked.                                         |
| GNOSWAP-STAKER-007 | Pool is not incentivized             | Occurs when a staking operation references a pool that has no incentives assigned.                                 |
| GNOSWAP-STAKER-008 | Cannot end incentive                 | Occurs when an incentive program is still active, and an attempt is made to end it prematurely.                    |
| GNOSWAP-STAKER-009 | Invalid incentive start time         | Occurs when an invalid start time is provided for an incentive program.                                            |
| GNOSWAP-STAKER-010 | Cannot delete default external token | Occurs when there is an attempt to delete a default token used for external rewards, which is not allowed.         |
| GNOSWAP-STAKER-011 | Invalid pool path                    | Occurs when an invalid or non-existent pool path is provided for staking or rewards.                               |
| GNOSWAP-STAKER-012 | Invalid pool tier                    | Occurs when an invalid pool tier is specified, which does not align with the staking contract's tier requirements. |
| GNOSWAP-STAKER-013 | Requested data not found             | Occurs when the system cannot locate the requested data needed for a staking operation.                            |
| GNOSWAP-STAKER-014 | Unexpected calculation error         | Occurs when a calculation within the staking contract produces an unexpected or invalid result.                    |
| GNOSWAP-STAKER-015 | Zero liquidity                       | Occurs when an operation that requires positive liquidity is attempted with zero liquidity.                        |
| GNOSWAP-STAKER-016 | Invalid incentive duration           | Occurs when the specified duration for an incentive program is outside the acceptable range.                       |
| GNOSWAP-STAKER-017 | Not allowed for external reward      | Occurs when an operation attempts to use a token not approved for external rewards.                                |
| GNOSWAP-STAKER-018 | Incentive already exists             | Occurs when same reward are being created in single transaction.                                                   |
| GNOSWAP-STAKER-019 | Overflow                             | Occurs when mathematical results overflow numeric range.                                                           |
| GNOSWAP-STAKER-020 | Cannot add existing token            | Occurs when attempting to add a token that is already registered for external rewards.                             |
| GNOSWAP-STAKER-021 | Not available to update collect time | Occurs when an attempt is made to update collection time under invalid conditions.                                 |


# Governance

The following table outlines potential errors that may occur during interactions with the governance contract in GnoSwap:

## Governance

| Code                   | Error                                   | Description                                                                                                         |
| ---------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| GNOSWAP-GOVERNANCE-001 | Invalid input                           | Occurs when input data does not meet the required format or values for a governance operation.                      |
| GNOSWAP-GOVERNANCE-002 | Requested data not found                | Occurs when the system is unable to locate the requested data for a governance action, such as a specific proposal. |
| GNOSWAP-GOVERNANCE-003 | Not enough balance                      | Occurs when a user attempts an action without sufficient token balance to fulfill the requirement.                  |
| GNOSWAP-GOVERNANCE-004 | Cannot vote twice                       | Occurs when a user tries to vote multiple times on the same proposal.                                               |
| GNOSWAP-GOVERNANCE-005 | Not enough voting power                 | Occurs when a user does not have enough voting power to cast a vote on a proposal.                                  |
| GNOSWAP-GOVERNANCE-006 | Cannot cancel already canceled proposal | Occurs when an attempt is made to cancel a proposal that has already been canceled.                                 |
| GNOSWAP-GOVERNANCE-007 | Unable to cancel voting proposal        | Occurs when a user tries to cancel a proposal that is in the voting phase and cannot be canceled.                   |
| GNOSWAP-GOVERNANCE-008 | Cannot execute text proposal            | Occurs when an attempt is made to execute a text proposal, which is not executable.                                 |
| GNOSWAP-GOVERNANCE-009 | Unable to vote out of voting period     | Occurs when a user votes to proposal while voting out of voting period.                                             |
| GNOSWAP-GOVERNANCE-010 | Invalid message format                  | Occurs when a user submits a proposal with invalid execution message format.                                        |
| GNOSWAP-GOVERNANCE-011 | Already active proposal                 | Occurs when there is already an active proposal and another proposal creation is attempted.                         |
| GNOSWAP-GOVERNANCE-012 | Proposal not found                      | Occurs when the specified proposal cannot be found.                                                                 |
| GNOSWAP-GOVERNANCE-013 | Proposal not executable                 | Occurs when a proposal is in a state that does not allow execution.                                                 |
| GNOSWAP-GOVERNANCE-014 | Not proposer                            | Occurs when a non-proposer attempts to perform an action reserved for the proposer.                                 |
| GNOSWAP-GOVERNANCE-015 | Invalid configuration                   | Occurs when governance configuration parameters are invalid.                                                        |
| GNOSWAP-GOVERNANCE-016 | Invalid execution: handler not found    | Occurs when the execution handler for a proposal cannot be found.                                                   |
| GNOSWAP-GOVERNANCE-017 | Invalid smoothing period                | Occurs when an invalid smoothing period is specified.                                                               |

## Governance Staker

| Code                    | Error                                    | Description                                                                                          |
| ----------------------- | ---------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| GNOSWAP-GOV\_STAKER-001 | Requested data not found                 | Occurs when the system is unable to locate the requested data for a staking or governance operation. |
| GNOSWAP-GOV\_STAKER-002 | Invalid amount                           | Occurs when a token transfer operation is attempted with invalid amounts.                            |
| GNOSWAP-GOV\_STAKER-003 | Zero delegated amount                    | Occurs when a delegation operation is attempted with an amount of zero, which is invalid.            |
| GNOSWAP-GOV\_STAKER-004 | Not enough delegated                     | Occurs when a user tries to undelegate more tokens than they have delegated.                         |
| GNOSWAP-GOV\_STAKER-005 | Invalid address                          | Occurs when an invalid address is provided in a staking or delegation operation.                     |
| GNOSWAP-GOV\_STAKER-006 | Not enough balance                       | Occurs when a user attempts an action without sufficient token balance to complete the operation.    |
| GNOSWAP-GOV\_STAKER-007 | Cannot delegate less than minimum amount | Occurs when a user attempts to delegate an amount that is below the minimum required.                |
| GNOSWAP-GOV\_STAKER-008 | Invalid snapshot time                    | Occurs when an invalid snapshot time is provided.                                                    |
| GNOSWAP-GOV\_STAKER-009 | Cannot redelegate to same address        | Occurs when a user attempts to redelegate to the same address they are currently delegating to.      |
| GNOSWAP-GOV\_STAKER-010 | Withdraw is not collectable              | Occurs when a user attempts to collect a withdrawal that is not yet available.                       |


# Launchpad

The following table outlines potential errors that may occur during interactions with the launchpad contract in GnoSwap:

| Code                  | Error                                    | Description                                                                                                 |
| --------------------- | ---------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| GNOSWAP-LAUNCHPAD-001 | No left reward                           | Occurs when there is no remaining reward available for distribution.                                        |
| GNOSWAP-LAUNCHPAD-002 | Invalid address                          | Occurs when an invalid address is provided for a project or funding operation.                              |
| GNOSWAP-LAUNCHPAD-003 | Requested data not found                 | Occurs when the system is unable to locate the requested data, such as project or tier information.         |
| GNOSWAP-LAUNCHPAD-004 | Project is inactive                      | Occurs when an operation requiring an active project is attempted on an inactive project.                   |
| GNOSWAP-LAUNCHPAD-005 | Invalid input data                       | Occurs when input data does not meet the required format or parameters, making the operation invalid.       |
| GNOSWAP-LAUNCHPAD-006 | Cannot create same project in same block | Occurs when there is an attempt to create two projects with identical configurations within the same block. |
| GNOSWAP-LAUNCHPAD-007 | Invalid tier                             | Occurs when a specified tier does not meet the criteria for use in the launchpad operation.                 |
| GNOSWAP-LAUNCHPAD-008 | Insufficient balance                     | Occurs when the contract balance is insufficient for the operation.                                         |
| GNOSWAP-LAUNCHPAD-009 | Invalid data                             | Occurs when deposit condition is nil.                                                                       |
| GNOSWAP-LAUNCHPAD-010 | Invalid amount                           | Occurs when transfer token with invalid amount.                                                             |
| GNOSWAP-LAUNCHPAD-011 | Invalid reward state                     | Occurs when collecting reward while state is invalid.                                                       |
| GNOSWAP-LAUNCHPAD-012 | Not exist deposit                        | Occurs when collecting reward from non exists deposit.                                                      |
| GNOSWAP-LAUNCHPAD-013 | Already collected                        | Occurs when collecting reward from same deposit in same block.                                              |
| GNOSWAP-LAUNCHPAD-014 | Invalid owner                            | Occurs when collecting reward, but caller is not address who made deposit.                                  |
| GNOSWAP-LAUNCHPAD-015 | Invalid time                             | Occurs when the provided time parameter is invalid.                                                         |
| GNOSWAP-LAUNCHPAD-016 | Project lock period is not over yet      | Occurs when attempting to perform an operation before the project lock period has ended.                    |
| GNOSWAP-LAUNCHPAD-017 | Overflow                                 | Occurs when mathematical results overflow numeric range.                                                    |


# Pool


# getter.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/pool/v1/getter.gno>" %}

## GetPoolCount

```go
func GetPoolCount() int
```

GetPoolCount returns the total number of pools.

#### Return Values

| Name    | Type | Description           |
| ------- | ---- | --------------------- |
| `count` | int  | total number of pools |

## GetPoolPaths

```go
func GetPoolPaths(
	offset int,
	count int
) []string
```

GetPoolPaths returns a paginated list of pool paths.

#### Parameters

| Name     | Type | Description                            |
| -------- | ---- | -------------------------------------- |
| `offset` | int  | starting index for pagination          |
| `count`  | int  | maximum number of pool paths to return |

#### Return Values

| Name        | Type      | Description                       |
| ----------- | --------- | --------------------------------- |
| `poolPaths` | \[]string | pool paths for the requested page |

## ExistsPoolPath

```go
func ExistsPoolPath(
	poolPath string
) bool
```

ExistsPoolPath checks if a pool exists at the given path.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name     | Type | Description             |
| -------- | ---- | ----------------------- |
| `exists` | bool | true if the pool exists |

## GetBalances

```go
func GetBalances(
	poolPath string
) (string, string)
```

GetBalances returns the balances of the pool.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name       | Type   | Description       |
| ---------- | ------ | ----------------- |
| `balance0` | string | balance of token0 |
| `balance1` | string | balance of token1 |

## GetBalanceToken0

```go
func GetBalanceToken0(
	poolPath string
) string
```

GetBalanceToken0 returns the balance of token0 in the pool.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name       | Type   | Description       |
| ---------- | ------ | ----------------- |
| `balance0` | string | balance of token0 |

## GetBalanceToken1

```go
func GetBalanceToken1(
	poolPath string
) string
```

GetBalanceToken1 returns the balance of token1 in the pool.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name       | Type   | Description       |
| ---------- | ------ | ----------------- |
| `balance1` | string | balance of token1 |

## GetFee

```go
func GetFee(
	poolPath string
) uint32
```

GetFee returns the fee tier of the pool.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name  | Type   | Description   |
| ----- | ------ | ------------- |
| `fee` | uint32 | pool fee tier |

## GetFeeAmountTickSpacing

```go
func GetFeeAmountTickSpacing(
	fee uint32
) (spacing int32)
```

GetFeeAmountTickSpacing returns the tick spacing for a given fee tier.

#### Parameters

| Name  | Type   | Description   |
| ----- | ------ | ------------- |
| `fee` | uint32 | pool fee tier |

#### Return Values

| Name      | Type  | Description                   |
| --------- | ----- | ----------------------------- |
| `spacing` | int32 | tick spacing for the fee tier |

## GetFeeAmountTickSpacings

```go
func GetFeeAmountTickSpacings() map[uint32]int32

```

GetFeeAmountTickSpacings returns all fee tier to tick spacing mappings.

#### Return Values

| Name                    | Type              | Description                         |
| ----------------------- | ----------------- | ----------------------------------- |
| `feeAmountTickSpacings` | map\[uint32]int32 | mapping of fee tier to tick spacing |

## GetFeeGrowthGlobal0X128

```go
func GetFeeGrowthGlobal0X128(
	poolPath string
) string
```

GetFeeGrowthGlobal0X128 returns the global fee growth for token0.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name                   | Type   | Description                       |
| ---------------------- | ------ | --------------------------------- |
| `feeGrowthGlobal0X128` | string | fee growth for token0 as Q128.128 |

## GetFeeGrowthGlobal1X128

```go
func GetFeeGrowthGlobal1X128(
	poolPath string
) string
```

GetFeeGrowthGlobal1X128 returns the global fee growth for token1.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name                   | Type   | Description                       |
| ---------------------- | ------ | --------------------------------- |
| `feeGrowthGlobal1X128` | string | fee growth for token1 as Q128.128 |

## GetFeeGrowthGlobalX128

```go
func GetFeeGrowthGlobalX128(
	poolPath string
) (*u256.Uint, *u256.Uint)

```

GetFeeGrowthGlobalX128 returns the global fee growth for both tokens.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name                   | Type        | Description                       |
| ---------------------- | ----------- | --------------------------------- |
| `feeGrowthGlobal0X128` | \*u256.Uint | fee growth for token0 as Q128.128 |
| `feeGrowthGlobal1X128` | \*u256.Uint | fee growth for token1 as Q128.128 |

## GetFeeGrowthGlobals

```go
func GetFeeGrowthGlobals(
	poolPath string
) (string, string)

```

GetFeeGrowthGlobals returns the global fee growth for both tokens.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name                   | Type   | Description                       |
| ---------------------- | ------ | --------------------------------- |
| `feeGrowthGlobal0X128` | string | fee growth for token0 as Q128.128 |
| `feeGrowthGlobal1X128` | string | fee growth for token1 as Q128.128 |

## GetLiquidity

```go
func GetLiquidity(
	poolPath string
) string

```

GetLiquidity returns the current liquidity in the pool.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name        | Type   | Description                           |
| ----------- | ------ | ------------------------------------- |
| `liquidity` | string | current liquidity as a decimal string |

## GetMaxLiquidityPerTick

```go
func GetMaxLiquidityPerTick(
	poolPath string
) string

```

GetMaxLiquidityPerTick returns the maximum liquidity per tick for the pool.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name                  | Type   | Description                                |
| --------------------- | ------ | ------------------------------------------ |
| `maxLiquidityPerTick` | string | max liquidity per tick as a decimal string |

## GetObservation

```go
func GetObservation(
	poolPath string,
	secondsAgo int64
) (tickCumulative int64, liquidityCumulative string, secondsPerLiquidityCumulativeX128 string, blockTimestamp int64)

```

GetObservation returns observation data for calculating time-weighted averages.

#### Parameters

| Name         | Type   | Description                                           |
| ------------ | ------ | ----------------------------------------------------- |
| `poolPath`   | string | pool identifier in token0:token1:fee form             |
| `secondsAgo` | int64  | time window to look back from current block timestamp |

#### Return Values

| Name                                | Type   | Description                                 |
| ----------------------------------- | ------ | ------------------------------------------- |
| `tickCumulative`                    | int64  | tick cumulative                             |
| `liquidityCumulative`               | string | liquidity cumulative                        |
| `secondsPerLiquidityCumulativeX128` | string | seconds per liquidity cumulative (Q128.128) |
| `blockTimestamp`                    | int64  | block timestamp of the observation          |

## GetPoolCreationFee

```go
func GetPoolCreationFee() int64
```

GetPoolCreationFee returns the current pool creation fee.

#### Return Values

| Name              | Type  | Description       |
| ----------------- | ----- | ----------------- |
| `poolCreationFee` | int64 | pool creation fee |

## GetInitializedTicksInRange

```go
func GetInitializedTicksInRange(
	poolPath string,
	tickLower int32,
	tickUpper int32
) []int32

```

GetInitializedTicksInRange returns initialized ticks within the given range.

#### Parameters

| Name        | Type   | Description                               |
| ----------- | ------ | ----------------------------------------- |
| `poolPath`  | string | pool identifier in token0:token1:fee form |
| `tickLower` | int32  | lower tick boundary                       |
| `tickUpper` | int32  | upper tick boundary                       |

#### Return Values

| Name    | Type     | Description                               |
| ------- | -------- | ----------------------------------------- |
| `ticks` | \[]int32 | initialized tick indices within the range |

## GetPoolPositionCount

```go
func GetPoolPositionCount(
	poolPath string
) int

```

GetPoolPositionCount returns the number of positions in a pool.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name    | Type | Description                     |
| ------- | ---- | ------------------------------- |
| `count` | int  | number of positions in the pool |

***

## GetPoolPositionKeys

```go
func GetPoolPositionKeys(
	poolPath string,
	offset int,
	count int
) []string

```

GetPoolPositionKeys returns a paginated list of position keys in a pool.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `offset`   | int    | starting index for pagination             |
| `count`    | int    | maximum number of keys to return          |

#### Return Values

| Name   | Type      | Description                          |
| ------ | --------- | ------------------------------------ |
| `keys` | \[]string | position keys for the requested page |

***

## GetPositionFeeGrowthInside0LastX128

```go
func GetPositionFeeGrowthInside0LastX128(
	poolPath string,
	key string
) string
```

GetPositionFeeGrowthInside0LastX128 returns the last recorded fee growth inside for token0.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `key`      | string | position key                              |

#### Return Values

| Name                       | Type   | Description                               |
| -------------------------- | ------ | ----------------------------------------- |
| `feeGrowthInside0LastX128` | string | fee growth for token0 inside the position |

***

## GetPositionFeeGrowthInside1LastX128

```go
func GetPositionFeeGrowthInside1LastX128(
	poolPath string,
	key string
) string
```

GetPositionFeeGrowthInside1LastX128 returns the last recorded fee growth inside for token1.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `key`      | string | position key                              |

#### Return Values

| Name                       | Type   | Description                               |
| -------------------------- | ------ | ----------------------------------------- |
| `feeGrowthInside1LastX128` | string | fee growth for token1 inside the position |

***

## GetPositionFeeGrowthInsideLastX128

```go
func GetPositionFeeGrowthInsideLastX128(
	poolPath string,
	key string
) (*u256.Uint, *u256.Uint)

```

GetPositionFeeGrowthInsideLastX128 returns the last recorded fee growth inside for both tokens.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `key`      | string | position key                              |

#### Return Values

| Name                       | Type        | Description                               |
| -------------------------- | ----------- | ----------------------------------------- |
| `feeGrowthInside0LastX128` | \*u256.Uint | fee growth for token0 inside the position |
| `feeGrowthInside1LastX128` | \*u256.Uint | fee growth for token1 inside the position |

***

## GetPositionFeeGrowthInsideLasts

```go
func GetPositionFeeGrowthInsideLasts(
	poolPath string,
	key string
) (string, string)

```

GetPositionFeeGrowthInsideLasts returns the last recorded fee growth inside for both tokens.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `key`      | string | position key                              |

#### Return Values

| Name                       | Type   | Description                               |
| -------------------------- | ------ | ----------------------------------------- |
| `feeGrowthInside0LastX128` | string | fee growth for token0 inside the position |
| `feeGrowthInside1LastX128` | string | fee growth for token1 inside the position |

***

## GetPositionLiquidity

```go
func GetPositionLiquidity(
	poolPath string,
	key string
) *u256.Uint

```

GetPositionLiquidity returns the liquidity of a position.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `key`      | string | position key                              |

#### Return Values

| Name        | Type        | Description        |
| ----------- | ----------- | ------------------ |
| `liquidity` | \*u256.Uint | position liquidity |

***

## GetPositionTokensOwed

```go
func GetPositionTokensOwed(
	poolPath string,
	key string
) (string, string)

```

GetPositionTokensOwed returns the amount of tokens owed for both tokens.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `key`      | string | position key                              |

#### Return Values

| Name          | Type   | Description                           |
| ------------- | ------ | ------------------------------------- |
| `tokensOwed0` | string | amount of token0 owed to the position |
| `tokensOwed1` | string | amount of token1 owed to the position |

***

## GetPositionTokensOwed0

```go
func GetPositionTokensOwed0(
	poolPath string,
	key string
) string

```

GetPositionTokensOwed0 returns the amount of token0 owed to a position.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `key`      | string | position key                              |

#### Return Values

| Name          | Type   | Description                           |
| ------------- | ------ | ------------------------------------- |
| `tokensOwed0` | string | amount of token0 owed to the position |

***

## GetPositionTokensOwed1

```go
func GetPositionTokensOwed1(
	poolPath string,
	key string
) string

```

GetPositionTokensOwed1 returns the amount of token1 owed to a position.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `key`      | string | position key                              |

#### Return Values

| Name          | Type   | Description                           |
| ------------- | ------ | ------------------------------------- |
| `tokensOwed1` | string | amount of token1 owed to the position |

***

## GetProtocolFeesToken0

```go
func GetProtocolFeesToken0(
	poolPath string
) string

```

GetProtocolFeesToken0 returns accumulated protocol fees for token0.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name                 | Type   | Description                          |
| -------------------- | ------ | ------------------------------------ |
| `protocolFeesToken0` | string | accumulated protocol fees for token0 |

***

## GetProtocolFeesToken1

```go
func GetProtocolFeesToken1(
	poolPath string
) string

```

GetProtocolFeesToken1 returns accumulated protocol fees for token1.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name                 | Type   | Description                          |
| -------------------- | ------ | ------------------------------------ |
| `protocolFeesToken1` | string | accumulated protocol fees for token1 |

***

## GetProtocolFeesTokens

```go
func GetProtocolFeesTokens(
	poolPath string
) (string, string)

```

GetProtocolFeesTokens returns the accumulated protocol fees for both tokens.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name                 | Type   | Description                          |
| -------------------- | ------ | ------------------------------------ |
| `protocolFeesToken0` | string | accumulated protocol fees for token0 |
| `protocolFeesToken1` | string | accumulated protocol fees for token1 |

***

## GetSlot0FeeProtocol

```go
func GetSlot0FeeProtocol(
	poolPath string
) uint8

```

GetSlot0FeeProtocol returns the protocol fee rate from slot0.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name          | Type  | Description                       |
| ------------- | ----- | --------------------------------- |
| `feeProtocol` | uint8 | protocol fee rate packed in slot0 |

***

## GetSlot0SqrtPriceX96

```go
func GetSlot0SqrtPriceX96(
	poolPath string
) *u256.Uint

```

GetSlot0SqrtPriceX96 returns the current sqrt price from slot0.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name           | Type        | Description                 |
| -------------- | ----------- | --------------------------- |
| `sqrtPriceX96` | \*u256.Uint | sqrt price in Q64.96 format |

***

## GetSlot0Tick

```go
func GetSlot0Tick(
	poolPath string
) int32

```

GetSlot0Tick returns the current tick from slot0.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name   | Type  | Description  |
| ------ | ----- | ------------ |
| `tick` | int32 | current tick |

***

## GetSlot0Unlocked

```go
func GetSlot0Unlocked(
	poolPath string
) bool

```

GetSlot0Unlocked returns the locked status from slot0.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name       | Type | Description              |
| ---------- | ---- | ------------------------ |
| `unlocked` | bool | true if pool is unlocked |

***

## GetTWAP

```go
func GetTWAP(
	poolPath string,
	secondsAgo uint32
) (int32, *u256.Uint, error)

```

GetTWAP returns the time-weighted average price for a pool. Returns arithmetic mean tick and harmonic mean liquidity over the time period.

#### Parameters

| Name         | Type   | Description                               |
| ------------ | ------ | ----------------------------------------- |
| `poolPath`   | string | pool identifier in token0:token1:fee form |
| `secondsAgo` | uint32 | lookback window in seconds                |

#### Return Values

| Name            | Type        | Description             |
| --------------- | ----------- | ----------------------- |
| `meanTick`      | int32       | arithmetic mean tick    |
| `meanLiquidity` | \*u256.Uint | harmonic mean liquidity |
| `err`           | error       | non-nil on failure      |

***

## GetTickBitmaps

```go
func GetTickBitmaps(
	poolPath string,
	wordPos int16
) (*u256.Uint, error)

```

GetTickBitmaps returns the tick bitmap for a given word position.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `wordPos`  | int16  | bitmap word position                      |

#### Return Values

| Name         | Type        | Description                            |
| ------------ | ----------- | -------------------------------------- |
| `tickBitmap` | \*u256.Uint | tick bitmap copy                       |
| `err`        | error       | non-nil if the bitmap cannot be loaded |

***

## GetTickCumulativeOutside

```go
func GetTickCumulativeOutside(
	poolPath string,
	tick int32
) int64

```

GetTickCumulativeOutside returns the tick cumulative value outside a tick.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `tick`     | int32  | tick index                                |

#### Return Values

| Name                    | Type  | Description                      |
| ----------------------- | ----- | -------------------------------- |
| `tickCumulativeOutside` | int64 | tick cumulative outside the tick |

***

## GetTickFeeGrowthOutside0X128

```go
func GetTickFeeGrowthOutside0X128(
	poolPath string,
	tick int32
) string

```

GetTickFeeGrowthOutside0X128 returns fee growth outside for token0 at a tick.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `tick`     | int32  | tick index                                |

#### Return Values

| Name                    | Type   | Description                               |
| ----------------------- | ------ | ----------------------------------------- |
| `feeGrowthOutside0X128` | string | fee growth outside for token0 as Q128.128 |

***

## GetTickFeeGrowthOutside1X128

```go
func GetTickFeeGrowthOutside1X128(
	poolPath string,
	tick int32
) string

```

GetTickFeeGrowthOutside1X128 returns fee growth outside for token1 at a tick.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `tick`     | int32  | tick index                                |

#### Return Values

| Name                    | Type   | Description                               |
| ----------------------- | ------ | ----------------------------------------- |
| `feeGrowthOutside1X128` | string | fee growth outside for token1 as Q128.128 |

***

## GetTickFeeGrowthOutsideX128

```go
func GetTickFeeGrowthOutsideX128(
	poolPath string,
	tick int32
) (*u256.Uint, *u256.Uint)

```

GetTickFeeGrowthOutsideX128 returns fee growth outside for both tokens at a tick.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `tick`     | int32  | tick index                                |

#### Return Values

| Name                    | Type        | Description                               |
| ----------------------- | ----------- | ----------------------------------------- |
| `feeGrowthOutside0X128` | \*u256.Uint | fee growth outside for token0 as Q128.128 |
| `feeGrowthOutside1X128` | \*u256.Uint | fee growth outside for token1 as Q128.128 |

***

## GetTickFeeGrowthOutsides

```go
func GetTickFeeGrowthOutsides(
	poolPath string,
	tick int32
) (string, string)

```

GetTickFeeGrowthOutsides returns fee growth outside for both tokens at a tick.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `tick`     | int32  | tick index                                |

#### Return Values

| Name                    | Type   | Description                               |
| ----------------------- | ------ | ----------------------------------------- |
| `feeGrowthOutside0X128` | string | fee growth outside for token0 as Q128.128 |
| `feeGrowthOutside1X128` | string | fee growth outside for token1 as Q128.128 |

***

## GetTickInitialized

```go
func GetTickInitialized(
	poolPath string,
	tick int32
) bool

```

GetTickInitialized returns whether a tick is initialized.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `tick`     | int32  | tick index                                |

#### Return Values

| Name          | Type | Description                     |
| ------------- | ---- | ------------------------------- |
| `initialized` | bool | true if the tick is initialized |

***

## GetTickLiquidityGross

```go
func GetTickLiquidityGross(
	poolPath string,
	tick int32
) string

```

GetTickLiquidityGross returns the total liquidity that references a tick.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `tick`     | int32  | tick index                                |

#### Return Values

| Name             | Type   | Description                  |
| ---------------- | ------ | ---------------------------- |
| `liquidityGross` | string | gross liquidity for the tick |

***

## GetTickLiquidityNet

```go
func GetTickLiquidityNet(
	poolPath string,
	tick int32
) string

```

GetTickLiquidityNet returns the net liquidity change at a tick.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `tick`     | int32  | tick index                                |

#### Return Values

| Name           | Type   | Description                      |
| -------------- | ------ | -------------------------------- |
| `liquidityNet` | string | net liquidity change at the tick |

***

## GetTickSecondsOutside

```go
func GetTickSecondsOutside(
	poolPath string,
	tick int32
) uint32

```

GetTickSecondsOutside returns seconds spent outside a tick.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `tick`     | int32  | tick index                                |

#### Return Values

| Name             | Type   | Description                    |
| ---------------- | ------ | ------------------------------ |
| `secondsOutside` | uint32 | seconds spent outside the tick |

***

## GetTickSecondsPerLiquidityOutsideX128

```go
func GetTickSecondsPerLiquidityOutsideX128(
	poolPath string,
	tick int32
) string

```

GetTickSecondsPerLiquidityOutsideX128 returns seconds per liquidity outside a tick.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |
| `tick`     | int32  | tick index                                |

#### Return Values

| Name                             | Type   | Description                                        |
| -------------------------------- | ------ | -------------------------------------------------- |
| `secondsPerLiquidityOutsideX128` | string | seconds per liquidity outside the tick as Q128.128 |

***

## GetTickSpacing

```go
func GetTickSpacing(
	poolPath string
) int32

```

GetTickSpacing returns the tick spacing of the pool.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name          | Type  | Description  |
| ------------- | ----- | ------------ |
| `tickSpacing` | int32 | tick spacing |

***

## GetToken0Path

```go
func GetToken0Path(
	poolPath string
) string

```

GetToken0Path returns the path of token0 in the pool.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name         | Type   | Description |
| ------------ | ------ | ----------- |
| `token0Path` | string | token0 path |

***

## GetToken1Path

```go
func GetToken1Path(
	poolPath string
) string

```

GetToken1Path returns the path of token1 in the pool.

#### Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| `poolPath` | string | pool identifier in token0:token1:fee form |

#### Return Values

| Name         | Type   | Description |
| ------------ | ------ | ----------- |
| `token1Path` | string | token1 path |

***

## GetWithdrawalFee

```go
func GetWithdrawalFee() uint64

```

GetWithdrawalFee returns the current withdrawal fee rate.

#### Return Values

| Name            | Type   | Description                    |
| --------------- | ------ | ------------------------------ |
| `withdrawalFee` | uint64 | withdrawal fee in basis points |


# manager.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/pool/v1/manager.gno>" %}

Creates and examines pools.

## CreatePool

```go
func CreatePool(
	cur realm,
	token0Path string,
	token1Path string,
	fee uint32,
	sqrtPriceX96 string
)
```

Creates a liquidity pool.

#### Parameters

| Name           | Type   | Description                                                                   |
| -------------- | ------ | ----------------------------------------------------------------------------- |
| `cur`          | realm  | Pass `cross` as argument.                                                     |
| `token0Path`   | string | The path of the token0 of the pool to create.                                 |
| `token1Path`   | string | The path of the token1 of the pool to create.                                 |
| `fee`          | uint32 | The fee tier of the pool. (100 = 0.01%, 500 = 0.05%, 3000 = 0.3%, 10000 = 1%) |
| `sqrtPriceX96` | string | The starting price of the pool.                                               |

## SetFeeProtocol

```go
func SetFeeProtocol(
	cur realm,
	feeProtocol0 uint8,
	feeProtocol1 uint8
)

```

SetFeeProtocol sets the Protocol Fee that is applied to all swaps.

#### Parameters

| Name           | Type  | Description                                      |
| -------------- | ----- | ------------------------------------------------ |
| `cur`          | realm | Pass `cross` as argument.                        |
| `feeProtocol0` | uint8 | The Protocol Fee for token0 of the desired pool. |
| `feeProtocol1` | uint8 | The Protocol Fee for token1 of the desired pool. |


# pool.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/pool/v1/pool.gno>" %}

Defines the basic functionality of a liquidity pool such as adding and removing liquidity or performing swaps.

## Mint

```go
func Mint(
	cur realm,
	token0Path string,
	token1Path string,
	fee uint32,
	tickLower int32,
	tickUpper int32,
	liquidityAmount string,
	positionCaller address
) (string, string)
```

Mint adds liquidity to a pool. This function can only be called by the Position contract, not by users.

#### Parameters

| Name              | Type    | Description                                                                                                                               |
| ----------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `cur`             | realm   | Pass `cross` as argument.                                                                                                                 |
| `token0Path`      | string  | The path of token0 of the desired pool.                                                                                                   |
| `token1Path`      | string  | The path of token1 of the desired pool.                                                                                                   |
| `fee`             | uint32  | The fee tier of the desired pool.                                                                                                         |
| `tickLower`       | int32   | The lower tick of the price range of the position.                                                                                        |
| `tickUpper`       | int32   | The upper tick of the price range of the position.                                                                                        |
| `liquidityAmount` | string  | The amount of liquidity to add. This value is calculated by the Position contract based on the amounts of token0 & token1, and the price. |
| `positionCaller`  | address | The caller address from the position contract.                                                                                            |

#### Return Values

| Name      | Type   | Description                                                                 |
| --------- | ------ | --------------------------------------------------------------------------- |
| `amount0` | string | The amount of token0 that added to the liquidity pool to mint the position. |
| `amount1` | string | The amount of token1 that added to the liquidity pool to mint the position. |

## Burn

```go
func Burn(
	cur realm,
	token0Path string,
	token1Path string,
	fee uint32,
	tickLower int32,
	tickUpper int32,
	liquidityAmount string,
	positionCaller address
) (string, string)
```

Burn removes liquidity from a pool. This function can only be called by the Position contract, not by users.

#### Parameters

| Name              | Type    | Description                                        |
| ----------------- | ------- | -------------------------------------------------- |
| `cur`             | realm   | Pass `cross` as argument.                          |
| `token0Path`      | string  | The path of token0 of the desired pool.            |
| `token1Path`      | string  | The path of token1 of the desired pool.            |
| `fee`             | uint32  | The fee tier of the desired pool.                  |
| `tickLower`       | int32   | The lower tick of the price range of the position. |
| `tickUpper`       | int32   | The upper tick of the price range of the position. |
| `liquidityAmount` | string  | The amount of liquidity to remove.                 |
| `positionCaller`  | address | The caller address from the position contract.     |

#### Return Values

| Name      | Type   | Description                                                                  |
| --------- | ------ | ---------------------------------------------------------------------------- |
| `amount0` | string | The amount of token0 that was removed from the pool by burning the position. |
| `amount1` | string | The amount of token1 that was removed from the pool by burning the position. |

## Collect

```go
func Collect(
	cur realm,
	token0Path string,
	token1Path string,
	fee uint32,
	recipient address,
	tickLower int32,
	tickUpper int32,
	amount0Requested string,
	amount1Requested string
) (string, string)

```

Collect collects swap fees in token0 and token1 accrued to a position. This function can only be called by the Position contract, not by users.

#### Parameters

| Name               | Type    | Description                                            |
| ------------------ | ------- | ------------------------------------------------------ |
| `cur`              | realm   | Pass `cross` as argument.                              |
| `token0Path`       | string  | The path of token0 of the desired pool.                |
| `token1Path`       | string  | The path of token1 of the desired pool.                |
| `fee`              | uint32  | The fee tier of the desired pool.                      |
| `recipient`        | address | The address that will receive the collected fees.      |
| `tickLower`        | int32   | The lower tick of the price range of the position.     |
| `tickUpper`        | int32   | The upper tick of the price range of the position.     |
| `amount0Requested` | string  | The maximum amount of token0 to collect from the pool. |
| `amount1Requested` | string  | The maximum amount of token1 to collect from the pool. |

#### Return Values

| Name      | Type   | Description                                                |
| --------- | ------ | ---------------------------------------------------------- |
| `amount0` | string | The amount of token0 that was collected from the position. |
| `amount1` | string | The amount of token1 that was collected from the position. |

## CollectProtocol

```go
func CollectProtocol(
	cur realm,
	token0Path string,
	token1Path string,
	fee uint32,
	recipient address,
	amount0Requested string,
	amount1Requested string
) (string, string)

```

CollectProtocol collects the Protocol Fee claimable from a pool.

#### Parameters

| Name               | Type    | Description                                               |
| ------------------ | ------- | --------------------------------------------------------- |
| `cur`              | realm   | Pass `cross` as argument.                                 |
| `token0Path`       | string  | The path of token0 of the desired pool.                   |
| `token1Path`       | string  | The path of token1 of the desired pool.                   |
| `fee`              | uint32  | The fee tier of the desired pool.                         |
| `recipient`        | address | The address that will receive the collected Protocol Fee. |
| `amount0Requested` | string  | The maximum amount of token0 to collect from the pool.    |
| `amount1Requested` | string  | The maximum amount of token1 to collect from the pool.    |

#### Return Values

| Name      | Type   | Description                                            |
| --------- | ------ | ------------------------------------------------------ |
| `amount0` | string | The amount of token0 that was collected from the pool. |
| `amount1` | string | The amount of token1 that was collected from the pool. |


# protocol\_fee.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/pool/v1/protocol_fee.gno>" %}

Getter and setter functions for the Pool Creation Fee, the protocol fee charged when creating a new pool. The default value is set to 100 GNS (=100,000,000 uGNS).

## GetPoolCreationFee

```go
func GetPoolCreationFee() int64
```

Returns the current pool creation fee.

#### Return Values

| Name              | Type  | Description       |
| ----------------- | ----- | ----------------- |
| `poolCreationFee` | int64 | pool creation fee |

## SetPoolCreationFee

```go
func SetPoolCreationFee(
	cur realm,
	fee int64
)
```

Modifies the `Pool` Creation Fee.

#### Parameters

| Name  | Type  | Description                                                                                           |
| ----- | ----- | ----------------------------------------------------------------------------------------------------- |
| `cur` | realm | Pass `cross` as argument.                                                                             |
| `fee` | int64 | The amount of tokens that will be set as the new Pool Creation Fee. (the amount should be in uTokens) |

## HandleWithdrawalFee

```go
func HandleWithdrawalFee(
	cur realm,
	positionId uint64,
	token0Path string,
	amount0 string,
	token1Path string,
	amount1 string,
	poolPath string,
	positionCaller address
) (string, string)
```

Handles withdrawal protocol fee for a position.

#### Parameters

| Name             | Type    | Description                                                        |
| ---------------- | ------- | ------------------------------------------------------------------ |
| `cur`            | realm   | Pass `cross` as argument.                                          |
| `positionId`     | uint64  | The ID of position which being handled to withdrawal protocol fee. |
| `token0Path`     | string  | The path of token0 of the position.                                |
| `amount0`        | string  | The amount of token0 to calculate withdrawal fee.                  |
| `token1Path`     | string  | The path of token1 of the position.                                |
| `amount1`        | string  | The amount of token1 to calculate withdrawal fee.                  |
| `poolPath`       | string  | The path of pool of the position was minted.                       |
| `positionCaller` | address | The caller address from position contract.                         |

#### Return Values

| Name      | Type   | Description                                                               |
| --------- | ------ | ------------------------------------------------------------------------- |
| `amount0` | string | The remaining amount of token0 after the protocol fee has been withdrawn. |
| `amount1` | string | The remaining amount of token1 after the protocol fee has been withdrawn. |

## IncreaseObservationCardinalityNext

```go
func IncreaseObservationCardinalityNext(
	cur realm,
	token0Path string,
	token1Path string,
	fee uint32,
	cardinalityNext uint16
)

```

IncreaseObservationCardinalityNext increases the observation cardinality for a pool.

#### Parameters

| Name              | Type   | Description                       |
| ----------------- | ------ | --------------------------------- |
| `cur`             | realm  | Pass `cross` as argument.         |
| `token0Path`      | string | path of the first token           |
| `token1Path`      | string | path of the second token          |
| `fee`             | uint32 | pool fee tier                     |
| `cardinalityNext` | uint16 | new observation cardinality limit |


# swap.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/pool/v1/swap.gno>" %}

## Swap

```go
func Swap(
	cur realm,
	token0Path string,
	token1Path string,
	fee uint32,
	recipient address,
	zeroForOne bool,
	amountSpecified string,
	sqrtPriceLimitX96 string,
	payer address,
	swapCallback func(realm, int64, int64, *CallbackMarker) error
) (string, string)
```

Swap swaps tokens from a pool from token0 to token1, or vice versa. This function can only be called by the Router contract, not by users.

#### Parameters

| Name                | Type                                              | Description                                                                                                         |
| ------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `cur`               | realm                                             | Pass `cross` as argument.                                                                                           |
| `token0Path`        | string                                            | The path of token0 of the desired pool.                                                                             |
| `token1Path`        | string                                            | The path of token1 of the desired pool.                                                                             |
| `fee`               | uint32                                            | The fee tier of the desired pool.                                                                                   |
| `recipient`         | address                                           | The address that will receive the output of the swap.                                                               |
| `zeroForOne`        | bool                                              | The direction of the swap. Set to true for swapping token0 to token1, and false for vice versa.                     |
| `amountSpecified`   | string                                            | The amount of tokens to swap. Set to a positive value for an exact input, and a negative value for an exact output. |
| `sqrtPriceLimitX96` | string                                            | The maximum price to accept for the swap.                                                                           |
| `payer`             | address                                           | The address from which to send the output tokens. (Relates to the Router contract)                                  |
| `swapCallback`      | func(realm, int64, int64, \*CallbackMarker) error | The callback function for token transfer.                                                                           |

#### Return Values

| Name      | Type   | Description                                                   |
| --------- | ------ | ------------------------------------------------------------- |
| `amount0` | string | The change in the amount of token0 as the result of the swap. |
| `amount1` | string | The change in the amount of token1 as the result of the swap. |

## DrySwap

```go
func DrySwap(
	token0Path string,
	token1Path string,
	fee uint32,
	zeroForOne bool,
	amountSpecified string,
	sqrtPriceLimitX96 string
) (string, string, bool)
```

DrySwap simulates a swap without executing it, returning the expected output.

#### Parameters

| Name                | Type   | Description                        |
| ------------------- | ------ | ---------------------------------- |
| `token0Path`        | string | path of the first token            |
| `token1Path`        | string | path of the second token           |
| `fee`               | uint32 | pool fee tier                      |
| `zeroForOne`        | bool   | true if swapping token0 for token1 |
| `amountSpecified`   | string | amount to swap                     |
| `sqrtPriceLimitX96` | string | price limit for the swap           |

#### Return Values

| Name           | Type   | Description            |
| -------------- | ------ | ---------------------- |
| `amount0Delta` | string | amount of token0 delta |
| `amount1Delta` | string | amount of token1 delta |
| `ok`           | bool   | swap success status    |

## SetSwapEndHook

```go
func SetSwapEndHook(
	cur realm,
	hook func(realm, string) error
)
```

SetSwapEndHook sets the hook to be called at the end of a swap.

#### Parameters

| Name   | Type                      | Description                                             |
| ------ | ------------------------- | ------------------------------------------------------- |
| `cur`  | realm                     | Pass `cross` as argument.                               |
| `hook` | func(realm, string) error | callback invoked after a swap completes for a pool path |

## SetSwapStartHook

```go
func SetSwapStartHook(
	cur realm,
	hook func(realm, string, int64)
)

```

SetSwapStartHook sets the hook to be called at the start of a swap.

#### Parameters

| Name   | Type                       | Description                                           |
| ------ | -------------------------- | ----------------------------------------------------- |
| `cur`  | realm                      | Pass `cross` as argument.                             |
| `hook` | func(realm, string, int64) | callback invoked before a swap starts for a pool path |

## SetTickCrossHook

```go
func SetTickCrossHook(
	cur realm,
	hook func(realm, string, int32, bool, int64)
)

```

SetTickCrossHook sets the hook to be called when a tick is crossed during a swap.

#### Parameters

| Name   | Type                                    | Description                                               |
| ------ | --------------------------------------- | --------------------------------------------------------- |
| `cur`  | realm                                   | Pass `cross` as argument.                                 |
| `hook` | func(realm, string, int32, bool, int64) | callback invoked when a swap crosses a tick within a pool |


# Position


# getter.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/position/v1/getter.gno>" %}

## GetPositionCount

```go
func GetPositionCount() int

```

GetPositionCount returns the total number of positions.

#### Return Values

| Name    | Type | Description               |
| ------- | ---- | ------------------------- |
| `count` | int  | total number of positions |

***

## GetPositionIDs

```go
func GetPositionIDs(
	offset int,
	count int
) []uint64

```

GetPositionIDs returns a paginated list of position IDs.

#### Parameters

| Name     | Type | Description                      |
| -------- | ---- | -------------------------------- |
| `offset` | int  | starting index for pagination    |
| `count`  | int  | number of position IDs to return |

#### Return Values

| Name          | Type      | Description           |
| ------------- | --------- | --------------------- |
| `positionIDs` | \[]uint64 | slice of position IDs |

***

## GetPosition

```go
func GetPosition(positionId uint64) (Position, error)

```

GetPosition returns the position data for a given position ID.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name       | Type     | Description                   |
| ---------- | -------- | ----------------------------- |
| `position` | Position | the position data             |
| `err`      | error    | non-nil if position not found |

***

## IsBurned

```go
func IsBurned(
	positionId uint64
) bool

```

IsBurned returns whether a position has been burned.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name     | Type | Description                      |
| -------- | ---- | -------------------------------- |
| `burned` | bool | true if position has been burned |

***

## IsInRange

```go
func IsInRange(
	positionId uint64
) bool

```

IsInRange returns whether a position's ticks are within the current price range.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name      | Type | Description                                    |
| --------- | ---- | ---------------------------------------------- |
| `inRange` | bool | true if position is within current price range |

***

## GetPositionToken0Balance

```go
func GetPositionToken0Balance(
	positionId uint64
) *u256.Uint

```

GetPositionToken0Balance returns the token0 balance of a position.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name      | Type        | Description    |
| --------- | ----------- | -------------- |
| `balance` | \*u256.Uint | token0 balance |

***

## GetPositionToken1Balance

```go
func GetPositionToken1Balance(
	positionId uint64
) *u256.Uint

```

GetPositionToken1Balance returns the token1 balance of a position.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name      | Type        | Description    |
| --------- | ----------- | -------------- |
| `balance` | \*u256.Uint | token1 balance |

***

## GetPositionTokenBalances

```go
func GetPositionTokenBalances(
	positionId uint64
) (string, string)

```

GetPositionTokenBalances returns the token balances of a position.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name            | Type   | Description       |
| --------------- | ------ | ----------------- |
| `token0Balance` | string | balance of token0 |
| `token1Balance` | string | balance of token1 |

***

## GetPositionFeeGrowthInside0LastX128

```go
func GetPositionFeeGrowthInside0LastX128(
	positionId uint64
) *u256.Uint

```

GetPositionFeeGrowthInside0LastX128 returns the last recorded fee growth inside for token0.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name        | Type        | Description                                 |
| ----------- | ----------- | ------------------------------------------- |
| `feeGrowth` | \*u256.Uint | fee growth inside for token0 in X128 format |

***

## GetPositionFeeGrowthInside1LastX128

```go
func GetPositionFeeGrowthInside1LastX128(
	positionId uint64
) *u256.Uint

```

GetPositionFeeGrowthInside1LastX128 returns the last recorded fee growth inside for token1.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name        | Type        | Description                                 |
| ----------- | ----------- | ------------------------------------------- |
| `feeGrowth` | \*u256.Uint | fee growth inside for token1 in X128 format |

***

## GetPositionFeeGrowthInsideLastX128

```go
func GetPositionFeeGrowthInsideLastX128(
	positionId uint64
) (*u256.Uint, *u256.Uint)

```

GetPositionFeeGrowthInsideLastX128 returns the last recorded fee growth inside for both tokens.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name         | Type        | Description                                 |
| ------------ | ----------- | ------------------------------------------- |
| `feeGrowth0` | \*u256.Uint | fee growth inside for token0 in X128 format |
| `feeGrowth1` | \*u256.Uint | fee growth inside for token1 in X128 format |

***

## GetPositionLiquidity

```go
func GetPositionLiquidity(
	positionId uint64
) *u256.Uint

```

GetPositionLiquidity returns the liquidity amount of a position.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name        | Type        | Description                      |
| ----------- | ----------- | -------------------------------- |
| `liquidity` | \*u256.Uint | liquidity amount of the position |

***

## GetPositionOperator

```go
func GetPositionOperator(
	positionId uint64
) address

```

GetPositionOperator returns the operator address of a position.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name       | Type    | Description                                 |
| ---------- | ------- | ------------------------------------------- |
| `operator` | address | address approved for spending this position |

***

## GetPositionOwner

```go
func GetPositionOwner(
	positionId uint64
) address

```

GetPositionOwner returns the owner address of a position NFT.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name    | Type    | Description                        |
| ------- | ------- | ---------------------------------- |
| `owner` | address | address that owns the position NFT |

***

## GetPositionPoolKey

```go
func GetPositionPoolKey(
	positionId uint64
) string

```

GetPositionPoolKey returns the pool key of a position.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name      | Type   | Description          |
| --------- | ------ | -------------------- |
| `poolKey` | string | pool path identifier |

***

## GetPositionTickLower

```go
func GetPositionTickLower(
	positionId uint64
) int32

```

GetPositionTickLower returns the lower tick of a position.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name        | Type  | Description         |
| ----------- | ----- | ------------------- |
| `tickLower` | int32 | lower tick boundary |

***

## GetPositionTickUpper

```go
func GetPositionTickUpper(
	positionId uint64
) int32

```

GetPositionTickUpper returns the upper tick of a position.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name        | Type  | Description         |
| ----------- | ----- | ------------------- |
| `tickUpper` | int32 | upper tick boundary |

***

## GetPositionTicks

```go
func GetPositionTicks(
	positionId uint64
) (int32, int32)

```

GetPositionTicks returns the lower and upper ticks of a position.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name        | Type  | Description         |
| ----------- | ----- | ------------------- |
| `tickLower` | int32 | lower tick boundary |
| `tickUpper` | int32 | upper tick boundary |

***

## GetPositionTokensOwed0

```go
func GetPositionTokensOwed0(
	positionId uint64
) *u256.Uint

```

GetPositionTokensOwed0 returns the amount of token0 owed to a position.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name         | Type        | Description           |
| ------------ | ----------- | --------------------- |
| `tokensOwed` | \*u256.Uint | amount of token0 owed |

***

## GetPositionTokensOwed1

```go
func GetPositionTokensOwed1(
	positionId uint64
) *u256.Uint

```

GetPositionTokensOwed1 returns the amount of token1 owed to a position.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name         | Type        | Description           |
| ------------ | ----------- | --------------------- |
| `tokensOwed` | \*u256.Uint | amount of token1 owed |

***

## GetPositionTokensOwed

```go
func GetPositionTokensOwed(
	positionId uint64
) (*u256.Uint, *u256.Uint)

```

GetPositionTokensOwed returns the amount of tokens owed to a position.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name          | Type        | Description           |
| ------------- | ----------- | --------------------- |
| `tokensOwed0` | \*u256.Uint | amount of token0 owed |
| `tokensOwed1` | \*u256.Uint | amount of token1 owed |

***

## GetUnclaimedFee

```go
func GetUnclaimedFee(
	positionId uint64
) (*u256.Uint, *u256.Uint)

```

GetUnclaimedFee returns the unclaimed fees for both tokens of a position.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name            | Type        | Description                     |
| --------------- | ----------- | ------------------------------- |
| `unclaimedFee0` | \*u256.Uint | unclaimed fee amount for token0 |
| `unclaimedFee1` | \*u256.Uint | unclaimed fee amount for token1 |


# position.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/position/v1/position.gno>" %}

Adds or removes liquidity from pools. Includes minting and burning of positions.

## Mint

```go
func Mint(
	cur realm,
	token0 string,
	token1 string,
	fee uint32,
	tickLower int32,
	tickUpper int32,
	amount0Desired string,
	amount1Desired string,
	amount0Min string,
	amount1Min string,
	deadline int64,
	mintTo address,
	caller address,
	referrer string
) (uint64, string, string, string)
```

Mint adds liquidity to a pool. Internally calls the `mint` function of the pool contract.

#### Parameters

| Name             | Type    | Description                                             |
| ---------------- | ------- | ------------------------------------------------------- |
| `cur`            | realm   | Pass `cross` as argument.                               |
| `token0`         | string  | The path of the token0 of the desired pool.             |
| `token1`         | string  | The path of the token1 of the desired pool.             |
| `fee`            | uint32  | The fee tier of the pool.                               |
| `tickLower`      | int32   | The lower tick of the price range of the position.      |
| `tickUpper`      | int32   | The upper tick of the price range of the position.      |
| `amount0Desired` | string  | The maximum amount of token0 to add.                    |
| `amount1Desired` | string  | The maximum amount of token1 to add.                    |
| `amount0Min`     | string  | The minimum amount of token0 to add.                    |
| `amount1Min`     | string  | The minimum amount of token1 to add.                    |
| `deadline`       | int64   | The deadline at which the transaction will expire.      |
| `mintTo`         | address | The address to receive the minted position.             |
| `caller`         | address | The caller address from staker (for one-click staking). |
| `referrer`       | string  | The referrer address for reward tracking.               |

#### Return Values

| Name         | Type   | Description                                |
| ------------ | ------ | ------------------------------------------ |
| `positionId` | uint64 | The ID of the position that was minted.    |
| `liquidity`  | string | The amount of liquidity added to the pool. |
| `amount0`    | string | The amount of token0 added to the pool.    |
| `amount1`    | string | The amount of token1 added to the pool.    |

## IncreaseLiquidity

```go
func IncreaseLiquidity(
	cur realm,
	positionId uint64,
	amount0DesiredStr string,
	amount1DesiredStr string,
	amount0MinStr string,
	amount1MinStr string,
	deadline int64
) (uint64, string, string, string, string)
```

IncreaseLiquidity adds additional liquidity to an existing position. Calling this function on a closed position will reopen it.

#### Parameters

| Name                | Type   | Description                                                |
| ------------------- | ------ | ---------------------------------------------------------- |
| `cur`               | realm  | Pass `cross` as argument.                                  |
| `positionId`        | uint64 | The ID of the position NFT in which to increase liquidity. |
| `amount0DesiredStr` | string | The maximum amount of token0 to increase.                  |
| `amount1DesiredStr` | string | The maximum amount of token1 to increase.                  |
| `amount0MinStr`     | string | The minimum amount of token0 to increase.                  |
| `amount1MinStr`     | string | The minimum amount of token1 to increase.                  |
| `deadline`          | int64  | The deadline at which the transaction will expire.         |

#### Return Values

| Name         | Type   | Description                                              |
| ------------ | ------ | -------------------------------------------------------- |
| `positionId` | uint64 | The ID of the position that the liquidity was increased. |
| `liquidity`  | string | The amount of liquidity added to the position.           |
| `amount0`    | string | The amount of token0 added to the position.              |
| `amount1`    | string | The amount of token1 added to the position.              |
| `poolPath`   | string | The path of the pool from which the position exists.     |

## DecreaseLiquidity

```go
func DecreaseLiquidity(
	cur realm,
	positionId uint64,
	liquidityStr string,
	amount0MinStr string,
	amount1MinStr string,
	deadline int64,
	unwrapResult bool
) (uint64, string, string, string, string, string, string)
```

DecreaseLiquidity decreases liquidity of an existing position.

#### Parameters

| Name            | Type   | Description                                                                                |
| --------------- | ------ | ------------------------------------------------------------------------------------------ |
| `cur`           | realm  | Pass `cross` as argument.                                                                  |
| `positionId`    | uint64 | The ID of the position to decrease liquidity from.                                         |
| `liquidityStr`  | string | The amount of liquidity to decrease.                                                       |
| `amount0MinStr` | string | The minimum amount of token0 to decrease.                                                  |
| `amount1MinStr` | string | The minimum amount of token1 to decrease.                                                  |
| `deadline`      | int64  | The deadline at which the transaction will expire.                                         |
| `unwrapResult`  | bool   | Whether or not to receive tokens in native `ugnot` if either token0 or token1 is `wugnot`. |

#### Return Values

| Name         | Type   | Description                                              |
| ------------ | ------ | -------------------------------------------------------- |
| `positionId` | uint64 | The ID of the position that the liquidity was decreased. |
| `liquidity`  | string | The amount of liquidity decreased from the position.     |
| `fee0`       | string | The amount of token0 fees collected.                     |
| `fee1`       | string | The amount of token1 fees collected.                     |
| `amount0`    | string | The amount of token0 decreased from the position.        |
| `amount1`    | string | The amount of token1 decreased from the position.        |
| `poolPath`   | string | The path of the pool in which the position exists.       |

## CollectFee

```go
func CollectFee(
	cur realm,
	positionId uint64,
	unwrapResult bool
) (uint64, string, string, string, string, string)
```

CollectFee collects fee accrued to a position.

#### Parameters

| Name           | Type   | Description                                                          |
| -------------- | ------ | -------------------------------------------------------------------- |
| `cur`          | realm  | Pass `cross` as argument.                                            |
| `positionId`   | uint64 | The ID of the position.                                              |
| `unwrapResult` | bool   | (if position has wugnot fee) whether to receive fee in ugnot or not. |

#### Return Values

| Name         | Type   | Description                                          |
| ------------ | ------ | ---------------------------------------------------- |
| `positionId` | uint64 | The ID of the position.                              |
| `afterFee0`  | string | The amount of token0 that was collected.             |
| `afterFee1`  | string | The amount of token1 that was collected.             |
| `poolPath`   | string | The path of the pool from which the position exists. |
| `origFee0`   | string | The fee amount of token0 before taking protocol fee. |
| `origFee1`   | string | The fee amount of token1 before taking protocol fee. |

## SetPositionOperator

```go
func SetPositionOperator(
	cur realm,
	positionId uint64,
	operator address
)

```

SetPositionOperator sets an operator for a position.

#### Parameters

| Name         | Type    | Description               |
| ------------ | ------- | ------------------------- |
| `cur`        | realm   | Pass `cross` as argument. |
| `positionId` | uint64  | ID of the position        |
| `operator`   | address | address of the operator   |


# reposition.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/position/v1/reposition.gno>" %}

## Reposition

```go
func Reposition(
	cur realm,
	positionId uint64,
	tickLower int32,
	tickUpper int32,
	amount0DesiredStr string,
	amount1DesiredStr string,
	amount0MinStr string,
	amount1MinStr string,
	deadline int64
) (uint64, string, int32, int32, string, string)

```

Reposition modifies the price range of a closed position while maintaining the `positionId`.

#### Parameters

| Name                | Type   | Description                                        |
| ------------------- | ------ | -------------------------------------------------- |
| `cur`               | realm  | Pass `cross` as argument.                          |
| `positionId`        | uint64 | The ID of the position.                            |
| `tickLower`         | int32  | The lower tick of the price range of the position. |
| `tickUpper`         | int32  | The upper tick of the price range of the position. |
| `amount0DesiredStr` | string | The maximum amount of token0 to add.               |
| `amount1DesiredStr` | string | The maximum amount of token1 to add.               |
| `amount0MinStr`     | string | The minimum amount of token0 to add.               |
| `amount1MinStr`     | string | The minimum amount of token1 to add.               |
| `deadline`          | int64  | The deadline at which the transaction will expire. |

#### Return Values

| Name         | Type   | Description                                 |
| ------------ | ------ | ------------------------------------------- |
| `positionId` | uint64 | The ID of the position.                     |
| `liquidity`  | string | The new liquidity amount.                   |
| `tickLower`  | int32  | The modified lower tick.                    |
| `tickUpper`  | int32  | The modified upper tick.                    |
| `amount0`    | string | The amount of token0 added to the position. |
| `amount1`    | string | The amount of token1 added to the position. |


# Router


# exact\_in.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/router/v1/exact_in.gno>" %}

## ExactInSwapRoute

```go
func ExactInSwapRoute(
	cur realm,
	inputToken string,
	outputToken string,
	amountIn string,
	routeArr string,
	quoteArr string,
	amountOutMin string,
	deadline int64,
	referrer string
) (string, string)
```

ExactInSwapRoute runs a exact-in direction swap through the route that offers the most favorable exchange rate.

#### Parameters

| Name           | Type   | Description                                                                                  |
| -------------- | ------ | -------------------------------------------------------------------------------------------- |
| `cur`          | realm  | Pass `cross` as argument.                                                                    |
| `inputToken`   | string | The path of the input token.                                                                 |
| `outputToken`  | string | The path of the output token.                                                                |
| `amountIn`     | string | The amount of the input token.                                                               |
| `routeArr`     | string | The route of the swap.                                                                       |
| `quoteArr`     | string | The share of each split of the route.                                                        |
| `amountOutMin` | string | Limits the number of tokens while routing the swap. The minimum amount of tokens to receive. |
| `deadline`     | int64  | The timestamp for transaction to be expired.                                                 |
| `referrer`     | string | The referrer address for reward tracking.                                                    |

#### Return Values

| Name       | Type   | Description                                                         |
| ---------- | ------ | ------------------------------------------------------------------- |
| `tokenIn`  | string | The amount sent to the pool from the user (the input of the swap).  |
| `tokenOut` | string | The amount sent to the user from the pool (the output of the swap). |

#### Return Values

| Name       | Type   | Description                                                         |
| ---------- | ------ | ------------------------------------------------------------------- |
| `tokenIn`  | string | The amount sent to the pool from the user (the input of the swap).  |
| `tokenOut` | string | The amount sent to the user from the pool (the output of the swap). |

## ExactOutSingleSwapRoute

```go
func ExactOutSingleSwapRoute(
	cur realm,
	inputToken string,
	outputToken string,
	amountOut string,
	routeArr string,
	amountInMax string,
	sqrtPriceLimitX96 string,
	deadline int64,
	referrer string
) (string, string)
```

ExactOutSingleSwapRoute executes a single-hop swap with exact output amount.

#### Parameters

| Name                | Type   | Description                          |
| ------------------- | ------ | ------------------------------------ |
| `cur`               | realm  | Pass `cross` as argument.            |
| `inputToken`        | string | path of input token                  |
| `outputToken`       | string | path of output token                 |
| `amountOut`         | string | exact output amount                  |
| `routeArr`          | string | encoded route                        |
| `amountInMax`       | string | maximum input amount                 |
| `sqrtPriceLimitX96` | string | price limit for the swap             |
| `deadline`          | int64  | transaction deadline                 |
| `referrer`          | string | referrer address for reward tracking |

#### Return Values

| Name        | Type   | Description          |
| ----------- | ------ | -------------------- |
| `amountIn`  | string | actual input amount  |
| `amountOut` | string | actual output amount |


# exact\_out.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/router/v1/exact_out.gno>" %}

## ExactOutSwapRoute

```go
func ExactOutSwapRoute(
	cur realm,
	inputToken string,
	outputToken string,
	amountOut string,
	routeArr string,
	quoteArr string,
	amountInMax string,
	deadline int64,
	referrer string
) (string, string)
```

ExactOutSwapRoute runs a exact-out direction swap through the route that offers the most favorable exchange rate.

#### Parameters

| Name          | Type   | Description                                                                              |
| ------------- | ------ | ---------------------------------------------------------------------------------------- |
| `cur`         | realm  | Pass `cross` as argument.                                                                |
| `inputToken`  | string | The path of the input token.                                                             |
| `outputToken` | string | The path of the output token.                                                            |
| `amountOut`   | string | The amount of the output token.                                                          |
| `routeArr`    | string | The route of the swap.                                                                   |
| `quoteArr`    | string | The share of each split of the route.                                                    |
| `amountInMax` | string | Limits the number of tokens while routing the swap. The maximum amount of tokens to pay. |
| `deadline`    | int64  | The timestamp for transaction to be expired.                                             |
| `referrer`    | string | The referrer address for reward tracking.                                                |

#### Return Values

| Name       | Type   | Description                                                         |
| ---------- | ------ | ------------------------------------------------------------------- |
| `tokenIn`  | string | The amount sent to the pool from the user (the input of the swap).  |
| `tokenOut` | string | The amount sent to the user from the pool (the output of the swap). |

## ExactOutSingleSwapRoute

```go
func ExactOutSingleSwapRoute(
	cur realm,
	inputToken string,
	outputToken string,
	amountOut string,
	routeArr string,
	amountInMax string,
	sqrtPriceLimitX96 string,
	deadline int64,
	referrer string
) (string, string)
```

ExactOutSingleSwapRoute executes a single-hop swap with exact output amount.

#### Parameters

| Name                | Type   | Description                          |
| ------------------- | ------ | ------------------------------------ |
| `cur`               | realm  | Pass `cross` as argument.            |
| `inputToken`        | string | path of input token                  |
| `outputToken`       | string | path of output token                 |
| `amountOut`         | string | exact output amount                  |
| `routeArr`          | string | encoded route                        |
| `amountInMax`       | string | maximum input amount                 |
| `sqrtPriceLimitX96` | string | price limit for the swap             |
| `deadline`          | int64  | transaction deadline                 |
| `referrer`          | string | referrer address for reward tracking |

#### Return Values

| Name        | Type   | Description          |
| ----------- | ------ | -------------------- |
| `amountIn`  | string | actual input amount  |
| `amountOut` | string | actual output amount |


# protocol\_fee\_swap.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/router/v1/protocol_fee_swap.gno>" %}

Getter and setter functions for the Swap Fee, the protocol fee charged when a user executes a swap via the router. The default value is set to 15 (=0.15% of the final output).

## GetSwapFee

```go
func GetSwapFee() uint64
```

GetSwapFee returns the current rate of the Swap Fee.

#### Return Values

| Name      | Type   | Description                       |
| --------- | ------ | --------------------------------- |
| `swapFee` | uint64 | The current rate of the swap fee. |

## SetSwapFee

```go
func SetSwapFee(
	cur realm,
	fee uint64
)
```

SetSwapFee modifies the Swap Fee.

#### Parameters

| Name  | Type   | Description                                                                 |
| ----- | ------ | --------------------------------------------------------------------------- |
| `cur` | realm  | Pass `cross` as argument.                                                   |
| `fee` | uint64 | The rate that will be set as the new Swap Fee. (the value should be in bps) |


# router\_dry.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/router/v1/router_dry.gno>" %}

## DrySwapRoute

```go
func DrySwapRoute(
	inputToken string,
	outputToken string,
	specifiedAmount string,
	swapTypeStr string,
	strRouteArr string,
	quoteArr string,
	tokenAmountLimit string
) (string, string, bool)
```

DrySwapRoute simulates a swap route without executing it.

#### Parameters

| Name               | Type   | Description                                |
| ------------------ | ------ | ------------------------------------------ |
| `inputToken`       | string | path of input token                        |
| `outputToken`      | string | path of output token                       |
| `specifiedAmount`  | string | specified amount for the swap              |
| `swapTypeStr`      | string | swap type string ("ExactIn" or "ExactOut") |
| `strRouteArr`      | string | encoded route array                        |
| `quoteArr`         | string | encoded quote array                        |
| `tokenAmountLimit` | string | token amount limit                         |

#### Return Values

| Name        | Type   | Description             |
| ----------- | ------ | ----------------------- |
| `amountIn`  | string | estimated input amount  |
| `amountOut` | string | estimated output amount |
| `ok`        | bool   | success status          |


# swap\_callback.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/router/v1/swap_callback.gno>" %}

## SwapCallback

```go
func SwapCallback(
	token0Path string,
	token1Path string,
	amount0Delta int64,
	amount1Delta int64,
	payer address
) error
```

SwapCallback is called by pools to transfer tokens during a swap.

#### Parameters

| Name           | Type    | Description                        |
| -------------- | ------- | ---------------------------------- |
| `token0Path`   | string  | path of token0                     |
| `token1Path`   | string  | path of token1                     |
| `amount0Delta` | int64   | amount change for token0           |
| `amount1Delta` | int64   | amount change for token1           |
| `payer`        | address | address that will pay for the swap |

#### Return Values

| Name  | Type  | Description             |
| ----- | ----- | ----------------------- |
| `err` | error | error if callback fails |


# Staker


# external\_deposit\_fee.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/staker/v1/external_deposit_fee.gno>" %}

## SetDepositGnsAmount

```go
func SetDepositGnsAmount(
	cur realm,
	amount int64
)
```

SetDepositGnsAmount sets the amount of GNS to deposit when creating an external incentive.

#### Parameters

| Name     | Type  | Description                                               |
| -------- | ----- | --------------------------------------------------------- |
| `cur`    | realm | Pass `cross` as argument.                                 |
| `amount` | int64 | The amount of GNS needed to create an external incentive. |

## SetMinimumRewardAmount

```go
func SetMinimumRewardAmount(
	cur realm,
	amount int64
)

```

SetMinimumRewardAmount sets the minimum reward amount to distribute.

#### Parameters

| Name     | Type  | Description               |
| -------- | ----- | ------------------------- |
| `cur`    | realm | Pass `cross` as argument. |
| `amount` | int64 | minimum reward amount     |

## SetTokenMinimumRewardAmount

```go
func SetTokenMinimumRewardAmount(
	cur realm,
	paramsStr string
)

```

SetTokenMinimumRewardAmount sets minimum reward amounts per token.

## SetUnStakingFee

```go
func SetUnStakingFee(
	cur realm,
	fee int64
)

```

SetUnStakingFee modifies the Unstaking Fee.

#### Parameters

| Name  | Type  | Description                                                                      |
| ----- | ----- | -------------------------------------------------------------------------------- |
| `cur` | realm | Pass `cross` as argument.                                                        |
| `fee` | int64 | The rate that will be set as the new Unstaking Fee. (the value should be in bps) |


# external\_incentive.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/staker/v1/external_incentive.gno>" %}

## CreateExternalIncentive

```go
func CreateExternalIncentive(
	cur realm,
	targetPoolPath string,
	rewardToken string,
	rewardAmount int64,
	startTimestamp int64,
	endTimestamp int64
)
```

CreateExternalIncentive creates an incentive program for a pool.

#### Parameters

| Name             | Type   | Description                                      |
| ---------------- | ------ | ------------------------------------------------ |
| `cur`            | realm  | Pass `cross` as argument.                        |
| `targetPoolPath` | string | The path of the pool in which to add incentives. |
| `rewardToken`    | string | The path of the token to add as incentives.      |
| `rewardAmount`   | int64  | The amount of tokens to add as incentives.       |
| `startTimestamp` | int64  | The time to start the incentive program.         |
| `endTimestamp`   | int64  | The time to end the incentive program.           |

## EndExternalIncentive

```go
func EndExternalIncentive(
	cur realm,
	targetPoolPath string,
	incentiveId string
)
```

EndExternalIncentive ends an incentive program.

#### Parameters

| Name             | Type   | Description                                        |
| ---------------- | ------ | -------------------------------------------------- |
| `cur`            | realm  | Pass `cross` as argument.                          |
| `targetPoolPath` | string | The path of the pool to end the incentive program. |
| `incentiveId`    | string | The ID of the incentive program to end.            |


# external\_token\_list.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/staker/v1/external_token_list.gno>" %}

## AddToken

```go
func AddToken(
	cur realm,
	tokenPath string
)
```

AddToken adds a token to the reward token whitelist.

#### Parameters

| Name        | Type   | Description               |
| ----------- | ------ | ------------------------- |
| `cur`       | realm  | Pass `cross` as argument. |
| `tokenPath` | string | path of the token to add  |

## RemoveToken

```go
func RemoveToken(
	cur realm,
	tokenPath string
)
```

RemoveToken removes a token from the reward token whitelist.

#### Parameters

| Name        | Type   | Description                 |
| ----------- | ------ | --------------------------- |
| `cur`       | realm  | Pass `cross` as argument.   |
| `tokenPath` | string | path of the token to remove |


# getter.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/staker/v1/getter.gno>" %}

## CollectableEmissionReward

```go
func CollectableEmissionReward(
	positionId uint64
) int64

```

CollectableEmissionReward returns the claimable internal reward amount.

#### Parameters

| Name         | Type   | Description               |
| ------------ | ------ | ------------------------- |
| `positionId` | uint64 | ID of the staked position |

#### Return Values

| Name     | Type  | Description                      |
| -------- | ----- | -------------------------------- |
| `reward` | int64 | claimable internal reward amount |

***

## CollectableExternalIncentiveReward

```go
func CollectableExternalIncentiveReward(
	positionId uint64,
	incentiveId string
) int64

```

CollectableExternalIncentiveReward returns the claimable external reward amount.

#### Parameters

| Name          | Type   | Description               |
| ------------- | ------ | ------------------------- |
| `positionId`  | uint64 | ID of the staked position |
| `incentiveId` | string | ID of the incentive       |

#### Return Values

| Name     | Type  | Description                      |
| -------- | ----- | -------------------------------- |
| `reward` | int64 | claimable external reward amount |

***

## GetAllowedTokens

```go
func GetAllowedTokens() []string

```

GetAllowedTokens returns the allowed external incentive tokens.

#### Return Values

| Name     | Type      | Description                 |
| -------- | --------- | --------------------------- |
| `tokens` | \[]string | list of allowed token paths |

***

## GetCreatedHeightOfIncentive

```go
func GetCreatedHeightOfIncentive(
	poolPath string,
	incentiveId string
) int64

```

GetCreatedHeightOfIncentive returns the block height when an incentive was created.

#### Parameters

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| `poolPath`    | string | path of the pool    |
| `incentiveId` | string | ID of the incentive |

#### Return Values

| Name     | Type  | Description              |
| -------- | ----- | ------------------------ |
| `height` | int64 | block height at creation |

***

## GetDepositCollectedExternalReward

```go
func GetDepositCollectedExternalReward(
	lpTokenId uint64,
	incentiveId string
) int64

```

GetDepositCollectedExternalReward returns the collected external reward amount of a position.

#### Parameters

| Name          | Type   | Description                 |
| ------------- | ------ | --------------------------- |
| `lpTokenId`   | uint64 | ID of the LP token position |
| `incentiveId` | string | ID of the incentive         |

#### Return Values

| Name     | Type  | Description                      |
| -------- | ----- | -------------------------------- |
| `amount` | int64 | collected external reward amount |

***

## GetDepositCollectedInternalReward

```go
func GetDepositCollectedInternalReward(
	lpTokenId uint64
) int64

```

GetDepositCollectedInternalReward returns the collected internal reward amount of a position.

#### Parameters

| Name        | Type   | Description                 |
| ----------- | ------ | --------------------------- |
| `lpTokenId` | uint64 | ID of the LP token position |

#### Return Values

| Name     | Type  | Description                      |
| -------- | ----- | -------------------------------- |
| `amount` | int64 | collected internal reward amount |

***

## GetDepositExternalIncentiveIdList

```go
func GetDepositExternalIncentiveIdList(
	lpTokenId uint64
) []string

```

GetDepositExternalIncentiveIdList returns external incentive IDs for a deposit.

#### Parameters

| Name        | Type   | Description                 |
| ----------- | ------ | --------------------------- |
| `lpTokenId` | uint64 | ID of the LP token position |

#### Return Values

| Name           | Type      | Description                    |
| -------------- | --------- | ------------------------------ |
| `incentiveIds` | \[]string | list of external incentive IDs |

***

## GetDepositExternalRewardLastCollectTimestamp

```go
func GetDepositExternalRewardLastCollectTimestamp(
	lpTokenId uint64,
	incentiveId string
) int64

```

GetDepositExternalRewardLastCollectTimestamp returns the last external reward collection time for a position.

#### Parameters

| Name          | Type   | Description                 |
| ------------- | ------ | --------------------------- |
| `lpTokenId`   | uint64 | ID of the LP token position |
| `incentiveId` | string | ID of the incentive         |

#### Return Values

| Name        | Type  | Description               |
| ----------- | ----- | ------------------------- |
| `timestamp` | int64 | last collection timestamp |

***

## GetDepositGnsAmount

```go
func GetDepositGnsAmount() int64

```

GetDepositGnsAmount returns the required GNS deposit amount for staking.

#### Return Values

| Name     | Type  | Description                 |
| -------- | ----- | --------------------------- |
| `amount` | int64 | required GNS deposit amount |

***

## GetDepositInternalRewardLastCollectTimestamp

```go
func GetDepositInternalRewardLastCollectTimestamp(
	lpTokenId uint64
) int64

```

GetDepositInternalRewardLastCollectTimestamp returns the last internal reward collection time for a position.

#### Parameters

| Name        | Type   | Description                 |
| ----------- | ------ | --------------------------- |
| `lpTokenId` | uint64 | ID of the LP token position |

#### Return Values

| Name        | Type  | Description               |
| ----------- | ----- | ------------------------- |
| `timestamp` | int64 | last collection timestamp |

***

## GetDepositLiquidity

```go
func GetDepositLiquidity(
	lpTokenId uint64
) *u256.Uint

```

GetDepositLiquidity returns the liquidity amount of a staked position.

#### Parameters

| Name        | Type   | Description                 |
| ----------- | ------ | --------------------------- |
| `lpTokenId` | uint64 | ID of the LP token position |

#### Return Values

| Name        | Type        | Description      |
| ----------- | ----------- | ---------------- |
| `liquidity` | \*u256.Uint | liquidity amount |

***

## GetDepositLiquidityAsString

```go
func GetDepositLiquidityAsString(
	lpTokenId uint64
) string

```

GetDepositLiquidityAsString returns the liquidity amount of a staked position as string.

#### Parameters

| Name        | Type   | Description                 |
| ----------- | ------ | --------------------------- |
| `lpTokenId` | uint64 | ID of the LP token position |

#### Return Values

| Name        | Type   | Description                |
| ----------- | ------ | -------------------------- |
| `liquidity` | string | liquidity amount as string |

***

## GetDepositOwner

```go
func GetDepositOwner(
	lpTokenId uint64
) address

```

GetDepositOwner returns the owner of a staked position.

#### Parameters

| Name        | Type   | Description                 |
| ----------- | ------ | --------------------------- |
| `lpTokenId` | uint64 | ID of the LP token position |

#### Return Values

| Name    | Type    | Description   |
| ------- | ------- | ------------- |
| `owner` | address | owner address |

***

## GetDepositStakeTime

```go
func GetDepositStakeTime(
	lpTokenId uint64
) int64

```

GetDepositStakeTime returns the staking duration of a position.

#### Parameters

| Name        | Type   | Description                 |
| ----------- | ------ | --------------------------- |
| `lpTokenId` | uint64 | ID of the LP token position |

#### Return Values

| Name        | Type  | Description       |
| ----------- | ----- | ----------------- |
| `stakeTime` | int64 | staking timestamp |

***

## GetDepositTargetPoolPath

```go
func GetDepositTargetPoolPath(
	lpTokenId uint64
) string

```

GetDepositTargetPoolPath returns the pool path of a staked position.

#### Parameters

| Name        | Type   | Description                 |
| ----------- | ------ | --------------------------- |
| `lpTokenId` | uint64 | ID of the LP token position |

#### Return Values

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| `poolPath` | string | target pool path |

***

## GetDepositTickLower

```go
func GetDepositTickLower(
	lpTokenId uint64
) int32

```

GetDepositTickLower returns the lower tick of a staked position.

#### Parameters

| Name        | Type   | Description                 |
| ----------- | ------ | --------------------------- |
| `lpTokenId` | uint64 | ID of the LP token position |

#### Return Values

| Name        | Type  | Description         |
| ----------- | ----- | ------------------- |
| `tickLower` | int32 | lower tick boundary |

***

## GetDepositTickUpper

```go
func GetDepositTickUpper(
	lpTokenId uint64
) int32

```

GetDepositTickUpper returns the upper tick of a staked position.

#### Parameters

| Name        | Type   | Description                 |
| ----------- | ------ | --------------------------- |
| `lpTokenId` | uint64 | ID of the LP token position |

#### Return Values

| Name        | Type  | Description         |
| ----------- | ----- | ------------------- |
| `tickUpper` | int32 | upper tick boundary |

***

## GetIncentiveCreatedTimestamp

```go
func GetIncentiveCreatedTimestamp(
	poolPath string,
	incentiveId string
) int64

```

GetIncentiveCreatedTimestamp returns the creation timestamp of an incentive.

#### Parameters

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| `poolPath`    | string | path of the pool    |
| `incentiveId` | string | ID of the incentive |

#### Return Values

| Name        | Type  | Description        |
| ----------- | ----- | ------------------ |
| `timestamp` | int64 | creation timestamp |

***

## GetIncentiveDepositGnsAmount

```go
func GetIncentiveDepositGnsAmount(
	poolPath string,
	incentiveId string
) int64

```

GetIncentiveDepositGnsAmount returns the deposited GNS amount of an incentive.

#### Parameters

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| `poolPath`    | string | path of the pool    |
| `incentiveId` | string | ID of the incentive |

#### Return Values

| Name     | Type  | Description          |
| -------- | ----- | -------------------- |
| `amount` | int64 | deposited GNS amount |

***

## GetIncentiveDistributedRewardAmount

```go
func GetIncentiveDistributedRewardAmount(
	poolPath string,
	incentiveId string
) int64

```

GetIncentiveDistributedRewardAmount returns the distributed reward amount of an incentive.

#### Parameters

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| `poolPath`    | string | path of the pool    |
| `incentiveId` | string | ID of the incentive |

#### Return Values

| Name     | Type  | Description               |
| -------- | ----- | ------------------------- |
| `amount` | int64 | distributed reward amount |

***

## GetIncentiveEndTimestamp

```go
func GetIncentiveEndTimestamp(
	poolPath string,
	incentiveId string
) int64

```

GetIncentiveEndTimestamp returns the end timestamp of an incentive.

#### Parameters

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| `poolPath`    | string | path of the pool    |
| `incentiveId` | string | ID of the incentive |

#### Return Values

| Name        | Type  | Description   |
| ----------- | ----- | ------------- |
| `timestamp` | int64 | end timestamp |

***

## GetIncentiveRefunded

```go
func GetIncentiveRefunded(
	poolPath string,
	incentiveId string
) bool

```

GetIncentiveRefunded returns whether an incentive has been refunded.

#### Parameters

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| `poolPath`    | string | path of the pool    |
| `incentiveId` | string | ID of the incentive |

#### Return Values

| Name       | Type | Description                         |
| ---------- | ---- | ----------------------------------- |
| `refunded` | bool | true if incentive has been refunded |

***

## GetIncentiveRefundee

```go
func GetIncentiveRefundee(
	poolPath string,
	incentiveId string
) address

```

GetIncentiveRefundee returns the refundee address of an incentive.

#### Parameters

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| `poolPath`    | string | path of the pool    |
| `incentiveId` | string | ID of the incentive |

#### Return Values

| Name       | Type    | Description      |
| ---------- | ------- | ---------------- |
| `refundee` | address | refundee address |

***

## GetIncentiveRemainingRewardAmount

```go
func GetIncentiveRemainingRewardAmount(
	poolPath string,
	incentiveId string
) int64

```

GetIncentiveRemainingRewardAmount returns the remaining reward amount of an incentive.

#### Parameters

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| `poolPath`    | string | path of the pool    |
| `incentiveId` | string | ID of the incentive |

#### Return Values

| Name     | Type  | Description             |
| -------- | ----- | ----------------------- |
| `amount` | int64 | remaining reward amount |

***

## GetIncentiveRewardAmount

```go
func GetIncentiveRewardAmount(
	poolPath string,
	incentiveId string
) *u256.Uint

```

GetIncentiveRewardAmount returns the total reward amount of an incentive.

#### Parameters

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| `poolPath`    | string | path of the pool    |
| `incentiveId` | string | ID of the incentive |

#### Return Values

| Name     | Type        | Description         |
| -------- | ----------- | ------------------- |
| `amount` | \*u256.Uint | total reward amount |

***

## GetIncentiveRewardAmountAsString

```go
func GetIncentiveRewardAmountAsString(
	poolPath string,
	incentiveId string
) string

```

GetIncentiveRewardAmountAsString returns the total reward amount of an incentive as string.

#### Parameters

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| `poolPath`    | string | path of the pool    |
| `incentiveId` | string | ID of the incentive |

#### Return Values

| Name     | Type   | Description                   |
| -------- | ------ | ----------------------------- |
| `amount` | string | total reward amount as string |

***

## GetIncentiveRewardPerSecond

```go
func GetIncentiveRewardPerSecond(
	poolPath string,
	incentiveId string
) int64

```

GetIncentiveRewardPerSecond returns the reward rate per second of an incentive.

#### Parameters

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| `poolPath`    | string | path of the pool    |
| `incentiveId` | string | ID of the incentive |

#### Return Values

| Name   | Type  | Description       |
| ------ | ----- | ----------------- |
| `rate` | int64 | reward per second |

***

## GetIncentiveRewardToken

```go
func GetIncentiveRewardToken(
	poolPath string,
	incentiveId string
) string

```

GetIncentiveRewardToken returns the reward token of an incentive.

#### Parameters

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| `poolPath`    | string | path of the pool    |
| `incentiveId` | string | ID of the incentive |

#### Return Values

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `tokenPath` | string | reward token path |

***

## GetIncentiveStartTimestamp

```go
func GetIncentiveStartTimestamp(
	poolPath string,
	incentiveId string
) int64

```

GetIncentiveStartTimestamp returns the start timestamp of an incentive.

#### Parameters

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| `poolPath`    | string | path of the pool    |
| `incentiveId` | string | ID of the incentive |

#### Return Values

| Name        | Type  | Description     |
| ----------- | ----- | --------------- |
| `timestamp` | int64 | start timestamp |

***

## GetIncentiveTotalRewardAmount

```go
func GetIncentiveTotalRewardAmount(
	poolPath string,
	incentiveId string
) int64

```

GetIncentiveTotalRewardAmount returns the total reward amount of an incentive.

#### Parameters

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| `poolPath`    | string | path of the pool    |
| `incentiveId` | string | ID of the incentive |

#### Return Values

| Name     | Type  | Description         |
| -------- | ----- | ------------------- |
| `amount` | int64 | total reward amount |

***

## GetMinimumRewardAmount

```go
func GetMinimumRewardAmount() int64

```

GetMinimumRewardAmount returns the minimum reward amount to distribute.

#### Return Values

| Name     | Type  | Description           |
| -------- | ----- | --------------------- |
| `amount` | int64 | minimum reward amount |

***

## GetMinimumRewardAmountForToken

```go
func GetMinimumRewardAmountForToken(
	tokenPath string
) int64

```

GetMinimumRewardAmountForToken returns the minimum reward amount for a specific token.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `tokenPath` | string | path of the token |

#### Return Values

| Name     | Type  | Description                         |
| -------- | ----- | ----------------------------------- |
| `amount` | int64 | minimum reward amount for the token |

***

## GetPoolGlobalRewardRatioAccumulation

```go
func GetPoolGlobalRewardRatioAccumulation(
	poolPath string,
	timestamp uint64
) *u256.Uint

```

GetPoolGlobalRewardRatioAccumulation returns the global reward ratio accumulation at a specific timestamp for a pool.

#### Parameters

| Name        | Type   | Description            |
| ----------- | ------ | ---------------------- |
| `poolPath`  | string | path of the pool       |
| `timestamp` | uint64 | accumulation timestamp |

#### Return Values

| Name    | Type        | Description                      |
| ------- | ----------- | -------------------------------- |
| `ratio` | \*u256.Uint | global reward ratio accumulation |

***

## GetPoolGlobalRewardRatioAccumulationCount

```go
func GetPoolGlobalRewardRatioAccumulationCount(
	poolPath string
) uint64

```

GetPoolGlobalRewardRatioAccumulationCount returns the number of global reward ratio accumulation entries for a pool.

#### Parameters

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| `poolPath` | string | path of the pool |

#### Return Values

| Name    | Type   | Description                    |
| ------- | ------ | ------------------------------ |
| `count` | uint64 | number of accumulation entries |

***

## GetPoolGlobalRewardRatioAccumulationIDs

```go
func GetPoolGlobalRewardRatioAccumulationIDs(
	poolPath string,
	offset int,
	count int
) []uint64

```

GetPoolGlobalRewardRatioAccumulationIDs returns a paginated list of timestamps for global reward ratio accumulation entries.

#### Parameters

| Name       | Type   | Description                 |
| ---------- | ------ | --------------------------- |
| `poolPath` | string | path of the pool            |
| `offset`   | int    | starting index              |
| `count`    | int    | number of entries to return |

#### Return Values

| Name         | Type      | Description                     |
| ------------ | --------- | ------------------------------- |
| `timestamps` | \[]uint64 | list of accumulation timestamps |

***

## GetPoolHistoricalTick

```go
func GetPoolHistoricalTick(
	poolPath string,
	tick uint64
) int32

```

GetPoolHistoricalTick returns the historical tick at a specific timestamp for a pool.

#### Parameters

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| `poolPath` | string | path of the pool |
| `tick`     | uint64 | tick index       |

#### Return Values

| Name   | Type  | Description           |
| ------ | ----- | --------------------- |
| `tick` | int32 | historical tick value |

***

## GetPoolHistoricalTickCount

```go
func GetPoolHistoricalTickCount(
	poolPath string
) uint64

```

GetPoolHistoricalTickCount returns the number of historical tick entries for a pool.

#### Parameters

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| `poolPath` | string | path of the pool |

#### Return Values

| Name    | Type   | Description                       |
| ------- | ------ | --------------------------------- |
| `count` | uint64 | number of historical tick entries |

***

## GetPoolHistoricalTickIDs

```go
func GetPoolHistoricalTickIDs(
	poolPath string,
	offset int,
	count int
) []int32

```

GetPoolHistoricalTickIDs returns a paginated list of historical tick values for a pool.

#### Parameters

| Name       | Type   | Description                 |
| ---------- | ------ | --------------------------- |
| `poolPath` | string | path of the pool            |
| `offset`   | int    | starting index              |
| `count`    | int    | number of entries to return |

#### Return Values

| Name    | Type     | Description                    |
| ------- | -------- | ------------------------------ |
| `ticks` | \[]int32 | list of historical tick values |

***

## GetPoolIncentiveCount

```go
func GetPoolIncentiveCount(
	poolPath string
) uint64

```

GetPoolIncentiveCount returns the number of incentives for a pool.

#### Parameters

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| `poolPath` | string | path of the pool |

#### Return Values

| Name    | Type   | Description          |
| ------- | ------ | -------------------- |
| `count` | uint64 | number of incentives |

***

## GetPoolIncentiveIDs

```go
func GetPoolIncentiveIDs(
	poolPath string,
	offset int,
	count int
) []string

```

GetPoolIncentiveIDs returns a paginated list of incentive IDs for a pool.

#### Parameters

| Name       | Type   | Description             |
| ---------- | ------ | ----------------------- |
| `poolPath` | string | path of the pool        |
| `offset`   | int    | starting index          |
| `count`    | int    | number of IDs to return |

#### Return Values

| Name           | Type      | Description           |
| -------------- | --------- | --------------------- |
| `incentiveIds` | \[]string | list of incentive IDs |

***

## GetPoolIncentiveIdList

```go
func GetPoolIncentiveIdList(
	poolPath string
) []string

```

GetPoolIncentiveIdList returns all incentive IDs for a pool.

#### Parameters

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| `poolPath` | string | path of the pool |

#### Return Values

| Name           | Type      | Description           |
| -------------- | --------- | --------------------- |
| `incentiveIds` | \[]string | list of incentive IDs |

***

## GetPoolReward

```go
func GetPoolReward(
	tier uint64
) int64

```

GetPoolReward returns the reward amount for a tier.

#### Parameters

| Name   | Type   | Description |
| ------ | ------ | ----------- |
| `tier` | uint64 | tier level  |

#### Return Values

| Name     | Type  | Description                |
| -------- | ----- | -------------------------- |
| `reward` | int64 | reward amount for the tier |

***

## GetPoolRewardCache

```go
func GetPoolRewardCache(
	poolPath string,
	timestamp uint64
) int64

```

GetPoolRewardCache returns the reward cache value at a specific timestamp for a pool.

#### Parameters

| Name        | Type   | Description      |
| ----------- | ------ | ---------------- |
| `poolPath`  | string | path of the pool |
| `timestamp` | uint64 | cache timestamp  |

#### Return Values

| Name     | Type  | Description         |
| -------- | ----- | ------------------- |
| `reward` | int64 | cached reward value |

***

## GetPoolRewardCacheCount

```go
func GetPoolRewardCacheCount(
	poolPath string
) uint64

```

GetPoolRewardCacheCount returns the number of reward cache entries for a pool.

#### Parameters

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| `poolPath` | string | path of the pool |

#### Return Values

| Name    | Type   | Description                    |
| ------- | ------ | ------------------------------ |
| `count` | uint64 | number of reward cache entries |

***

## GetPoolRewardCacheIDs

```go
func GetPoolRewardCacheIDs(
	poolPath string,
	offset int,
	count int
) []int64

```

GetPoolRewardCacheIDs returns a paginated list of reward cache timestamps for a pool.

#### Parameters

| Name       | Type   | Description                 |
| ---------- | ------ | --------------------------- |
| `poolPath` | string | path of the pool            |
| `offset`   | int    | starting index              |
| `count`    | int    | number of entries to return |

#### Return Values

| Name         | Type     | Description                     |
| ------------ | -------- | ------------------------------- |
| `timestamps` | \[]int64 | list of reward cache timestamps |

***

## GetPoolStakedLiquidity

```go
func GetPoolStakedLiquidity(
	poolPath string
) string

```

GetPoolStakedLiquidity returns the current total staked liquidity of a pool.

#### Parameters

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| `poolPath` | string | path of the pool |

#### Return Values

| Name        | Type   | Description                      |
| ----------- | ------ | -------------------------------- |
| `liquidity` | string | total staked liquidity as string |

***

## GetPoolTier

```go
func GetPoolTier(
	poolPath string
) uint64

```

GetPoolTier returns the tier of a pool.

#### Parameters

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| `poolPath` | string | path of the pool |

#### Return Values

| Name   | Type   | Description |
| ------ | ------ | ----------- |
| `tier` | uint64 | tier level  |

***

## GetPoolTierCount

```go
func GetPoolTierCount(
	tier uint64
) uint64

```

GetPoolTierCount returns the number of pools in a tier.

#### Parameters

| Name   | Type   | Description |
| ------ | ------ | ----------- |
| `tier` | uint64 | tier level  |

#### Return Values

| Name    | Type   | Description     |
| ------- | ------ | --------------- |
| `count` | uint64 | number of pools |

***

## GetPoolTierRatio

```go
func GetPoolTierRatio(
	poolPath string
) uint64

```

GetPoolTierRatio returns the reward ratio of a pool.

#### Parameters

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| `poolPath` | string | path of the pool |

#### Return Values

| Name    | Type   | Description  |
| ------- | ------ | ------------ |
| `ratio` | uint64 | reward ratio |

***

## GetPoolsByTier

```go
func GetPoolsByTier(
	tier uint64
) []string

```

GetPoolsByTier returns the pool list for a tier.

#### Parameters

| Name   | Type   | Description |
| ------ | ------ | ----------- |
| `tier` | uint64 | tier level  |

#### Return Values

| Name    | Type      | Description        |
| ------- | --------- | ------------------ |
| `pools` | \[]string | list of pool paths |

***

## GetSpecificTokenMinimumRewardAmount

```go
func GetSpecificTokenMinimumRewardAmount(
	tokenPath string
) (int64, bool)

```

GetSpecificTokenMinimumRewardAmount returns the minimum reward amount for a specific token.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `tokenPath` | string | path of the token |

#### Return Values

| Name     | Type  | Description                        |
| -------- | ----- | ---------------------------------- |
| `amount` | int64 | minimum reward amount              |
| `exists` | bool  | true if token has specific minimum |

***

## GetStakedPositionsByUser

```go
func GetStakedPositionsByUser(
	owner address,
	offset int,
	count int
) []uint64

```

GetStakedPositionsByUser returns staked position IDs for a user with pagination.

#### Parameters

| Name     | Type    | Description                   |
| -------- | ------- | ----------------------------- |
| `owner`  | address | owner address                 |
| `offset` | int     | starting index                |
| `count`  | int     | number of positions to return |

#### Return Values

| Name          | Type      | Description                 |
| ------------- | --------- | --------------------------- |
| `positionIds` | \[]uint64 | list of staked position IDs |

***

## GetTargetPoolPathByIncentiveId

```go
func GetTargetPoolPathByIncentiveId(
	poolPath string,
	incentiveId string
) string

```

GetTargetPoolPathByIncentiveId returns the pool path for an incentive ID.

#### Parameters

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| `poolPath`    | string | path of the pool    |
| `incentiveId` | string | ID of the incentive |

#### Return Values

| Name             | Type   | Description      |
| ---------------- | ------ | ---------------- |
| `targetPoolPath` | string | target pool path |

***

## GetTotalEmissionSent

```go
func GetTotalEmissionSent() int64

```

GetTotalEmissionSent returns the total GNS emission sent.

#### Return Values

| Name     | Type  | Description             |
| -------- | ----- | ----------------------- |
| `amount` | int64 | total GNS emission sent |

***

## GetTotalStakedUserCount

```go
func GetTotalStakedUserCount() uint64

```

GetTotalStakedUserCount returns the total number of staked users.

#### Return Values

| Name    | Type   | Description                                 |
| ------- | ------ | ------------------------------------------- |
| `count` | uint64 | total number of users with staked positions |

***

## GetTotalStakedUserPositionCount

```go
func GetTotalStakedUserPositionCount(
	user address
) uint64

```

GetTotalStakedUserPositionCount returns the staked position count for a user.

#### Parameters

| Name   | Type    | Description  |
| ------ | ------- | ------------ |
| `user` | address | user address |

#### Return Values

| Name    | Type   | Description                |
| ------- | ------ | -------------------------- |
| `count` | uint64 | number of staked positions |

***

## GetUnstakingFee

```go
func GetUnstakingFee() int64

```

GetUnstakingFee returns the unstaking fee percentage.

#### Return Values

| Name  | Type  | Description              |
| ----- | ----- | ------------------------ |
| `fee` | int64 | unstaking fee percentage |

***

## IsIncentiveActive

```go
func IsIncentiveActive(
	poolPath string,
	incentiveId string
) bool

```

IsIncentiveActive returns whether an incentive is active.

#### Parameters

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| `poolPath`    | string | path of the pool    |
| `incentiveId` | string | ID of the incentive |

#### Return Values

| Name     | Type | Description                 |
| -------- | ---- | --------------------------- |
| `active` | bool | true if incentive is active |

***

## IsStaked

```go
func IsStaked(
	positionId uint64
) bool

```

IsStaked returns whether a position is staked.

#### Parameters

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| `positionId` | uint64 | ID of the position |

#### Return Values

| Name     | Type | Description                |
| -------- | ---- | -------------------------- |
| `staked` | bool | true if position is staked |


# manage\_pool\_tier\_and\_warmup.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/staker/v1/manage_pool_tier_and_warmup.gno>" %}

## SetPoolTier

```go
func SetPoolTier(
	cur realm,
	poolPath string,
	tier uint64
)
```

SetPoolTier sets the reward tier for a pool.

#### Parameters

| Name       | Type   | Description               |
| ---------- | ------ | ------------------------- |
| `cur`      | realm  | Pass `cross` as argument. |
| `poolPath` | string | path of the pool          |
| `tier`     | uint64 | reward tier level         |

## ChangePoolTier

```go
func ChangePoolTier(
	cur realm,
	poolPath string,
	tier uint64
)
```

ChangePoolTier changes the reward tier of a pool.

#### Parameters

| Name       | Type   | Description               |
| ---------- | ------ | ------------------------- |
| `cur`      | realm  | Pass `cross` as argument. |
| `poolPath` | string | path of the pool          |
| `tier`     | uint64 | new reward tier level     |

## RemovePoolTier

```go
func RemovePoolTier(
	cur realm,
	poolPath string
)
```

RemovePoolTier removes a pool from the tier system.

#### Parameters

| Name       | Type   | Description               |
| ---------- | ------ | ------------------------- |
| `cur`      | realm  | Pass `cross` as argument. |
| `poolPath` | string | path of the pool          |

## SetWarmUp

```go
func SetWarmUp(
	cur realm,
	pct int64,
	timeDuration int64
)

```

SetWarmUp sets the warm-up period parameters for staking.

#### Parameters

| Name           | Type  | Description                     |
| -------------- | ----- | ------------------------------- |
| `cur`          | realm | Pass `cross` as argument.       |
| `pct`          | int64 | warmup percentage               |
| `timeDuration` | int64 | warmup time duration in seconds |


# mint\_stake.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/staker/v1/mint_stake.gno>" %}

Creates a new position and stakes it in a single transaction.

## MintAndStake

```go
func MintAndStake(
	cur realm,
	token0 string,
	token1 string,
	fee uint32,
	tickLower int32,
	tickUpper int32,
	amount0Desired string,
	amount1Desired string,
	amount0Min string,
	amount1Min string,
	deadline int64,
	referrer string
) (uint64, string, string, string, string)
```

MintAndStake mints and stakes an LP token.

#### Parameters

| Name             | Type   | Description                                        |
| ---------------- | ------ | -------------------------------------------------- |
| `cur`            | realm  | Pass `cross` as argument.                          |
| `token0`         | string | The path of token0.                                |
| `token1`         | string | The path of token1.                                |
| `fee`            | uint32 | The fee tier of the pool.                          |
| `tickLower`      | int32  | The lower tick of the price range of the position. |
| `tickUpper`      | int32  | The upper tick of the price range of the position. |
| `amount0Desired` | string | The maximum amount of token0 to add and stake.     |
| `amount1Desired` | string | The maximum amount of token1 to add and stake.     |
| `amount0Min`     | string | The minimum amount of token0 to add and stake.     |
| `amount1Min`     | string | The minimum amount of token1 to add and stake.     |
| `deadline`       | int64  | The deadline at which the transaction will expire. |
| `referrer`       | string | The referrer address for reward tracking.          |

#### Return Values

| Name         | Type   | Description                                                           |
| ------------ | ------ | --------------------------------------------------------------------- |
| `positionId` | uint64 | The ID of the position to be created and staked.                      |
| `liquidity`  | string | The liquidity amount of the position.                                 |
| `amount0`    | string | The amount of token0 to be staked.                                    |
| `amount1`    | string | The amount of token1 to be staked.                                    |
| `poolPath`   | string | The path of the pool that the position will be created and staked in. |


# protocol\_fee\_unstaking.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/staker/v1/protocol_fee_unstaking.gno>" %}

Getter and setter functions for the Unstaking Fee, the protocol fee charged when a user claims the staking rewards for staking positions by unstaking positions or calling the `CollectReward` function. The default value is set to 100 (=1% of total staking rewards claimed).

## GetUnstakingFee

```go
func GetUnstakingFee()
```

Returns the current rate of the Unstaking Fee.

#### Return Values

| Name        | Type   | Description                            |
| ----------- | ------ | -------------------------------------- |
| `rewardFee` | uint64 | The current rate of the Unstaking Fee. |

## SetUnstakingFee

```go
func SetUnstakingFee(
  fee uint64
)
```

Modifies the Unstaking Fee.

#### Parameters

| Name  | Type   | Description                                                                      |
| ----- | ------ | -------------------------------------------------------------------------------- |
| `fee` | uint64 | The rate that will be set as the new Unstaking Fee. (the value should be in bps) |


# staker.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/staker/v1/staker.gno>" %}

Stakes or unstakes a position obtained from adding liquidity.

## StakeToken

```go
func StakeToken(
	cur realm,
	positionId uint64,
	referrer string
) string
```

StakeToken stakes a position.

#### Parameters

| Name         | Type   | Description                               |
| ------------ | ------ | ----------------------------------------- |
| `cur`        | realm  | Pass `cross` as argument.                 |
| `positionId` | uint64 | The ID of the position to stake.          |
| `referrer`   | string | The referrer address for reward tracking. |

#### Return Values

| Name       | Type   | Description                                    |
| ---------- | ------ | ---------------------------------------------- |
| `poolPath` | string | The path of the pool that the position exists. |

## UnStakeToken

```go
func UnStakeToken(
	cur realm,
	positionId uint64,
	unwrapResult bool
) string
```

UnStakeToken unstakes a position.

#### Parameters

| Name           | Type   | Description                        |
| -------------- | ------ | ---------------------------------- |
| `cur`          | realm  | Pass `cross` as argument.          |
| `positionId`   | uint64 | The ID of the position to unstake. |
| `unwrapResult` | bool   | Whether to unwrap WGNOT to GNOT.   |

#### Return Values

| Name       | Type   | Description                                                   |
| ---------- | ------ | ------------------------------------------------------------- |
| `poolPath` | string | The path of the pool that the position will be unstaked from. |

## CollectReward

```go
func CollectReward(
	cur realm,
	positionId uint64,
	unwrapResult bool
) (string, string, map[string]int64, map[string]int64)
```

CollectReward collects staking rewards accrued to a position.

#### Parameters

| Name           | Type   | Description                                                             |
| -------------- | ------ | ----------------------------------------------------------------------- |
| `cur`          | realm  | Pass `cross` as argument.                                               |
| `positionId`   | uint64 | The ID of the position to collect incentives from.                      |
| `unwrapResult` | bool   | (if position has wugnot fee) whether to receive reward in ugnot or not. |

#### Return Values

| Name              | Type              | Description                                    |
| ----------------- | ----------------- | ---------------------------------------------- |
| `poolPath`        | string            | The path of the pool that the position exists. |
| `stakeDetail`     | string            | The staking details.                           |
| `internalRewards` | map\[string]int64 | The internal rewards.                          |
| `externalRewards` | map\[string]int64 | The external rewards.                          |


# Launchpad


# getter.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/launchpad/v1/getter.gno>" %}

## GetCurrentDepositId

```go
func GetCurrentDepositId() int64

```

GetCurrentDepositId returns the current deposit counter value.

#### Return Values

| Name        | Type  | Description             |
| ----------- | ----- | ----------------------- |
| `depositId` | int64 | current deposit counter |

***

## GetDepositCount

```go
func GetDepositCount() int

```

GetDepositCount returns the total number of deposits.

#### Return Values

| Name    | Type | Description              |
| ------- | ---- | ------------------------ |
| `count` | int  | total number of deposits |

***

## GetDepositAmount

```go
func GetDepositAmount(
	depositId string
) (int64, error)

```

GetDepositAmount returns the deposit amount of a deposit by its ID.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `depositId` | string | ID of the deposit |

#### Return Values

| Name     | Type  | Description        |
| -------- | ----- | ------------------ |
| `amount` | int64 | deposit amount     |
| `err`    | error | error if not found |

***

## GetDepositCreatedAt

```go
func GetDepositCreatedAt(
	depositId string
) (int64, error)

```

GetDepositCreatedAt returns the created time of a deposit by its ID.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `depositId` | string | ID of the deposit |

#### Return Values

| Name        | Type  | Description        |
| ----------- | ----- | ------------------ |
| `timestamp` | int64 | creation timestamp |
| `err`       | error | error if not found |

***

## GetDepositCreatedHeight

```go
func GetDepositCreatedHeight(
	depositId string
) (int64, error)

```

GetDepositCreatedHeight returns the created height of a deposit by its ID.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `depositId` | string | ID of the deposit |

#### Return Values

| Name     | Type  | Description              |
| -------- | ----- | ------------------------ |
| `height` | int64 | block height at creation |
| `err`    | error | error if not found       |

***

## GetDepositEndTime

```go
func GetDepositEndTime(
	depositId string
) (int64, error)

```

GetDepositEndTime returns the end time of a deposit by its ID.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `depositId` | string | ID of the deposit |

#### Return Values

| Name        | Type  | Description        |
| ----------- | ----- | ------------------ |
| `timestamp` | int64 | end timestamp      |
| `err`       | error | error if not found |

***

## GetDepositProjectID

```go
func GetDepositProjectID(
	depositId string
) (string, error)

```

GetDepositProjectID returns the project ID of a deposit by its ID.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `depositId` | string | ID of the deposit |

#### Return Values

| Name        | Type   | Description        |
| ----------- | ------ | ------------------ |
| `projectId` | string | project ID         |
| `err`       | error  | error if not found |

***

## GetDepositProjectTierID

```go
func GetDepositProjectTierID(
	depositId string
) (string, error)

```

GetDepositProjectTierID returns the project tier ID of a deposit by its ID.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `depositId` | string | ID of the deposit |

#### Return Values

| Name            | Type   | Description        |
| --------------- | ------ | ------------------ |
| `projectTierId` | string | project tier ID    |
| `err`           | error  | error if not found |

***

## GetDepositTier

```go
func GetDepositTier(
	depositId string
) (int64, error)

```

GetDepositTier returns the tier of a deposit by its ID.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `depositId` | string | ID of the deposit |

#### Return Values

| Name   | Type  | Description        |
| ------ | ----- | ------------------ |
| `tier` | int64 | tier level         |
| `err`  | error | error if not found |

***

## GetDepositWithdrawnHeight

```go
func GetDepositWithdrawnHeight(
	depositId string
) (int64, error)

```

GetDepositWithdrawnHeight returns the withdrawn height of a deposit by its ID.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `depositId` | string | ID of the deposit |

#### Return Values

| Name     | Type  | Description                |
| -------- | ----- | -------------------------- |
| `height` | int64 | block height at withdrawal |
| `err`    | error | error if not found         |

***

## GetDepositWithdrawnTime

```go
func GetDepositWithdrawnTime(
	depositId string
) (int64, error)

```

GetDepositWithdrawnTime returns the withdrawn time of a deposit by its ID.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `depositId` | string | ID of the deposit |

#### Return Values

| Name        | Type  | Description          |
| ----------- | ----- | -------------------- |
| `timestamp` | int64 | withdrawal timestamp |
| `err`       | error | error if not found   |

***

## GetProjectCount

```go
func GetProjectCount() int

```

GetProjectCount returns the total number of projects.

#### Return Values

| Name    | Type | Description              |
| ------- | ---- | ------------------------ |
| `count` | int  | total number of projects |

***

## GetProjectIDs

```go
func GetProjectIDs(
	offset int,
	count int
) []string

```

GetProjectIDs returns a paginated list of project IDs.

#### Parameters

| Name     | Type | Description             |
| -------- | ---- | ----------------------- |
| `offset` | int  | starting index          |
| `count`  | int  | number of IDs to return |

#### Return Values

| Name         | Type      | Description         |
| ------------ | --------- | ------------------- |
| `projectIds` | \[]string | list of project IDs |

***

## GetProjectActiveStatus

```go
func GetProjectActiveStatus(
	projectId string
) (bool, error)

```

GetProjectActiveStatus returns whether a project is currently active.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `projectId` | string | ID of the project |

#### Return Values

| Name     | Type  | Description               |
| -------- | ----- | ------------------------- |
| `active` | bool  | true if project is active |
| `err`    | error | error if not found        |

***

## GetProjectCreatedAt

```go
func GetProjectCreatedAt(
	projectId string
) (int64, error)

```

GetProjectCreatedAt returns the created time of a project by its ID.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `projectId` | string | ID of the project |

#### Return Values

| Name        | Type  | Description        |
| ----------- | ----- | ------------------ |
| `timestamp` | int64 | creation timestamp |
| `err`       | error | error if not found |

***

## GetProjectCreatedHeight

```go
func GetProjectCreatedHeight(
	projectId string
) (int64, error)

```

GetProjectCreatedHeight returns the created height of a project by its ID.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `projectId` | string | ID of the project |

#### Return Values

| Name     | Type  | Description              |
| -------- | ----- | ------------------------ |
| `height` | int64 | block height at creation |
| `err`    | error | error if not found       |

***

## GetProjectDepositAmount

```go
func GetProjectDepositAmount(
	projectId string
) (int64, error)

```

GetProjectDepositAmount returns the deposit amount of a project by its ID.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `projectId` | string | ID of the project |

#### Return Values

| Name     | Type  | Description        |
| -------- | ----- | ------------------ |
| `amount` | int64 | deposit amount     |
| `err`    | error | error if not found |

***

## GetProjectName

```go
func GetProjectName(
	projectId string
) (string, error)

```

GetProjectName returns the name of a project by its ID.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `projectId` | string | ID of the project |

#### Return Values

| Name   | Type   | Description        |
| ------ | ------ | ------------------ |
| `name` | string | project name       |
| `err`  | error  | error if not found |

***

## GetProjectRecipient

```go
func GetProjectRecipient(
	projectId string
) (address, error)

```

GetProjectRecipient returns the recipient address of a project by its ID.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `projectId` | string | ID of the project |

#### Return Values

| Name        | Type    | Description        |
| ----------- | ------- | ------------------ |
| `recipient` | address | recipient address  |
| `err`       | error   | error if not found |

***

## GetProjectTokenPath

```go
func GetProjectTokenPath(
	projectId string
) (string, error)

```

GetProjectTokenPath returns the token path of a project by its ID.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `projectId` | string | ID of the project |

#### Return Values

| Name        | Type   | Description        |
| ----------- | ------ | ------------------ |
| `tokenPath` | string | project token path |
| `err`       | error  | error if not found |

***

## GetProjectTiersRatios

```go
func GetProjectTiersRatios(
	projectId string
) (map[int64]int64, error)

```

GetProjectTiersRatios returns the tiers ratios map of a project by its ID.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `projectId` | string | ID of the project |

#### Return Values

| Name     | Type             | Description          |
| -------- | ---------------- | -------------------- |
| `ratios` | map\[int64]int64 | map of tier to ratio |
| `err`    | error            | error if not found   |

***

## GetProjectTierDepositCount

```go
func GetProjectTierDepositCount(
	projectId string,
	tier int64
) int

```

GetProjectTierDepositCount returns the total number of deposits for a project tier.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `projectId` | string | ID of the project |
| `tier`      | int64  | tier level        |

#### Return Values

| Name    | Type | Description        |
| ------- | ---- | ------------------ |
| `count` | int  | number of deposits |

***

## GetProjectTierDepositIDs

```go
func GetProjectTierDepositIDs(
	projectId string,
	tier int64,
	offset int,
	count int
) []string

```

GetProjectTierDepositIDs returns a paginated list of deposit IDs for a project tier.

#### Parameters

| Name        | Type   | Description             |
| ----------- | ------ | ----------------------- |
| `projectId` | string | ID of the project       |
| `tier`      | int64  | tier level              |
| `offset`    | int    | starting index          |
| `count`     | int    | number of IDs to return |

#### Return Values

| Name         | Type      | Description         |
| ------------ | --------- | ------------------- |
| `depositIds` | \[]string | list of deposit IDs |

***

## GetProjectTierStartTime

```go
func GetProjectTierStartTime(
	projectId string,
	tier int64
) (int64, error)

```

GetProjectTierStartTime returns the start time of a project tier.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `projectId` | string | ID of the project |
| `tier`      | int64  | tier level        |

#### Return Values

| Name        | Type  | Description        |
| ----------- | ----- | ------------------ |
| `timestamp` | int64 | start timestamp    |
| `err`       | error | error if not found |

***

## GetProjectTierEndTime

```go
func GetProjectTierEndTime(
	projectId string,
	tier int64
) (int64, error)

```

GetProjectTierEndTime returns the end time of a project tier.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `projectId` | string | ID of the project |
| `tier`      | int64  | tier level        |

#### Return Values

| Name        | Type  | Description        |
| ----------- | ----- | ------------------ |
| `timestamp` | int64 | end timestamp      |
| `err`       | error | error if not found |

***

## GetProjectTierDistributeAmountPerSecondX128

```go
func GetProjectTierDistributeAmountPerSecondX128(
	projectId string,
	tier int64
) (*u256.Uint, error)

```

GetProjectTierDistributeAmountPerSecondX128 returns the distribute amount per second (Q128) of a project tier.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `projectId` | string | ID of the project |
| `tier`      | int64  | tier level        |

#### Return Values

| Name     | Type        | Description                                 |
| -------- | ----------- | ------------------------------------------- |
| `amount` | \*u256.Uint | distribute amount per second in Q128 format |
| `err`    | error       | error if not found                          |

***

## GetProjectTierTotalCollectedAmount

```go
func GetProjectTierTotalCollectedAmount(
	projectId string,
	tier int64
) (int64, error)

```

GetProjectTierTotalCollectedAmount returns the total collected amount of a project tier.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `projectId` | string | ID of the project |
| `tier`      | int64  | tier level        |

#### Return Values

| Name     | Type  | Description            |
| -------- | ----- | ---------------------- |
| `amount` | int64 | total collected amount |
| `err`    | error | error if not found     |

***

## GetProjectTierTotalDepositAmount

```go
func GetProjectTierTotalDepositAmount(
	projectId string,
	tier int64
) (int64, error)

```

GetProjectTierTotalDepositAmount returns the total deposit amount of a project tier.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `projectId` | string | ID of the project |
| `tier`      | int64  | tier level        |

#### Return Values

| Name     | Type  | Description          |
| -------- | ----- | -------------------- |
| `amount` | int64 | total deposit amount |
| `err`    | error | error if not found   |

***

## GetProjectTierTotalDepositCount

```go
func GetProjectTierTotalDepositCount(
	projectId string,
	tier int64
) (int64, error)

```

GetProjectTierTotalDepositCount returns the total deposit count of a project tier.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `projectId` | string | ID of the project |
| `tier`      | int64  | tier level        |

#### Return Values

| Name    | Type  | Description         |
| ------- | ----- | ------------------- |
| `count` | int64 | total deposit count |
| `err`   | error | error if not found  |

***

## GetProjectTierTotalDistributeAmount

```go
func GetProjectTierTotalDistributeAmount(
	projectId string,
	tier int64
) (int64, error)

```

GetProjectTierTotalDistributeAmount returns the total distribute amount of a project tier.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `projectId` | string | ID of the project |
| `tier`      | int64  | tier level        |

#### Return Values

| Name     | Type  | Description             |
| -------- | ----- | ----------------------- |
| `amount` | int64 | total distribute amount |
| `err`    | error | error if not found      |

***

## GetProjectTierTotalWithdrawAmount

```go
func GetProjectTierTotalWithdrawAmount(
	projectId string,
	tier int64
) (int64, error)

```

GetProjectTierTotalWithdrawAmount returns the total withdraw amount of a project tier.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `projectId` | string | ID of the project |
| `tier`      | int64  | tier level        |

#### Return Values

| Name     | Type  | Description           |
| -------- | ----- | --------------------- |
| `amount` | int64 | total withdraw amount |
| `err`    | error | error if not found    |

***

## GetProjectTierTotalWithdrawCount

```go
func GetProjectTierTotalWithdrawCount(
	projectId string,
	tier int64
) (int64, error)

```

GetProjectTierTotalWithdrawCount returns the total withdraw count of a project tier.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `projectId` | string | ID of the project |
| `tier`      | int64  | tier level        |

#### Return Values

| Name    | Type  | Description          |
| ------- | ----- | -------------------- |
| `count` | int64 | total withdraw count |
| `err`   | error | error if not found   |

***

## GetProjectTierRewardManagerCount

```go
func GetProjectTierRewardManagerCount() int

```

GetProjectTierRewardManagerCount returns the total number of reward managers.

#### Return Values

| Name    | Type | Description                     |
| ------- | ---- | ------------------------------- |
| `count` | int  | total number of reward managers |

***

## GetProjectTierRewardAccumulatedDistributeAmount

```go
func GetProjectTierRewardAccumulatedDistributeAmount(
	projectTierId string
) (int64, error)

```

GetProjectTierRewardAccumulatedDistributeAmount returns the accumulated distribute amount of a reward manager.

#### Parameters

| Name            | Type   | Description            |
| --------------- | ------ | ---------------------- |
| `projectTierId` | string | ID of the project tier |

#### Return Values

| Name     | Type  | Description                   |
| -------- | ----- | ----------------------------- |
| `amount` | int64 | accumulated distribute amount |
| `err`    | error | error if not found            |

***

## GetProjectTierRewardAccumulatedHeight

```go
func GetProjectTierRewardAccumulatedHeight(
	projectTierId string
) (int64, error)

```

GetProjectTierRewardAccumulatedHeight returns the accumulated height of a reward manager.

#### Parameters

| Name            | Type   | Description            |
| --------------- | ------ | ---------------------- |
| `projectTierId` | string | ID of the project tier |

#### Return Values

| Name     | Type  | Description              |
| -------- | ----- | ------------------------ |
| `height` | int64 | accumulated block height |
| `err`    | error | error if not found       |

***

## GetProjectTierRewardAccumulatedRewardPerDepositX128

```go
func GetProjectTierRewardAccumulatedRewardPerDepositX128(
	projectTierId string
) (*u256.Uint, error)

```

GetProjectTierRewardAccumulatedRewardPerDepositX128 returns the accumulated reward per deposit (Q128) of a reward manager.

#### Parameters

| Name            | Type   | Description            |
| --------------- | ------ | ---------------------- |
| `projectTierId` | string | ID of the project tier |

#### Return Values

| Name     | Type        | Description                                   |
| -------- | ----------- | --------------------------------------------- |
| `amount` | \*u256.Uint | accumulated reward per deposit in Q128 format |
| `err`    | error       | error if not found                            |

***

## GetProjectTierRewardAccumulatedTime

```go
func GetProjectTierRewardAccumulatedTime(
	projectTierId string
) (int64, error)

```

GetProjectTierRewardAccumulatedTime returns the accumulated time of a reward manager.

#### Parameters

| Name            | Type   | Description            |
| --------------- | ------ | ---------------------- |
| `projectTierId` | string | ID of the project tier |

#### Return Values

| Name        | Type  | Description           |
| ----------- | ----- | --------------------- |
| `timestamp` | int64 | accumulated timestamp |
| `err`       | error | error if not found    |

***

## GetProjectTierRewardClaimableDuration

```go
func GetProjectTierRewardClaimableDuration(
	projectTierId string
) (int64, error)

```

GetProjectTierRewardClaimableDuration returns the reward claimable duration of a reward manager.

#### Parameters

| Name            | Type   | Description            |
| --------------- | ------ | ---------------------- |
| `projectTierId` | string | ID of the project tier |

#### Return Values

| Name       | Type  | Description                   |
| ---------- | ----- | ----------------------------- |
| `duration` | int64 | claimable duration in seconds |
| `err`      | error | error if not found            |

***

## GetProjectTierRewardDistributeAmountPerSecondX128

```go
func GetProjectTierRewardDistributeAmountPerSecondX128(
	projectTierId string
) (*u256.Uint, error)

```

GetProjectTierRewardDistributeAmountPerSecondX128 returns the distribute amount per second (Q128) of a reward manager.

#### Parameters

| Name            | Type   | Description            |
| --------------- | ------ | ---------------------- |
| `projectTierId` | string | ID of the project tier |

#### Return Values

| Name     | Type        | Description                                 |
| -------- | ----------- | ------------------------------------------- |
| `amount` | \*u256.Uint | distribute amount per second in Q128 format |
| `err`    | error       | error if not found                          |

***

## GetProjectTierRewardDistributeEndTime

```go
func GetProjectTierRewardDistributeEndTime(
	projectTierId string
) (int64, error)

```

GetProjectTierRewardDistributeEndTime returns the distribute end time of a reward manager.

#### Parameters

| Name            | Type   | Description            |
| --------------- | ------ | ---------------------- |
| `projectTierId` | string | ID of the project tier |

#### Return Values

| Name        | Type  | Description              |
| ----------- | ----- | ------------------------ |
| `timestamp` | int64 | distribute end timestamp |
| `err`       | error | error if not found       |

***

## GetProjectTierRewardDistributeStartTime

```go
func GetProjectTierRewardDistributeStartTime(
	projectTierId string
) (int64, error)

```

GetProjectTierRewardDistributeStartTime returns the distribute start time of a reward manager.

#### Parameters

| Name            | Type   | Description            |
| --------------- | ------ | ---------------------- |
| `projectTierId` | string | ID of the project tier |

#### Return Values

| Name        | Type  | Description                |
| ----------- | ----- | -------------------------- |
| `timestamp` | int64 | distribute start timestamp |
| `err`       | error | error if not found         |

***

## GetProjectTierRewardTotalClaimedAmount

```go
func GetProjectTierRewardTotalClaimedAmount(
	projectTierId string
) (int64, error)

```

GetProjectTierRewardTotalClaimedAmount returns the total claimed amount of a reward manager.

#### Parameters

| Name            | Type   | Description            |
| --------------- | ------ | ---------------------- |
| `projectTierId` | string | ID of the project tier |

#### Return Values

| Name     | Type  | Description          |
| -------- | ----- | -------------------- |
| `amount` | int64 | total claimed amount |
| `err`    | error | error if not found   |

***

## GetProjectTierRewardTotalDistributeAmount

```go
func GetProjectTierRewardTotalDistributeAmount(
	projectTierId string
) (int64, error)

```

GetProjectTierRewardTotalDistributeAmount returns the total distribute amount of a reward manager.

#### Parameters

| Name            | Type   | Description            |
| --------------- | ------ | ---------------------- |
| `projectTierId` | string | ID of the project tier |

#### Return Values

| Name     | Type  | Description             |
| -------- | ----- | ----------------------- |
| `amount` | int64 | total distribute amount |
| `err`    | error | error if not found      |


# launchpad\_deposit.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/launchpad/v1/launchpad_deposit.gno>" %}

## DepositGns

```go
func DepositGns(
	cur realm,
	targetProjectTierID string,
	depositAmount int64,
	referrer string
) string
```

DepositGns deposits GNS to a launchpad project pool.

#### Parameters

| Name                  | Type   | Description                               |
| --------------------- | ------ | ----------------------------------------- |
| `cur`                 | realm  | Pass `cross` as argument.                 |
| `targetProjectTierID` | string | The pool tier ID to deposit.              |
| `depositAmount`       | int64  | The amount of GNS token to deposit.       |
| `referrer`            | string | The referrer address for reward tracking. |

#### Return Values

| Name        | Type   | Description            |
| ----------- | ------ | ---------------------- |
| `depositId` | string | The ID of the deposit. |


# launchpad\_project.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/launchpad/v1/launchpad_project.gno>" %}

## CreateProject

```go
func CreateProject(
	cur realm,
	name string,
	tokenPath string,
	recipient address,
	depositAmount int64,
	conditionTokens string,
	conditionAmounts string,
	tier30Ratio int64,
	tier90Ratio int64,
	tier180Ratio int64,
	startTime int64
) string
```

CreateProject creates a new launchpad project (only callable by the admin).

#### Parameters

| Name               | Type    | Description                                                                                                                      |
| ------------------ | ------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `cur`              | realm   | Pass `cross` as argument.                                                                                                        |
| `name`             | string  | The name of a project.                                                                                                           |
| `tokenPath`        | string  | The token path to distribute as reward.                                                                                          |
| `recipient`        | address | The address of the project's to receive reward.                                                                                  |
| `depositAmount`    | int64   | The amount of token to distribute as reward.                                                                                     |
| `conditionTokens`  | string  | A list of token paths to use as a condition when depositing (It's optional, and for multiple tokens, use `*PAD*` as separator).  |
| `conditionAmounts` | string  | A list of tokens' amount to use as condition when depositing (It's optional, and for multiple tokens, use `*PAD*` as separator). |
| `tier30Ratio`      | int64   | The distribution ratio of the 30 days pool.                                                                                      |
| `tier90Ratio`      | int64   | The distribution ratio of the 90 days pool.                                                                                      |
| `tier180Ratio`     | int64   | The distribution ratio of the 180 days pool.                                                                                     |
| `startTime`        | int64   | The start time of the project.                                                                                                   |

#### Return Values

| Name        | Type   | Description                    |
| ----------- | ------ | ------------------------------ |
| `projectId` | string | The ID of the created project. |

## TransferLeftFromProjectByAdmin

```go
func TransferLeftFromProjectByAdmin(
	cur realm,
	projectID string,
	recipient address
) int64
```

TransferLeftFromProjectByAdmin transfers the remaining amount from the ended project to the recipient.

#### Parameters

| Name        | Type    | Description                                            |
| ----------- | ------- | ------------------------------------------------------ |
| `cur`       | realm   | Pass `cross` as argument.                              |
| `projectID` | string  | The ID of the ended project.                           |
| `recipient` | address | The recipient address to receive the remaining tokens. |

#### Return Values

| Name     | Type  | Description                       |
| -------- | ----- | --------------------------------- |
| `amount` | int64 | The amount of transferred tokens. |


# launchpad\_protocol\_fee.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/launchpad/v1/launchpad_protocol_fee.gno>" %}

## CollectProtocolFee

```go
func CollectProtocolFee(
	cur realm
)
```

CollectProtocolFee collects the protocol fees from the governance contract. The reward is for projects, not for users, and it occurs based on the xGNS holdings that users deposited via launchpad to receive the project tokens.

#### Parameters

| Name  | Type  | Description               |
| ----- | ----- | ------------------------- |
| `cur` | realm | Pass `cross` as argument. |


# launchpad\_reward.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/launchpad/v1/launchpad_reward.gno>" %}

## CollectRewardByDepositId

```go
func CollectRewardByDepositId(
	cur realm,
	depositID string
) int64
```

CollectRewardByDepositId collects the project token reward for users using a depositId.

#### Parameters

| Name        | Type   | Description                                  |
| ----------- | ------ | -------------------------------------------- |
| `cur`       | realm  | Pass `cross` as argument.                    |
| `depositID` | string | The ID of a deposit to collect reward token. |

#### Return Values

| Name     | Type  | Description                           |
| -------- | ----- | ------------------------------------- |
| `amount` | int64 | The amount of collected reward token. |


# launchpad\_withdraw\.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/launchpad/v1/launchpad_withdraw.gno>" %}

## CollectDepositGns

```go
func CollectDepositGns(
	cur realm,
	depositID string
) (int64, error)
```

CollectDepositGns collects the deposited GNS using a depositID.

#### Parameters

| Name        | Type   | Description                         |
| ----------- | ------ | ----------------------------------- |
| `cur`       | realm  | Pass `cross` as argument.           |
| `depositID` | string | The ID of a deposit to collect GNS. |

#### Return Values

| Name     | Type  | Description                  |
| -------- | ----- | ---------------------------- |
| `amount` | int64 | The collected amount of GNS. |
| `err`    | error | Error if collection fails.   |


# Governance


# Governance


# config.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/gov/governance/v1/config.gno>" %}

## Reconfigure

```go
func Reconfigure(
	cur realm,
	votingStartDelay int64,
	votingPeriod int64,
	votingWeightSmoothingDuration int64,
	quorum int64,
	proposalCreationThreshold int64,
	executionDelay int64,
	executionWindow int64
) int64
```

Reconfigure updates the governance configuration parameters. Only callable by admin or governance.

#### Parameters

| Name                            | Type  | Description                                 |
| ------------------------------- | ----- | ------------------------------------------- |
| `cur`                           | realm | Pass `cross` as argument.                   |
| `votingStartDelay`              | int64 | delay before voting starts (seconds)        |
| `votingPeriod`                  | int64 | voting duration (seconds)                   |
| `votingWeightSmoothingDuration` | int64 | weight smoothing duration (seconds)         |
| `quorum`                        | int64 | minimum voting weight required (percentage) |
| `proposalCreationThreshold`     | int64 | minimum weight to create proposal           |
| `executionDelay`                | int64 | delay before execution (seconds)            |
| `executionWindow`               | int64 | execution time window (seconds)             |

#### Return Values

| Name    | Type  | Description               |
| ------- | ----- | ------------------------- |
| `int64` | int64 | new configuration version |


# execute.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/gov/governance/v1/governance_execute.gno>" %}

## Execute

```go
func Execute(
	cur realm,
	proposalId int64
) int64
```

Execute executes the given proposal.

The proposal must have reached quorum and have more `Yes` voting power than `No` voting power to become executable. Tied votes are rejected and cannot be executed.

#### Parameters

| Name         | Type  | Description                        |
| ------------ | ----- | ---------------------------------- |
| `cur`        | realm | Pass `cross` as argument.          |
| `proposalId` | int64 | The ID of the proposal to execute. |

#### Return Values

| Name         | Type  | Description             |
| ------------ | ----- | ----------------------- |
| `proposalId` | int64 | The ID of the proposal. |

## Cancel

```go
func Cancel(
	cur realm,
	proposalId int64
) int64
```

Cancel cancels the proposal with the given ID.

#### Parameters

| Name         | Type  | Description                       |
| ------------ | ----- | --------------------------------- |
| `cur`        | realm | Pass `cross` as argument.         |
| `proposalId` | int64 | The ID of the proposal to cancel. |

#### Return Values

| Name         | Type  | Description             |
| ------------ | ----- | ----------------------- |
| `proposalId` | int64 | The ID of the proposal. |


# getter.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/gov/governance/v1/getter.gno>" %}

## ExistsProposal

```go
func ExistsProposal(
	proposalID int64
) bool

```

ExistsProposal checks if a proposal exists.

#### Parameters

| Name         | Type  | Description        |
| ------------ | ----- | ------------------ |
| `proposalID` | int64 | ID of the proposal |

#### Return Values

| Name     | Type | Description             |
| -------- | ---- | ----------------------- |
| `exists` | bool | true if proposal exists |

***

## ExistsVotingInfo

```go
func ExistsVotingInfo(
	proposalID int64,
	addr address
) bool

```

ExistsVotingInfo checks if a voting info exists for a user on a proposal.

#### Parameters

| Name         | Type    | Description        |
| ------------ | ------- | ------------------ |
| `proposalID` | int64   | ID of the proposal |
| `addr`       | address | voter address      |

#### Return Values

| Name     | Type | Description                |
| -------- | ---- | -------------------------- |
| `exists` | bool | true if voting info exists |

***

## GetLatestConfigVersion

```go
func GetLatestConfigVersion() int64

```

GetLatestConfigVersion returns the current config version.

#### Return Values

| Name      | Type  | Description                   |
| --------- | ----- | ----------------------------- |
| `version` | int64 | current config version number |

***

## GetCurrentProposalID

```go
func GetCurrentProposalID() int64

```

GetCurrentProposalID returns the current proposal ID counter.

#### Return Values

| Name         | Type  | Description                 |
| ------------ | ----- | --------------------------- |
| `proposalId` | int64 | current proposal ID counter |

***

## GetMaxSmoothingPeriod

```go
func GetMaxSmoothingPeriod() int64

```

GetMaxSmoothingPeriod returns the maximum smoothing period for delegation history cleanup.

#### Return Values

| Name     | Type  | Description                         |
| -------- | ----- | ----------------------------------- |
| `period` | int64 | maximum smoothing period in seconds |

***

## GetProposalCount

```go
func GetProposalCount() int

```

GetProposalCount returns the total number of proposals.

#### Return Values

| Name    | Type | Description               |
| ------- | ---- | ------------------------- |
| `count` | int  | total number of proposals |

***

## GetProposalIDs

```go
func GetProposalIDs(
	offset int,
	count int
) []int64

```

GetProposalIDs returns a paginated list of proposal IDs.

#### Parameters

| Name     | Type | Description             |
| -------- | ---- | ----------------------- |
| `offset` | int  | starting index          |
| `count`  | int  | number of IDs to return |

#### Return Values

| Name          | Type     | Description          |
| ------------- | -------- | -------------------- |
| `proposalIds` | \[]int64 | list of proposal IDs |

***

## GetProposerByProposalId

```go
func GetProposerByProposalId(
	proposalId int64
) (address, error)

```

GetProposerByProposalId returns the proposer address of a proposal.

#### Parameters

| Name         | Type  | Description        |
| ------------ | ----- | ------------------ |
| `proposalId` | int64 | ID of the proposal |

#### Return Values

| Name       | Type    | Description        |
| ---------- | ------- | ------------------ |
| `proposer` | address | proposer address   |
| `err`      | error   | error if not found |

***

## GetYeaByProposalId

```go
func GetYeaByProposalId(
	proposalId int64
) (int64, error)

```

GetYeaByProposalId returns the yes vote weight of a proposal.

#### Parameters

| Name         | Type  | Description        |
| ------------ | ----- | ------------------ |
| `proposalId` | int64 | ID of the proposal |

#### Return Values

| Name  | Type  | Description           |
| ----- | ----- | --------------------- |
| `yea` | int64 | total yes vote weight |
| `err` | error | error if not found    |

***

## GetNayByProposalId

```go
func GetNayByProposalId(
	proposalId int64
) (int64, error)

```

GetNayByProposalId returns the no vote weight of a proposal.

#### Parameters

| Name         | Type  | Description        |
| ------------ | ----- | ------------------ |
| `proposalId` | int64 | ID of the proposal |

#### Return Values

| Name  | Type  | Description          |
| ----- | ----- | -------------------- |
| `nay` | int64 | total no vote weight |
| `err` | error | error if not found   |

***

## GetConfigVersionByProposalId

```go
func GetConfigVersionByProposalId(
	proposalId int64
) (int64, error)

```

GetConfigVersionByProposalId returns the config version used by a proposal.

#### Parameters

| Name         | Type  | Description        |
| ------------ | ----- | ------------------ |
| `proposalId` | int64 | ID of the proposal |

#### Return Values

| Name            | Type  | Description           |
| --------------- | ----- | --------------------- |
| `configVersion` | int64 | config version number |
| `err`           | error | error if not found    |

***

## GetQuorumAmountByProposalId

```go
func GetQuorumAmountByProposalId(
	proposalId int64
) (int64, error)

```

GetQuorumAmountByProposalId returns the quorum requirement for a proposal.

#### Parameters

| Name         | Type  | Description        |
| ------------ | ----- | ------------------ |
| `proposalId` | int64 | ID of the proposal |

#### Return Values

| Name     | Type  | Description            |
| -------- | ----- | ---------------------- |
| `quorum` | int64 | required quorum amount |
| `err`    | error | error if not found     |

***

## GetTitleByProposalId

```go
func GetTitleByProposalId(
	proposalId int64
) (string, error)

```

GetTitleByProposalId returns the title of a proposal.

#### Parameters

| Name         | Type  | Description        |
| ------------ | ----- | ------------------ |
| `proposalId` | int64 | ID of the proposal |

#### Return Values

| Name    | Type   | Description        |
| ------- | ------ | ------------------ |
| `title` | string | proposal title     |
| `err`   | error  | error if not found |

***

## GetDescriptionByProposalId

```go
func GetDescriptionByProposalId(
	proposalId int64
) (string, error)

```

GetDescriptionByProposalId returns the description of a proposal.

#### Parameters

| Name         | Type  | Description        |
| ------------ | ----- | ------------------ |
| `proposalId` | int64 | ID of the proposal |

#### Return Values

| Name          | Type   | Description          |
| ------------- | ------ | -------------------- |
| `description` | string | proposal description |
| `err`         | error  | error if not found   |

***

## GetProposalStatusByProposalId

```go
func GetProposalStatusByProposalId(
	proposalId int64
) (string, error)

```

GetProposalStatusByProposalId returns the current status of a proposal.

#### Parameters

| Name         | Type  | Description        |
| ------------ | ----- | ------------------ |
| `proposalId` | int64 | ID of the proposal |

#### Return Values

| Name     | Type   | Description            |
| -------- | ------ | ---------------------- |
| `status` | string | proposal status string |
| `err`    | error  | error if not found     |

***

## GetProposalCreatedAt

```go
func GetProposalCreatedAt(
	proposalId int64
) (int64, error)

```

GetProposalCreatedAt returns the creation timestamp of a proposal.

#### Parameters

| Name         | Type  | Description        |
| ------------ | ----- | ------------------ |
| `proposalId` | int64 | ID of the proposal |

#### Return Values

| Name        | Type  | Description        |
| ----------- | ----- | ------------------ |
| `timestamp` | int64 | creation timestamp |
| `err`       | error | error if not found |

***

## GetProposalCreatedHeight

```go
func GetProposalCreatedHeight(
	proposalId int64
) (int64, error)

```

GetProposalCreatedHeight returns the creation block height of a proposal.

#### Parameters

| Name         | Type  | Description        |
| ------------ | ----- | ------------------ |
| `proposalId` | int64 | ID of the proposal |

#### Return Values

| Name     | Type  | Description           |
| -------- | ----- | --------------------- |
| `height` | int64 | creation block height |
| `err`    | error | error if not found    |

***

## GetVoteStatus

```go
func GetVoteStatus(
	proposalId int64
) (quorum int64, maxVotingWeight int64, yesWeight int64, noWeight int64, err error)

```

GetVoteStatus returns the vote status of a proposal.

#### Parameters

| Name         | Type  | Description        |
| ------------ | ----- | ------------------ |
| `proposalId` | int64 | ID of the proposal |

#### Return Values

| Name              | Type  | Description                                       |
| ----------------- | ----- | ------------------------------------------------- |
| `quorum`          | int64 | minimum vote weight required for proposal to pass |
| `maxVotingWeight` | int64 | maximum possible voting weight                    |
| `yesWeight`       | int64 | total weight of "yes" votes                       |
| `noWeight`        | int64 | total weight of "no" votes                        |
| `err`             | error | error if not found                                |

***

## GetVotingInfoCount

```go
func GetVotingInfoCount(
	proposalID int64
) int

```

GetVotingInfoCount returns the number of voters for a proposal.

#### Parameters

| Name         | Type  | Description        |
| ------------ | ----- | ------------------ |
| `proposalID` | int64 | ID of the proposal |

#### Return Values

| Name    | Type | Description      |
| ------- | ---- | ---------------- |
| `count` | int  | number of voters |

***

## GetVotingInfoAddresses

```go
func GetVotingInfoAddresses(
	proposalID int64,
	offset int,
	count int
) []address

```

GetVotingInfoAddresses returns a paginated list of voter addresses for a proposal.

#### Parameters

| Name         | Type  | Description                   |
| ------------ | ----- | ----------------------------- |
| `proposalID` | int64 | ID of the proposal            |
| `offset`     | int   | starting index                |
| `count`      | int   | number of addresses to return |

#### Return Values

| Name        | Type       | Description             |
| ----------- | ---------- | ----------------------- |
| `addresses` | \[]address | list of voter addresses |

***

## GetVoteWeight

```go
func GetVoteWeight(
	proposalID int64,
	addr address
) (int64, error)

```

GetVoteWeight returns the voting weight of an address for a proposal.

#### Parameters

| Name         | Type    | Description        |
| ------------ | ------- | ------------------ |
| `proposalID` | int64   | ID of the proposal |
| `addr`       | address | voter address      |

#### Return Values

| Name     | Type  | Description        |
| -------- | ----- | ------------------ |
| `weight` | int64 | voting weight      |
| `err`    | error | error if not found |

***

## GetVotedHeight

```go
func GetVotedHeight(
	proposalID int64,
	addr address
) (int64, error)

```

GetVotedHeight returns the block height when an address voted on a proposal.

#### Parameters

| Name         | Type    | Description        |
| ------------ | ------- | ------------------ |
| `proposalID` | int64   | ID of the proposal |
| `addr`       | address | voter address      |

#### Return Values

| Name     | Type  | Description             |
| -------- | ----- | ----------------------- |
| `height` | int64 | block height when voted |
| `err`    | error | error if not found      |

***

## GetVotedAt

```go
func GetVotedAt(
	proposalID int64,
	addr address
) (int64, error)

```

GetVotedAt returns the timestamp when an address voted on a proposal.

#### Parameters

| Name         | Type    | Description        |
| ------------ | ------- | ------------------ |
| `proposalID` | int64   | ID of the proposal |
| `addr`       | address | voter address      |

#### Return Values

| Name        | Type  | Description        |
| ----------- | ----- | ------------------ |
| `timestamp` | int64 | time when voted    |
| `err`       | error | error if not found |

***

## GetUserProposalCount

```go
func GetUserProposalCount(
	user address
) int

```

GetUserProposalCount returns the number of proposals created by a user.

#### Parameters

| Name   | Type    | Description  |
| ------ | ------- | ------------ |
| `user` | address | user address |

#### Return Values

| Name    | Type | Description                         |
| ------- | ---- | ----------------------------------- |
| `count` | int  | number of proposals created by user |

***

## GetUserProposalIDs

```go
func GetUserProposalIDs(
	user address,
	offset int,
	count int
) []int64

```

GetUserProposalIDs returns a paginated list of proposal IDs created by a user.

#### Parameters

| Name     | Type    | Description             |
| -------- | ------- | ----------------------- |
| `user`   | address | user address            |
| `offset` | int     | starting index          |
| `count`  | int     | number of IDs to return |

#### Return Values

| Name          | Type     | Description          |
| ------------- | -------- | -------------------- |
| `proposalIds` | \[]int64 | list of proposal IDs |

***

## GetOldestActiveProposalSnapshotTime

```go
func GetOldestActiveProposalSnapshotTime() (int64, bool)

```

GetOldestActiveProposalSnapshotTime returns the oldest snapshot time among active proposals.

#### Return Values

| Name           | Type  | Description                    |
| -------------- | ----- | ------------------------------ |
| `snapshotTime` | int64 | oldest snapshot timestamp      |
| `exists`       | bool  | true if active proposals exist |

***

## GetCurrentVotingWeightSnapshot

```go
func GetCurrentVotingWeightSnapshot() (int64, int64, error)

```

GetCurrentVotingWeightSnapshot returns the current voting weight snapshot.

#### Return Values

| Name             | Type  | Description              |
| ---------------- | ----- | ------------------------ |
| `snapshotHeight` | int64 | snapshot block height    |
| `snapshotTime`   | int64 | snapshot timestamp       |
| `err`            | error | error if retrieval fails |


# proposal.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/gov/governance/v1/governance_propose.gno>" %}

## ProposeText

```go
func ProposeText(
	cur realm,
	title string,
	description string
) int64
```

ProposeText creates a new text proposal with the provided data.

#### Parameters

| Name          | Type   | Description                      |
| ------------- | ------ | -------------------------------- |
| `cur`         | realm  | Pass `cross` as argument.        |
| `title`       | string | The title of the proposal.       |
| `description` | string | The description of the proposal. |

#### Return Values

| Name         | Type  | Description             |
| ------------ | ----- | ----------------------- |
| `proposalId` | int64 | The ID of the proposal. |

## ProposeCommunityPoolSpend

```go
func ProposeCommunityPoolSpend(
	cur realm,
	title string,
	description string,
	to address,
	tokenPath string,
	amount int64
) int64
```

ProposeCommunityPoolSpend creates a CommunityPoolSpend proposal with the provided data.

#### Parameters

| Name          | Type    | Description                             |
| ------------- | ------- | --------------------------------------- |
| `cur`         | realm   | Pass `cross` as argument.               |
| `title`       | string  | The title of the proposal.              |
| `description` | string  | The description of the proposal.        |
| `to`          | address | The address to receive the spent token. |
| `tokenPath`   | string  | The path of the token to be sent.       |
| `amount`      | int64   | The amount of the token to be sent.     |

#### Return Values

| Name         | Type  | Description             |
| ------------ | ----- | ----------------------- |
| `proposalId` | int64 | The ID of the proposal. |

## ProposeParameterChange

```go
func ProposeParameterChange(
	cur realm,
	title string,
	description string,
	numToExecute int64,
	executions string
) int64
```

ProposeParameterChange creates a ParameterChange proposal with the provided data.

#### Parameters

| Name           | Type   | Description                       |
| -------------- | ------ | --------------------------------- |
| `cur`          | realm  | Pass `cross` as argument.         |
| `title`        | string | The title of the proposal.        |
| `description`  | string | The description of the proposal.  |
| `numToExecute` | int64  | The number of changes to execute. |
| `executions`   | string | The list of changes to execute.   |

#### Return Values

| Name         | Type  | Description             |
| ------------ | ----- | ----------------------- |
| `proposalId` | int64 | The ID of the proposal. |


# vote.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/gov/governance/v1/governance_vote.gno>" %}

## Vote

```go
func Vote(
	cur realm,
	proposalId int64,
	yes bool
) string
```

Vote allows a user to vote on a given proposal.

#### Parameters

| Name         | Type  | Description                     |
| ------------ | ----- | ------------------------------- |
| `cur`        | realm | Pass `cross` as argument.       |
| `proposalId` | int64 | The ID of the proposal to vote. |
| `yes`        | bool  | The flag to vote as yes or not. |

#### Return Values

| Name      | Type   | Description          |
| --------- | ------ | -------------------- |
| `voteKey` | string | The key of the vote. |


# Staker


# getter.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/gov/staker/v1/getter.gno>" %}

## ExistsDelegation

```go
func ExistsDelegation(
	delegationID int64
) bool

```

ExistsDelegation checks if a delegation exists.

#### Parameters

| Name           | Type  | Description          |
| -------------- | ----- | -------------------- |
| `delegationID` | int64 | ID of the delegation |

#### Return Values

| Name     | Type | Description               |
| -------- | ---- | ------------------------- |
| `exists` | bool | true if delegation exists |

***

## GetClaimableRewardByAddress

```go
func GetClaimableRewardByAddress(
	addr address
) (int64, map[string]int64, error)

```

GetClaimableRewardByAddress returns claimable rewards for an address.

#### Parameters

| Name   | Type    | Description  |
| ------ | ------- | ------------ |
| `addr` | address | user address |

#### Return Values

| Name                 | Type              | Description                        |
| -------------------- | ----------------- | ---------------------------------- |
| `emissionReward`     | int64             | emission reward amount             |
| `protocolFeeRewards` | map\[string]int64 | protocol fee rewards by token path |
| `err`                | error             | error if retrieval fails           |

***

## GetClaimableRewardByLaunchpad

```go
func GetClaimableRewardByLaunchpad(
	addr address
) (int64, map[string]int64, error)

```

GetClaimableRewardByLaunchpad returns claimable launchpad rewards for an address.

#### Parameters

| Name   | Type    | Description  |
| ------ | ------- | ------------ |
| `addr` | address | user address |

#### Return Values

| Name                 | Type              | Description                        |
| -------------------- | ----------------- | ---------------------------------- |
| `emissionReward`     | int64             | emission reward amount             |
| `protocolFeeRewards` | map\[string]int64 | protocol fee rewards by token path |
| `err`                | error             | error if retrieval fails           |

***

## GetClaimableRewardByRewardID

```go
func GetClaimableRewardByRewardID(
	rewardID string
) (int64, map[string]int64, error)

```

GetClaimableRewardByRewardID returns claimable reward details by reward ID.

#### Parameters

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| `rewardID` | string | ID of the reward |

#### Return Values

| Name                 | Type              | Description                        |
| -------------------- | ----------------- | ---------------------------------- |
| `emissionReward`     | int64             | emission reward amount             |
| `protocolFeeRewards` | map\[string]int64 | protocol fee rewards by token path |
| `err`                | error             | error if retrieval fails           |

***

## GetCollectableWithdrawAmount

```go
func GetCollectableWithdrawAmount(
	delegationID int64
) int64

```

GetCollectableWithdrawAmount returns the collectable withdraw amount for a specific delegation.

#### Parameters

| Name           | Type  | Description          |
| -------------- | ----- | -------------------- |
| `delegationID` | int64 | ID of the delegation |

#### Return Values

| Name     | Type  | Description                 |
| -------- | ----- | --------------------------- |
| `amount` | int64 | collectable withdraw amount |

***

## GetDelegationCount

```go
func GetDelegationCount() int

```

GetDelegationCount returns the total number of delegations.

#### Return Values

| Name    | Type | Description                 |
| ------- | ---- | --------------------------- |
| `count` | int  | total number of delegations |

***

## GetDelegationIDs

```go
func GetDelegationIDs(
	offset int,
	count int
) []int64

```

GetDelegationIDs returns a paginated list of delegation IDs.

#### Parameters

| Name     | Type | Description             |
| -------- | ---- | ----------------------- |
| `offset` | int  | starting index          |
| `count`  | int  | number of IDs to return |

#### Return Values

| Name            | Type     | Description            |
| --------------- | -------- | ---------------------- |
| `delegationIds` | \[]int64 | list of delegation IDs |

***

## GetDelegationWithdrawCount

```go
func GetDelegationWithdrawCount(
	delegationID int64
) int

```

GetDelegationWithdrawCount returns the total number of delegation withdraws for a specific delegation.

#### Parameters

| Name           | Type  | Description          |
| -------------- | ----- | -------------------- |
| `delegationID` | int64 | ID of the delegation |

#### Return Values

| Name    | Type | Description         |
| ------- | ---- | ------------------- |
| `count` | int  | number of withdraws |

***

## GetDelegatorDelegateeAddresses

```go
func GetDelegatorDelegateeAddresses(
	delegator address,
	offset int,
	count int
) []address

```

GetDelegatorDelegateeAddresses returns a paginated list of delegatee addresses for a specific delegator.

#### Parameters

| Name        | Type    | Description                   |
| ----------- | ------- | ----------------------------- |
| `delegator` | address | delegator address             |
| `offset`    | int     | starting index                |
| `count`     | int     | number of addresses to return |

#### Return Values

| Name        | Type       | Description                 |
| ----------- | ---------- | --------------------------- |
| `addresses` | \[]address | list of delegatee addresses |

***

## GetDelegatorDelegateeCount

```go
func GetDelegatorDelegateeCount(
	delegator address
) int

```

GetDelegatorDelegateeCount returns the number of delegatees for a specific delegator.

#### Parameters

| Name        | Type    | Description       |
| ----------- | ------- | ----------------- |
| `delegator` | address | delegator address |

#### Return Values

| Name    | Type | Description          |
| ------- | ---- | -------------------- |
| `count` | int  | number of delegatees |

***

## GetEmissionAccumulatedTimestamp

```go
func GetEmissionAccumulatedTimestamp() int64

```

GetEmissionAccumulatedTimestamp returns the accumulated timestamp for emission rewards.

#### Return Values

| Name        | Type  | Description           |
| ----------- | ----- | --------------------- |
| `timestamp` | int64 | accumulated timestamp |

***

## GetEmissionAccumulatedX128PerStake

```go
func GetEmissionAccumulatedX128PerStake() *u256.Uint

```

GetEmissionAccumulatedX128PerStake returns the accumulated emission per stake (Q128).

#### Return Values

| Name                  | Type        | Description                    |
| --------------------- | ----------- | ------------------------------ |
| `accumulatedEmission` | \*u256.Uint | accumulated emission per stake |

***

## GetEmissionDistributedAmount

```go
func GetEmissionDistributedAmount() int64

```

GetEmissionDistributedAmount returns the total distributed emission amount.

#### Return Values

| Name     | Type  | Description                       |
| -------- | ----- | --------------------------------- |
| `amount` | int64 | total distributed emission amount |

***

## GetEmissionRewardBalance

```go
func GetEmissionRewardBalance() int64

```

GetEmissionRewardBalance returns the current emission reward balance.

#### Return Values

| Name      | Type  | Description                     |
| --------- | ----- | ------------------------------- |
| `balance` | int64 | current emission reward balance |

***

## GetLaunchpadProjectDeposit

```go
func GetLaunchpadProjectDeposit(
	projectAddr string
) (int64, bool)

```

GetLaunchpadProjectDeposit returns the deposit amount for a launchpad project.

#### Parameters

| Name          | Type   | Description     |
| ------------- | ------ | --------------- |
| `projectAddr` | string | project address |

#### Return Values

| Name     | Type  | Description            |
| -------- | ----- | ---------------------- |
| `amount` | int64 | deposit amount         |
| `exists` | bool  | true if project exists |

***

## GetLockedAmount

```go
func GetLockedAmount() int64

```

GetLockedAmount returns the total locked GNS amount.

#### Return Values

| Name     | Type  | Description             |
| -------- | ----- | ----------------------- |
| `amount` | int64 | total locked GNS amount |

***

## GetProtocolFeeAccumulatedTimestamp

```go
func GetProtocolFeeAccumulatedTimestamp() int64

```

GetProtocolFeeAccumulatedTimestamp returns the accumulated timestamp for protocol fee rewards.

#### Return Values

| Name        | Type  | Description           |
| ----------- | ----- | --------------------- |
| `timestamp` | int64 | accumulated timestamp |

***

## GetProtocolFeeAccumulatedX128PerStake

```go
func GetProtocolFeeAccumulatedX128PerStake(
	tokenPath string
) *u256.Uint

```

GetProtocolFeeAccumulatedX128PerStake returns the accumulated protocol fee per stake (Q128) for a token path.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `tokenPath` | string | path of the token |

#### Return Values

| Name             | Type        | Description                        |
| ---------------- | ----------- | ---------------------------------- |
| `accumulatedFee` | \*u256.Uint | accumulated protocol fee per stake |

***

## GetProtocolFeeAmount

```go
func GetProtocolFeeAmount(
	tokenPath string
) int64

```

GetProtocolFeeAmount returns the protocol fee amounts for a token path.

#### Parameters

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| `tokenPath` | string | path of the token |

#### Return Values

| Name     | Type  | Description         |
| -------- | ----- | ------------------- |
| `amount` | int64 | protocol fee amount |

***

## GetTotalDelegated

```go
func GetTotalDelegated() int64

```

GetTotalDelegated returns the total amount of GNS delegated.

#### Return Values

| Name     | Type  | Description                |
| -------- | ----- | -------------------------- |
| `amount` | int64 | total delegated GNS amount |

***

## GetTotalDelegationAmountAtSnapshot

```go
func GetTotalDelegationAmountAtSnapshot(
	snapshotTime int64
) (int64, bool)

```

GetTotalDelegationAmountAtSnapshot returns the total delegation amount at a specific snapshot time.

#### Parameters

| Name           | Type  | Description        |
| -------------- | ----- | ------------------ |
| `snapshotTime` | int64 | snapshot timestamp |

#### Return Values

| Name     | Type  | Description             |
| -------- | ----- | ----------------------- |
| `amount` | int64 | total delegation amount |
| `exists` | bool  | true if snapshot exists |

***

## GetTotalLockedAmount

```go
func GetTotalLockedAmount() int64

```

GetTotalLockedAmount returns the total amount of GNS locked in undelegation.

#### Return Values

| Name     | Type  | Description             |
| -------- | ----- | ----------------------- |
| `amount` | int64 | total locked GNS amount |

***

## GetTotalxGnsSupply

```go
func GetTotalxGnsSupply() int64

```

GetTotalxGnsSupply returns the total supply of xGNS tokens.

#### Return Values

| Name     | Type  | Description             |
| -------- | ----- | ----------------------- |
| `supply` | int64 | total xGNS token supply |

***

## GetUnDelegationLockupPeriod

```go
func GetUnDelegationLockupPeriod() int64

```

GetUnDelegationLockupPeriod returns the undelegation lockup period in seconds.

#### Return Values

| Name     | Type  | Description              |
| -------- | ----- | ------------------------ |
| `period` | int64 | lockup period in seconds |

***

## GetUserDelegationAmountAtSnapshot

```go
func GetUserDelegationAmountAtSnapshot(
	userAddr address,
	snapshotTime int64
) (int64, bool)

```

GetUserDelegationAmountAtSnapshot returns the user delegation amount at a specific snapshot time.

#### Parameters

| Name           | Type    | Description        |
| -------------- | ------- | ------------------ |
| `userAddr`     | address | user address       |
| `snapshotTime` | int64   | snapshot timestamp |

#### Return Values

| Name     | Type  | Description             |
| -------- | ----- | ----------------------- |
| `amount` | int64 | user delegation amount  |
| `exists` | bool  | true if snapshot exists |

***

## GetUserDelegationCount

```go
func GetUserDelegationCount(
	delegator address,
	delegatee address
) int

```

GetUserDelegationCount returns the number of delegations for a specific delegator-delegatee pair.

#### Parameters

| Name        | Type    | Description       |
| ----------- | ------- | ----------------- |
| `delegator` | address | delegator address |
| `delegatee` | address | delegatee address |

#### Return Values

| Name    | Type | Description           |
| ------- | ---- | --------------------- |
| `count` | int  | number of delegations |

***

## GetUserDelegationIDs

```go
func GetUserDelegationIDs(
	delegator address,
	delegatee address
) []int64

```

GetUserDelegationIDs returns a list of delegation IDs for a specific delegator-delegatee pair.

#### Parameters

| Name        | Type    | Description       |
| ----------- | ------- | ----------------- |
| `delegator` | address | delegator address |
| `delegatee` | address | delegatee address |

#### Return Values

| Name            | Type     | Description            |
| --------------- | -------- | ---------------------- |
| `delegationIds` | \[]int64 | list of delegation IDs |

***

## HasDelegationSnapshotsKey

```go
func HasDelegationSnapshotsKey() bool

```

HasDelegationSnapshotsKey returns true if delegation history exists.

#### Return Values

| Name     | Type | Description                       |
| -------- | ---- | --------------------------------- |
| `exists` | bool | true if delegation history exists |


# staker\_delegate.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/gov/staker/v1/staker.gno>" %}

Delegates/Undeleates GNS for governance.

## Delegate

```go
func Delegate(
	cur realm,
	to address,
	amount int64,
	referrer string
) int64
```

Delegate delegates GNS to a delegate.

#### Parameters

| Name       | Type    | Description                               |
| ---------- | ------- | ----------------------------------------- |
| `cur`      | realm   | Pass `cross` as argument.                 |
| `to`       | address | The address to delegate.                  |
| `amount`   | int64   | The amount of GNS.                        |
| `referrer` | string  | The referrer address for reward tracking. |

#### Return Values

| Name           | Type  | Description               |
| -------------- | ----- | ------------------------- |
| `delegationId` | int64 | The ID of the delegation. |

## Undelegate

```go
func Undelegate(
	cur realm,
	from address,
	amount int64
) int64
```

Undelegate undelegates xGNS from the existing delegate.

#### Parameters

| Name     | Type    | Description                |
| -------- | ------- | -------------------------- |
| `cur`    | realm   | Pass `cross` as argument.  |
| `from`   | address | The address to undelegate. |
| `amount` | int64   | The amount of xGNS.        |

#### Return Values

| Name      | Type  | Description             |
| --------- | ----- | ----------------------- |
| `tokenId` | int64 | The ID of the position. |

## Redelegate

```go
func Redelegate(
	cur realm,
	delegatee address,
	newDelegatee address,
	amount int64
) int64

```

Redelegate redelegates xGNS from the existing delegate to another.

#### Parameters

| Name           | Type    | Description                |
| -------------- | ------- | -------------------------- |
| `cur`          | realm   | Pass `cross` as argument.  |
| `delegatee`    | address | The address to undelegate. |
| `newDelegatee` | address | The address to delegate.   |
| `amount`       | int64   | The amount of xGNS.        |

#### Return Values

| Name         | Type  | Description                   |
| ------------ | ----- | ----------------------------- |
| `resultCode` | int64 | The redelegation result code. |

## CollectUndelegatedGns

```go
func CollectUndelegatedGns(
	cur realm
) int64
```

CollectUndelegatedGns collects the amount of the undelegated GNS.

#### Parameters

| Name  | Type  | Description               |
| ----- | ----- | ------------------------- |
| `cur` | realm | Pass `cross` as argument. |

#### Return Values

| Name     | Type  | Description                        |
| -------- | ----- | ---------------------------------- |
| `amount` | int64 | The amount of GNS token collected. |


# staker\_delegation\_snapshot.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/gov/staker/v1/staker_delegation_snapshot.gno>" %}

## CleanStakerDelegationSnapshotByAdmin

```go
func CleanStakerDelegationSnapshotByAdmin(
	cur realm,
	threshold int64
)
```

CleanStakerDelegationSnapshotByAdmin removes old delegation snapshots. Only callable by admin.

#### Parameters

| Name        | Type  | Description                     |
| ----------- | ----- | ------------------------------- |
| `cur`       | realm | Pass `cross` as argument.       |
| `threshold` | int64 | timestamp threshold for cleanup |

## SetUnDelegationLockupPeriodByAdmin

```go
func SetUnDelegationLockupPeriodByAdmin(
	cur realm,
	period int64
)
```

SetUnDelegationLockupPeriodByAdmin sets the undelegation lockup period. Only callable by admin.

#### Parameters

| Name     | Type  | Description               |
| -------- | ----- | ------------------------- |
| `cur`    | realm | Pass `cross` as argument. |
| `period` | int64 | lockup period in seconds  |


# staker\_reward.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/gov/staker/v1/staker_reward.gno>" %}

## CollectReward

```go
func CollectReward(
	cur realm
)
```

CollectReward collects the rewards from the protocol fee contract based on the holdings of xGNS.

#### Parameters

| Name  | Type  | Description               |
| ----- | ----- | ------------------------- |
| `cur` | realm | Pass `cross` as argument. |

## CollectRewardFromLaunchPad

```go
func CollectRewardFromLaunchPad(
	cur realm,
	to address
)
```

CollectRewardFromLaunchPad collects the rewards from the protocol fee contract based on the holdings of xGNS in the launchpad contract (only callable by the launchpad contract).

#### Parameters

| Name  | Type    | Description               |
| ----- | ------- | ------------------------- |
| `cur` | realm   | Pass `cross` as argument. |
| `to`  | address | The address to delegate.  |

## SetAmountByProjectWallet

```go
func SetAmountByProjectWallet(
	cur realm,
	addr address,
	amount int64,
	add bool
)
```

SetAmountByProjectWallet sets reward amount for a project wallet. Only callable by launchpad contract.

#### Parameters

| Name     | Type    | Description                    |
| -------- | ------- | ------------------------------ |
| `cur`    | realm   | Pass `cross` as argument.      |
| `addr`   | address | project wallet address         |
| `amount` | int64   | reward amount                  |
| `add`    | bool    | true to add, false to subtract |


# Onboarding Guide

Creating a pool on GnoSwap is entirely permissionless. Build liquidity for your project and allow your community to seamlessly trade tokens in a secure, non-custodial, and decentralized environment. Follow a simple 4-step process to get started.

### 1. Integrate your token

To display the full information of your token on GnoSwap, register it on [Gno Token Resources](https://github.com/onbloc/gno-token-resource), a comprehensive list of tokens on Gnoland. Follow the step-by-step guide in the link below on how to submit a registration request.

{% embed url="<https://github.com/onbloc/gno-token-resource#how-to-add-your-token>" %}
How to add your token to the `gno-token-resource`
{% endembed %}

### 2. Create a pool

[Create a new pool and add some liquidity](/user-guide/providing-liquidity/create-a-position) to ensure your tokens are available for trading.

{% hint style="info" %}
**Helpful Tips for Pool Creators**

* When selecting a fee tier, we recommend a lower tier for a stable pair and a higher tier for a volatile pair to offset the impermanent loss that LPs will experience.
* Concentrate your liquidity around the starting price of the pool to lower the price impact that traders will experience. On the other hand, select a full range to ensure that your pair is available for trading at all times.
* Pairing your token with $USDC, $GNOT, or $GNS will allow swaps to be routed through the most liquid pools in Gnoswap while meeting the baseline requirement for TWAP price display.
  {% endhint %}

### 3. Add Incentives

To bootstrap some initial liquidity for your project, we recommend [adding incentives](/user-guide/staking/add-incentives). GnoSwap will distribute these rewards to LPs who stake their positions in your pool. Adding incentives to your pool will show your commitment, which will help build trust between your project and the community.

<figure><img src="/files/AGDKmYACLp3R6Mjzwjth" alt=""><figcaption></figcaption></figure>

Adding incentives will also display your pool under the Incentivized Pools in the Earn Menu for more exposure to Gnoswap's users.

<figure><img src="/files/pZ0V4AxzrRsGSrr1I335" alt=""><figcaption></figcaption></figure>

### 4. Share a direct link

In the **Swap** Menu, select your token inside the modal and click the **Copy URL** button at the top right corner to generate a unique link which will take the users directly inside the Swap menu with your tokens selected upon landing. Share the link to invite your community to trade your token.

<figure><img src="/files/nc3pjElswzX4mMpuhMsZ" alt=""><figcaption></figcaption></figure>




---

[Next Page](/llms-full.txt/1)

