# Reference
If you have questions about calling Open API, this document provides full request body params and response body.
# OpenOcean API Document (opens new window)
# Files and modules needed for API users
Here are some modules you need to import in addition to the open API:
npm install bignumber.js
npm install web3
The web3.js library is a collection of modules that contain functionality for the Ethereum ecosystem. Meanwhile, bignumber is the module used to operate the multiple-precision floating-point number, which is used in all smart contract's number running.
# web3.js (opens new window)
# bignumber.js (opens new window)
- Table of chainId you need for directing your wallet plugin to the blockchain you select.
Chain_Name | Chain_ID | main-pair |
---|---|---|
Ethereum Mainnet | 1 | eth-usdt |
Binance Smart Chain | 56 | bnb-busd |
Solana Mainnet | -- | eth-usdt |
Polygon Mainnet | 137 | matic-usdt |
Avalanche | 43114 | avax-usdt.e |
Fantom | 250 | ftm-usdc |
Arbitrum | 42161 | uni-usdc |
Terra Mainnet | columbus-5 | luna-ust |
Gnosis Mainnet | 100 | xdai-usdt |
Boba Mainnet | 288 | weth-usdt |
Ontology Mainnet | -- | wing-ontd |
Tron Mainnet | -- | trx-usdt |
Heco Mainnet | 128 | ht-usdc |
OEC Mainnet | 66 | okt-usdt |
Optimism | 10 | uni-usdc |
Moonriver | 1285 | eth-usdt |
- Erc20 Abi: Contains the abi you need to approve your token.
[{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [{
"name": "",
"type": "string"
}],
"payable": false,
"stateMutability": "view",
"type": "function"
}, {
"constant": false,
"inputs": [{
"name": "_spender",
"type": "address"
}, {
"name": "_value",
"type": "uint256"
}],
"name": "approve",
"outputs": [{
"name": "",
"type": "bool"
}],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}, {
"constant": true,
"inputs": [],
"name": "totalSupply",
"outputs": [{
"name": "",
"type": "uint256"
}],
"payable": false,
"stateMutability": "view",
"type": "function"
}, {
"constant": false,
"inputs": [{
"name": "_from",
"type": "address"
}, {
"name": "_to",
"type": "address"
}, {
"name": "_value",
"type": "uint256"
}],
"name": "transferFrom",
"outputs": [{
"name": "",
"type": "bool"
}],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}, {
"constant": true,
"inputs": [],
"name": "decimals",
"outputs": [{
"name": "",
"type": "uint8"
}],
"payable": false,
"stateMutability": "view",
"type": "function"
}, {
"constant": true,
"inputs": [{
"name": "_owner",
"type": "address"
}],
"name": "balanceOf",
"outputs": [{
"name": "balance",
"type": "uint256"
}],
"payable": false,
"stateMutability": "view",
"type": "function"
}, {
"constant": true,
"inputs": [],
"name": "symbol",
"outputs": [{
"name": "",
"type": "string"
}],
"payable": false,
"stateMutability": "view",
"type": "function"
}, {
"constant": false,
"inputs": [{
"name": "_to",
"type": "address"
}, {
"name": "_value",
"type": "uint256"
}],
"name": "transfer",
"outputs": [{
"name": "",
"type": "bool"
}],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}, {
"constant": true,
"inputs": [{
"name": "_owner",
"type": "address"
}, {
"name": "_spender",
"type": "address"
}],
"name": "allowance",
"outputs": [{
"name": "",
"type": "uint256"
}],
"payable": false,
"stateMutability": "view",
"type": "function"
}, {
"payable": true,
"stateMutability": "payable",
"type": "fallback"
}, {
"anonymous": false,
"inputs": [{
"indexed": true,
"name": "owner",
"type": "address"
}, {
"indexed": true,
"name": "spender",
"type": "address"
}, {
"indexed": false,
"name": "value",
"type": "uint256"
}],
"name": "Approval",
"type": "event"
}, {
"anonymous": false,
"inputs": [{
"indexed": true,
"name": "from",
"type": "address"
}, {
"indexed": true,
"name": "to",
"type": "address"
}, {
"indexed": false,
"name": "value",
"type": "uint256"
}],
"name": "Transfer",
"type": "event"
}];
# Glossary
Below we explain several terms that will help you start programming.
# API
An application programming interface (API) is a set of protocols and codes that determine how different software platforms communicate and share information. APIs define different types of requests and calls that can be made, the data types that can be used, and how to make these requests. It serves as an intermediary between different software systems. A developer can use an API to incorporate features of an external application into their own software. By allowing different platforms to communicate, APIs enhance interoperability across the web.
# SDK
A software development kit (SDK) is a collection of software development tools in one installable package.They ease creation of applications by having compiler, debugger and perhaps a software framework.They are normally specific to a hardware platform and operating system combination.
# Wallet
In the Crypto Defi world, wallets are software that can be used to view cryptocurrency balances and make transactions. Each wallet type is a little bit different, but in general, any given wallet will work with one or more cryptocurrencies and will be able to store one or more cryptocurrency-specific “public addresses. Cryptocurrency itself is not actually “stored” in a wallet, it is stored on a coin’s blockchain. Your wallet is simply software designed to interact with the blockchain. That is the magic part of Defi application, you can finish you trade business on the customer side!
# Contract
Smart contracts are simply programs stored on a blockchain that run when predetermined conditions are met. They typically are used to automate the execution of an agreement so that all participants can be immediately certain of the outcome, without any intermediary's involvement or time loss.
# OOP
As a developer, you should know the Defi project programing is a good case for Object Oriented Programming (OOP). OOP is a popular programming paradigm based on the concept of "Object", which can contain data and code: data in the form of fields (often known as attributes or properties), and code, in the form of procedures (often known as methods). In Defi programming, you have the two most important "Objects" to work with, wallet object and contract object. They are the tools you need to interact with blockchain, and these two objects have all the medhods you need for your transaction.
# Arbitrage
To arbitrage is to get benefit from the price difference of an asset or security between two markets for profit. We can make an example in the crypto case, some token is selling in market A in $3 but selling in market B with $5. So there is $2 per token's profit if someone sold the tokens he/she get from market A to market B. Arbitrage is a necessary financial mechanism that keeps prices consistent between different exchanges and wider markets.
# GasPrice
Gas refers to the fee, or pricing value, required to successfully conduct a transaction or execute a contract on the Ethereum blockchain platform. Priced in small fractions of the cryptocurrency ether (ETH), commonly referred to as gwei and sometimes also called nanoeth, the gas is used to allocate resources of the Ethereum virtual machine (EVM) so that decentralized applications such as smart contracts can self-execute in a secured but decentralized fashion.
# Slippage
Slippage happens when traders have to settle for a different price than what they initially requested due to a movement in price between the time the order (say for Bitcoin) enters the market and the execution of a trade. This phenomenon can occur in all markets, like forex and stocks. However, it is more frequent, and a lot worse, in crypto markets (especially on decentralized exchanges like Uniswap) due to the high levels of price volatility.