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

[NES-190] add named Proxy contracts #4

Merged
merged 2 commits into from
Sep 14, 2024
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
19 changes: 11 additions & 8 deletions nest/script/DeployNestContracts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ pragma solidity ^0.8.25;
import "forge-std/Script.sol";

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Upgrades } from "openzeppelin-foundry-upgrades/Upgrades.sol";

import { AggregateToken } from "../src/AggregateToken.sol";
import { FakeComponentToken } from "../src/FakeComponentToken.sol";
import { AggregateTokenProxy } from "../src/proxies/AggregateTokenProxy.sol";
import { FakeComponentTokenProxy } from "../src/proxies/FakeComponentTokenProxy.sol";

contract DeployNestContracts is Script {

Expand All @@ -17,31 +18,33 @@ contract DeployNestContracts is Script {
function run() external {
vm.startBroadcast(ARC_ADMIN_ADDRESS);

address fakeComponentTokenProxy = Upgrades.deployUUPSProxy(
"FakeComponentToken.sol",
FakeComponentToken fakeComponentToken = new FakeComponentToken();
FakeComponentTokenProxy fakeComponentTokenProxy = new FakeComponentTokenProxy(
address(fakeComponentToken),
abi.encodeCall(
FakeComponentToken.initialize, (ARC_ADMIN_ADDRESS, "Banana", "BAN", IERC20(USDC_ADDRESS), 18)
)
);
console.log("FakeComponentToken deployed to:", fakeComponentTokenProxy);
console.log("FakeComponentTokenProxy deployed to:", address(fakeComponentTokenProxy));

address aggregateTokenProxy = Upgrades.deployUUPSProxy(
"AggregateToken.sol",
AggregateToken aggregateToken = new AggregateToken();
AggregateTokenProxy aggregateTokenProxy = new AggregateTokenProxy(
address(aggregateToken),
abi.encodeCall(
AggregateToken.initialize,
(
ARC_ADMIN_ADDRESS,
"Apple",
"AAPL",
IERC20(USDC_ADDRESS),
USDC_ADDRESS,
18,
15e17,
12e17,
"https://assets.plumenetwork.xyz/metadata/mineral-vault.json"
)
)
);
console.log("AggregateToken deployed to:", aggregateTokenProxy);
console.log("AggregateTokenProxy deployed to:", address(aggregateTokenProxy));

vm.stopBroadcast();
}
Expand Down
10 changes: 5 additions & 5 deletions nest/src/AggregateToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ contract AggregateToken is
* @param owner Address of the owner of the AggregateToken
* @param name Name of the AggregateToken
* @param symbol Symbol of the AggregateToken
* @param currencyToken CurrencyToken used to mint and burn the AggregateToken
* @param currencyAddress Address of the CurrencyToken used to mint and burn the AggregateToken
* @param decimals_ Number of decimals of the AggregateToken
* @param askPrice Price at which users can buy the AggregateToken using CurrencyToken, times the base
* @param bidPrice Price at which users can sell the AggregateToken to receive CurrencyToken, times the base
Expand All @@ -151,7 +151,7 @@ contract AggregateToken is
address owner,
string memory name,
string memory symbol,
IERC20 currencyToken,
address currencyAddress,
uint8 decimals_,
uint256 askPrice,
uint256 bidPrice,
Expand All @@ -165,9 +165,9 @@ contract AggregateToken is
_grantRole(UPGRADER_ROLE, owner);

AggregateTokenStorage storage $ = _getAggregateTokenStorage();
$.componentTokenMap[currencyToken] = true;
$.componentTokenList.push(currencyToken);
$.currencyToken = currencyToken;
$.componentTokenMap[IComponentToken(currencyAddress)] = true;
$.componentTokenList.push(IComponentToken(currencyAddress));
$.currencyToken = IERC20(currencyAddress);
$.decimals = decimals_;
$.askPrice = askPrice;
$.bidPrice = bidPrice;
Expand Down
15 changes: 15 additions & 0 deletions nest/src/proxies/AggregateTokenProxy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

/**
* @title AggregateTokenProxy
* @author Eugene Y. Q. Shen
* @notice Proxy contract for the AggregateToken
*/
contract AggregateTokenProxy is ERC1967Proxy {

constructor(address logic, bytes memory data) ERC1967Proxy(logic, data) { }

}
15 changes: 15 additions & 0 deletions nest/src/proxies/FakeComponentTokenProxy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

/**
* @title FakeComponentTokenProxy
* @author Eugene Y. Q. Shen
* @notice Proxy contract for the FakeComponentToken
*/
contract FakeComponentTokenProxy is ERC1967Proxy {

constructor(address logic, bytes memory data) ERC1967Proxy(logic, data) { }

}