project screenshot 1
project screenshot 2
project screenshot 3
project screenshot 4
project screenshot 5

GHO-payment-SDK

šŸ›  An SDK for building applications on tops of GHO as payment input.

GHO-payment-SDK

Created At

LFGHO

Project Description

Github: https://github.com/zhxinyu/gho-payment-sdk

The package GHO-payment-sdk mainly aims to provide GHO token users and holders to make payments activity more easily. GHO is a decentralized multi-collateral stablecoin that is fully backed, transparent and native to the Aave Protocol. Typical payment activity involves transfer and trade. Users can simply call our exported helper functions to perform various transactions using GHO tokens. In particular, the package includes utility functions to transfer, approve, permit, transferFrom and trade.

Here some simple snippets to use:

  • getAllowanceGHO(from: string, to: string, provider)
  • approveGHO(signer, amount: string, to: string)
  • permitGHO(signer, amount: string, spender: string)
  • transferGHO(to: string, amount: string, tokenOwner)
  • transferFromGHO(from: string, to: string, amount: string, allowanceOwner: ethers.Signer)
  • getOutputQuote(tokenA: Token, amountIn: string, provider)
  • executeTrade(tradeAccount, signer)

Further usage can see notebook

How it's Made

The project leverages ethers library to export easy-to-use helper function for GHO tokens payment. All the source codes are located in the src directory.

In particular, the tree structure of the project is

ā”œā”€ā”€ src
ā”‚  ā”œā”€ā”€ constants
ā”‚  ā”‚  ā”œā”€ā”€ abi.ts
ā”‚  ā”‚  ā”œā”€ā”€ abi_json.ts
ā”‚  ā”‚  ā”œā”€ā”€ address.ts
ā”‚  ā”‚  ā””ā”€ā”€ index.ts
ā”‚  ā”œā”€ā”€ entities
ā”‚  ā”‚  ā”œā”€ā”€ index.ts
ā”‚  ā”‚  ā””ā”€ā”€ tokens.ts
ā”‚  ā”œā”€ā”€ index.ts
ā”‚  ā”œā”€ā”€ trade
ā”‚  ā”‚  ā”œā”€ā”€ dex
ā”‚  ā”‚  ā”‚  ā””ā”€ā”€ uniswap
ā”‚  ā”‚  ā”‚      ā”œā”€ā”€ contract-address.ts
ā”‚  ā”‚  ā”‚      ā”œā”€ā”€ index.ts
ā”‚  ā”‚  ā”‚      ā”œā”€ā”€ pool.ts
ā”‚  ā”‚  ā”‚      ā””ā”€ā”€ trade.ts
ā”‚  ā”‚  ā””ā”€ā”€ index.ts
ā”‚  ā”œā”€ā”€ transfer
ā”‚  ā”‚  ā”œā”€ā”€ index.ts
ā”‚  ā”‚  ā””ā”€ā”€ transfer.ts
ā”‚  ā””ā”€ā”€ utils
ā”‚      ā”œā”€ā”€ allowance.ts
ā”‚      ā”œā”€ā”€ assert.ts
ā”‚      ā”œā”€ā”€ conversion.ts
ā”‚      ā”œā”€ā”€ format.ts
ā”‚      ā”œā”€ā”€ index.ts
ā”‚      ā”œā”€ā”€ print.ts
ā”‚      ā””ā”€ā”€ providers.ts
ā”œā”€ā”€ tests
ā”‚  ā””ā”€ā”€ index.test.ts
  • Trade Export a trade (buy or sell) helper function for GHO token. At present, we support uniswap DEX.

  • Transfer Export transfer-related helper function for payments via GHO token. In particular, we include transferGHO, transferFromGHO, transfer, transferFrom.

  • Approval Add approve and permit function to increse allowance of GHO token.

  • Utilities Add Token entities to facilitate caching and retrieval of token information such as chainId, address, decimals, symbol, abi and contract instance. In particular,

    • getAllowanceGHO, getAllowance
    • approveGHO, approve
    • off-chain signature preparation: permitGHO
    • assert: throw an error if false statement.
    • print:
      • printBalance
    • providers:
      • getJsonRpcProvider,
      • getWallet,
      • sendTransaction,

In the end, we also add a demo via a jupyter notebook. pg2.html

background image mobile

Join the mailing list

Get the latest news and updates