forked from debtdao/Line-of-Credit
-
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.
* add custom error message to spigot and escrow * add gas optimizations to all contracts * update tests * removes usd updates from each function since updated on every cratio check * optimize escrow liquidate call * init externalize modules * create libraries * minor cleanup * fix unused spigot loan tokens and add tests * added gorli test net config files and deploy scripts * testnet deploy files testnet deploy stuff * Adding Forge files * named things correclty * Renamed things again * add test to ensure tokens arent traded in spigotedloan if they are the same * changed address(this) to msg.sender * add getter for active/total ids and write invariant test that loaun.count == non null ids * add rollover function to reuse modules and add tests * libratize SpigiotedLoan * rename loan -> line * addtest for HAL-30 SpigLine defaul split validation * Adding Forge files (debtdao#91) * Adding Forge files * named things correclty * Renamed things again * changed address(this) to msg.sender * remove nvm file * added type conversion for assertEq * added Lineofcredit test file made address payable in deploy scriipt * fixed assertEq * remove sender, origin and rpc endpoints Co-authored-by: Momin Ahmad <[email protected]> Co-authored-by: Momin Ahmad <[email protected]>
- Loading branch information
1 parent
2cc3259
commit e41f5b2
Showing
8 changed files
with
396 additions
and
14 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 |
---|---|---|
|
@@ -3,6 +3,7 @@ package-lock.json | |
out | ||
docs | ||
.env | ||
lib | ||
|
||
|
||
#Hardhat files | ||
|
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,28 @@ | ||
pragma solidity ^0.8.9; | ||
|
||
|
||
import "forge-std/Test.sol"; | ||
import { Denominations } from "@chainlink/contracts/src/v0.8/Denominations.sol"; | ||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; | ||
|
||
import {LineLib} from "../../utils/LineLib.sol"; | ||
import {CreditLib} from "../../utils/CreditLib.sol"; | ||
import {CreditListLib} from "../../utils/CreditListLib.sol"; | ||
import {MutualConsent} from "../../utils/MutualConsent.sol"; | ||
import {InterestRateCredit} from "../interest-rate/InterestRateCredit.sol"; | ||
|
||
import {IOracle} from "../../interfaces/IOracle.sol"; | ||
import {ILineOfCredit} from "../../interfaces/ILineOfCredit.sol"; | ||
|
||
contract LineTest is Test{ | ||
|
||
|
||
|
||
function setUp() public { | ||
|
||
|
||
} | ||
|
||
|
||
} |
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,89 @@ | ||
pragma solidity ^0.8.9; | ||
|
||
import {Script} from "../lib/forge-std/src/Script.sol"; | ||
import {CreditLib } from "../contracts/utils/CreditLib.sol"; | ||
import {CreditListLib } from "../contracts/utils/CreditListLib.sol"; | ||
import {LineLib } from "../contracts/utils/LineLib.sol"; | ||
import {SpigotedLineLib } from "../contracts/utils/SpigotedLineLib.sol"; | ||
import {RevenueToken} from "../contracts/mock/RevenueToken.sol"; | ||
import {SimpleOracle} from "../contracts/mock/SimpleOracle.sol"; | ||
import {SecuredLine} from "../contracts/modules/credit/SecuredLine.sol"; | ||
import {Spigot} from "../contracts/modules/spigot/Spigot.sol"; | ||
import {Escrow} from "../contracts/modules/escrow/Escrow.sol"; | ||
|
||
import "hardhat/console.sol"; | ||
|
||
|
||
contract DeployScript is Script { | ||
Escrow escrow; | ||
RevenueToken supportedToken1; | ||
RevenueToken supportedToken2; | ||
RevenueToken unsupportedToken; | ||
SimpleOracle oracle; | ||
SecuredLine line; | ||
uint mintAmount = 100 ether; | ||
uint MAX_INT = 115792089237316195423570985008687907853269984665640564039457584007913129639935; | ||
uint minCollateralRatio = 1 ether; // 100% | ||
uint128 drawnRate = 100; | ||
uint128 facilityRate = 1; | ||
|
||
address borrower; | ||
address arbiter; | ||
address lender; | ||
|
||
function run() external { | ||
|
||
vm.startBroadcast(); | ||
borrower = msg.sender; | ||
lender = msg.sender; | ||
arbiter = msg.sender; | ||
supportedToken1 = new RevenueToken(); | ||
supportedToken2 = new RevenueToken(); | ||
unsupportedToken = new RevenueToken(); | ||
|
||
Spigot spigot = new Spigot(msg.sender, borrower, borrower); | ||
oracle = new SimpleOracle(address(supportedToken1), address(supportedToken2)); | ||
escrow = new Escrow(minCollateralRatio, address(oracle), msg.sender, borrower); | ||
|
||
line = new SecuredLine( | ||
address(oracle), | ||
arbiter, | ||
borrower, | ||
payable(address(0)), | ||
address(spigot), | ||
address(escrow), | ||
150 days, | ||
0 | ||
); | ||
|
||
console.log("sender", msg.sender); | ||
console.log("spigot owner", spigot.owner()); | ||
console.log("line address", address(line)); | ||
|
||
escrow.updateLine(address(line)); | ||
spigot.updateOwner(address(line)); | ||
|
||
line.init(); | ||
|
||
escrow.enableCollateral( address(supportedToken1)); | ||
escrow.enableCollateral( address(supportedToken2)); | ||
_mintAndApprove(); | ||
escrow.addCollateral(1 ether, address(supportedToken2)); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
|
||
function _mintAndApprove() internal { | ||
supportedToken1.mint(borrower, mintAmount); | ||
supportedToken1.approve(address(escrow), MAX_INT); | ||
supportedToken1.approve(address(line), MAX_INT); | ||
|
||
supportedToken2.mint(borrower, mintAmount); | ||
supportedToken2.approve(address(escrow), MAX_INT); | ||
supportedToken2.approve(address(line), MAX_INT); | ||
|
||
unsupportedToken.mint(borrower, mintAmount); | ||
unsupportedToken.approve(address(escrow), MAX_INT); | ||
unsupportedToken.approve(address(line), MAX_INT); | ||
} | ||
} |
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,15 @@ | ||
pragma solidity ^0.8.9; | ||
|
||
import {Script} from "../lib/forge-std/src/Script.sol"; | ||
import {RevenueToken} from "../contracts/mock/RevenueToken.sol"; | ||
|
||
contract SmallDeploy is Script { | ||
RevenueToken token; | ||
function run() external{ | ||
vm.startBroadcast(); | ||
|
||
token = new RevenueToken(); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
170 changes: 170 additions & 0 deletions
170
deployments/gorli/solcInputs/ae19c6f185a746e8a25af9abfb56b5c9.json
Large diffs are not rendered by default.
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,75 @@ | ||
[profile.default] | ||
src = 'contracts' | ||
test = 'test' | ||
script = 'script' | ||
out = 'out' | ||
libs = [ | ||
'lib', | ||
'node_modules', | ||
] | ||
remappings = [ | ||
'@chainlink/=node_modules/@chainlink/', | ||
'@ensdomains/=node_modules/@ensdomains/', | ||
'@openzeppelin/=node_modules/@openzeppelin/', | ||
'ds-test/=lib/ds-test/src/', | ||
'forge-std/=lib/forge-std/src/', | ||
'hardhat-deploy/=node_modules/hardhat-deploy/', | ||
'hardhat/=node_modules/hardhat/', | ||
] | ||
libraries = [] | ||
cache = true | ||
cache_path = 'cache' | ||
broadcast = 'broadcast' | ||
allow_paths = [] | ||
include_paths = [] | ||
force = false | ||
evm_version = 'london' | ||
gas_reports = ['*'] | ||
gas_reports_ignore = [] | ||
auto_detect_solc = true | ||
offline = false | ||
optimizer = true | ||
optimizer_runs = 200 | ||
verbosity = 0 | ||
ignored_error_codes = [ | ||
1878, | ||
5574, | ||
] | ||
fuzz_runs = 256 | ||
invariant_runs = 256 | ||
invariant_depth = 15 | ||
invariant_fail_on_revert = false | ||
invariant_call_override = false | ||
ffi = false | ||
initial_balance = '0xffffffffffffffffffffffff' | ||
block_number = 1 | ||
gas_limit = 9223372036854775807 | ||
block_base_fee_per_gas = 0 | ||
block_coinbase = '0x0000000000000000000000000000000000000000' | ||
block_timestamp = 1 | ||
block_difficulty = 0 | ||
memory_limit = 33554432 | ||
extra_output = [] | ||
extra_output_files = [] | ||
fuzz_max_local_rejects = 1024 | ||
fuzz_max_global_rejects = 65536 | ||
names = false | ||
sizes = false | ||
via_ir = false | ||
no_storage_caching = false | ||
bytecode_hash = 'ipfs' | ||
sparse_mode = false | ||
build_info = false | ||
|
||
[profile.default.rpc_storage_caching] | ||
chains = 'all' | ||
endpoints = 'all' | ||
|
||
[fmt] | ||
line_length = 120 | ||
tab_width = 4 | ||
bracket_spacing = false | ||
int_types = 'long' | ||
func_attrs_with_params_multiline = true | ||
quote_style = 'double' | ||
number_underscore = 'preserve' |