mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
add supprot for allow swapFee change on sideStaking contract
This commit is contained in:
parent
112a552b90
commit
9d2c0d86ed
@ -1202,6 +1202,17 @@ export class Datatoken {
|
|||||||
return nftAddress
|
return nftAddress
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns true if address has deployERC20 role
|
||||||
|
* @param {String} dtAddress Datatoken adress
|
||||||
|
* @param {String} dtAddress Datatoken adress
|
||||||
|
* @return {Promise<number>}
|
||||||
|
*/
|
||||||
|
public async isERC20Deployer(dtAddress: string, adddress: string): Promise<string> {
|
||||||
|
const dtContract = new this.web3.eth.Contract(this.datatokensABI, dtAddress)
|
||||||
|
const isERC20Deployer = await dtContract.methods.isERC20Deployer(adddress).call()
|
||||||
|
return isERC20Deployer
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Address Balance for datatoken
|
* Get Address Balance for datatoken
|
||||||
* @param {String} dtAddress Datatoken adress
|
* @param {String} dtAddress Datatoken adress
|
||||||
|
@ -337,6 +337,76 @@ export class SideStaking {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Estimate gas cost for getVesting
|
||||||
|
* @param {String} account
|
||||||
|
* @param {String} ssAddress side staking contract address
|
||||||
|
* @param {String} datatokenAddress datatokenAddress
|
||||||
|
* @param {Contract} contractInstance optional contract instance
|
||||||
|
* @return {Promise<number>}
|
||||||
|
*/
|
||||||
|
public async estSetPoolSwapFee(
|
||||||
|
account: string,
|
||||||
|
ssAddress: string,
|
||||||
|
datatokenAddress: string,
|
||||||
|
poolAddress: string,
|
||||||
|
swapFee: number,
|
||||||
|
contractInstance?: Contract
|
||||||
|
): Promise<number> {
|
||||||
|
const sideStaking =
|
||||||
|
contractInstance || new this.web3.eth.Contract(this.ssABI as AbiItem[], ssAddress)
|
||||||
|
|
||||||
|
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
||||||
|
let estGas
|
||||||
|
try {
|
||||||
|
estGas = await sideStaking.methods
|
||||||
|
.setPoolSwapFee(datatokenAddress, poolAddress, swapFee)
|
||||||
|
.estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
||||||
|
} catch (e) {
|
||||||
|
estGas = gasLimitDefault
|
||||||
|
}
|
||||||
|
return estGas
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Send vested tokens available to the publisher address, can be called by anyone
|
||||||
|
*
|
||||||
|
* @param {String} account
|
||||||
|
* @param {String} ssAddress side staking contract address
|
||||||
|
* @param {String} datatokenAddress datatokenAddress
|
||||||
|
* @return {TransactionReceipt}
|
||||||
|
*/
|
||||||
|
async setPoolSwapFee(
|
||||||
|
account: string,
|
||||||
|
ssAddress: string,
|
||||||
|
datatokenAddress: string,
|
||||||
|
poolAddress: string,
|
||||||
|
swapFee: number
|
||||||
|
): Promise<TransactionReceipt> {
|
||||||
|
const sideStaking = new this.web3.eth.Contract(this.ssABI, ssAddress)
|
||||||
|
let result = null
|
||||||
|
|
||||||
|
const estGas = await this.estSetPoolSwapFee(
|
||||||
|
account,
|
||||||
|
ssAddress,
|
||||||
|
datatokenAddress,
|
||||||
|
poolAddress,
|
||||||
|
swapFee,
|
||||||
|
sideStaking
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
result = await sideStaking.methods
|
||||||
|
.setPoolSwapFee(datatokenAddress, poolAddress, swapFee)
|
||||||
|
.send({
|
||||||
|
from: account,
|
||||||
|
gas: estGas + 1,
|
||||||
|
gasPrice: await getFairGasPrice(this.web3)
|
||||||
|
})
|
||||||
|
} catch (e) {
|
||||||
|
LoggerInstance.error('ERROR: Failed to join swap pool amount out')
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Router address set in side staking contract
|
* Get Router address set in side staking contract
|
||||||
* @param {String} ssAddress side staking contract address
|
* @param {String} ssAddress side staking contract address
|
||||||
|
Loading…
x
Reference in New Issue
Block a user