Skip to content

Commit b271f18

Browse files
committed
Merge branch 'main' of github.com:imadarchid/MADT
2 parents e443c30 + faad950 commit b271f18

3 files changed

Lines changed: 12 additions & 14 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ redeem-collateral:
7777

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

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

don-simulator/src/source/source.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@
4747
// const medianRate = prices.sort((a, b) => a - b)[Math.round(prices.length / 2)];
4848
// console.log(`Median MAD rate: $${medianRate.toFixed(2)}`);
4949

50-
// return Functions.encodeUint256(Math.round(medianRate * 100));
51-
return Functions.encodeUint256(11);
50+
// return Functions.encodeUint256(Math.round(medianRate));
51+
return Functions.encodeUint256(13);

src/MADT.sol

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ contract MADT is ERC20, Ownable {
1010
error MADT__InvalidVaultAddress();
1111

1212
address public vault;
13-
uint256 public rebaseFactor = 1e18;
13+
uint256 public rebaseFactor = 10 ** 8;
14+
15+
event Rebase(uint256 oldRebaseFactor, uint256 newRebaseFactor);
1416

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

@@ -33,29 +35,25 @@ contract MADT is ERC20, Ownable {
3335
}
3436

3537
function balanceOf(address account) public view override returns (uint256) {
36-
return (super.balanceOf(account) * rebaseFactor) / 1e18;
38+
return (super.balanceOf(account) * rebaseFactor) / (10 ** 8);
3739
}
3840

3941
function transfer(address to, uint256 amount) public override returns (bool) {
40-
uint256 scaledAmount = (amount * 1e18) / rebaseFactor;
42+
uint256 scaledAmount = (amount * (10 ** 8)) / rebaseFactor;
4143
return super.transfer(to, scaledAmount);
4244
}
4345

4446
function transferFrom(address from, address to, uint256 amount) public override returns (bool) {
45-
uint256 scaledAmount = (amount * 1e18) / rebaseFactor;
47+
uint256 scaledAmount = (amount * (10 ** 8)) / rebaseFactor;
4648
return super.transferFrom(from, to, scaledAmount);
4749
}
4850

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

52-
// uint256 oldRebaseFactor = rebaseFactor;
53-
uint256 scalingFactor = 100;
54-
55-
// Calculate the new rebase factor based on the ratio
56-
uint256 newRebaseFactor = (rebaseFactor * madtToUSDTPrice) / scalingFactor;
57-
rebaseFactor = newRebaseFactor;
58-
// emit Rebase(oldRebaseFactor, rebaseFactor);
54+
uint256 oldRebaseFactor = rebaseFactor;
55+
rebaseFactor = madtToUSDTPrice * (10 ** 7);
56+
emit Rebase(oldRebaseFactor, rebaseFactor);
5957
}
6058

6159
function decimals() public pure override returns (uint8) {

0 commit comments

Comments
 (0)