Skip to content

Commit

Permalink
feat(TWABDelegator): add decimals function
Browse files Browse the repository at this point in the history
  • Loading branch information
PierrickGT committed Mar 14, 2022
1 parent 2b65097 commit 0df4f36
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions contracts/TWABDelegator.sol
Expand Up @@ -489,6 +489,15 @@ contract TWABDelegator is ERC20, LowLevelDelegator, PermitAndMulticall {
return _computeAddress(_delegator, _slot);
}

/**
* @notice Returns the ERC20 token decimals.
* @dev This value is equal to the decimals of the ticket being delegated.
* @return ERC20 token decimals
*/
function decimals() public view virtual override returns (uint8) {
return ERC20(address(ticket)).decimals();
}

/* ============ Internal Functions ============ */

/**
Expand Down
8 changes: 7 additions & 1 deletion test/TWABDelegator.test.ts
Expand Up @@ -63,7 +63,7 @@ describe('Test Set Name', () => {
ticket = await ticketContractFactory.deploy(
'PoolTogether aUSDC Ticket',
'PTaUSDC',
18,
6,
controller.address,
);

Expand Down Expand Up @@ -858,4 +858,10 @@ describe('Test Set Name', () => {
expect(wasCreated).to.equal(true);
});
});

describe('decimals()', () => {
it('should return ticket decimals', async () => {
expect(await twabDelegator.decimals()).to.eq(6);
});
});
});

0 comments on commit 0df4f36

Please sign in to comment.