Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🛁 Use XC-20 standard for contracts-watr TrueUSD #1252

Merged
merged 104 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
c319da6
WIP deployment script
abam-iksde Mar 1, 2023
548673e
Add initialize method to contracts
abam-iksde Mar 1, 2023
1dec588
Deployment script
abam-iksde Mar 1, 2023
6ca7aab
Make test showOwner script
abam-iksde Mar 1, 2023
6f81400
Add network parameter and prompt for PRIVATE_KEY in script
abam-iksde Mar 2, 2023
826450e
Add canary generation to build
abam-iksde Mar 2, 2023
106917a
Change `pnpm` to `yarn`
abam-iksde Mar 2, 2023
ec77b85
Don't pass `args`
abam-iksde Mar 2, 2023
069d102
Add `Registry` to deployment
abam-iksde Mar 2, 2023
692a708
Create `IClaimableOwnable` interface
abam-iksde Mar 2, 2023
20706b6
Remove constructor from interface
abam-iksde Mar 2, 2023
80954e0
Implement `IClaimableOwnable` interface
abam-iksde Mar 2, 2023
29689af
Lint
abam-iksde Mar 2, 2023
62c62ed
Verify ownership with tests
abam-iksde Mar 2, 2023
74186ab
Verify registry with test
abam-iksde Mar 2, 2023
c6d9e48
Use `transferProxyOwnership`
abam-iksde Mar 2, 2023
4b8ee20
Handle proxy ownership
abam-iksde Mar 2, 2023
68235c2
Add `upgradeTo`
abam-iksde Mar 2, 2023
d310d0a
Use deployed implementation address
abam-iksde Mar 2, 2023
6503d22
Add ownership transfer
abam-iksde Mar 2, 2023
317e452
Refactor deployment
abam-iksde Mar 2, 2023
e2a68df
Verify proxy ownership with test
abam-iksde Mar 2, 2023
ced264e
Hello mints
tt-krzysztof Mar 2, 2023
5074e64
WIP on xc-20
tt-krzysztof Mar 3, 2023
d75f88e
remove deployments
tt-krzysztof Mar 3, 2023
c15a9f3
WIP2
tt-krzysztof Mar 3, 2023
c355e95
Work in heavy progress
abam-iksde Mar 3, 2023
f13ddd9
little cleanup, use astar interface
tt-krzysztof Mar 3, 2023
4af9e61
Use native assets
abam-iksde Mar 3, 2023
84e6141
Test native token for ERC20 functionality
abam-iksde Mar 3, 2023
68d1d61
Merge remote-tracking branch 'origin/kj/xc-20' into kj/xc-20
abam-iksde Mar 3, 2023
b626eba
Fix build
abam-iksde Mar 6, 2023
0d17bd4
Correct accidental typo
abam-iksde Mar 6, 2023
83f5e8c
Update tests
Wojstan Mar 7, 2023
ea20041
Refactor deployment tests & lint
abam-iksde Mar 8, 2023
56915f1
Restore porcelain check
tt-krzysztof Mar 9, 2023
f28a852
Remove automatic submission from deployment
abam-iksde Mar 9, 2023
a39c798
Use balance matchers in `verifyDeployment` tests
abam-iksde Mar 9, 2023
f98d30a
Extract provider parameters
abam-iksde Mar 9, 2023
47d1805
Revert not required `ProxyStorage` changes
abam-iksde Mar 9, 2023
655548f
Support redemptions
abam-iksde Mar 13, 2023
bc0fb5e
Emit event on transfer
abam-iksde Mar 13, 2023
a266d88
Remove `_getTransferAmount` function
abam-iksde Mar 14, 2023
7cd17e1
Test for compatibility with ERC20 standard
abam-iksde Mar 15, 2023
c329c54
Use `_allowances` field that was already there
abam-iksde Mar 15, 2023
a7a6deb
Test for redemptions functionality
abam-iksde Mar 15, 2023
73bf6d6
Move `parseTrueUSD` to utils
abam-iksde Mar 16, 2023
5724590
Use `trueUSDDecimals` constant
abam-iksde Mar 16, 2023
61183a6
Delete `TokenControllerMock`
abam-iksde Mar 17, 2023
709930f
Pass paused implementation as parameter
abam-iksde Mar 17, 2023
8f5e375
Set `initialized=true` at the start of `initialize`
abam-iksde Mar 17, 2023
15e5508
Add paused TrueUSD implementation
abam-iksde Mar 20, 2023
3bbb11f
Create `contracts-watr` package
abam-iksde Apr 7, 2023
e40c0b5
Add initialize method to contracts
abam-iksde Mar 1, 2023
6e30c4f
Deployment script
abam-iksde Mar 1, 2023
3935f93
Make test showOwner script
abam-iksde Mar 1, 2023
c28994b
Add network parameter and prompt for PRIVATE_KEY in script
abam-iksde Mar 2, 2023
c35a211
Add canary generation to build
abam-iksde Mar 2, 2023
21d9030
Change `pnpm` to `yarn`
abam-iksde Mar 2, 2023
2749876
Don't pass `args`
abam-iksde Mar 2, 2023
736abf8
Add `Registry` to deployment
abam-iksde Mar 2, 2023
c7e674d
Create `IClaimableOwnable` interface
abam-iksde Mar 2, 2023
cb8fc57
Remove constructor from interface
abam-iksde Mar 2, 2023
12f66a0
Implement `IClaimableOwnable` interface
abam-iksde Mar 2, 2023
f6500f9
Lint
abam-iksde Mar 2, 2023
c1a0894
Verify ownership with tests
abam-iksde Mar 2, 2023
d20ba3d
Verify registry with test
abam-iksde Mar 2, 2023
1cd84e2
Use `transferProxyOwnership`
abam-iksde Mar 2, 2023
720db28
Handle proxy ownership
abam-iksde Mar 2, 2023
80953f0
Add `upgradeTo`
abam-iksde Mar 2, 2023
4c12812
Use deployed implementation address
abam-iksde Mar 2, 2023
7dc8927
Add ownership transfer
abam-iksde Mar 2, 2023
c620a98
Refactor deployment
abam-iksde Mar 2, 2023
e80ab8c
Verify proxy ownership with test
abam-iksde Mar 2, 2023
6e22a0a
Use XC-20 standard for TrueUSD
abam-iksde Apr 7, 2023
b56a3b1
Match `TrueCurrencyWithProofOfReserve` to contracts-por
abam-iksde Apr 12, 2023
c48ce32
Match `TrueUSD.test.ts` to contracts-por
abam-iksde Apr 12, 2023
dc65658
Merge branch 'watr-package' into watr-deployment
abam-iksde Apr 12, 2023
ee2d07f
Merge branch 'watr-deployment' into watr-xc20
abam-iksde Apr 12, 2023
2da15f4
Remove redundant test suite
abam-iksde Apr 12, 2023
e2de4f4
Revert `TrueUSD` test changes
abam-iksde Apr 12, 2023
6ff14cb
Remove `pausedImplementation` from `TokenControllerPauseMock`
abam-iksde Apr 12, 2023
b8e695d
Merge branch 'main' into watr-deployment
abam-iksde Apr 12, 2023
4111172
Merge branch 'watr-deployment' into watr-xc20
abam-iksde Apr 12, 2023
ea45bec
Extract `ClaimableOwnable` interface
abam-iksde Apr 13, 2023
a04fa87
Merge branch 'watr-deployment' into watr-xc20
abam-iksde Apr 13, 2023
690e49f
Remove `ERC20.sol`
abam-iksde Apr 13, 2023
a4e78c0
Mark all `XC20Wrapper` functions `virtual`
abam-iksde Apr 13, 2023
ede1393
Reorder `XC20Wrapper` functions to match `IERC20` interface
abam-iksde Apr 13, 2023
2325697
Use `_msgSender()` helper function
abam-iksde Apr 13, 2023
b61c2cf
Make `XC20Wrapper`'s `name` and `symbol` purely virtual
abam-iksde Apr 13, 2023
38aac05
Use decimals from precompile in `TrueUSD`
abam-iksde Apr 13, 2023
4d43902
Extract `pausedImplementationAddress` in tests
abam-iksde Apr 13, 2023
4ee7c1f
Lint
abam-iksde Apr 13, 2023
8ea8889
Set assetId with `.env` file
abam-iksde Apr 13, 2023
5ef04fe
Throw on invalid `TRUE_USD_ASSET_ID`
abam-iksde Apr 13, 2023
356f0a7
Add `.env.deploy` to `.gitignore`
abam-iksde Apr 13, 2023
fd2dde0
Set burn bounds on deploy
abam-iksde Apr 13, 2023
9f28a6e
Add link to `ERC20Plus` interface source
abam-iksde Apr 13, 2023
ebf48c5
Merge branch 'main' into watr-deployment
tt-krzysztof Apr 14, 2023
b9743c1
Merge branch 'watr-deployment' into watr-xc20
abam-iksde Apr 14, 2023
3ddab28
Merge branch 'main' into watr-xc20
abam-iksde Apr 14, 2023
054e08b
Remove redundant test suite
abam-iksde Apr 14, 2023
56346c7
Remove `decimals` function from `MockTrueCurrency`
abam-iksde Apr 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/contracts-watr/.env.deploy.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TRUE_USD_ASSET_ID=1983
2 changes: 2 additions & 0 deletions packages/contracts-watr/.env.test.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# required to run `yarn verify:deployments`
PRIVATE_KEY_DEPLOYER=private_key
3 changes: 3 additions & 0 deletions packages/contracts-watr/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
/build
/cache
/flattened_contracts
deployments-watr_local.json
.env.test
.env.deploy
9 changes: 5 additions & 4 deletions packages/contracts-watr/contracts/TokenControllerV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ contract TokenControllerV3 {

// paused version of TrueCurrency in Production
// pausing the contract upgrades the proxy to this implementation
address public constant PAUSED_IMPLEMENTATION = 0x3c8984DCE8f68FCDEEEafD9E0eca3598562eD291;
address public pausedImplementation;

modifier onlyMintKeyOrOwner() {
require(msg.sender == mintKey || msg.sender == owner, "must be mintKey or owner");
Expand Down Expand Up @@ -184,10 +184,11 @@ contract TokenControllerV3 {
_;
}

function initialize() external {
function initialize(address _pausedImplementation) external {
require(!initialized, "already initialized");
owner = msg.sender;
initialized = true;
pausedImplementation = _pausedImplementation;
owner = msg.sender;
}

/**
Expand Down Expand Up @@ -592,7 +593,7 @@ contract TokenControllerV3 {
* @dev pause all pausable actions on TrueCurrency, mints/burn/transfer/approve
*/
function pauseToken() external virtual onlyOwner {
IOwnedUpgradeabilityProxy(address(token)).upgradeTo(PAUSED_IMPLEMENTATION);
IOwnedUpgradeabilityProxy(address(token)).upgradeTo(pausedImplementation);
}

/**
Expand Down
13 changes: 9 additions & 4 deletions packages/contracts-watr/contracts/TrueCurrency.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity 0.6.10;

import {BurnableTokenWithBounds} from "./common/BurnableTokenWithBounds.sol";
import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol";

/**
* @title TrueCurrency
Expand Down Expand Up @@ -39,6 +40,8 @@ import {BurnableTokenWithBounds} from "./common/BurnableTokenWithBounds.sol";
* - ERC20 Tokens and Ether sent to this contract can be reclaimed by the owner
*/
abstract contract TrueCurrency is BurnableTokenWithBounds {
using SafeMath for uint256;

uint256 constant CENT = 10**16;
uint256 constant REDEMPTION_ADDRESS_COUNT = 0x100000;

Expand All @@ -54,10 +57,11 @@ abstract contract TrueCurrency is BurnableTokenWithBounds {
*/
event Mint(address indexed to, uint256 value);

function initialize() external {
function initialize(address _nativeToken) external {
require(!initialized, "already initialized");
owner = msg.sender;
initialized = true;
owner = msg.sender;
nativeToken = _nativeToken;
}

/**
Expand Down Expand Up @@ -126,8 +130,9 @@ abstract contract TrueCurrency is BurnableTokenWithBounds {
require(!isBlacklisted[recipient], "TrueCurrency: recipient is blacklisted");

if (isRedemptionAddress(recipient)) {
super._transfer(sender, recipient, amount.sub(amount.mod(CENT)));
_burn(recipient, amount.sub(amount.mod(CENT)));
uint256 _amount = amount.sub(amount.mod(CENT));
super._transfer(sender, recipient, _amount);
_burn(recipient, _amount);
} else {
super._transfer(sender, recipient, amount);
}
Expand Down
284 changes: 0 additions & 284 deletions packages/contracts-watr/contracts/common/ERC20.sol

This file was deleted.

3 changes: 3 additions & 0 deletions packages/contracts-watr/contracts/common/ProxyStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ contract ProxyStorage {
address public chainReserveFeed;
bool public proofOfReserveEnabled;

// XC20Wrapper variables
address public nativeToken;

/* Additionally, we have several keccak-based storage locations.
* If you add more keccak-based storage mappings, such as mappings, you must document them here.
* If the length of the keccak input is the same as an existing mapping, it is possible there could be a preimage collision.
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-watr/contracts/common/ReclaimerToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ pragma solidity 0.6.10;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ITrueCurrency} from "../interface/ITrueCurrency.sol";
import {ERC20} from "./ERC20.sol";
import {XC20Wrapper} from "./XC20Wrapper.sol";

/**
* @title ReclaimerToken
* @dev ERC20 token which allows owner to reclaim ERC20 tokens
* or ether sent to this contract
*/
abstract contract ReclaimerToken is ERC20, ITrueCurrency {
abstract contract ReclaimerToken is XC20Wrapper, ITrueCurrency {
/**
* @dev send all eth balance in the contract to another address
* @param _to address to send eth balance to
Expand Down
Loading