This repository contains the v3-core and v3-periphery smart contracts for the Sunswap V3 Protocol.
SunSwap V3 Core is the foundational contract library of SunSwap V3, a decentralized exchange built on the TRON blockchain.
It introduces concentrated liquidity, allowing liquidity providers to allocate capital within specific price ranges rather than across the entire spectrum. This design improves capital efficiency and enables providers to earn higher returns in volatile ranges.
The core contracts implement:
- Liquidity management: minting, burning, and collecting fees within chosen price intervals.
- Swap operations: single-hop and multi-hop token swaps across pools.
- Dynamic fee tiers: flexible fee structures that incentivize liquidity provision in different ranges.
By combining concentrated liquidity with TRON’s high-performance infrastructure, SunSwap V3 Core delivers a more efficient and customizable AMM model, enhancing both trading execution and liquidity provider strategies.
SunSwap V3 Periphery provides the higher-level contracts and interfaces that simplify interaction with the SunSwap V3 Core.
While the Core contracts implement the fundamental AMM logic (liquidity management and swaps), the Periphery contracts are designed to make these operations more user-friendly and accessible.
Key components include:
- SwapRouter: routes single-hop and multi-hop swaps across pools.
- NonfungiblePositionManager: manages liquidity positions represented as NFTs, allowing minting, burning, and fee collection.
- Supporting utilities: helper contracts and libraries for interacting with pools and managing approvals.
Together, the Periphery contracts bridge the gap between low-level protocol logic and end-user applications, enabling wallets, dApps, and integrators to interact with SunSwap V3 efficiently and securely.
This v3-core contains the core contracts of v3, namely v3Pool, which implements the liquidity management and swap operations of the v3 trading pool.
The v3-core also includes a factory contract responsible for managing and deploying v3Pools.
The v3-periphery contains the NonfungiblePositionManager contract to manage the position nfts.
NftPositionDescriptor used to describe the nft with positon infomations.
SwapRouter provides interfaces related to token swaps.
SunSwap V3 introduces a concept called concentrated capital efficiency. This mechanism empowers liquidity providers to concentrate their funds within a specific price range, thereby allowing them to provide liquidity more effectively and earn higher rewards within a price range featuring high price volatility.
| contract | chain | address |
|---|---|---|
| Factory | TRON Mainnet | TThJt8zaJzJMhCEScH7zWKnp5buVZqys9x |
| NILE Testnet | TUTGcsGDRScK1gsDPMELV2QZxeESWb1Gac | |
| SwapRouter | TRON Mainnet | TQAvWQpT9H916GckwWDJNhYZvQMkuRL7PN |
| NILE Testnet | TFkswj6rUfK3cQtFGzungCkNXxD2UCpEVD | |
| NonfungiblePositionManager | TRON Mainnet | TLSWrv7eC1AZCXkRjpqMZUmvgd99cj7pPF |
| NILE Testnet | TPQzqHbCzQfoVdAV6bLwGDos8Lk2UjXz2R | |
| Quoter | TRON Mainnet | TLhZ48yfHygMLM2uZr87zJJusHjGen97gh |
| NILE Testnet | TUcM2gkpWEJxBpkweLdVoRp6DAUsw2vWR6 | |
| TickLens | TRON Mainnet | TBBjWiPHouzEx2QRjBzTw9EA8YjG43XiAi |
| NILE Testnet | TXWuk11iagFK2qAWbBsP58A5ncU5L1LYq5 |
You can deploy the SunSwap v3 Factory and NonfungiblePositionManager contracts to the TRON Nile TestNet using the provided scripts.
First, export your private key for the Nile TestNet account (use a test account, never a production key):
export PRIVATE_KEY_NILE='Your private key'Then run:
npm run deploy-tronThis will:
- Use the
PRIVATE_KEY_NILEenvironment variable to sign transactions - Deploy the factory and related contracts to Nile
- Output the deployed addresses to the console or logs
Security Warning
Do not commit or share your private key. Use environment variables or secure secrets management. For production deployment, use hardened operational security processes.
- Review the contract source files to understand the exact AMM logic, fees, and token requirements.
- When modifying contracts, always:
- Re-run
npm run compile - Add or update tests where applicable
- Perform manual verification on a test network before mainnet deployment
- Re-run
This project provides comprehensive resources to help developers understand the contract architecture, integrate with the protocol, and ensure secure usage. The documentation covers contract mechanism and functions.
If you have questions about this project, find bugs, or would like to contribute, you can reach the team and community via:
Please follow official announcements from these channels for the latest information on deployments, upgrades, and security notices.