← Back to home

GHO-payment-SDK

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

Screenshots

GHO-payment-SDK screenshot 1
GHO-payment-SDK screenshot 2
GHO-payment-SDK screenshot 3
GHO-payment-SDK screenshot 4
GHO-payment-SDK screenshot 5

Problem Statement

Github: https://github.com/zhxinyu/gho-payment-sdkThe 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 seenotebook

Solution

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.tsTrade 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, getAllowanceapproveGHO, approveoff-chain signature preparation: permitGHOassert: throw an error if false statement.print:printBalanceproviders:getJsonRpcProvider,getWallet,sendTransaction,In the end, we also add a demo via a jupyter notebook. pg2.html

Hackathon

LFGHO

2024

Contributors