-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
250 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.28; | ||
|
||
import {Script} from "forge-std/Script.sol"; | ||
import {console} from "forge-std/console.sol"; | ||
import { StableAssetFactory } from "../src/StableAssetFactory.sol"; | ||
|
||
contract Config is Script { | ||
bool testnet = vm.envBool("TESTNET"); | ||
|
||
uint256 deployerPrivateKey; | ||
uint256 initialMinterPrivateKey; | ||
|
||
address GOVERNANCE; | ||
address DEPLOYER; | ||
address INITIAL_MINTER; | ||
|
||
address usdc; | ||
address usdt; | ||
|
||
StableAssetFactory factory; | ||
address stableAssetBeacon; | ||
address lpTokenBeacon; | ||
address wlpTokenBeacon; | ||
|
||
struct JSONData { | ||
address USDC; | ||
address USDT; | ||
address Factory; | ||
address StableAssetBeacon; | ||
address LPTokenBeacon; | ||
address WLPTokenBeacon; | ||
} | ||
|
||
function loadConfig() internal { | ||
if (!testnet) { | ||
usdc = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; | ||
usdt = 0xdAC17F958D2ee523a2206206994597C13D831ec7; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.28; | ||
|
||
import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; | ||
import {stdJson} from "forge-std/StdJson.sol"; | ||
import {console} from "forge-std/console.sol"; | ||
import { StableAsset } from "../src/StableAsset.sol"; | ||
import { LPToken } from "../src/LPToken.sol"; | ||
import { WLPToken } from "../src/WLPToken.sol"; | ||
import { StableAssetFactory } from "../src/StableAssetFactory.sol"; | ||
import {Config} from "script/Config.sol"; | ||
import "../src/misc/ConstantExchangeRateProvider.sol"; | ||
|
||
contract Deploy is Config { | ||
function deployBeacons() internal { | ||
console.log("---------------"); | ||
console.log("deploy-beacon-logs"); | ||
console.log("---------------"); | ||
|
||
address stableAssetImplentation = address(new StableAsset()); | ||
address lpTokenImplentation = address(new LPToken()); | ||
address wlpTokenImplentation = address(new WLPToken()); | ||
|
||
UpgradeableBeacon beacon = new UpgradeableBeacon(stableAssetImplentation); | ||
beacon.transferOwnership(GOVERNANCE); | ||
stableAssetBeacon = address(beacon); | ||
|
||
beacon = new UpgradeableBeacon(lpTokenImplentation); | ||
beacon.transferOwnership(GOVERNANCE); | ||
lpTokenBeacon = address(beacon); | ||
|
||
beacon = new UpgradeableBeacon(wlpTokenImplentation); | ||
beacon.transferOwnership(GOVERNANCE); | ||
wlpTokenBeacon = address(beacon); | ||
} | ||
|
||
function deployFactory() internal { | ||
console.log("---------------"); | ||
console.log("deploy-factory-logs"); | ||
console.log("---------------"); | ||
|
||
factory = new StableAssetFactory(); | ||
|
||
factory.initialize( | ||
GOVERNANCE, | ||
0, | ||
0, | ||
0, | ||
100, | ||
stableAssetBeacon, | ||
lpTokenBeacon, | ||
wlpTokenBeacon, | ||
new ConstantExchangeRateProvider() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.28; | ||
|
||
import { Vm } from "forge-std/Vm.sol"; | ||
import {stdJson} from "forge-std/StdJson.sol"; | ||
import {console} from "forge-std/console.sol"; | ||
import {Config} from "script/Config.sol"; | ||
import { StableAssetFactory } from "../src/StableAssetFactory.sol"; | ||
|
||
contract Pool is Config { | ||
function createStandardPool() internal returns(address, address, address) { | ||
console.log("---------------"); | ||
console.log("create-pool-logs"); | ||
console.log("---------------"); | ||
|
||
StableAssetFactory.CreatePoolArgument memory arg = StableAssetFactory.CreatePoolArgument({ | ||
tokenA: usdc, | ||
tokenB: usdt, | ||
initialMinter: INITIAL_MINTER, | ||
tokenBType: StableAssetFactory.TokenBType.Standard, | ||
tokenBOracle: address(0), | ||
tokenBFunctionSig: "" | ||
}); | ||
|
||
vm.recordLogs(); | ||
factory.createPool(arg); | ||
Vm.Log[] memory entries = vm.getRecordedLogs(); | ||
bytes32 eventSig = keccak256("PoolCreated(address,address,address)"); | ||
|
||
address decodedPoolToken; | ||
address decodedStableAsset; | ||
address decodedWrappedPoolToken; | ||
|
||
for (uint256 i = 0; i < entries.length; i++) { | ||
Vm.Log memory log = entries[i]; | ||
|
||
if (log.topics[0] == eventSig) { | ||
(decodedPoolToken, decodedStableAsset, decodedWrappedPoolToken) = | ||
abi.decode(log.data, (address, address, address)); | ||
} | ||
} | ||
|
||
return (decodedPoolToken, decodedStableAsset, decodedWrappedPoolToken); | ||
} | ||
|
||
function initialMintAndUnpause( | ||
uint256 usdcAmount, | ||
uint256 usdtAmount, | ||
address decodedStableAsset, | ||
) internal { | ||
console.log("---------------"); | ||
console.log("initial-mint-logs"); | ||
console.log("---------------"); | ||
|
||
usdc.approve(address(factory), usdcAmount); | ||
usdt.approve(address(factory), usdtAmount); | ||
|
||
uint256[] memory amounts = new uint256[](2); | ||
amounts[0] = usdcAmount; | ||
amounts[1] = usdtAmount; | ||
|
||
StableAsset stableAsset = StableAsset(decodedStableAsset); | ||
stableAsset.mint(amounts, 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.28; | ||
|
||
|
||
import {stdJson} from "forge-std/StdJson.sol"; | ||
import {console} from "forge-std/console.sol"; | ||
import { MockToken } from "../src/mock/MockToken.sol"; | ||
import {Config} from "script/Config.sol"; | ||
|
||
contract Setup is Config { | ||
function deployMocks() internal { | ||
MockToken tokenA = new MockToken("USDC", "USDC", 6); | ||
MockToken tokenB = new MockToken("USDT", "USDT", 6); | ||
|
||
usdc = address(tokenA); | ||
usdt = address(tokenB); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.28; | ||
|
||
import {stdJson} from "forge-std/StdJson.sol"; | ||
import {console} from "forge-std/console.sol"; | ||
|
||
import {Deploy} from "script/Deploy.sol"; | ||
import {Setup} from "script/Setup.sol"; | ||
|
||
contract Testnet is Deploy, Setup { | ||
function init() internal { | ||
if (vm.envUint("HEX_PRIV_KEY") == 0) revert("No private key found"); | ||
deployerPrivateKey = vm.envUint("HEX_PRIV_KEY"); | ||
initialMinterPrivateKey = vm.envUint("HEX_PRIV_KEY"); | ||
GOVERNANCE = vm.addr(deployerPrivateKey); | ||
DEPLOYER = vm.addr(deployerPrivateKey); | ||
INITIAL_MINTER = vm.addr(initialMinterPrivateKey); | ||
testnet = true; | ||
} | ||
|
||
function run() public payable { | ||
init(); | ||
loadConfig(); | ||
|
||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
deployMocks(); | ||
deployBeacons(); | ||
deployFactory(); | ||
|
||
vm.writeJson( | ||
vm.serializeAddress("contracts", "USDC", usdc), | ||
"./broadcast/testnet.json" | ||
); | ||
|
||
vm.writeJson( | ||
vm.serializeAddress("contracts", "USDT", usdt), | ||
"./broadcast/testnet.json" | ||
); | ||
|
||
vm.writeJson( | ||
vm.serializeAddress("contracts", "Factory", address(factory)), | ||
"./broadcast/testnet.json" | ||
); | ||
|
||
vm.writeJson( | ||
vm.serializeAddress("contracts", "StableAssetBeacon", stableAssetBeacon), | ||
"./broadcast/testnet.json" | ||
); | ||
|
||
vm.writeJson( | ||
vm.serializeAddress("contracts", "LPTokenBeacon", lpTokenBeacon), | ||
"./broadcast/testnet.json" | ||
); | ||
|
||
vm.writeJson( | ||
vm.serializeAddress("contracts", "WLPTokenBeacon", wlpTokenBeacon), | ||
"./broadcast/testnet.json" | ||
); | ||
|
||
|
||
|
||
vm.stopBroadcast(); | ||
} | ||
} |