Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ redeem-collateral:

# Rebase
rebase:
forge script script/VaultInteractions.s.sol:VaultInteractions --sig "rebase()" --rpc-url http://localhost:8545 --private-key $(DEFAULT_ANVIL_KEY) --broadcast -vv
forge script script/VaultInteractions.s.sol:VaultInteractions --sig "rebase()" --rpc-url http://localhost:8545 --private-key $(DEFAULT_ANVIL_KEY) --broadcast -vvvvvv

NETWORK_ARGS := --rpc-url http://localhost:8545 --private-key $(DEFAULT_ANVIL_KEY) --broadcast

Expand Down
4 changes: 2 additions & 2 deletions don-simulator/src/source/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@
// const medianRate = prices.sort((a, b) => a - b)[Math.round(prices.length / 2)];
// console.log(`Median MAD rate: $${medianRate.toFixed(2)}`);

// return Functions.encodeUint256(Math.round(medianRate * 100));
return Functions.encodeUint256(11);
// return Functions.encodeUint256(Math.round(medianRate));
return Functions.encodeUint256(13);
20 changes: 9 additions & 11 deletions src/MADT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ contract MADT is ERC20, Ownable {
error MADT__InvalidVaultAddress();

address public vault;
uint256 public rebaseFactor = 1e18;
uint256 public rebaseFactor = 10 ** 8;

event Rebase(uint256 oldRebaseFactor, uint256 newRebaseFactor);

constructor() ERC20("Tokenized MAD", "MADT") Ownable(msg.sender) {}

Expand All @@ -33,29 +35,25 @@ contract MADT is ERC20, Ownable {
}

function balanceOf(address account) public view override returns (uint256) {
return (super.balanceOf(account) * rebaseFactor) / 1e18;
return (super.balanceOf(account) * rebaseFactor) / (10 ** 8);
}

function transfer(address to, uint256 amount) public override returns (bool) {
uint256 scaledAmount = (amount * 1e18) / rebaseFactor;
uint256 scaledAmount = (amount * (10 ** 8)) / rebaseFactor;
return super.transfer(to, scaledAmount);
}

function transferFrom(address from, address to, uint256 amount) public override returns (bool) {
uint256 scaledAmount = (amount * 1e18) / rebaseFactor;
uint256 scaledAmount = (amount * (10 ** 8)) / rebaseFactor;
return super.transferFrom(from, to, scaledAmount);
}

function rebase(uint256 madtToUSDTPrice) public onlyVault {
require(madtToUSDTPrice > 0, "Invalid MADT to USDT price");

// uint256 oldRebaseFactor = rebaseFactor;
uint256 scalingFactor = 100;

// Calculate the new rebase factor based on the ratio
uint256 newRebaseFactor = (rebaseFactor * madtToUSDTPrice) / scalingFactor;
rebaseFactor = newRebaseFactor;
// emit Rebase(oldRebaseFactor, rebaseFactor);
uint256 oldRebaseFactor = rebaseFactor;
rebaseFactor = madtToUSDTPrice * (10 ** 7);
emit Rebase(oldRebaseFactor, rebaseFactor);
}

function decimals() public pure override returns (uint8) {
Expand Down
Loading