diff --git a/src/datatokens/Datatoken.ts b/src/datatokens/Datatoken.ts index 6f9f8fb7..7182a96b 100644 --- a/src/datatokens/Datatoken.ts +++ b/src/datatokens/Datatoken.ts @@ -1202,6 +1202,17 @@ export class Datatoken { return nftAddress } + /** Returns true if address has deployERC20 role + * @param {String} dtAddress Datatoken adress + * @param {String} dtAddress Datatoken adress + * @return {Promise} + */ + public async isERC20Deployer(dtAddress: string, adddress: string): Promise { + 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 * @param {String} dtAddress Datatoken adress diff --git a/src/pools/ssContracts/SideStaking.ts b/src/pools/ssContracts/SideStaking.ts index c53b5740..7bca7abf 100644 --- a/src/pools/ssContracts/SideStaking.ts +++ b/src/pools/ssContracts/SideStaking.ts @@ -337,6 +337,76 @@ export class SideStaking { 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} + */ + public async estSetPoolSwapFee( + account: string, + ssAddress: string, + datatokenAddress: string, + poolAddress: string, + swapFee: number, + contractInstance?: Contract + ): Promise { + 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 { + 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 * @param {String} ssAddress side staking contract address