project screenshot 1
project screenshot 2
project screenshot 3

Variable Finance

A decentralized PoS (Proof Of Sale) mechanism for ERC20 tokens. From Smart Contract to Brick & Mortar Store, accept any ERC20 token as payments. Also, we implement an on-chain approval manager. Approve it Once, Use it Anywhere.

Variable Finance

Created At

HackMoney 2021

Project Description

Variable Finance introduces two new products to the market,

Onchain PoS (Proof Of Sale) verified & entirely run by the smart contracts with real-time gross settlements under an efficient approval mechanism.

An Approvals Manager for managing all the D-Apps you've approved for efficient & secure management of ERC20s. Currently on ethereum mainnet supporting CIRCLE DOLLAR (USDC), Compound (COMP) and Uniswap (UNI) Tokens.


  1. Register as a merchant to accept ERC20 token payments at your store.
  2. Pay merchants using any ERC20 token. Currently (UNI. USDC. COMP) for PoC.
  3. Manage all your ERC20 token approvals from one place irrespective of wallet.
  4. Smart Contract has the ability to process n-ERC20 tokens without upgrading, so listing new tokens is just one step away.
  5. Sub-Graphs are deployed for the POS network to enable faster indexing and complex queries.
  6. Merchant information is store decentralized including their store logo in IPFS.

POS Network:

ERC20s represents a wider class of assets ranging from a dollar to gold to liquidity in a defi pool. So we're looking to exploit the value of these assets by enabling holders to use them in their day-to-day activities. Like spending an LP token for buying coffee at Starbucks. Currently, it would be difficult for us to declare the value of the LP token so we implemented the PoC with wBTC, COMP & USDC that have well established and stable price feeds through chainlink.

The user walks into a store and scan qr code and pays their ERC20 tokens in stores. It would be similar to the traditional approach where the merchant would have a payment pointer to which the user can pay their tokens.

Decentralized Merchant Network - All merchant information including the logo is updated to IPFS and their hash is stored to the merchant oracle (variable merchant oracle).

Merchant List: (Served from the graph, IPFS & smart contract)

Merchant Oracle Contract:

POS Contract:

For Tokens Listed on Our POS Network: (We can list all ERC20 tokens with a chainlink price oracle)

We use chainlink for fetching real-time price and use our conversion inside the POS contract that resolved the value to the amount to be paid by the use for equivalent USD. Any other payment provided can use this smart contract to build their internal payment infrastructure.

Future plan:

We're working on an on-chain POS gateway(Started but unable to complete in 3-weeks) for allowing smart contracts to process multiple token payments. Currently most of them depend on the native token of the blockchain but we wish to enable smart contracts to accept any token payment not just the native token or wrapped native token for wider acceptance & ease of use.

Approvals Manager:

The current ERC20 protocol allows third parties to transfer tokens only if they approve them before the transaction, making things more difficult for onboarding new users to the platform as there would be two transactions.

ERC20 approvals consume approximately 50,000 GAS for every smart contract to use the token inside them, which can avoid using a single approval manager for all the ERC20 tickets that could control all the payments.

We should acknowledge that the ERC20 approvals are one of the biggest gas guzzlers, and it takes up 1/3 of the total transaction on the ethereum network. So by removing the approval mechanism in play, we could allow room for other transactions to be allowed on the network.

Approval itself is not safe:

The ERC-20 allowance mechanism is susceptible to the multiple withdrawal attack/SWC-114 and encourages antipatterns such as using the "infinite" allowance. The wide prevalence of upgradeable contracts has made the conditions favourable for these attacks to happen in the wild.

We don't even know how much we've approved for which application. So we plan to streamline it through our application.

Approve Once, Use it Everywhere:

Our PoS (Proof Of Sale) smart contract is self-governed. Once the oracle & token contracts are set, it will automatically process payments using a payment pointer (added by the merchant to merchant oracle). Hence the settlement happens in real-time. The client application / smart contract doesn't need to worry about approving/handling approvals; they can process payment using TICKER & USD value.

Does it make a single point of failure easier?

The POS(Proof of Sale) smart contract has a locking mechanism that allows users to lock their accounts from transferring; they can set limits per transaction and other cool features that cannot be added using current ERC20 approvals.

Our repositories

  1. - our subgraphs for Proof Of Sale
  2. - our subgraphs for approvals manager.
  3. - smart contracts.
  4. - Client Code (Redux & React)

Our Subgraphs

Staging URL (Approvals manager on ETH mainnet & POS on ETH Kovan testnet) Approvals Manager - (Mainnet Ethereum) Paying Merchant - (KOVAN testnet) Merchant Dashboard - (KOVAN testnet)

All merchant routes will connect to Kovan Testnet & others will be on the mainnet. We will change this once we push our app live on the mainnet.

How it's Made

This project uses basic web3 wallets to allow users to interact with the system like metamask, wallet connect & coinbase wallet.

This app used three major cryptocurrencies as payment options for its users. They are COMP, UNI, wBTC & USDC.

Real-time price feeds powered by "Chainlink"

We used solidity alongside truffle for the smart contract development. Both Ethereum mainnet & Testnets are being used. The project also used the "The Graph" protocol for indexing & querying information.

Real-time price feeds are fetched from chainlink oracles. The frontend interaction to a blockchain is built using ethers & the client app is built using React & Redux.

background image mobile

Join the mailing list

Get the latest news and updates