Skip to content

Commit

Permalink
Add decimals in mock token (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoncoding authored Sep 3, 2020
1 parent 9abbfc1 commit 4459ce7
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 23 deletions.
7 changes: 6 additions & 1 deletion contracts/mocks/MockERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ pragma solidity 0.6.10;
import {ERC20Initializable} from "../packages/oz/upgradeability/ERC20Initializable.sol";

contract MockERC20 is ERC20Initializable {
constructor(string memory _name, string memory _symbol) public {
constructor(
string memory _name,
string memory _symbol,
uint8 _decimals
) public {
__ERC20_init_unchained(_name, _symbol);
_setupDecimals(_decimals);
}

function mint(address account, uint256 amount) public {
Expand Down
4 changes: 2 additions & 2 deletions test/MarginAccount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ contract('MarginAccount', ([deployer, controller]) => {

before('Deployment', async () => {
// deploy WETH token
weth = await MockERC20.new('WETH', 'WETH')
weth = await MockERC20.new('WETH', 'WETH', 18)
// usdc
usdc = await MockERC20.new('USDC', 'USDC')
usdc = await MockERC20.new('USDC', 'USDC', 6)
// deploy AddressBook token
addressBook = await MockAddressBook.new()
await addressBook.setController(controller)
Expand Down
4 changes: 2 additions & 2 deletions test/Otoken.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract('Otoken', ([deployer, controller, user1, user2, random]) => {
// deploy oToken with addressbook
otoken = await Otoken.new()

usdc = await MockERC20.new('USDC', 'USDC')
usdc = await MockERC20.new('USDC', 'USDC', 6)
})

describe('Otoken Initialization', () => {
Expand Down Expand Up @@ -74,7 +74,7 @@ contract('Otoken', ([deployer, controller, user1, user2, random]) => {
})

it('should set the right name for non-eth options', async () => {
const weth = await MockERC20.new('WETH', 'WETH')
const weth = await MockERC20.new('WETH', 'WETH', 18)
const putOption = await Otoken.new(addressBookAddr)
await putOption.init(addressBookAddr, weth.address, usdc.address, usdc.address, strikePrice, expiry, isPut, {
from: deployer,
Expand Down
4 changes: 2 additions & 2 deletions test/OtokenFactory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ contract('OTokenFactory', ([user1, user2]) => {
const expiry = 1753776000 // 07/29/2025 @ 8:00am (UTC)

before('Deploy otoken logic and Factory contract', async () => {
usdc = await MockERC20.new('USDC', 'USDC')
shitcoin = await MockERC20.new('Shit coin', 'STC')
usdc = await MockERC20.new('USDC', 'USDC', 6)
shitcoin = await MockERC20.new('Shit coin', 'STC', 18)

const logic = await MockOtoken.new()

Expand Down
6 changes: 3 additions & 3 deletions test/Whitelist.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ contract('Whitelist', ([owner, otokenFactoryAddress, random, newOwner]) => {

before('Deployment', async () => {
// deploy USDC token
usdc = await MockERC20.new('USDC', 'USDC')
usdc = await MockERC20.new('USDC', 'USDC', 6)
// deploy DAI token
dai = await MockERC20.new('DAI', 'DAI')
dai = await MockERC20.new('DAI', 'DAI', 18)
// deploy option
otoken = await MockERC20.new('OETH', 'OETH')
otoken = await MockERC20.new('OETH', 'OETH', 18)

// deploy AddressBook mock
addressBook = await MockAddressBook.new()
Expand Down
2 changes: 1 addition & 1 deletion test/addressBook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ contract('AddressBook', ([owner, otokenImplAdd, marginPoolAdd, random]) => {

before('Deployment', async () => {
// deploy WETH token
weth = await MockERC20.new('WETH', 'WETH')
weth = await MockERC20.new('WETH', 'WETH', 18)
// deploy AddressBook token
addressBook = await AddressBook.new()
})
Expand Down
2 changes: 1 addition & 1 deletion test/chainlinkPricer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ contract('ChainlinkPricer', () => {
// deploy mock contracts
oracle = await MockOracle.new()
wethAggregator = await MockChainlinkAggregator.new()
weth = await MockERC20.new('WETH', 'WETH')
weth = await MockERC20.new('WETH', 'WETH', 18)
//
pricer = await ChainlinkPricer.new(weth.address, wethAggregator.address, oracle.address)
})
Expand Down
6 changes: 3 additions & 3 deletions test/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ contract('Controller', ([owner, accountOwner1, accountOperator1, random]) => {

before('Deployment', async () => {
// ERC20 deployment
usdc = await MockERC20.new('USDC', 'USDC')
weth = await MockERC20.new('WETH', 'WETH')
usdc = await MockERC20.new('USDC', 'USDC', 8)
weth = await MockERC20.new('WETH', 'WETH', 18)
// Otoken deployment
otoken = await MockOtoken.new()
// addressbook deployment
Expand Down Expand Up @@ -1174,7 +1174,7 @@ contract('Controller', ([owner, accountOwner1, accountOperator1, random]) => {
describe('Deposit un-whitelisted collateral asset', () => {
it('should revert depositing a collateral asset that is not whitelisted', async () => {
// deploy a shitcoin
const trx: MockERC20Instance = await MockERC20.new('TRX', 'TRX')
const trx: MockERC20Instance = await MockERC20.new('TRX', 'TRX', 18)
await trx.mint(accountOwner1, new BigNumber('1000'))

const vaultCounter = new BigNumber(await controller.getAccountVaultCounter(accountOwner1))
Expand Down
6 changes: 3 additions & 3 deletions test/integration-tests/open-markets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ contract('OTokenFactory + Otoken: Cloning of real otoken instances.', ([deployer
const expiry = 1753776000 // 07/29/2025 @ 8:00am (UTC)

before('Deploy addressBook, otoken logic, whitelist, Factory contract', async () => {
usdc = await MockERC20.new('USDC', 'USDC')
dai = await MockERC20.new('DAI', 'DAI')
randomERC20 = await MockERC20.new('RANDOM', 'RAM')
usdc = await MockERC20.new('USDC', 'USDC', 6)
dai = await MockERC20.new('DAI', 'DAI', 18)
randomERC20 = await MockERC20.new('RANDOM', 'RAM', 10)

// Setup AddresBook
addressBook = await AddressBook.new({from: deployer})
Expand Down
6 changes: 3 additions & 3 deletions test/marginCalculator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ contract('MarginCalculator', () => {
oracle = await MockOracle.new()
await addressBook.setOracle(oracle.address)
// setup usdc and weth
usdc = await MockERC20.new('USDC', 'USDC')
dai = await MockERC20.new('DAI', 'DAI')
weth = await MockERC20.new('WETH', 'WETH')
usdc = await MockERC20.new('USDC', 'USDC', 6)
dai = await MockERC20.new('DAI', 'DAI', 18)
weth = await MockERC20.new('WETH', 'WETH', 18)
// setup put tokens
eth300Put = await MockOtoken.new()
eth250Put = await MockOtoken.new()
Expand Down
2 changes: 1 addition & 1 deletion test/marginPool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract('MarginPool', ([controllerAddress, user1, random]) => {

before('Deployment', async () => {
// deploy USDC token
usdc = await MockERC20.new('USDC', 'USDC')
usdc = await MockERC20.new('USDC', 'USDC', 8)
// deploy WETH token for testing
weth = await WETH9.new()
// deploy AddressBook mock
Expand Down
2 changes: 1 addition & 1 deletion test/oracle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract('Oracle', ([owner, disputer, controllerAddress, random, collateral, str
oracle = await Oracle.new(addressBook.address, {from: owner})

// mock tokens
weth = await MockERC20.new('WETH', 'WETH')
weth = await MockERC20.new('WETH', 'WETH', 18)
otoken = await Otoken.new()
otokenExpiry = new BigNumber((await time.latest()).toNumber() + time.duration.days(30).toNumber())
await otoken.init(addressBook.address, weth.address, strike, collateral, '200', otokenExpiry, true)
Expand Down

0 comments on commit 4459ce7

Please sign in to comment.