Skip to content

Commit

Permalink
Add a getShare(token) view to TrueMultiFarm (#890)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuchenlintt authored Aug 24, 2021
1 parent 7251c19 commit 2af46c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions contracts/truefi2/TrueMultiFarm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/truefi2/TrueMultiFarm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2af46c0

Please sign in to comment.