Twin Documentation
  • Overview
  • Consumer
  • Developer
  • Operations
Arquitectura
Flujos Técnicos
    Minting & RedeemBridge Cross-chainUniswap V4 Liquidity ManagementOracle Price UpdatesAuto-RebalanceRewardsAuthentication (Platform)Circulation ManagementDisperse (Batch Transfer)Market Data PipelineSupply API (CoinGecko)Contract Data CollectionCron Jobs: Flujos Detallados
Base de Datos
Local SetupConventions
powered by Zudoku
Flujos Técnicos

Minting & Redeem

Emission and burning of Twin tokens (ARGt, BRAt, COLt, etc.) backed by fiat reserves.

Overview

Minting creates new tokens on-chain when fiat is deposited. Redeem burns tokens when fiat is withdrawn. The dashboard supports two signing paths:

PathSignerSyncUse Case
BitGo MintBitGo Express (custodial)Cron MINTING_TX_SYNCPrimary operational flow
Wallet MintRainbowKit (Safe/EOA)Manual / on-chain onlyMultisig or direct wallet

1. BitGo Mint Flow

Admin creates a mint transaction through the dashboard API. BitGo Express signs and broadcasts.

Key Details

  • Coin format: Full token-qualified coin, e.g. baseeth:argt, polygon:argt (NOT just baseeth).
  • Amount: Always "0" for contract calls (no native value transfer).
  • Calldata: mint(address recipient, uint256 amount) encoded via viem.
  • Amounts: String-based base unit conversion. NEVER parseFloat * Math.pow(10, decimals).

2. Wallet Mint Flow

Admin connects a wallet (Safe multisig or EOA) via RainbowKit in the dashboard frontend, signs the transaction client-side, then records it in the backend.

Safe Wallet Limitations

ConstraintReason
No useWaitForTransactionReceiptSafe returns safeTxHash which never appears on-chain until all signers approve
No useSwitchChain()Safe wallets don't support wallet_switchEthereumChain. Show an Alert asking the user to connect on the correct network
Cancel not supportedWallet-mint TXs are canceled in Safe UI, not via dashboard

3. Cron MINTING_TX_SYNC

Synchronizes BitGo-sourced transaction statuses. Runs on schedule, queries BitGo for updates.

Critical Filter

The cron only processes transactions where source = 'bitgo'. Wallet-mint transactions are excluded because BitGo has no knowledge of them.

Code
WHERE source = 'bitgo' AND status IN ('pending', 'approved', 'submitted')

Entity Relationship Diagram


Amount Conversion

Amounts are stored and transmitted as base unit strings (e.g. "1000000" for 1 USDC with 6 decimals).

Code
NEVER: parseFloat(amount) * Math.pow(10, decimals) // overflow, scientific notation ALWAYS: string split + pad/truncate decimal part + concatenate

Backend schemas validate with pattern: '^[0-9]+$' (digits only).


API Endpoints

MethodPathDescription
POST/api/operations/minting/mintBitGo mint (creates TX + sends to BitGo)
POST/api/operations/minting/wallet-mintRecord wallet-mint TX
GET/api/operations/minting/transactionList transactions (paginated)
GET/api/operations/minting/transaction/:idGet single transaction
PUT/api/operations/minting/transaction/:id/cancelCancel BitGo-mint only

Route Registration Order

Static routes (/minting/wallet-mint) must be registered before parameterized routes (/minting/transaction/:id). Fastify matches in registration order.


Dashboard Frontend Components

  • MintingPage (/operations/minting): Transaction list with filters, status badges, BitGo mint dialog.
  • WalletMintModal: RainbowKit-connected flow. Encodes calldata, sends via connected wallet, records in backend.
  • ConnectButton: Global in top-bar.tsx, compact props. Shared with bridge flow.

RainbowKit / wagmi Stack

  • WagmiProvider > QueryClientProvider > Redux > ThemeProvider > RainbowKitThemeWrapper
  • RainbowKitThemeWrapper syncs dark/light mode via useThemeMode().
  • VITE_WALLET_CONNECT_PROJECT_ID is embedded at build time (not runtime). Must be set as GitHub Secret for CI/CD.
Last modified on May 12, 2026
Flujos TécnicosBridge Cross-chain
On this page
  • Overview
  • 1. BitGo Mint Flow
    • Key Details
  • 2. Wallet Mint Flow
    • Safe Wallet Limitations
  • 3. Cron MINTING_TX_SYNC
    • Critical Filter
  • Entity Relationship Diagram
  • Amount Conversion
  • API Endpoints
    • Route Registration Order
  • Dashboard Frontend Components
    • RainbowKit / wagmi Stack