Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ft combined l2 #39

Open
wants to merge 299 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
299 commits
Select commit Hold shift + click to select a range
fc4ecd1
Merge pull request #7 from Brahma-fi/batcher-convex
Bapi-Reddy Mar 10, 2022
143f775
compilation changes
Mar 10, 2022
4ffec54
removed lpToken assignment and fixed safe approve error
Mar 10, 2022
a3b3c84
fixed approve error
Mar 10, 2022
74c418f
added tests and removed solmate
Mar 10, 2022
8ccb018
fixed only keeper
Mar 11, 2022
43d903c
tests for add and remove
Mar 11, 2022
4c29975
added batcher
Mar 11, 2022
3f7d0b8
Adding deposit tracking and maxlimt
0xad1onchain Mar 11, 2022
a3a64b1
Merge pull request #8 from Brahma-fi/hauler-deposit-limit
Bapi-Reddy Mar 11, 2022
1f04cfa
batcher deposit verified
Mar 11, 2022
ab083bc
setup for batcher tester
Mar 11, 2022
7ad71bb
completed testing of deposit/withdraw
Mar 12, 2022
ab26fe0
added usdc to curve lp deposit
Mar 12, 2022
bbd2172
deposit verification failing
Mar 12, 2022
322e5ec
fixed the issue in testcase
Mar 12, 2022
f849b10
Merge branch 'master' into testing
Bapi-Reddy Mar 12, 2022
6403b68
Merge pull request #9 from Brahma-fi/testing
Bapi-Reddy Mar 12, 2022
fe29c6d
fixed setPosvalue in Perp
Mar 14, 2022
636515d
added test cases for metarouter
Mar 14, 2022
b55aa96
added test cases for funds transfer and keeper/governance change
Mar 14, 2022
837a248
added deployment scripts
Mar 14, 2022
c5717c5
Merge pull request #10 from Brahma-fi/testing
Bapi-Reddy Mar 14, 2022
1ad9bc2
Replacing router with hauler
0xad1onchain Mar 14, 2022
5e683c7
Adding Hauler deployment script
0xad1onchain Mar 14, 2022
413e422
Adding onlyBatcher
0xad1onchain Mar 14, 2022
b61fcf7
Merge pull request #11 from Brahma-fi/onlyBatcher
Bapi-Reddy Mar 14, 2022
a5f73d8
added tests for batcher on hauler
Mar 14, 2022
81ff936
added tests for batcher only deposit
Mar 14, 2022
936fadb
Adding sweep to TE
0xad1onchain Mar 15, 2022
8142647
ft: merge with master
Pradeep-selva Mar 16, 2022
64c0664
ft: deposit & open tests
Pradeep-selva Mar 16, 2022
e82c555
ft: integrate convex booster to deposit&stake
Pradeep-selva Mar 16, 2022
f5c7124
ft: harvester setup & reward harvesting tests
Pradeep-selva Mar 16, 2022
1f3d6f2
ft: close position & withdraw tests
Pradeep-selva Mar 16, 2022
d8f0e43
Adding changes to Perp TE
0xad1onchain Mar 16, 2022
1358713
Editing existing constants
0xad1onchain Mar 16, 2022
e68a71a
ft: getting reward test fixes
Pradeep-selva Mar 16, 2022
45b53d4
bg: fixed withdrawal flow on convex
Pradeep-selva Mar 16, 2022
8f1d946
rf: migrate from univ3->v2
Pradeep-selva Mar 16, 2022
71f9c9c
added swap using crv and uniswap
Mar 17, 2022
3119e91
ft: harvester add _crv and additional fixes
Pradeep-selva Mar 17, 2022
c7e74c7
ft: remove approveRewardTokensToHarvester
Pradeep-selva Mar 17, 2022
5df457c
ft: testing new convex flow
Pradeep-selva Mar 17, 2022
f7f5b46
removed decimal part for conversion
Mar 17, 2022
e53f072
ft: lp-> usdc & usdc-> lp estimation fix
Pradeep-selva Mar 17, 2022
bdeb5f5
simplification
Mar 17, 2022
d056ae9
rf: minor cleanup
Pradeep-selva Mar 17, 2022
36e6a1c
rf: test changes
Pradeep-selva Mar 17, 2022
3ec9bd3
convex test one block
Mar 17, 2022
f224a84
Merge pull request #13 from Brahma-fi/convex-tests
Pradeep-selva Mar 17, 2022
e6b5dd7
brett review comments
Mar 17, 2022
64a8537
Merge pull request #14 from Brahma-fi/convex-tests
Pradeep-selva Mar 17, 2022
aa50a34
ft: harvester deployment
Pradeep-selva Mar 18, 2022
f7f260c
ft: ConvexTradeExecutor deployment
Pradeep-selva Mar 18, 2022
c37d90a
ft: bytes generation script
Pradeep-selva Mar 18, 2022
04a987d
ft: ConvexTradeExecutor tests for mainnet
Pradeep-selva Mar 18, 2022
ea28636
ft: lp->usdc conversion checks and access checks
Pradeep-selva Mar 21, 2022
0c5a5d6
Adding changes to Perp TE
0xad1onchain Mar 16, 2022
7560cd7
Editing existing constants
0xad1onchain Mar 16, 2022
5d9df15
comitting perp handler changes
0xad1onchain Mar 22, 2022
4b62491
testing changes
0xad1onchain Mar 22, 2022
4fc807a
fixing conflicts
0xad1onchain Mar 22, 2022
421557c
Adding tests
0xad1onchain Mar 23, 2022
10c3fb4
Adding long position tests
0xad1onchain Mar 23, 2022
0333ea1
formating files
Mar 23, 2022
43d112f
fixed openLong/Short issue
Mar 23, 2022
9d2b03e
Implementing PR review
0xad1onchain Mar 23, 2022
0edafa0
Fixing Movr calldata validation bugs
0xad1onchain Mar 24, 2022
027eba6
Adding PerpL2 deployer
0xad1onchain Mar 24, 2022
bd8a01f
Adding more tests for PerpL1
0xad1onchain Mar 24, 2022
a9bbc98
Adding test validation for L2 messages
0xad1onchain Mar 25, 2022
5ae2c06
Removing hardhat console
0xad1onchain Mar 25, 2022
cda2dff
Hardcoding chain Ids
0xad1onchain Mar 25, 2022
c2b7f30
Cleaning tests
0xad1onchain Mar 25, 2022
5e06466
Fomatting code
0xad1onchain Mar 25, 2022
ceae0d1
Removing hardhat config urls
0xad1onchain Mar 25, 2022
46b02d3
Adding test documentation
0xad1onchain Mar 25, 2022
0fa3839
Merge pull request #12 from Brahma-fi/PerpTests
Bapi-Reddy Mar 25, 2022
05f2693
deployment scripts
Mar 25, 2022
0edbb7f
merge
Pradeep-selva Mar 25, 2022
31cf2eb
ft: deposit and withdraw processing scripts
Pradeep-selva Mar 25, 2022
7e3bef3
added flow as comments
Mar 25, 2022
1cccc56
added deployed contract addresses
Mar 25, 2022
729169a
ft: batchProcessor script
Pradeep-selva Mar 25, 2022
fe9e975
added scripts for batcher processing
Mar 28, 2022
b7266d3
added scripts for simulating perpl2 closeposition
Mar 28, 2022
3382d11
Upgrading Batcher
0xad1onchain Mar 29, 2022
33094a6
added fee claims
Mar 30, 2022
59144bb
Adding review changes
0xad1onchain Mar 31, 2022
ca2e375
Natspecing the shit out of batcher
0xad1onchain Mar 31, 2022
6940cf0
ft: events added to ConvexPositionHandler
Pradeep-selva Mar 31, 2022
9dabbfd
Adding Perp Handler improvements
0xad1onchain Mar 31, 2022
19b010f
Merge pull request #15 from Brahma-fi/ft_batcher_improvements
Bapi-Reddy Apr 1, 2022
b21bf65
added scripts for testing
Apr 2, 2022
96cf362
🔥 Lit documented code
Apr 2, 2022
8d90faa
intial doc for hauler
Apr 2, 2022
41409ad
📝 updated doc specs
Apr 4, 2022
186184c
fixed prevHaulerFunds part
Apr 4, 2022
ebcb64d
Merge pull request #17 from Brahma-fi/ft-hauler-changes
Bapi-Reddy Apr 4, 2022
34cda31
added allowance check
Apr 4, 2022
cac6670
Merge pull request #18 from Brahma-fi/ft-hauler-changes
Bapi-Reddy Apr 4, 2022
3ad11dc
dc: ConvexPositionHandler docs
Pradeep-selva Apr 4, 2022
4172989
dc: Harvester docs
Pradeep-selva Apr 4, 2022
2a70e4b
dc: ConvexTradeExecutor detailed docs
Pradeep-selva Apr 4, 2022
07dd3f4
dc: ConvexTradeExecutor docs
Pradeep-selva Apr 4, 2022
6513f67
dc: ConvexPositionHandler doc changes
Pradeep-selva Apr 4, 2022
7dba82f
dc: doc fixes
Pradeep-selva Apr 4, 2022
357ac3b
setup for testing
Apr 5, 2022
bb60c7b
🐛 fixed fees part on hauler
Apr 5, 2022
4f4c75f
Merge pull request #19 from Brahma-fi/convex-docs
Bapi-Reddy Apr 5, 2022
32ce682
added env_example
Apr 5, 2022
9e691dd
Merge branch 'master' of github.com:Brahma-fi/protected_moonshots
Apr 5, 2022
efe5863
added reentrancy gaurd & fees check
Apr 5, 2022
b6ea81b
🔥 removed accuredFees
Apr 6, 2022
7eed6cb
📝 added docs for architecutre
Apr 6, 2022
cdd457e
💚 fix to architecture image
Apr 6, 2022
236eb35
rf: Hauler -> Vault
Pradeep-selva Apr 6, 2022
1e6b931
rf: Hauler -> Vault
Pradeep-selva Apr 6, 2022
b208690
♻️ hauler --> vault in test
Apr 6, 2022
b74e0ab
🔧 minor fix for perfomanceFee
Apr 6, 2022
3e66826
🔧 minor fix in var names
Apr 6, 2022
dfeeb5f
🔀 merge changes from master
Apr 6, 2022
187ae40
Merge pull request #20 from Brahma-fi/ft-hauler-changes
Bapi-Reddy Apr 6, 2022
f7e7879
♻️refactored Readme
Apr 6, 2022
7b9adb6
added License file
Bapi-Reddy Apr 6, 2022
81ee7b6
Formatting acc to doc standard
0xad1onchain Apr 6, 2022
cd2a5b2
changing accept gov msg
0xad1onchain Apr 6, 2022
c31a7a3
Merge pull request #21 from Brahma-fi/ft_batcher_improvements
0xad1onchain Apr 6, 2022
374788a
Adding spec docs
0xad1onchain Apr 6, 2022
96028b5
Merge branch 'master' into ft_perp_improvements
0xad1onchain Apr 6, 2022
ef00215
Merge pull request #16 from Brahma-fi/ft_perp_improvements
0xad1onchain Apr 6, 2022
96eaca8
Fixing vault rename
0xad1onchain Apr 6, 2022
6337079
rf: hauler -> vault fixes
Pradeep-selva Apr 6, 2022
6a5a182
rf: hauler -> vault fixes (2)
Pradeep-selva Apr 6, 2022
a7fa04a
Making events common for position handlers
0xad1onchain Apr 6, 2022
d5d89b5
Updating PerpL2 tests
0xad1onchain Apr 6, 2022
3aa2e8d
Adding batcher test fix, utils getvault fix
0xad1onchain Apr 6, 2022
a7f61a8
ft: minor changes in ConvexTE
Pradeep-selva Apr 6, 2022
da3f899
Adding test chains
0xad1onchain Apr 6, 2022
529ad92
Updating IPositionHandler
0xad1onchain Apr 6, 2022
04839d1
ft: slither tests
Pradeep-selva Apr 6, 2022
9da6514
🔒️error strings reduction and new testcases
Apr 7, 2022
660460e
🔧 perp l1 fixes
Apr 7, 2022
3d25950
🔧 perp l2 fixes
Apr 7, 2022
39289cc
📦 repacking test cases
Apr 7, 2022
91af8f0
Merge pull request #22 from Brahma-fi/ft_cleanup
Bapi-Reddy Apr 8, 2022
7351c7f
Merge pull request #23 from Brahma-fi/ft_docs
Bapi-Reddy Apr 8, 2022
eb9e85f
Update README.md
0xad1onchain Apr 8, 2022
3ddb712
Update README.md
0xad1onchain Apr 8, 2022
58a4134
ft: PerpPositionHandlerL2.sol slither tests
Pradeep-selva Apr 8, 2022
5cdde7c
Merge branch 'master' of https://github.com/Brahma-fi/protected_moons…
Pradeep-selva Apr 8, 2022
5182f9b
🚀 changes for unified testing
Apr 11, 2022
c410751
Adding security reports
0xad1onchain Apr 11, 2022
57eccca
ft: fix convex docs
Pradeep-selva Apr 11, 2022
f101579
ft: fix convex docs
Pradeep-selva Apr 11, 2022
1ad30ea
ft: fix convex docs and natspec
Pradeep-selva Apr 11, 2022
06abda7
Updating documentation
0xad1onchain Apr 11, 2022
9f76fde
Merge changes
0xad1onchain Apr 11, 2022
8d04195
init test pipeline
Arthurgallina1 Apr 12, 2022
c0991a1
add checkout
Arthurgallina1 Apr 12, 2022
54049c0
add secrets on pipeline env
Arthurgallina1 Apr 12, 2022
6a4aa87
add right test command
Arthurgallina1 Apr 12, 2022
1e5daa3
update yaml to remove echo, update env example
Arthurgallina1 Apr 12, 2022
a8860ac
update hardconfig and pipeline to run test on mainnet and optimism
Arthurgallina1 Apr 12, 2022
6404f2a
fix typo on mainnet
Arthurgallina1 Apr 12, 2022
d04a117
ft: claim event
Pradeep-selva Apr 12, 2022
0de44e9
Merge pull request #24 from Brahma-fi/feature/test-pipeline
0xad1onchain Apr 13, 2022
fe01e29
🚑 fix for slippage
Apr 14, 2022
68ea50a
Adding fix
0xad1onchain Apr 19, 2022
a4ff78b
🔧 added brett review changes
Apr 21, 2022
4a20c45
Removing CRV LP deposit
0xad1onchain Apr 21, 2022
7514c60
Fixing tests
0xad1onchain Apr 21, 2022
976e78c
Adding bretts changes
0xad1onchain Apr 21, 2022
d25daab
Adding bapis review changes
0xad1onchain Apr 22, 2022
cb95751
Fixing spelling
0xad1onchain Apr 22, 2022
6575d51
Removing unused imports
0xad1onchain Apr 22, 2022
835123e
Merge pull request #25 from Brahma-fi/vault_deposit_limit_fix
Bapi-Reddy Apr 22, 2022
acac4af
ft: add prettier
Pradeep-selva Apr 22, 2022
8677c67
ft: prettified files
Pradeep-selva Apr 22, 2022
b315c35
Merge pull request #29 from Brahma-fi/add-prettier
Bapi-Reddy Apr 22, 2022
893a434
🔧 new deployment script for batcher
Apr 22, 2022
09ad733
🔧 formatted
Apr 22, 2022
8e3ef4e
Adding recipient to erc20 flow functions
0xad1onchain Apr 25, 2022
712d301
Fixing comments
0xad1onchain Apr 25, 2022
6dcede3
Adding relevant tests
0xad1onchain Apr 25, 2022
c6983ac
Merge pull request #31 from Brahma-fi/zapper_support
Bapi-Reddy Apr 25, 2022
623254e
⬆️ new emergencyMode on Vault
Apr 26, 2022
670445e
⚡prettier formatting
Apr 26, 2022
8622e93
🚨 batcher conflicts fix
Apr 26, 2022
62f0edd
📝 package.json
Apr 26, 2022
bf13307
🐛 fix for batcher testing
Apr 26, 2022
5202548
Merge pull request #26 from Brahma-fi/ft-vault-changes
0xad1onchain Apr 26, 2022
75d8ddb
Adding strategy to PerpL2
0xad1onchain Apr 26, 2022
7b91433
🔨 fix function roles
Apr 26, 2022
8e9310d
Merge pull request #33 from Brahma-fi/ft-role-changes
Bapi-Reddy Apr 26, 2022
a2968c1
Fixing tests
0xad1onchain Apr 26, 2022
979b629
Fixing typos
0xad1onchain Apr 26, 2022
f0a0dac
Renaming strategy to strategist
0xad1onchain Apr 26, 2022
2066af5
Renaming strategy to strategist
0xad1onchain Apr 26, 2022
9e541c9
Merge pull request #32 from Brahma-fi/perp_l2_access_changes
Bapi-Reddy Apr 26, 2022
8a6df96
added vault docs
May 2, 2022
b0a7209
Porting batcher, vault from eth_maxi
0xad1onchain May 2, 2022
5899429
Adding perp test environment check
0xad1onchain May 2, 2022
56d7244
🎨 changes for convex te
May 2, 2022
b049050
ft: minor changes
Pradeep-selva May 2, 2022
3a85caa
Merge pull request #34 from Brahma-fi/review_changes
Pradeep-selva May 2, 2022
36b15b3
Merge branch 'ft_docs_update' of https://github.com/Brahma-fi/protect…
Pradeep-selva May 2, 2022
1bfbe16
dc: changes in convex docs
Pradeep-selva May 2, 2022
363454b
Removing old methods
0xad1onchain May 2, 2022
858e146
Merge pull request #35 from Brahma-fi/ft_docs_update
Bapi-Reddy May 2, 2022
b390b34
Adding batcher fix for valid signature deposit recipient
0xad1onchain May 16, 2022
32d30c8
3.3_unwanted_deposits_withdraws_fix
0xad1onchain May 17, 2022
0c2c815
3.5_invalid_business_logic_fix
0xad1onchain May 17, 2022
c2d85f2
curve_peg_fixes
0xad1onchain May 17, 2022
8a9d8e2
Fixing outdated documentation
0xad1onchain May 23, 2022
413b9cc
3.1 fixing deposit frontrun
0xad1onchain May 24, 2022
6f14028
Adding usdc balance to positionInUSDC for l2 perp controller
0xad1onchain May 26, 2022
239956a
Adding usdc balance to positionInUSDC for l2 perp controller
0xad1onchain May 26, 2022
fc5ab0b
Adding permit to batcher for USDC want token
0xad1onchain May 26, 2022
2437144
Adding EIP2612 Permit to Vault tokens
0xad1onchain May 26, 2022
e3fba4f
Adding migration contracts
0xad1onchain May 28, 2022
80db99a
Adding migration testing script
0xad1onchain May 28, 2022
14de6b9
Merge pull request #37 from Brahma-fi/audit-fixes
0xad1onchain Jun 1, 2022
4c7bdc8
ft: ported lyra files
Pradeep-selva Jun 7, 2022
9a1ab2d
ft: add chainlink data feed
Pradeep-selva Jun 7, 2022
b240d58
ft: uni wrapper for usdc -> susd
Pradeep-selva Jun 7, 2022
ea9e914
ft: helper to get usdc price in susd
Pradeep-selva Jun 7, 2022
0baa96f
bg: normalize to 1e18 instead of chainlink decimals
Pradeep-selva Jun 7, 2022
6d4b3be
ft: position in want token lyra L2 fixed
Pradeep-selva Jun 7, 2022
945e2cf
ft: fixed eth deposit and withdraw flows to usdc
Pradeep-selva Jun 7, 2022
f1dca73
ft: remove lyra globals
Pradeep-selva Jun 7, 2022
f553c7b
ft: remove iweth9
Pradeep-selva Jun 7, 2022
c94fae9
Adding comments
0xad1onchain Jun 7, 2022
99943c2
Adding Perp L1 tests
0xad1onchain Jun 7, 2022
37d56ad
ft: want token balance added in position calculation
Pradeep-selva Jun 7, 2022
754f6e8
Merge branch 'ft-moonshots-v2' of https://github.com/Brahma-fi/protec…
Pradeep-selva Jun 7, 2022
2bc9b2f
ft: change safeApprove -> approve
Pradeep-selva Jun 8, 2022
d08f624
added new L2 Executor
Jun 13, 2022
bbca8dc
fixed issues on compiling
Jun 13, 2022
d7a5624
all compilier issues fixed
Jun 13, 2022
e89febf
combined position operations
Jun 14, 2022
0fcf6ea
combined with no errors
Jun 14, 2022
68b71b3
reduced positionInWantToken
Jun 14, 2022
8dd43a5
removed perpL2, lyraL2 and PerpL1, LyraL1
Jun 14, 2022
d09d025
struct clean ups
Jun 14, 2022
6599203
Merge pull request #38 from Brahma-fi/ft_migrator
0xad1onchain Jun 15, 2022
2078810
Merge branch 'master' into ft_combined_l2
0xad1onchain Jun 16, 2022
680d6bf
Merge branch 'master' of https://github.com/Brahma-fi/protected_moons…
0xad1onchain Jun 16, 2022
37dbef9
Adding PerpL2Handler
0xad1onchain Jun 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ALCHEMY_KEY=
ETHERSCAN_API_KEY=
TENDERLY_FORK_ID=
QUICKNODE_OPTIMISM_URL=
OPTIMISM_BLOCK_NUMBER=
BLOCK_NUMBER=
FORK_OPTIMISM=
37 changes: 37 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Run Tests on Push

