-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: shivangrawat30 <[email protected]>
- Loading branch information
1 parent
0d3693d
commit eef9bc1
Showing
19 changed files
with
1,435 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
[submodule "lib/forge-std"] | ||
path = lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std | ||
[submodule "lib/foundry-devops"] | ||
path = lib/foundry-devops | ||
url = https://github.com/cyfrin/foundry-devops | ||
[submodule "lib/chainlink-brownie-contracts"] | ||
path = lib/chainlink-brownie-contracts | ||
url = https://github.com/smartcontractkit/chainlink-brownie-contracts | ||
[submodule "lib/openzeppelin-contracts"] | ||
path = lib/openzeppelin-contracts | ||
url = https://github.com/openzeppelin/openzeppelin-contracts |
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,3 @@ | ||
{ | ||
"solidity.compileUsingRemoteVersion": "v0.8.19+commit.7dd6d404" | ||
} |
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,46 @@ | ||
-include .env | ||
|
||
.PHONY: all test clean deploy fund help install snapshot format anvil | ||
|
||
DEFAULT_ANVIL_KEY := 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 | ||
|
||
help: | ||
@echo "Usage:" | ||
@echo " make deploy [ARGS=...]\n example: make deploy ARGS=\"--network sepolia\"" | ||
@echo "" | ||
@echo " make fund [ARGS=...]\n example: make deploy ARGS=\"--network sepolia\"" | ||
|
||
all: clean remove install update build | ||
|
||
# Clean the repo | ||
clean :; forge clean | ||
|
||
# Remove modules | ||
remove :; rm -rf .gitmodules && rm -rf .git/modules/* && rm -rf lib && touch .gitmodules && git add . && git commit -m "modules" | ||
|
||
install :; forge install cyfrin/[email protected] --no-commit && forge install smartcontractkit/[email protected] --no-commit && forge install foundry-rs/[email protected] --no-commit && forge install openzeppelin/[email protected] --no-commit | ||
|
||
# Update Dependencies | ||
update:; forge update | ||
|
||
build:; forge build | ||
|
||
test :; forge test | ||
|
||
coverage :; forge coverage --report debug > coverage-report.txt | ||
|
||
snapshot :; forge snapshot | ||
|
||
format :; forge fmt | ||
|
||
anvil :; anvil -m 'test test test test test test test test test test test junk' --steps-tracing --block-time 1 | ||
|
||
NETWORK_ARGS := --rpc-url http://localhost:8545 --private-key $(DEFAULT_ANVIL_KEY) --broadcast | ||
|
||
ifeq ($(findstring --network sepolia,$(ARGS)),--network sepolia) | ||
NETWORK_ARGS := --rpc-url $(SEPOLIA_RPC_URL) --private-key $(PRIVATE_KEY) --broadcast --verify --etherscan-api-key $(ETHERSCAN_API_KEY) -vvvv | ||
endif | ||
|
||
deploy: | ||
@forge script script/DeployDSC.s.sol:DeployDSC $(NETWORK_ARGS) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@chainlink/contracts/=lib/chainlink-brownie-contracts/contracts/ | ||
@solmate/=lib/solmate/src/ | ||
chainlink-brownie-contracts/=lib/chainlink-brownie-contracts/contracts/src/v0.6/vendor/@arbitrum/nitro-contracts/src/ | ||
ds-test/=lib/solmate/lib/ds-test/src/ | ||
forge-std/=lib/forge-std/src/ | ||
solmate/=lib/solmate/src/ | ||
weird-erc20/=lib/solmate/lib/weird-erc20/src/ | ||
@openzeppelin/contracts=lib/openzeppelin-contracts/contracts |
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,29 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.19; | ||
|
||
import {Script} from "forge-std/Script.sol"; | ||
import {HelperConfig} from "./HelperConfig.s.sol"; | ||
import {DecentralizedStableCoin} from "../src/DecentralizedStableCoin.sol"; | ||
import {DSCEngine} from "../src/DSCEngine.sol"; | ||
|
||
contract DeployDSC is Script { | ||
address[] public tokenAddresses; | ||
address[] public priceFeedAddresses; | ||
|
||
function run() external returns (DecentralizedStableCoin, DSCEngine, HelperConfig) { | ||
HelperConfig helperConfig = new HelperConfig(); | ||
|
||
(address wethUsdPriceFeed, address wbtcUsdPriceFeed, address weth, address wbtc, uint256 deployerKey) = | ||
helperConfig.activeNetworkConfig(); | ||
|
||
tokenAddresses = [weth, wbtc]; | ||
priceFeedAddresses = [wethUsdPriceFeed, wbtcUsdPriceFeed]; | ||
vm.startBroadcast(deployerKey); | ||
DecentralizedStableCoin dsc = new DecentralizedStableCoin(); | ||
DSCEngine dscEngine = new DSCEngine(tokenAddresses, priceFeedAddresses, address(dsc)); | ||
dsc.transferOwnership(address(dscEngine)); | ||
vm.stopBroadcast(); | ||
return (dsc, dscEngine, helperConfig); | ||
} | ||
} |
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,61 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {MockV3Aggregator} from "../test/mocks/MockV3Aggregator.sol"; | ||
import {Script} from "forge-std/Script.sol"; | ||
import {ERC20Mock} from "../test/mocks/ERC20Mock.sol"; | ||
|
||
contract HelperConfig is Script { | ||
struct NetworkConfig { | ||
address wethUsdPriceFeed; | ||
address wbtcUsdPriceFeed; | ||
address weth; | ||
address wbtc; | ||
uint256 deployerKey; | ||
} | ||
|
||
NetworkConfig public activeNetworkConfig; | ||
uint8 public constant DECIMALS = 8; | ||
int256 public constant ETH_USD_PRICE = 2000e8; | ||
int256 public constant BTC_USD_PRICE = 1000e8; | ||
uint256 public DEFAULT_ANVIL_PRIVATE_KEY = 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80; | ||
|
||
constructor() { | ||
if (block.chainid == 11_155_111) { | ||
activeNetworkConfig = getSepoliaEthConfig(); | ||
} else { | ||
activeNetworkConfig = getOrCreateAnvilEthConfig(); | ||
} | ||
} | ||
|
||
function getSepoliaEthConfig() public view returns (NetworkConfig memory) { | ||
return NetworkConfig({ | ||
wethUsdPriceFeed: 0x694AA1769357215DE4FAC081bf1f309aDC325306, | ||
wbtcUsdPriceFeed: 0x1b44F3514812d835EB1BDB0acB33d3fA3351Ee43, | ||
weth: 0xdd13E55209Fd76AfE204dBda4007C227904f0a81, | ||
wbtc: 0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063, | ||
deployerKey: vm.envUint("PRIVATE_KEY") | ||
}); | ||
} | ||
|
||
function getOrCreateAnvilEthConfig() public returns (NetworkConfig memory anvilNetworkConfig) { | ||
if (activeNetworkConfig.wethUsdPriceFeed != address(0)) { | ||
return activeNetworkConfig; | ||
} | ||
|
||
vm.startBroadcast(); | ||
MockV3Aggregator ethUsdPriceFeeds = new MockV3Aggregator(DECIMALS, ETH_USD_PRICE); | ||
ERC20Mock wethMock = new ERC20Mock("WETH", "WETH", msg.sender, 1000e8); | ||
MockV3Aggregator btcUsdPriceFeed = new MockV3Aggregator(DECIMALS, BTC_USD_PRICE); | ||
ERC20Mock wbtcMock = new ERC20Mock("WBTC", "WBTC", msg.sender, 1000e8); | ||
vm.stopBroadcast(); | ||
|
||
anvilNetworkConfig = NetworkConfig({ | ||
wethUsdPriceFeed: address(ethUsdPriceFeeds), | ||
wbtcUsdPriceFeed: address(btcUsdPriceFeed), | ||
weth: address(wethMock), | ||
wbtc: address(wbtcMock), | ||
deployerKey: DEFAULT_ANVIL_PRIVATE_KEY | ||
}); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.