diff --git a/src/providers/BSCDeFi.js b/src/providers/BSCDeFi.js index 3f3ad74..dc7460f 100644 --- a/src/providers/BSCDeFi.js +++ b/src/providers/BSCDeFi.js @@ -37,7 +37,8 @@ class BSCDeFi extends AbstractExplorer { pancakeSwap: new PancakeSwapChef(web3), ramen: new PancakeSwapCloneChef(web3, '0x97dd424b4628c8d3bd7fcf3a4e974cebba011651', 'pendingCake', 'RAMEN'), saltSwap: new PancakeSwapCloneChef(web3, '0xB4405445fFAcF2B86BC2bD7D1C874AC739265658', 'pendingSalt', 'SALT'), - slime: new PancakeSwapCloneChef(web3, '0x4B0073A79f2b46Ff5a62fA1458AAc86Ed918C80C', 'pendingReward', 'SLIME') + slime: new PancakeSwapCloneChef(web3, '0x4B0073A79f2b46Ff5a62fA1458AAc86Ed918C80C', 'pendingReward', 'SLIME', 'slimesPerBlock'), + valueDefi: new PancakeSwapCloneChef(web3, '0xd56339F80586c08B7a4E3a68678d16D37237Bd96', 'pendingReward', 'vBSWAP', 'getCurrentRewardPerBlock') } } diff --git a/src/providers/bsc/MasterChef.js b/src/providers/bsc/MasterChef.js index 9688e74..92e5caa 100644 --- a/src/providers/bsc/MasterChef.js +++ b/src/providers/bsc/MasterChef.js @@ -96,24 +96,29 @@ class MasterChef { return await this.contract.methods.poolLength().call() } - async listStakedPools (walletAddress, tx) { - const poolLength = await this.getPoolLength() - this.totalAllocPoint = await this.contract.methods.totalAllocPoint().call() - + async getRewardPerBlock () { try { - this.rewardPerBlock = await this.contract.methods[this.pendingSymbol.toLowerCase() + 'PerBlock']().call() + return await this.contract.methods[this.pendingSymbol.toLowerCase() + 'PerBlock']().call() } catch (e) { try { - this.rewardPerBlock = await this.contract.methods[this.pendingSymbol + 'PerBlock']().call() + return await this.contract.methods[this.pendingSymbol + 'PerBlock']().call() } catch (e) { try { const ABISymbol = this.pendingMethodName.replace('pending', '').toLowerCase() - this.rewardPerBlock = await this.contract.methods[ABISymbol + 'PerBlock']().call() + return await this.contract.methods[ABISymbol + 'PerBlock']().call() } catch (e) { - this.rewardPerBlock = 0 + console.warn('Pending reward method not found. rewardPerYear is not correctly calculated.', this.address) + return 0 } } } + } + + async listStakedPools (walletAddress, tx) { + const poolLength = await this.getPoolLength() + this.totalAllocPoint = await this.contract.methods.totalAllocPoint().call() + + this.rewardPerBlock = await this.getRewardPerBlock() let pools = [] for (let poolID = 1; poolID < poolLength; poolID++) { diff --git a/src/providers/bsc/PancakeSwapCloneChef.js b/src/providers/bsc/PancakeSwapCloneChef.js index 69ac027..b86274a 100644 --- a/src/providers/bsc/PancakeSwapCloneChef.js +++ b/src/providers/bsc/PancakeSwapCloneChef.js @@ -4,13 +4,22 @@ const MasterChef = require('./MasterChef') const pancakeSwapABI = require('../resources/abis/pancakeSwap.json') class PancakeSwapCloneChef extends MasterChef { - constructor (web3, address, pendingMethodName, tokenSymbol) { + constructor (web3, address, pendingMethodName, tokenSymbol, rewardPerBlockName = '') { const ABISymbol = pendingMethodName.replace('pending', '').toLowerCase() - + rewardPerBlockName = rewardPerBlockName !== '' ? rewardPerBlockName : ABISymbol + 'PerBlock' const newChefABI = pancakeSwapABI .map(replaceABIMap('pendingCake', pendingMethodName)) - .map(replaceABIMap('cakePerBlock', ABISymbol + 'PerBlock')) + .map(replaceABIMap('cakePerBlock', rewardPerBlockName)) super(web3, newChefABI, address, pendingMethodName, tokenSymbol) + this.rewardPerBlockName = rewardPerBlockName + } + + async getRewardPerBlock () { + try { + return await this.contract.methods[this.rewardPerBlockName]().call() + } catch (e) { + return await MasterChef.prototype.getRewardPerBlock.call(this) + } } }