1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

Merge pull request #234 from oceanprotocol/feature/typings

pool transaction typings
This commit is contained in:
Matthias Kretschmann 2020-08-28 18:25:43 +02:00 committed by GitHub
commit 5508aa5532
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 24 deletions

View File

@ -1,5 +1,6 @@
import Web3 from 'web3'
import { AbiItem } from 'web3-utils/types'
import { TransactionReceipt } from 'web3-core'
import { Pool } from './Pool'
/**
@ -170,7 +171,7 @@ export class OceanPool extends Pool {
* @param {String} amount Data Token amount
* @param {String} oceanAmount Ocean Token amount expected
* @param {String} maxPrice Minimum price to sell
* @return {any}
* @return {TransactionReceipt}
*/
public async sellDT(
account: string,
@ -178,7 +179,7 @@ export class OceanPool extends Pool {
amount: string,
oceanAmount: string,
minPrice: string
): Promise<any> {
): Promise<TransactionReceipt> {
if (this.oceanAddress == null) {
console.error('oceanAddress is not defined')
return null
@ -200,13 +201,13 @@ export class OceanPool extends Pool {
* @param {String} account
* @param {String} poolAddress
* @param {String} amount Data Token amount
* @return {any}
* @return {TransactionReceipt}
*/
public async addDTLiquidity(
account: string,
poolAddress: string,
amount: string
): Promise<any> {
): Promise<TransactionReceipt> {
await this.getDTAddress(account, poolAddress)
await super.approve(
account,
@ -229,14 +230,14 @@ export class OceanPool extends Pool {
* @param {String} account
* @param {String} poolAddress
* @param {String} amount Data Token amount
* @return {any}
* @return {TransactionReceipt}
*/
public async removeDTLiquidity(
account: string,
poolAddress: string,
amount: string,
maximumPoolShares: string
): Promise<any> {
): Promise<TransactionReceipt> {
await this.getDTAddress(account, poolAddress)
// TODO Check balance of PoolShares before doing exit
return this.exitswapExternAmountOut(
@ -253,13 +254,13 @@ export class OceanPool extends Pool {
* @param {String} account
* @param {String} poolAddress
* @param {String} amount Ocean Token amount in OCEAN
* @return {any}
* @return {TransactionReceipt}
*/
public async addOceanLiquidity(
account: string,
poolAddress: string,
amount: string
): Promise<any> {
): Promise<TransactionReceipt> {
if (this.oceanAddress == null) {
console.error('oceanAddress is not defined')
return null
@ -285,14 +286,14 @@ export class OceanPool extends Pool {
* @param {String} account
* @param {String} poolAddress
* @param {String} amount Ocean Token amount in OCEAN
* @return {any}
* @return {TransactionReceipt}
*/
public removeOceanLiquidity(
account: string,
poolAddress: string,
amount: string,
maximumPoolShares: string
): Promise<any> {
): Promise<TransactionReceipt> {
if (this.oceanAddress == null) {
console.error('oceanAddress is not defined')
return null

View File

@ -1,5 +1,6 @@
import Web3 from 'web3'
import { AbiItem } from 'web3-utils/types'
import { TransactionReceipt } from 'web3-core'
import Decimal from 'decimal.js'
import jsonpoolABI from '@oceanprotocol/contracts/artifacts/SPool.json'
import { PoolFactory } from './PoolFactory'
@ -539,7 +540,7 @@ export class Pool extends PoolFactory {
* @param {String} tokenOut
* @param {String} minAmountOut will be converted to wei
* @param {String} maxPrice will be converted to wei
* @return {any}
* @return {TransactionReceipt}
*/
async swapExactAmountIn(
account: string,
@ -549,7 +550,7 @@ export class Pool extends PoolFactory {
tokenOut: string,
minAmountOut: string,
maxPrice: string
): Promise<any> {
): Promise<TransactionReceipt> {
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
from: account
})
@ -579,7 +580,7 @@ export class Pool extends PoolFactory {
* @param {String} tokenOut
* @param {String} minAmountOut will be converted to wei
* @param {String} maxPrice will be converted to wei
* @return {any}
* @return {TransactionReceipt}
*/
async swapExactAmountOut(
account: string,
@ -589,7 +590,7 @@ export class Pool extends PoolFactory {
tokenOut: string,
minAmountOut: string,
maxPrice: string
): Promise<any> {
): Promise<TransactionReceipt> {
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
from: account
})
@ -687,7 +688,7 @@ export class Pool extends PoolFactory {
* @param {String} tokenIn
* @param {String} tokenAmountIn will be converted to wei
* @param {String} minPoolAmountOut will be converted to wei
* @return {any}
* @return {TransactionReceipt}
*/
async joinswapExternAmountIn(
account: string,
@ -695,7 +696,7 @@ export class Pool extends PoolFactory {
tokenIn: string,
tokenAmountIn: string,
minPoolAmountOut: string
): Promise<any> {
): Promise<TransactionReceipt> {
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
from: account
})
@ -721,7 +722,7 @@ export class Pool extends PoolFactory {
* @param {String} tokenIn
* @param {String} poolAmountOut will be converted to wei
* @param {String} maxAmountIn will be converted to wei
* @return {any}
* @return {TransactionReceipt}
*/
async joinswapPoolAmountOut(
account: string,
@ -729,7 +730,7 @@ export class Pool extends PoolFactory {
tokenIn: string,
poolAmountOut: string,
maxAmountIn: string
): Promise<any> {
): Promise<TransactionReceipt> {
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
from: account
})
@ -755,7 +756,7 @@ export class Pool extends PoolFactory {
* @param {String} tokenOut
* @param {String} poolAmountIn will be converted to wei
* @param {String} minTokenAmountOut will be converted to wei
* @return {any}
* @return {TransactionReceipt}
*/
async exitswapPoolAmountIn(
account: string,
@ -763,7 +764,7 @@ export class Pool extends PoolFactory {
tokenOut: string,
poolAmountIn: string,
minTokenAmountOut: string
): Promise<any> {
): Promise<TransactionReceipt> {
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
from: account
})
@ -789,7 +790,7 @@ export class Pool extends PoolFactory {
* @param {String} tokenOut
* @param {String} tokenAmountOut will be converted to wei
* @param {String} maxPoolAmountIn will be converted to wei
* @return {any}
* @return {TransactionReceipt}
*/
async exitswapExternAmountOut(
account: string,
@ -797,7 +798,7 @@ export class Pool extends PoolFactory {
tokenOut: string,
tokenAmountOut: string,
maxPoolAmountIn: string
): Promise<any> {
): Promise<TransactionReceipt> {
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
from: account
})
@ -822,14 +823,14 @@ export class Pool extends PoolFactory {
* @param {String} poolAddress
* @param {String} tokenIn
* @param {String} tokenOut
* @return {any}
* @return {String}
*/
async getSpotPrice(
account: string,
poolAddress: string,
tokenIn: string,
tokenOut: string
): Promise<any> {
): Promise<string> {
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
from: account
})