Skip to content

Commit 2af46c0

Browse files
authored
Add a getShare(token) view to TrueMultiFarm (#890)
1 parent 7251c19 commit 2af46c0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

contracts/truefi2/TrueMultiFarm.sol

+8
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@ contract TrueMultiFarm is ITrueMultiFarm, UpgradeableClaimable {
175175
}
176176
}
177177

178+
/*
179+
* What proportional share of rewards get distributed to this token?
180+
* The denominator is visible in the public `shares()` view.
181+
*/
182+
function getShare(IERC20 token) external view returns (uint256) {
183+
return shares.staked[address(token)];
184+
}
185+
178186
/**
179187
* @dev Set shares for farms
180188
* Example: setShares([DAI, USDC], [1, 2]) will ensure that 33.(3)% of rewards will go to DAI farm and rest to USDC farm

test/truefi2/TrueMultiFarm.test.ts

+5
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,11 @@ describe('TrueMultiFarm', () => {
321321
await farm.setShares([secondToken.address], [3], txArgs)
322322
})
323323

324+
it('getShare shows pool shares', async () => {
325+
expect(await farm.getShare(firstToken.address)).to.equal(1)
326+
expect(await farm.getShare(secondToken.address)).to.equal(3)
327+
})
328+
324329
describe('one staker', () => {
325330
beforeEach(async () => {
326331
await timeTravelTo(provider, start)

0 commit comments

Comments
 (0)