Experimental DeFi Smart Contract Development - SpiritSwap

SpiritSwap allows network users to easily make liquidity pairs and use them in farms for rewards as well as fast swaps between different tokens.


SpiritSwap is a decentralized exchange (DEX) and is one of the main liquidity providers in the Fantom Opera Chain. It aims to be a mega-hub of DefF products including:

  • Token swaps
  • Bridges
  • Liquidity Pools
  • Lending/Borrowing

Project Objective:

We were approached to adapt, develop, and deploy the following:

  • Stable Swap contracts are meant to create liquidity pools for stablecoins. This custom version would contain specific math functions to handle rewards and exchanges
  • Balancer V2 smart contracts: a DeFi protocol for token exchange that focuses on security, flexibility, capital efficiency, and gas efficiency.


  • Study of relevant documentation
  • Planning of where to implement custom logic as set by the client
  • Breakdown of minimum unit tests to cover

Technologies Used:

  • Node.js
  • Solidity
  • Vyper
  • Hardhat
  • Truffle
  • TypeScript


  • Protocol Vault for all Balancer pool assets
  • Gas efficiency
  • Permissionless and customizable Automated Market Maker (AMM) logic
  • Asset managers
  • Low gas cost and resilient oracles
  • Protocol fees that are community-governed

Project Challenges:

  • With smart contracts, mistakes can result in tremendous losses to end users, so it was important to make sure the underlying logic was solid with a low probability of exploitability.
  • Balancer V2 protocol was also different from other liquidity implementations at the time so a proper understanding of its structure was required.

Solutions we developed:

  • Experimental contracts to create stable liquidity pairs for the project,
  • After becoming knowledgeable on the functionality of Balancer V2 contracts, we worked on a modified version integrating business logic and helped with their deployment.
  • Wrote extensive unit tests to test the logic of Factory, Pairs, Deposits, Vaults, and other functions so they would be ready for front-end integration.
¬©EastCode 2024