on: push

env:
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
TENDERLY_FORK_ID: ${{ secrets.TENDERLY_FORK_ID }}
QUICKNODE_OPTIMISM_URL: ${{ secrets.QUICKNODE_OPTIMISM_URL }}
OPTIMISM_BLOCK_NUMBER: ${{ secrets.OPTIMISM_BLOCK_NUMBER }}
BLOCK_NUMBER: ${{ secrets.BLOCK_NUMBER }}

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Install
run: npm install

- name: Compile
run: npx hardhat compile

- name: Test Mainnet 🚨
env:
FORK_OPTIMISM: ${{ secrets.FORK_OPTIMISM_MAINNET }}
run: npx hardhat test test/mainnet/*

- name: Test Optimism 🚨
env:
FORK_OPTIMISM: ${{ secrets.FORK_OPTIMISM }}
run: npx hardhat test test/optimism/*
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.env
node_modules/*

coverage/*
artifacts/
cache/
types/
types/
src/
coverage.json
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

64 changes: 22 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,30 @@
# Starter Hardhat Template for advanced users

This project demonstrates an advanced Hardhat use case, integrating other tools commonly used alongside Hardhat in the ecosystem.

Some of the pre-included features:

- Preconfigured Forking
- Gas Estimates
- Contract size alert on compilation
- Automatic typedef generation for contracts
- Easy to use `.env` file for configuration

```shell
npx hardhat accounts
npx hardhat compile
npx hardhat clean
npx hardhat test
npx hardhat node
npx hardhat help
REPORT_GAS=true npx hardhat test
npx hardhat coverage
npx hardhat run scripts/deploy.ts
TS_NODE_FILES=true npx ts-node scripts/deploy.ts
npx eslint '**/*.{js,ts}'
npx eslint '**/*.{js,ts}' --fix
npx prettier '**/*.{json,sol,md}' --check
npx prettier '**/*.{json,sol,md}' --write
npx solhint 'contracts/**/*.sol'
npx solhint 'contracts/**/*.sol' --fix
```
# Brahma

# Etherscan verification
[![MythXBadge](https://badgen.net/https/api.mythx.io/v1/projects/35f819a5-d41f-46be-b931-56d6db199881/badge/data?cache=300&icon=https://raw.githubusercontent.com/ConsenSys/mythx-github-badge/main/logo_white.svg)](https://dashboard.mythx.io/#/console/projects/35f819a5-d41f-46be-b931-56d6db199881)

To try out Etherscan verification, you first need to deploy a contract to an Ethereum network that's supported by Etherscan, such as Ropsten.
This repository contains the smart contracts source code and configuration for Brahma Vaults. The repository uses Hardhat as development environment for compilation, testing and deployment tasks. The repository mainly hosts the source file for protected moonshot vault.

In this project, copy the .env.example file to a file named .env, and then edit it to fill in the details. Enter your Etherscan API key, your Ropsten node URL (eg from Alchemy), and the private key of the account which will send the deployment transaction. With a valid .env file in place, first deploy your contract:
## What is Protected MoonShot Vault?

```shell
hardhat run --network ropsten scripts/sample-script.ts
```
The Protected Moonshot DegenVault aims to achieve to hold stables but still take leveraged positions to maximise the base yield.

Then, copy the deployment address and paste it in to replace `DEPLOYED_CONTRACT_ADDRESS` in this command:
## Structure

```shell
npx hardhat verify --network ropsten DEPLOYED_CONTRACT_ADDRESS "Hello, Hardhat!"
```
[contracts](./contracts): Contains all the source code of contracts used for protected moonshot vault. <br>
[docs](./docs): Contains all the documentation related core contracts.

## Connect with the community

# Performance optimizations
You can join at the [Discord](https://discord.gg/brahma) channel for asking questions about the protocol or talk about new defi strategies.

For faster runs of your tests and scripts, consider skipping ts-node's type checking by setting the environment variable `TS_NODE_TRANSPILE_ONLY` to `1` in hardhat's environment. For more details see [the documentation](https://hardhat.org/guides/typescript.html#performance-optimizations).
## Setup

You can install `hardhat` as an NPM package to get started with contracts. Setup an `.env` as shown in [.env_example](./env_example).
You can run the full test suite with the following commands:

```
# In one terminal
npx hardhat test test/mainnet/*
export FORK_OPTIMISM = 1
npx hardhat test test/optimism/*
```
84 changes: 84 additions & 0 deletions contracts/BaseTradeExecutor.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import "../interfaces/ITradeExecutor.sol";
import "../interfaces/IVault.sol";

abstract contract BaseTradeExecutor is ITradeExecutor {
uint256 constant MAX_INT = 2**256 - 1;

ActionStatus public override depositStatus;
ActionStatus public override withdrawalStatus;

address public override vault;

constructor(address _vault) {
vault = _vault;
IERC20(vaultWantToken()).approve(vault, MAX_INT);
}

function vaultWantToken() public view returns (address) {
return IVault(vault).wantToken();
}

function governance() public view returns (address) {
return IVault(vault).governance();
}

function keeper() public view returns (address) {
return IVault(vault).keeper();
}

modifier onlyGovernance() {
require(msg.sender == governance(), "access :: Governance");
_;
}

modifier onlyKeeper() {
require(msg.sender == keeper(), "access :: Keeper");
_;
}

function sweep(address _token) public onlyGovernance {
IERC20(_token).transfer(
governance(),
IERC20(_token).balanceOf(address(this))
);
}

function initiateDeposit(bytes calldata _data) public override onlyKeeper {
require(!depositStatus.inProcess, "Deposit already in process");
depositStatus.inProcess = true;
_initateDeposit(_data);
}

function confirmDeposit() public override onlyKeeper {
require(depositStatus.inProcess, "No Deposit Pending");
_confirmDeposit();
depositStatus.inProcess = false;
}

function initateWithdraw(bytes calldata _data) public override onlyKeeper {
require(!withdrawalStatus.inProcess, "Withdraw already in process");
withdrawalStatus.inProcess = true;
_initiateWithdraw(_data);
}

function confirmWithdraw() public override onlyKeeper {
require(withdrawalStatus.inProcess, "No Withdraw Pending");
_confirmWithdraw();
withdrawalStatus.inProcess = false;
}

/// Internal Funcs

function _initateDeposit(bytes calldata _data) internal virtual;

function _confirmDeposit() internal virtual;

function _initiateWithdraw(bytes calldata _data) internal virtual;

function _confirmWithdraw() internal virtual;
}
Loading