diff --git a/.env.example b/.env.example index 5d64f35..c7e244a 100644 --- a/.env.example +++ b/.env.example @@ -1,10 +1,5 @@ -## NODE URLS -MAINNET_URL=https://eth-mainnet.alchemyapi.io/v2/API_KEY -MAINNET_KEY=API_KEY -POLYGON_MAINNET_URL=https://polygon-mainnet.g.alchemy.com/v2/API_KEY -RINKEBY_URL= -DEFAULT_FORK_BLOCK=15001901 - -## Always consider these compromised -MNEMONIC= -PRIVATE_KEY= \ No newline at end of file +RPC_URL= +PRIVATE_KEY= +FRAXLEND_CIRCUIT_BREAKER= +FRAXLEND_COMPTROLLER= +FRAXLEND_TIMELOCK= \ No newline at end of file diff --git a/README.md b/README.md index fd95958..6e9927d 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,32 @@ -## [Fraxlend Documentation](https://docs.frax.finance/fraxlend/fraxlend-overview) -
+# Fraxlend -# Introduction to Fraxlend +## Overview - Fraxlend is a lending platform that allows anyone to create a market between a pair of ERC-20 tokens. Any token part of a Chainlink data feed can be lent to borrowers or used as collateral. Each pair is an isolated, permission-less market which allows anyone to create and participate in lending and borrowing activities. -Fraxlend adheres to the EIP-4626: Tokenized Vault Standard, lenders are able to deposit ERC-20 assets into the pair and receive yield-bearing fTokens. +Fraxlend is a lending platform that allows anyone to create a market between a pair of ERC-20 tokens. Any token part of a Chainlink data feed can be lent to borrowers or used as collateral. Each pair is an isolated, permission-less market which allows anyone to create and participate in lending and borrowing activities. -## Overview +Fraxlend adheres to the EIP-4626: Tokenized Vault Standard, lenders are able to deposit ERC-20 assets into the pair and receive yield-bearing fTokens. ![https://github.com/FraxFinance/fraxlend/raw/main/documentation/_images/PairOverview.png](https://github.com/FraxFinance/fraxlend/raw/main/documentation/_images/PairOverview.png) -

-# Building and Testing +## Usage -- First copy `.env.example` to `.env` and fill in archival node URLs as well as a mnemonic (hardhat only) -- To download needed modules run `npm install` -- This repository contains scripts to compile using both Hardhat and Foundry -- You will need to [install foundry](https://book.getfoundry.sh/getting-started/installation) -- Install foundry submodules `git submodule init && git submodule update` +```bash +# Compile +forge build -Compilation +# Test +forge test -- `forge build` -- `npx hardhat compile` +# Deploy +source .env +forge script DeployFraxlend --private-key $PRIVATE_KEY --rpc-url $RPC_URL +``` -

-# License +## License Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/foundry.toml b/foundry.toml index bae55f0..0931e1c 100644 --- a/foundry.toml +++ b/foundry.toml @@ -1,21 +1,12 @@ [profile.default] -src = 'src/contracts' -test = 'src/test' -out = 'out' -libs = ['node_modules', 'lib'] -#block number -block_number = 100 -# The block timestamp in tests -block_timestamp = 1500 -# allow ffi -ffi = true -# gas limit in tests -gas_limit = 30000000 -# optimizer -optimizer = true -# optimizer runs -optimizer_runs = 200 -# use via-ir optimizer -# via_ir = true + src = 'src/contracts' + test = 'test' + out = 'out' + libs = ['node_modules', 'lib'] + + solc = "0.8.19" + ffi = true + optimizer = false + optimizer_runs = 200 # See more config options https://github.com/gakonst/foundry/tree/master/config \ No newline at end of file diff --git a/script/Deploy.s.sol b/script/Deploy.s.sol new file mode 100644 index 0000000..9494c55 --- /dev/null +++ b/script/Deploy.s.sol @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: The Unlicense +pragma solidity ^0.8.0; + +import {Script, console2} from "forge-std/Script.sol"; + +import {FraxlendPair} from "../src/contracts/FraxlendPair.sol"; +import {FraxlendWhitelist} from "../src/contracts/FraxlendWhitelist.sol"; +import {FraxlendPairRegistry} from "../src/contracts/FraxlendPairRegistry.sol"; +import {FraxlendPairDeployer, ConstructorParams} from "../src/contracts/FraxlendPairDeployer.sol"; + +contract DeployFraxlend is Script { + FraxlendWhitelist whitelist; + FraxlendPairRegistry registry; + FraxlendPairDeployer pairDeployer; + + function run() public virtual { + vm.startBroadcast(); + + console2.log("Deploying `FraxlendWhitelist`...\n"); + whitelist = new FraxlendWhitelist(); + console2.log("`FraxlendWhitelist`: ", address(whitelist), "\n"); + + console2.log("Deploying `FraxlendPairRegistry`...\n"); + registry = new FraxlendPairRegistry(msg.sender, new address[](0)); + console2.log("`FraxlendPairRegistry`: ", address(registry), "\n"); + + console2.log("Deploying `FraxlendPairDeployer`...\n"); + pairDeployer = new FraxlendPairDeployer( + ConstructorParams( + vm.envAddress("FRAXLEND_CIRCUIT_BREAKER"), + vm.envAddress("FRAXLEND_COMPTROLLER"), + vm.envAddress("FRAXLEND_TIMELOCK"), + address(whitelist), + address(registry) + ) + ); + console2.log("`FraxlendPairDeployer`: ", address(pairDeployer), "\n"); + + pairDeployer.setCreationCode(type(FraxlendPair).creationCode); + + address[] memory deployers = new address[](1); + deployers[0] = msg.sender; + + registry.setDeployers(deployers, true); + whitelist.setFraxlendDeployerWhitelist(deployers, true); + + vm.stopBroadcast(); + } +}