Skip to content

Commit

Permalink
fix: fixed admin privilages
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSolDev committed Dec 24, 2024
1 parent 421add1 commit d31c92f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
8 changes: 7 additions & 1 deletion script/Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ contract Pool is Config {
return (decodedPoolToken, decodedSelfPeggingAsset, decodedWrappedPoolToken);
}

function initialMintAndUnpause(uint256 usdcAmount, uint256 usdtAmount, SelfPeggingAsset selfPeggingAsset) internal {
function initialMintAndUnpause(
uint256 usdcAmount,
uint256 usdtAmount,
SelfPeggingAsset selfPeggingAsset
)
internal
{
console.log("---------------");
console.log("initial-mint-logs");
console.log("---------------");
Expand Down
3 changes: 2 additions & 1 deletion script/Testnet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ contract Testnet is Deploy, Setup {
vm.writeJson(vm.serializeAddress("contracts", "Factory", address(factory)), "./broadcast/testnet.json");

vm.writeJson(
vm.serializeAddress("contracts", "SelfPeggingAssetBeacon", selfPeggingAssetBeacon), "./broadcast/testnet.json"
vm.serializeAddress("contracts", "SelfPeggingAssetBeacon", selfPeggingAssetBeacon),
"./broadcast/testnet.json"
);

vm.writeJson(vm.serializeAddress("contracts", "LPTokenBeacon", lpTokenBeacon), "./broadcast/testnet.json");
Expand Down
12 changes: 8 additions & 4 deletions src/SelfPeggingAsset.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ error ImbalancedPool(uint256 oldD, uint256 newD);
* @title SelfPeggingAsset swap
* @author Nuts Finance Developer
* @notice The SelfPeggingAsset pool provides a way to swap between different tokens
* @dev The SelfPeggingAsset contract allows users to trade between different tokens, with prices determined algorithmically
* @dev The SelfPeggingAsset contract allows users to trade between different tokens, with prices determined
* algorithmically
* based on the current supply and demand of each token
*/
contract SelfPeggingAsset is Initializable, ReentrancyGuardUpgradeable, OwnableUpgradeable {
Expand Down Expand Up @@ -142,7 +143,8 @@ contract SelfPeggingAsset is Initializable, ReentrancyGuardUpgradeable, OwnableU
*/
address[] public tokens;
/**
* @dev This is an array of uint256 values representing the precisions of each token in the SelfPeggingAsset contract.
* @dev This is an array of uint256 values representing the precisions of each token in the SelfPeggingAsset
* contract.
* The precision of each token is calculated as 10 ** (18 - token decimals).
*/
uint256[] public precisions;
Expand Down Expand Up @@ -989,17 +991,19 @@ contract SelfPeggingAsset is Initializable, ReentrancyGuardUpgradeable, OwnableU
/**
* @dev Pause mint/swap/redeem actions. Can unpause later.
*/
function pause() external onlyOwner {
function pause() external {
require(!paused, "paused");
require(admins[msg.sender], "not admin");

paused = true;
}

/**
* @dev Unpause mint/swap/redeem actions.
*/
function unpause() external onlyOwner {
function unpause() external {
require(paused, "not paused");
require(admins[msg.sender], "not admin");

paused = false;
}
Expand Down
4 changes: 3 additions & 1 deletion src/SelfPeggingAssetFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,14 @@ contract SelfPeggingAssetFactory is UUPSUpgradeable, ReentrancyGuardUpgradeable,
}

bytes memory selfPeggingAssetInit = abi.encodeCall(
SelfPeggingAsset.initialize, (tokens, precisions, fees, LPToken(address(lpTokenProxy)), A, exchangeRateProviders)
SelfPeggingAsset.initialize,
(tokens, precisions, fees, LPToken(address(lpTokenProxy)), A, exchangeRateProviders)
);
BeaconProxy selfPeggingAssetProxy = new BeaconProxy(selfPeggingAssetBeacon, selfPeggingAssetInit);
SelfPeggingAsset selfPeggingAsset = SelfPeggingAsset(address(selfPeggingAssetProxy));
LPToken lpToken = LPToken(address(lpTokenProxy));

selfPeggingAsset.setAdmin(governor, true);
selfPeggingAsset.transferOwnership(governor);
lpToken.addPool(address(selfPeggingAsset));
lpToken.transferOwnership(governor);
Expand Down
10 changes: 9 additions & 1 deletion test/Factory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ contract FactoryTest is Test {
address wlpTokenBeacon = address(beacon);

factory.initialize(
governor, 0, 0, 0, 100, selfPeggingAssetBeacon, lpTokenBeacon, wlpTokenBeacon, new ConstantExchangeRateProvider()
governor,
0,
0,
0,
100,
selfPeggingAssetBeacon,
lpTokenBeacon,
wlpTokenBeacon,
new ConstantExchangeRateProvider()
);
}

Expand Down

0 comments on commit d31c92f

Please sign in to comment.