Contract that is integrated with Pancakeswap
to exchange any tokens for POOLX DelayVault NFT
.
The audit report is available here: Audit Report
Install the packages:
npm i
yarn
Compile contracts:
npx hardhat compile
Run tests:
npx hardhat test
Run coverage:
npx hardhat coverage
Deploy:
truffle dashboard
npx hardhat run ./scripts/deploy.ts --network truffleDashboard
The TokenNFTConnector contract operates in the following steps:
-
Token Swap:
- Users call the
createLeaderboard
function, providing the amount of tokens they want to swap and an array ofSwapParams
specifying the tokens to swap through and their. - The contract uses PancakeSwap's router (
ISwapRouter
) to execute the token swap. It calculates the path based on the provided swap parameters and swaps the tokens, considering the pool fees.
- Users call the
-
Fee Deduction:
- The contract calculates the remaining amount after deducting the project owner fee using the
calcMinusFee
function.
- The contract calculates the remaining amount after deducting the project owner fee using the
-
DelayVault Creation:
- The remaining amount after fees is then approved for the
DelayVaultProvider
contract. - The contract calls
createNewDelayVault
on theDelayVaultProvider
, associating the newly createdDelayVault
with the user.
- The remaining amount after fees is then approved for the
-
Result:
- Users receive a
POOLX DelayVault NFT
associated with the POOLX tokens.
- Users receive a
function createLeaderboard(uint256 amountIn, SwapParams[] calldata poolsData) external
struct SwapParams {
address token;
uint24 fee;
}
Swaps the specified amount of tokens for POOLX DelayVault NFTs
. Users provide the amount of tokens to swap and an array of SwapParams
specifying the token swap details. The contract concatenates the provided path array with a predefined swap path, where the last path element is always from the paired token
to the ERC-20
token (USDT -> POOLX)
. SwapParams
can be empty, which means that the exchange is being used in one path.
function getBytes(SwapParams[] calldata data) public view returns (bytes memory result)
Utility function that returns paths in bytes.
function pause() external onlyOwner
Pauses the contract, preventing further token swaps.
function unpause() external onlyOwner
Unpauses the contract, allowing token swaps to resume.
function withdrawFee() external onlyOwner
Allows the contract owner to withdraw accumulated fees in the form of tokens.
function calcMinusFee(uint256 amount) public view returns (uint256 leftAmount)
Calculates the remaining amount after deducting the project owner fee from the given amount.
function setProjectOwnerFee(uint24 fee) external onlyOwner
Allows the contract owner to set the project owner fee, ensuring it is a valid percentage. Where 10000 is 100%.
The-Poolz Contracts is released under the MIT License.