Skip to content
Open

R #21

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
93d6937
update USTB contract with further testcases.
c-n-o-t-e Dec 19, 2023
7ae6fa2
Update param.
c-n-o-t-e Dec 19, 2023
d4a91a8
Update Version.
c-n-o-t-e Dec 19, 2023
8688614
Update Version.
c-n-o-t-e Dec 19, 2023
4cc4955
Add audit.
c-n-o-t-e Jan 2, 2024
630bb8c
Update audit report.
c-n-o-t-e Jan 2, 2024
9e0f835
Update audit report.
c-n-o-t-e Jan 2, 2024
3fd1e80
Update Audit Report.
c-n-o-t-e Jan 2, 2024
c6a7b7b
Update Audit Report.
c-n-o-t-e Jan 2, 2024
be34d92
Update Audit Report.
c-n-o-t-e Jan 2, 2024
007a65a
Update Audit Report.
c-n-o-t-e Jan 2, 2024
25313fc
Update Audit Report.
c-n-o-t-e Jan 3, 2024
e78d6cd
Update Audit Report.
c-n-o-t-e Jan 3, 2024
f1a285b
Update Audit Report.
c-n-o-t-e Jan 3, 2024
2323ea4
Update Audit Report.
c-n-o-t-e Jan 3, 2024
70fdb45
Update Audit Report.
c-n-o-t-e Jan 3, 2024
4948bef
Update Audit Report.
c-n-o-t-e Jan 3, 2024
6e0cd0a
Update Audit Report.
c-n-o-t-e Jan 3, 2024
f67b16e
Update Audit Report.
c-n-o-t-e Jan 3, 2024
6e452eb
Update Audit Report.
c-n-o-t-e Jan 3, 2024
cd6e03f
Update Audit Report.
c-n-o-t-e Jan 3, 2024
d1ed482
Update Audit Report.
c-n-o-t-e Jan 3, 2024
7d509a0
Update Audit Report.
c-n-o-t-e Jan 3, 2024
7ab0af7
Update Audit Report.
c-n-o-t-e Jan 3, 2024
e9790f6
Update Audit Report.
c-n-o-t-e Jan 3, 2024
570a076
Update Audit Report.
c-n-o-t-e Jan 3, 2024
03e5950
Update Audit Report.
c-n-o-t-e Jan 3, 2024
b75dc2e
Update Audit Report.
c-n-o-t-e Jan 3, 2024
6d3c48b
Update Audit Report.
c-n-o-t-e Jan 3, 2024
1d34876
Update Audit Report.
c-n-o-t-e Jan 3, 2024
864cadd
Update Audit Report.
c-n-o-t-e Jan 3, 2024
c5230b5
Update Audit Report.
c-n-o-t-e Jan 3, 2024
f5b6873
Update Audit Report.
c-n-o-t-e Jan 3, 2024
2ca6961
Update Audit Report.
c-n-o-t-e Jan 3, 2024
7f76608
Update Audit Report.
c-n-o-t-e Jan 3, 2024
89e22ac
Update README.md
c-n-o-t-e Jan 23, 2024
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

The USTB Token project is a Solidity-based smart contract system designed to provide a rebase token with cross-chain and Layer Zero functionalities. It's built with upgradeability in mind, ensuring that the token logic can evolve over time.
The USTB Token project is a Solidity-based smart contract system designed to provide a rebase token with cross-chain and Layer Zero functionalities. It's built with upgradeability in mind, ensuring that the token logic can evolve.

## Key Components

Expand Down
2 changes: 2 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ unreal = { key = "", url = "https://unreal.blockscout.com/api" }
[fmt]
wrap_comments = true

[invariant]

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
38 changes: 29 additions & 9 deletions src/USTB.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ contract USTB is IUSTB, LayerZeroRebaseTokenUpgradeable, UUPSUpgradeable {
}

// keccak256(abi.encode(uint256(keccak256("tangible.storage.USTB")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant USTBStorageLocation = 0x56cb630b12f1f031f72de1d734e98085323517cc6515c1c85452dc02f218dd00;
bytes32 private constant USTBStorageLocation =
0x56cb630b12f1f031f72de1d734e98085323517cc6515c1c85452dc02f218dd00;

function _getUSTBStorage() private pure returns (USTBStorage storage $) {
// slither-disable-next-line assembly
Expand Down Expand Up @@ -70,15 +71,18 @@ contract USTB is IUSTB, LayerZeroRebaseTokenUpgradeable, UUPSUpgradeable {
* @param endpoint The Layer Zero endpoint for cross-chain operations.
* @custom:oz-upgrades-unsafe-allow constructor
*/
constructor(address underlying, uint256 mainChainId, address endpoint)
CrossChainToken(mainChainId)
LayerZeroRebaseTokenUpgradeable(endpoint)
{
constructor(
address underlying,
uint256 mainChainId,
address endpoint
) CrossChainToken(mainChainId) LayerZeroRebaseTokenUpgradeable(endpoint) {
UNDERLYING = underlying;
_disableInitializers();
}

function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
function _authorizeUpgrade(
address newImplementation
) internal override onlyOwner {}

/**
* @notice Initializes the USTB contract with essential parameters.
Expand Down Expand Up @@ -146,11 +150,20 @@ contract USTB is IUSTB, LayerZeroRebaseTokenUpgradeable, UUPSUpgradeable {
_disableRebase(account, disable);
}

function rebaseIndexManager() external view override returns (address _rebaseIndexManager) {
function rebaseIndexManager()
external
view
override
returns (address _rebaseIndexManager)
{
USTBStorage storage $ = _getUSTBStorage();
_rebaseIndexManager = $.rebaseIndexManager;
}

function isNotRebase(address account) external view returns (bool) {
return _isRebaseDisabled(account);
}

/**
* @notice Sets the rebase index and its corresponding nonce on non-main chains.
* @dev This function allows the rebase index manager to manually update the rebase index and nonce when not on the
Expand All @@ -162,7 +175,10 @@ contract USTB is IUSTB, LayerZeroRebaseTokenUpgradeable, UUPSUpgradeable {
* @param index The new rebase index to set.
* @param nonce The new nonce corresponding to the rebase index.
*/
function setRebaseIndex(uint256 index, uint256 nonce) public onlyIndexManager mainChain(false) {
function setRebaseIndex(
uint256 index,
uint256 nonce
) public onlyIndexManager mainChain(false) {
_setRebaseIndex(index, nonce);
}

Expand Down Expand Up @@ -210,7 +226,11 @@ contract USTB is IUSTB, LayerZeroRebaseTokenUpgradeable, UUPSUpgradeable {
* @param to The address to which tokens are being transferred or minted.
* @param amount The amount of tokens being transferred, minted, or burned.
*/
function _update(address from, address to, uint256 amount) internal virtual override {
function _update(
address from,
address to,
uint256 amount
) internal virtual override {
refreshRebaseIndex();
super._update(from, to, amount);
}
Expand Down
Loading