All projects

DeFi · Blockchain · Full-Stack

Mango DeFi

Multi-chain token swap with tax token & 5-level referrals

Overview

Mango DeFi is a token swap platform spanning Base and Solana, built around the MANGO token. Users can swap through the web app or directly inside Telegram via a Web3 mini-app.

I built it end to end: the swap and referral contracts on Base, the Rust/Anchor swap programs and Token-2022 tax token on Solana, the Node.js services behind referral payouts and tax collection, and the React frontends — deployed on AWS S3.

What it does

  • Swaps on Base through a router contract that picks a Uniswap V2 or V3 pool automatically
  • Swaps on Solana through custom Anchor programs that trade on Raydium CLMM and CPMM pools
  • Custom SPL Token-2022 with an on-chain transfer tax
  • 5-level referral system splitting fees 40/25/15/10/10, paid out in MANGO
  • Node.js + MySQL referral service that prices rewards from Uniswap pools and pays out in batches
  • Automated tax-withdrawal service running against an authority wallet
  • Telegram Web3 mini-app for trading without leaving the chat

The hard parts

Swapping on Raydium from my own program

The Solana swaps run through my own Anchor programs, which call into Raydium's CLMM and CPMM pools via CPI. A config PDA holds the fee collector, so the platform fee is enforced on-chain inside the same transaction as the swap rather than trusted to the frontend.

A transfer tax enforced on-chain

Instead of taxing trades in the app layer (which anyone can bypass), the token itself is an SPL Token-2022 with a transfer-fee extension — every transfer pays the tax at the protocol level, no matter which wallet or DEX it moves through.

5-level referral splits

1% of each swap funds referral rewards, split 40/25/15/10/10 up the referrer chain and paid in MANGO. The Solidity contract walks up to five levels, stops cleanly when the chain runs out, and blocks self-referral; a Node.js service prices each reward from Uniswap pools (token → WETH → USDC) and settles payouts in batches.

Automating the tax treasury

Token-2022 transfer fees accrue inside holders' token accounts and must be actively withdrawn. A Node.js service scans for accrued fees and withdraws them via the authority wallet, so the treasury never depends on manual operations.

Tech stack

ReactSolidityRust / Anchorethers.js@solana/web3.jsUniswapRaydiumNode.jsMySQLAWS