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

general renaming in SideStaking

This commit is contained in:
Miquel A. Cabot 2022-06-14 11:12:06 +02:00
parent eb41dfc7ef
commit efc4b8b521
2 changed files with 73 additions and 73 deletions

View File

@ -20,15 +20,15 @@ export class SideStaking extends SmartContract {
datatokenAddress: string datatokenAddress: string
): Promise<string> { ): Promise<string> {
const sideStaking = this.getContract(ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let supply = null
try { try {
result = await sideStaking.methods supply = await sideStaking.methods
.getDatatokenCirculatingSupply(datatokenAddress) .getDatatokenCirculatingSupply(datatokenAddress)
.call() .call()
} catch (e) { } catch (e) {
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
} }
return result.toString() return supply.toString()
} }
/** /**
@ -44,11 +44,11 @@ export class SideStaking extends SmartContract {
): Promise<string> { ): Promise<string> {
try { try {
const sideStaking = this.getContract(ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let supply = null
result = await sideStaking.methods supply = await sideStaking.methods
.getDatatokenCurrentCirculatingSupply(datatokenAddress) .getDatatokenCurrentCirculatingSupply(datatokenAddress)
.call() .call()
return result.toString() return supply.toString()
} catch (e) { } catch (e) {
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
} }
@ -65,13 +65,13 @@ export class SideStaking extends SmartContract {
datatokenAddress: string datatokenAddress: string
): Promise<string> { ): Promise<string> {
const sideStaking = this.getContract(ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let address = null
try { try {
result = await sideStaking.methods.getPublisherAddress(datatokenAddress).call() address = await sideStaking.methods.getPublisherAddress(datatokenAddress).call()
} catch (e) { } catch (e) {
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
} }
return result return address
} }
/** /**
@ -80,15 +80,15 @@ export class SideStaking extends SmartContract {
* @param {String} datatokenAddress datatokenAddress * @param {String} datatokenAddress datatokenAddress
* @return {String} * @return {String}
*/ */
async getBaseToken(ssAddress: string, datatokenAddress: string): Promise<string> { async getBasetoken(ssAddress: string, datatokenAddress: string): Promise<string> {
const sideStaking = this.getContract(ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let address = null
try { try {
result = await sideStaking.methods.getBaseTokenAddress(datatokenAddress).call() address = await sideStaking.methods.getBaseTokenAddress(datatokenAddress).call()
} catch (e) { } catch (e) {
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
} }
return result return address
} }
/** /**
@ -99,13 +99,13 @@ export class SideStaking extends SmartContract {
*/ */
async getPoolAddress(ssAddress: string, datatokenAddress: string): Promise<string> { async getPoolAddress(ssAddress: string, datatokenAddress: string): Promise<string> {
const sideStaking = this.getContract(ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let address = null
try { try {
result = await sideStaking.methods.getPoolAddress(datatokenAddress).call() address = await sideStaking.methods.getPoolAddress(datatokenAddress).call()
} catch (e) { } catch (e) {
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
} }
return result return address
} }
/** /**
@ -114,18 +114,18 @@ export class SideStaking extends SmartContract {
* @param {String} datatokenAddress datatokenAddress * @param {String} datatokenAddress datatokenAddress
* @return {String} * @return {String}
*/ */
async getBaseTokenBalance( async getBasetokenBalance(
ssAddress: string, ssAddress: string,
datatokenAddress: string datatokenAddress: string
): Promise<string> { ): Promise<string> {
const sideStaking = this.getContract(ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let balance = null
try { try {
result = await sideStaking.methods.getBaseTokenBalance(datatokenAddress).call() balance = await sideStaking.methods.getBaseTokenBalance(datatokenAddress).call()
} catch (e) { } catch (e) {
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
} }
return result return balance
} }
/** /**
@ -141,14 +141,14 @@ export class SideStaking extends SmartContract {
tokenDecimals?: number tokenDecimals?: number
): Promise<string> { ): Promise<string> {
const sideStaking = this.getContract(ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let balance = null
try { try {
result = await sideStaking.methods.getDatatokenBalance(datatokenAddress).call() balance = await sideStaking.methods.getDatatokenBalance(datatokenAddress).call()
} catch (e) { } catch (e) {
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
} }
result = await this.unitsToAmount(datatokenAddress, result, tokenDecimals) balance = await this.unitsToAmount(datatokenAddress, balance, tokenDecimals)
return result return balance
} }
/** /**
@ -157,15 +157,15 @@ export class SideStaking extends SmartContract {
* @param {String} datatokenAddress datatokenAddress * @param {String} datatokenAddress datatokenAddress
* @return {String} end block for vesting amount * @return {String} end block for vesting amount
*/ */
async getvestingEndBlock(ssAddress: string, datatokenAddress: string): Promise<string> { async getVestingEndBlock(ssAddress: string, datatokenAddress: string): Promise<string> {
const sideStaking = this.getContract(ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let block = null
try { try {
result = await sideStaking.methods.getvestingEndBlock(datatokenAddress).call() block = await sideStaking.methods.getvestingEndBlock(datatokenAddress).call()
} catch (e) { } catch (e) {
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
} }
return result return block
} }
/** /**
@ -175,20 +175,20 @@ export class SideStaking extends SmartContract {
* @param {number} tokenDecimals optional number of decimals of the token * @param {number} tokenDecimals optional number of decimals of the token
* @return {String} * @return {String}
*/ */
async getvestingAmount( async getVestingAmount(
ssAddress: string, ssAddress: string,
datatokenAddress: string, datatokenAddress: string,
tokenDecimals?: number tokenDecimals?: number
): Promise<string> { ): Promise<string> {
const sideStaking = this.getContract(ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let amount = null
try { try {
result = await sideStaking.methods.getvestingAmount(datatokenAddress).call() amount = await sideStaking.methods.getvestingAmount(datatokenAddress).call()
} catch (e) { } catch (e) {
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
} }
result = await this.unitsToAmount(datatokenAddress, result, tokenDecimals) amount = await this.unitsToAmount(datatokenAddress, amount, tokenDecimals)
return result return amount
} }
/** /**
@ -197,18 +197,18 @@ export class SideStaking extends SmartContract {
* @param {String} datatokenAddress datatokenAddress * @param {String} datatokenAddress datatokenAddress
* @return {String} * @return {String}
*/ */
async getvestingLastBlock( async getVestingLastBlock(
ssAddress: string, ssAddress: string,
datatokenAddress: string datatokenAddress: string
): Promise<string> { ): Promise<string> {
const sideStaking = this.getContract(ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let block = null
try { try {
result = await sideStaking.methods.getvestingLastBlock(datatokenAddress).call() block = await sideStaking.methods.getvestingLastBlock(datatokenAddress).call()
} catch (e) { } catch (e) {
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
} }
return result return block
} }
/** /**
@ -218,20 +218,20 @@ export class SideStaking extends SmartContract {
* @param {number} tokenDecimals optional number of decimals of the token * @param {number} tokenDecimals optional number of decimals of the token
* @return {String} * @return {String}
*/ */
async getvestingAmountSoFar( async getVestingAmountSoFar(
ssAddress: string, ssAddress: string,
datatokenAddress: string, datatokenAddress: string,
tokenDecimals?: number tokenDecimals?: number
): Promise<string> { ): Promise<string> {
const sideStaking = this.getContract(ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let amount = null
try { try {
result = await sideStaking.methods.getvestingAmountSoFar(datatokenAddress).call() amount = await sideStaking.methods.getvestingAmountSoFar(datatokenAddress).call()
} catch (e) { } catch (e) {
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
} }
result = await this.unitsToAmount(datatokenAddress, result, tokenDecimals) amount = await this.unitsToAmount(datatokenAddress, amount, tokenDecimals)
return result return amount
} }
/** Send vested tokens available to the publisher address, can be called by anyone /** Send vested tokens available to the publisher address, can be called by anyone
@ -248,7 +248,7 @@ export class SideStaking extends SmartContract {
estimateGas?: G estimateGas?: G
): Promise<G extends false ? TransactionReceipt : number> { ): Promise<G extends false ? TransactionReceipt : number> {
const sideStaking = this.getContract(ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let vesting = null
const estGas = await calculateEstimatedGas( const estGas = await calculateEstimatedGas(
account, account,
@ -258,7 +258,7 @@ export class SideStaking extends SmartContract {
if (estimateGas) return estGas if (estimateGas) return estGas
try { try {
result = await sideStaking.methods.getVesting(datatokenAddress).send({ vesting = await sideStaking.methods.getVesting(datatokenAddress).send({
from: account, from: account,
gas: estGas + 1, gas: estGas + 1,
gasPrice: await this.getFairGasPrice() gasPrice: await this.getFairGasPrice()
@ -266,7 +266,7 @@ export class SideStaking extends SmartContract {
} catch (e) { } catch (e) {
LoggerInstance.error('ERROR: Failed to join swap pool amount out') LoggerInstance.error('ERROR: Failed to join swap pool amount out')
} }
return result return vesting
} }
/** Send vested tokens available to the publisher address, can be called by anyone /** Send vested tokens available to the publisher address, can be called by anyone
@ -285,7 +285,7 @@ export class SideStaking extends SmartContract {
estimateGas?: G estimateGas?: G
): Promise<G extends false ? TransactionReceipt : number> { ): Promise<G extends false ? TransactionReceipt : number> {
const sideStaking = this.getContract(ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let fee = null
const estGas = await calculateEstimatedGas( const estGas = await calculateEstimatedGas(
account, account,
@ -297,7 +297,7 @@ export class SideStaking extends SmartContract {
if (estimateGas) return estGas if (estimateGas) return estGas
try { try {
result = await sideStaking.methods fee = await sideStaking.methods
.setPoolSwapFee(datatokenAddress, poolAddress, swapFee) .setPoolSwapFee(datatokenAddress, poolAddress, swapFee)
.send({ .send({
from: account, from: account,
@ -307,7 +307,7 @@ export class SideStaking extends SmartContract {
} catch (e) { } catch (e) {
LoggerInstance.error('ERROR: Failed to join swap pool amount out') LoggerInstance.error('ERROR: Failed to join swap pool amount out')
} }
return result return fee
} }
/** /**
@ -317,12 +317,12 @@ export class SideStaking extends SmartContract {
*/ */
public async getRouter(ssAddress: string): Promise<string> { public async getRouter(ssAddress: string): Promise<string> {
const sideStaking = this.getContract(ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let router = null
try { try {
result = await sideStaking.methods.router().call() router = await sideStaking.methods.router().call()
} catch (e) { } catch (e) {
LoggerInstance.error(`ERROR: Failed to get Router address: ${e.message}`) LoggerInstance.error(`ERROR: Failed to get Router address: ${e.message}`)
} }
return result return router
} }
} }

View File

@ -193,9 +193,9 @@ describe('SideStaking unit test', () => {
).to.equal(web3.utils.toWei(BASE_TOKEN_LIQUIDITY.toString())) ).to.equal(web3.utils.toWei(BASE_TOKEN_LIQUIDITY.toString()))
}) })
it('#getBaseToken - should get baseToken address', async () => { it('#getBasetoken - should get baseToken address', async () => {
expect( expect(
await sideStaking.getBaseToken(contracts.sideStakingAddress, datatoken) await sideStaking.getBasetoken(contracts.sideStakingAddress, datatoken)
).to.equal(contracts.daiAddress) ).to.equal(contracts.daiAddress)
}) })
@ -211,9 +211,9 @@ describe('SideStaking unit test', () => {
).to.equal(factoryOwner) ).to.equal(factoryOwner)
}) })
it('#getBaseTokenBalance ', async () => { it('#getBasetokenBalance ', async () => {
expect( expect(
await sideStaking.getBaseTokenBalance(contracts.sideStakingAddress, datatoken) await sideStaking.getBasetokenBalance(contracts.sideStakingAddress, datatoken)
).to.equal('0') ).to.equal('0')
}) })
@ -232,21 +232,21 @@ describe('SideStaking unit test', () => {
) )
}) })
it('#getvestingAmount ', async () => { it('#getVestingAmount ', async () => {
expect( expect(
await sideStaking.getvestingAmount(contracts.sideStakingAddress, datatoken) await sideStaking.getVestingAmount(contracts.sideStakingAddress, datatoken)
).to.equal('0') ).to.equal('0')
}) })
it('#getvestingLastBlock ', async () => { it('#getVestingLastBlock ', async () => {
expect( expect(
await sideStaking.getvestingLastBlock(contracts.sideStakingAddress, datatoken) await sideStaking.getVestingLastBlock(contracts.sideStakingAddress, datatoken)
).to.equal(initialBlock.toString()) ).to.equal(initialBlock.toString())
}) })
it('#getvestingAmountSoFar ', async () => { it('#getVestingAmountSoFar ', async () => {
expect( expect(
await sideStaking.getvestingAmountSoFar(contracts.sideStakingAddress, datatoken) await sideStaking.getVestingAmountSoFar(contracts.sideStakingAddress, datatoken)
).to.equal('0') ).to.equal('0')
}) })
@ -325,11 +325,11 @@ describe('SideStaking unit test', () => {
) )
}) })
it('#exitswapPoolAmountIn- user1 exit the pool receiving only DAI', async () => { it('#exitSwapPoolAmountIn- user1 exit the pool receiving only DAI', async () => {
const BPTAmountIn = '0.5' const BPTAmountIn = '0.5'
const minDAIOut = '0.5' const minDAIOut = '0.5'
const tx = await pool.exitswapPoolAmountIn( const tx = await pool.exitSwapPoolAmountIn(
user1, user1,
poolAddress, poolAddress,
BPTAmountIn, BPTAmountIn,
@ -391,9 +391,9 @@ describe('SideStaking unit test', () => {
expect(await datatokenContract.methods.balanceOf(user1).call()).to.equal('0') expect(await datatokenContract.methods.balanceOf(user1).call()).to.equal('0')
}) })
it('#getBaseTokenBalance ', async () => { it('#getBasetokenBalance ', async () => {
expect( expect(
await sideStaking.getBaseTokenBalance(contracts.sideStakingAddress, datatoken) await sideStaking.getBasetokenBalance(contracts.sideStakingAddress, datatoken)
).to.equal('0') ).to.equal('0')
}) })
@ -412,21 +412,21 @@ describe('SideStaking unit test', () => {
) )
}) })
it('#getvestingAmount ', async () => { it('#getVestingAmount ', async () => {
expect( expect(
await sideStaking.getvestingAmount(contracts.sideStakingAddress, datatoken) await sideStaking.getVestingAmount(contracts.sideStakingAddress, datatoken)
).to.equal('0') ).to.equal('0')
}) })
it('#getvestingLastBlock ', async () => { it('#getVestingLastBlock ', async () => {
expect( expect(
await sideStaking.getvestingLastBlock(contracts.sideStakingAddress, datatoken) await sideStaking.getVestingLastBlock(contracts.sideStakingAddress, datatoken)
).to.equal(initialBlock.toString()) ).to.equal(initialBlock.toString())
}) })
it('#getvestingAmountSoFar ', async () => { it('#getVestingAmountSoFar ', async () => {
expect( expect(
await sideStaking.getvestingAmountSoFar(contracts.sideStakingAddress, datatoken) await sideStaking.getVestingAmountSoFar(contracts.sideStakingAddress, datatoken)
).to.equal('0') ).to.equal('0')
}) })
@ -501,11 +501,11 @@ describe('SideStaking unit test', () => {
) )
}) })
it('#exitswapPoolAmountIn- user1 exit the pool receiving only USDC', async () => { it('#exitSwapPoolAmountIn- user1 exit the pool receiving only USDC', async () => {
const BPTAmountIn = '0.5' const BPTAmountIn = '0.5'
const minUSDCOut = '0.5' const minUSDCOut = '0.5'
const tx = await pool.exitswapPoolAmountIn( const tx = await pool.exitSwapPoolAmountIn(
user1, user1,
poolAddress, poolAddress,
BPTAmountIn, BPTAmountIn,