Skip to content

Commit

Permalink
Chore/usdc decimals (#236)
Browse files Browse the repository at this point in the history
* chore/fix-usdc-decimals

* fix: lint
  • Loading branch information
albert-llimos authored Sep 20, 2022
1 parent 92c03ed commit e598cf7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
21 changes: 21 additions & 0 deletions contracts/mocks/MockUSDC.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

/**
* @title Token
* @dev Creates a mock USDC contract just for the internal ETH network testing
*/
contract MockUSDC is ERC20 {
constructor(
string memory name,
string memory symbol,
uint256 mintAmount
) ERC20(name, symbol) {
_mint(msg.sender, mintAmount);
}

function decimals() public view override returns (uint8) {
return 6;
}
}
8 changes: 4 additions & 4 deletions scripts/deploy_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

sys.path.append(os.path.abspath("tests"))
from consts import *
from brownie import chain, accounts, KeyManager, Vault, StakeManager, FLIP, Token
from brownie import chain, accounts, KeyManager, Vault, StakeManager, FLIP, MockUSDC
from deploy import deploy_set_Chainflip_contracts, deploy_usdc_contract


Expand Down Expand Up @@ -35,9 +35,9 @@ def main():

# Deploy USDC mimic token only on private ETH network
if chain.id == 10997:
cf.usdc = deploy_usdc_contract(DEPLOYER, Token, cf_accs[0:10])
print(f"USDC: {cf.usdc.address}")
addressDump["USDC_ADDRESS"] = cf.usdc.address
cf.mockUSDC = deploy_usdc_contract(DEPLOYER, MockUSDC, cf_accs[0:10])
print(f"USDC: {cf.mockUSDC.address}")
addressDump["USDC_ADDRESS"] = cf.mockUSDC.address

if DEPLOY_ARTEFACT_ID:
json_content = json.dumps(addressDump)
Expand Down
10 changes: 5 additions & 5 deletions tests/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ def deploy_set_Chainflip_contracts(


# Deploy USDC mimic token (standard ERC20) and transfer init amount to several accounts.
def deploy_usdc_contract(deployer, Token, accounts):
def deploy_usdc_contract(deployer, MockUSDC, accounts):

usdc = deployer.deploy(Token, "USD Coin", "USDC", INIT_USDC_SUPPLY)
mockUsdc = deployer.deploy(MockUSDC, "USD Coin", "USDC", INIT_USDC_SUPPLY)
# Distribute tokens to other accounts
for account in accounts:
if account != deployer and usdc.balanceOf(deployer) >= INIT_USDC_ACCOUNT:
usdc.transfer(account, INIT_USDC_ACCOUNT, {"from": deployer})
if account != deployer and mockUsdc.balanceOf(deployer) >= INIT_USDC_ACCOUNT:
mockUsdc.transfer(account, INIT_USDC_ACCOUNT, {"from": deployer})

return usdc
return mockUsdc

0 comments on commit e598cf7

Please sign in to comment.