Skip to main content

Smart Contracts Architecture

Summary of the FiatsendGateway contract system and supporting libraries.

Structure

contracts/
├── interfaces/IFiatsendGateway.sol
├── abstract/FiatsendBase.sol
├── libraries/TokenManager.sol
├── FiatsendGatewayV2.sol
└── mocks/*

Highlights

  • UUPS upgradeable pattern, access control, pausable, reentrancy guards
  • Decimal‑aware calculations via TokenManager
  • Safe offramp flow with eventing and auditability

Example: Decimal‑Aware Conversion

function calculateGhsFiatAmount(address token, uint256 tokenAmount)
public view returns (uint256 ghsFiatAmount)
{
uint8 tokenDecimalsValue = tokenDecimals[token];
return TokenManager.calculateGhsFiatAmount(
tokenDecimalsValue,
tokenAmount,
conversionRate
);
}

Testing & Deployment

# Run tests
npx hardhat test

# Coverage
npx hardhat coverage

# Deploy / upgrade (example)
npx hardhat run scripts/deploy-gateway-v2.js --network lisk
npx hardhat run scripts/upgrade-gateway-v2.js --network lisk

See apps/contract/CONTRACT_ARCHITECTURE.md for full details.