diff --git a/contracts/truefi2/TrueMultiFarm.sol b/contracts/truefi2/TrueMultiFarm.sol index 37d11ee52..1ed393b2e 100644 --- a/contracts/truefi2/TrueMultiFarm.sol +++ b/contracts/truefi2/TrueMultiFarm.sol @@ -175,6 +175,14 @@ contract TrueMultiFarm is ITrueMultiFarm, UpgradeableClaimable { } } + /* + * What proportional share of rewards get distributed to this token? + * The denominator is visible in the public `shares()` view. + */ + function getShare(IERC20 token) external view returns (uint256) { + return shares.staked[address(token)]; + } + /** * @dev Set shares for farms * Example: setShares([DAI, USDC], [1, 2]) will ensure that 33.(3)% of rewards will go to DAI farm and rest to USDC farm diff --git a/test/truefi2/TrueMultiFarm.test.ts b/test/truefi2/TrueMultiFarm.test.ts index 99a041a88..ad9840ab6 100644 --- a/test/truefi2/TrueMultiFarm.test.ts +++ b/test/truefi2/TrueMultiFarm.test.ts @@ -321,6 +321,11 @@ describe('TrueMultiFarm', () => { await farm.setShares([secondToken.address], [3], txArgs) }) + it('getShare shows pool shares', async () => { + expect(await farm.getShare(firstToken.address)).to.equal(1) + expect(await farm.getShare(secondToken.address)).to.equal(3) + }) + describe('one staker', () => { beforeEach(async () => { await timeTravelTo(provider, start)