> For the complete documentation index, see [llms.txt](https://neurapepeai.gitbook.io/neurapepeai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://neurapepeai.gitbook.io/neurapepeai/smartswap-dev-guide.md).

# SmartSwap - Dev Guide

***

**1. Pepe Terminal B2B Swap (For Developer)**

**Token Registration:**

* Developers connect their wallet to the Pepe Terminal platform (via Web3/MetaMask).
* The developer submits the contract address of the token they wish to list.
* The smart contract checks whether the wallet address (`msg.sender`) matches the token owner (via the `owner()` function or similar logic).
* If it matches, the token is allowed to be listed, and the creator’s address is stored for fee distribution.
* If it does not match, the transaction is rejected (revert).

**Automatic Fees:**

* Each swap involving a listed token will incur a fee (e.g., 0.1% platform + 0.1% creator).
* The creator’s fee is automatically sent to the stored creator address during listing.

**Interaction with PancakeSwap:**

* Swaps still use PancakeSwap's pool and router.
* Additional fees are taken before/after the swap via the PancakeSwap Router.

***

**2. Smart Contract**

**Smart Contract Includes:**

* A function for listing tokens with creator verification.
* A mapping to store listed tokens and their associated creator addresses.
* Swap logic that distributes fees to both the platform and the token creator.

***

**3. Smart Contract Explanation**

**Listing Token (`listToken`):**

* Checks whether the token is already listed (`isTokenListed`).
* Calls the `owner()` function on the token contract to get the owner’s address.
* Verifies whether `msg.sender` (the connected wallet address) matches the token owner.
* If verification passes, it stores the creator address and marks the token as listed.

**Swapping Tokens (`swapTokens`):**

* Only allows swaps if at least one of the tokens (input/output) is listed.
* Takes a total fee (0.2% split as 0.1% to platform + 0.1% to creator).
* Distributes the fee accordingly to the platform and creator (if any).
* The remaining amount is used for the swap via PancakeSwap Router.

**Events:**

* `TokenListed`: Logs when a token is successfully listed.
* `SwapExecuted`: Logs every swap for transparency.

***

**6. Additional Notes**

**Tokens Without `owner()`:**

* If a token lacks the `owner()` function (e.g., older or custom tokens), developers can be asked to upload off-chain proof of ownership or the creator fee can be skipped.

**Flexible Fees:**

* A function to adjust `platformFee` and `creatorFee` (only the platform owner can modify these values).

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

***
