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

[WIP] Skybridge v3 → main #30

Open
wants to merge 217 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
217 commits
Select commit Hold shift + click to select a range
ae5f1e0
added UML doc and skypools diagram to docs folder
jbarber13 Aug 11, 2021
00802e8
updated diagram, added stub functions and initial logic for skypools
jbarber13 Aug 12, 2021
47343c9
Switching to skypools branch
jbarber13 Aug 16, 2021
b3f2ecc
updated recordSkyPoolsTx
jbarber13 Aug 16, 2021
ec81ad0
updated recordSkyPoolsTx
jbarber13 Aug 16, 2021
89009ce
recordSkyPoolsTX complete and tests passing
jbarber13 Aug 17, 2021
e349e2d
quick fix to include logic for miner fees
jbarber13 Aug 17, 2021
97368c4
First round of tests for redeemERC20 token, decimals are off by 8...
jbarber13 Aug 18, 2021
99d1d50
redeemERC20Token tests passing with explicit console logs to step thr…
jbarber13 Aug 19, 2021
b08c6c6
updated tests, float values in 18 or 8 decimals?
jbarber13 Aug 23, 2021
613cf7c
Added interfaces for ParaSwap
jbarber13 Aug 24, 2021
8b8487b
working on API data for ParaSwap
jbarber13 Aug 25, 2021
60de14b
API is working for paraswap in testing
jbarber13 Aug 27, 2021
c900fe9
First attempt at executing paraswap for skypools
jbarber13 Sep 5, 2021
8f384fa
Fixed spelling mistake: IAugustusSwapper
jbarber13 Sep 5, 2021
60255a7
feat: modified registration logic for node
syrohei Sep 6, 2021
76f6ef1
Merge pull request #14 from SwingbyProtocol/f-staking
jbarber13 Sep 6, 2021
d1bec04
Call to uniswap proxy failed
jbarber13 Sep 6, 2021
e702335
Call to uniswap proxy failed
jbarber13 Sep 6, 2021
9da06bf
Merge branch 'skypools' of https://github.com/SwingbyProtocol/skybrid…
jbarber13 Sep 6, 2021
ba3d4f9
low-level call failed
jbarber13 Sep 7, 2021
5069958
Switched to ParaAPI V5, which fixes issues regarding the number of pa…
jbarber13 Sep 10, 2021
2a2e838
Switched all to paraV5, still having approval issues
jbarber13 Sep 10, 2021
bdbc74e
Balance is not updating
jbarber13 Sep 14, 2021
a7b1da4
Balances seeded, going through the steps to execute paraswap
jbarber13 Sep 16, 2021
ab04257
TXs going through in forked hardhat
jbarber13 Sep 16, 2021
108cab5
Updated comments for doParaSwap
jbarber13 Sep 16, 2021
c96d013
Added deposit functions and other features for flow 2
jbarber13 Sep 21, 2021
46c571d
Deposit functions tested, working on flow 2 TX
jbarber13 Sep 21, 2021
46c0516
removed useless payable attribute to doParaSwap
jbarber13 Sep 21, 2021
dd93c30
Fixed security issues, working on flow 2 and tests
jbarber13 Sep 24, 2021
1e8c4b6
Working on flow 2, switched spPendingTXs to array instead of mapping
jbarber13 Sep 29, 2021
a07c3e9
Switched back to mapping with indexes for pending TXs
jbarber13 Sep 30, 2021
18404ff
Switched to tracking wBTC balances in tokens, switched to use wETH, c…
jbarber13 Oct 1, 2021
2c4f9a9
updated solidity code and openzeppelin libs to latest versions
jbarber13 Oct 4, 2021
208a524
ETH flow working now using regular approve
jbarber13 Oct 4, 2021
1ac538e
Switched BTC address storage to bytes32
jbarber13 Oct 4, 2021
ef49166
Refactored and cleanded up, user now pays gas for cleaning old TXs
jbarber13 Oct 5, 2021
78c4ef4
Reverting without reason on single transfer ERC20
jbarber13 Oct 6, 2021
ada207f
Refund case is testing successfully, calculating received amount rath…
jbarber13 Oct 7, 2021
5d4260c
Updated churn to set expiration time, updated interface as well
jbarber13 Oct 10, 2021
a85fd75
Updated deployment params
jbarber13 Oct 11, 2021
ec66a2a
Added fixes from review
jbarber13 Oct 13, 2021
e70dd36
Added external function to clean up pending TXs
jbarber13 Oct 14, 2021
59ba59e
Deployed and verrified to ropsten
jbarber13 Oct 19, 2021
1cf318f
feat: added hardhat-abi-gen plugin and modified abigen generator
syrohei Oct 20, 2021
6380979
feat: removed interface contracts
syrohei Oct 20, 2021
0594462
feat: remove BurnableToken.go
syrohei Oct 20, 2021
985909d
feat: remove some abigo
syrohei Oct 20, 2021
c92b653
feat: regenerated with latest abigen ver
syrohei Oct 20, 2021
41ed222
updated sol version in truffle
jbarber13 Oct 25, 2021
9d8ba88
Fixed hardhat config, abiExporter is breaking the compiler
jbarber13 Oct 25, 2021
4e87c49
gitignore ./cache/*
jbarber13 Oct 26, 2021
df8fd76
set token decimals to 8 for ropsten, confirmed all sol versions are 0…
jbarber13 Oct 26, 2021
8a18e5a
fixed gitignore ./cache
jbarber13 Oct 26, 2021
9b7f0df
git ignore cache
jbarber13 Oct 26, 2021
a23cc96
feat: modified recordSkyPoolsTX and fixed some tests
syrohei Nov 9, 2021
c333304
feat: added _usedTxIds
syrohei Nov 9, 2021
4202fce
feat: bugfix recordSkyPoolsTX
syrohei Nov 9, 2021
83ba0bb
Fixed tests for updated recordSkyPoolsTX, all passing, deploying to R…
jbarber13 Nov 9, 2021
3d50bc0
Added ref comments in truffle.config
jbarber13 Nov 9, 2021
536ab74
testSkyPoolV2 stub
jbarber13 Nov 9, 2021
0649823
Added testnet.js to ./scripts/
jbarber13 Nov 9, 2021
7cab301
Collected megaSwap data for testV2
jbarber13 Nov 9, 2021
27ccae7
Updated ISwapContract
jbarber13 Nov 9, 2021
ec7b6a9
Removed spGetPendingSwaps() from interface, does not seem to be possi…
jbarber13 Nov 9, 2021
0852632
feat: updated abigo for SwapContract
syrohei Nov 10, 2021
2dd864b
Finished testSkyPoolsV2 - hard coded API data
jbarber13 Nov 10, 2021
098964d
Merge branch 'skypools' of https://github.com/SwingbyProtocol/skybrid…
jbarber13 Nov 10, 2021
29616e5
fixed wBTC addr in migrations
jbarber13 Nov 11, 2021
d9850d6
Added functionality for swapOnUniswapFork for flow2
jbarber13 Nov 11, 2021
e954a7e
Added functionality and tests for swapOnUniswap
jbarber13 Nov 11, 2021
91cdab8
Deployed to BSC testnet
jbarber13 Nov 16, 2021
3ac6fee
Added implementation for SwapOnUniswap and SwapOnUniswapFork for flow…
jbarber13 Nov 17, 2021
e2d37b9
Updated deploy_contracts, deploying to ropsten
jbarber13 Nov 17, 2021
98deb69
Updated ISwapContract interface
jbarber13 Nov 18, 2021
fd51356
Removed restriction preventing swap to naitive ETH for spFlow1SimpleSwap
jbarber13 Nov 19, 2021
f5e1740
Refactored tests and added flow 1 -> naitive ETH case
jbarber13 Nov 22, 2021
6792c13
Added flow1 stress tests with multiple contract methods and TXs, passing
jbarber13 Nov 22, 2021
71d82e6
Added test uniswap -> ETH on flow 1
jbarber13 Nov 23, 2021
1aa3e28
Merge remote-tracking branch 'skybridge/updated-skypools' into skypools
jbarber13 Nov 23, 2021
61f12ab
Added descriptive comments for data params
jbarber13 Nov 25, 2021
47747f3
Switched dest BTC address to bytes and updated tests as well as ISwap…
jbarber13 Nov 29, 2021
19fb1c3
Switched dest addr for BTC to STRING
jbarber13 Nov 30, 2021
1a2f8e2
re-deploying with updated BTC addr as String, still troubleshooting o…
jbarber13 Dec 1, 2021
dacbed2
Fixed off-by-1 error, now uses oldestActiveIndex to point to oldest a…
jbarber13 Dec 1, 2021
e9fac63
Added tests for cleaning up old TXs, dest BTC addr is type string cal…
jbarber13 Dec 1, 2021
22571cf
faet: updated abigo
syrohei Dec 2, 2021
d7ca84d
Fixed issue with spCleanUpOldTXs (MANUAL CLEANUP) and added tests to …
jbarber13 Dec 2, 2021
2247d5e
Merge branch 'skypools' of https://github.com/SwingbyProtocol/skybrid…
jbarber13 Dec 2, 2021
ab2c663
feat: added limitation&checker of BTC floats for SPFlow2
syrohei Dec 7, 2021
423a891
feat: removed tracker of BTCT amounts on swapcontract for SPFlow2 (no…
syrohei Dec 7, 2021
f14d0c5
Merge pull request #15 from SwingbyProtocol/f-limitBTCfloats
jbarber13 Dec 7, 2021
add1cec
reduced size to below 24kb limit
jbarber13 Dec 7, 2021
c075aa1
feat: modified interface of SwapContract & abi updated
syrohei Dec 8, 2021
3fe4259
feat: update abigo
syrohei Dec 8, 2021
571ff8b
Merge branch 'skypools' of https://github.com/SwingbyProtocol/skybrid…
jbarber13 Dec 8, 2021
b31e505
Tests passing for newest update to contract
jbarber13 Dec 8, 2021
cf268c6
Added failure case test for max float amounts
jbarber13 Dec 8, 2021
30a9159
feat: added new getter for getting staking amount for node
syrohei Dec 14, 2021
5f645b7
Merge pull request #16 from SwingbyProtocol/f-getNode
jbarber13 Dec 15, 2021
b97a808
Cleaned up linter warnings and imports
jbarber13 Dec 16, 2021
7fc17ec
Implemented change for min amount of sats received
jbarber13 Dec 20, 2021
494fe6d
Deployed with change for min sats for Flow 2
jbarber13 Dec 20, 2021
8b48169
feat: updated ABI
syrohei Dec 21, 2021
8a4f8a0
removed unused ABIS folder
jbarber13 Jan 4, 2022
4ac2e99
Merge branch 'skypools' of https://github.com/SwingbyProtocol/skybrid…
jbarber13 Jan 4, 2022
aac29dc
Added multiRecordSkyPoolsTX function and tests
jbarber13 Jan 5, 2022
87ed578
Added max loop count of 10 to _spCleanUpOldTXs
jbarber13 Jan 5, 2022
3507500
Switched to error codes to condense space
jbarber13 Jan 11, 2022
7da96e7
Merge pull request #17 from SwingbyProtocol/skypools-errorCodes
jbarber13 Jan 20, 2022
244058c
fixed an error in collectSwapFeesForBTC
jbarber13 Jan 20, 2022
fefce1d
fixed errors in testSkyPoolsV2 for error codes
jbarber13 Jan 20, 2022
eb24797
feat: applied new sbbTC send out model & changed churn logic
syrohei Jan 21, 2022
ec67cfc
feat: renamed totalStakedAmount
syrohei Jan 21, 2022
2dc7b23
Fixed tests for updated churn in testSkypoolsV2
jbarber13 Jan 21, 2022
d547bed
feat: removed distributeNodeRewards & deposit fees
syrohei Jan 22, 2022
c0fbd7c
feat: removed deposit fees logic
syrohei Jan 22, 2022
f03a41a
Merge branch 'f-fix-stake-erc20' of https://github.com/SwingbyProtoco…
syrohei Jan 22, 2022
1c3a588
feat: updated interfaces
syrohei Jan 22, 2022
19fe7f3
feat: added SwapRewards contract and modified logic on SwapContract t…
syrohei Jan 24, 2022
0d5117c
faet: modified interfaces and changed logic of pullRewards
syrohei Jan 24, 2022
5f82c4e
feat: added _thresholdRatio to change ratio of rebates
syrohei Jan 25, 2022
54adebe
feat: removed factory contract & made abi & abigo
syrohei Jan 25, 2022
7e0a212
Merge pull request #18 from SwingbyProtocol/f-fix-stake-erc20
jbarber13 Jan 25, 2022
bdcc0c5
feat: removed multiTransferERC20TightlyPacked to reduce contract size…
syrohei Jan 26, 2022
15f9268
feat: fixed collectSwapFeesForBTC interface and fixed SwapRewards logic
syrohei Jan 26, 2022
014b01c
Merge pull request #19 from SwingbyProtocol/f-fix-churn
jbarber13 Jan 27, 2022
c40d988
overwrite
jbarber13 Jan 27, 2022
8a09bea
Merged to skypools, tests passing, omit collectSwapFees for refund ca…
jbarber13 Jan 27, 2022
e0995fd
Fixed error: pullRewardsMulti return did not match interface, switche…
jbarber13 Jan 27, 2022
827bae6
Fixed implementation of collectSwapFees in flow2 tests, all passing
jbarber13 Jan 27, 2022
6d3bbf2
added params.sol
jbarber13 Feb 1, 2022
f1df218
Added IParams.sol
jbarber13 Feb 1, 2022
2a34563
Completed implementation of Params contract
jbarber13 Feb 1, 2022
7699489
Fixed implementation of Params contract, removed args from churn, fix…
jbarber13 Feb 2, 2022
71d24a0
Added more varriables from churn to Params contract
jbarber13 Feb 2, 2022
3fa8ea9
Removed unused event for expiration time
jbarber13 Feb 2, 2022
46d7e9f
Switched public functions to external, streamlined implemtation of IP…
jbarber13 Feb 3, 2022
0f9df87
Added implementation for ISwapRewards on swap contract, reduced contr…
jbarber13 Feb 3, 2022
973d204
Consolidated cleanup of old TXs into 1 public function with loopcount…
jbarber13 Feb 3, 2022
8292a49
Compressed down to 23.41KB
jbarber13 Feb 3, 2022
27cf351
Reduced to 23.05KB by adjusting Ownable.sol modifyer to use a private…
jbarber13 Feb 3, 2022
22d4433
Added multiTransfer back in as reduced size allows for it, current si…
jbarber13 Feb 3, 2022
a2da091
Merge pull request #23 from SwingbyProtocol/reducedSwapContract
jbarber13 Feb 5, 2022
af792e3
Removed unused code, current size is 23.6KB
jbarber13 Feb 5, 2022
12474ce
feat: lpToken is changed to instance
syrohei Feb 5, 2022
9e46e54
Merge pull request #24 from SwingbyProtocol/f-refactor-fees-collection
jbarber13 Feb 7, 2022
09cd7c2
Merging to skypools
jbarber13 Feb 10, 2022
b958f8e
Merge pull request #25 from SwingbyProtocol/f-Params-Contract
jbarber13 Feb 10, 2022
ba45e86
feat: added swingby price
syrohei Feb 15, 2022
97a2464
feat: modified math
syrohei Feb 15, 2022
ac31034
faet: changed base to bps
syrohei Feb 15, 2022
2a927bc
feat: fixed interface for SwapRewards.sol and modified logic
syrohei Feb 22, 2022
1a18be0
feat: replace amount calculation to local variable for reduce gas cost
syrohei Feb 22, 2022
b8a49d2
Merge pull request #26 from SwingbyProtocol/f-swap-rewards
jbarber13 Feb 24, 2022
9b6cdb6
feat: fixed some logic
syrohei Mar 9, 2022
b13d768
feat: updated ABI
syrohei Mar 9, 2022
07a33f9
feat: updated abigo
syrohei Mar 9, 2022
c01632b
feat: active hardhat deploy
syrohei Mar 9, 2022
14929fd
feat: removed 2 abigo files
syrohei Mar 25, 2022
d7d3548
feat: removed totalStakedAmount from churn
syrohei Mar 25, 2022
03684e8
feat: modified tests
syrohei Mar 25, 2022
95c42bd
feat: updated abigo for SwapContract
syrohei Mar 25, 2022
c04dec5
feat: updated deploy script
syrohei Mar 28, 2022
ca70256
feat: deployed all contracts
syrohei Mar 29, 2022
2f1de4b
feat: added chaosnet contracts
syrohei Mar 30, 2022
6af1a90
Update README.md
syrohei Mar 30, 2022
4197c8a
feat: added LPT convertor moved sbBTCPool.sol
syrohei Apr 24, 2023
735ef7e
feat: refactor swap contract, removed sp logics
syrohei Apr 24, 2023
6d3af10
feat: update ABI
syrohei Apr 24, 2023
13611de
feat: update dependencies and env configs
syrohei Apr 24, 2023
53975a9
feat: remove cache
syrohei Apr 24, 2023
f7861c2
feat: added buyback logic
syrohei Apr 27, 2023
7c07121
feat: removed _isUpdatelimitBTCForSPFlow2 from contract interface
syrohei Apr 29, 2023
6dc407f
feat: added new function for change params
syrohei Apr 30, 2023
8934ef5
feat: updated to new ABI
syrohei Apr 30, 2023
bcf8178
feat: added deployer for goerli
syrohei Apr 30, 2023
0cf335d
feat: removed cache
syrohei Apr 30, 2023
ec2c333
feat: chagned optimizer run count and support EIP1559 tx
syrohei Apr 30, 2023
b7436df
feat: updated ABI & abigo
syrohei Apr 30, 2023
8e0d4cf
feat: udpated buyback fee ratio
syrohei Apr 30, 2023
b3f7621
feat: added all test for v3
syrohei Apr 30, 2023
71ccd28
feat: updated deployer
syrohei Apr 30, 2023
e72b2b6
feat: updated LPT convertor
syrohei May 13, 2023
7623972
feat: update LPT abi
syrohei May 13, 2023
a2542ab
feat: added onchain tests
syrohei May 13, 2023
aa4e6c3
feat: added deployment order
syrohei May 13, 2023
66bf4d4
feat: update on-chain tests
syrohei May 13, 2023
84fe893
feat: polish sbBTCPool contract
syrohei May 16, 2023
c64c748
feat: support EIP1559
syrohei May 16, 2023
5b32c9e
feat: added churn test
syrohei May 16, 2023
1d24c4e
feat: added sbBTCPool on-chain test
syrohei May 16, 2023
3d5de88
feat: changed permission for update stakes
syrohei May 16, 2023
5ff272f
feat: fix-onchain test for sbBTCPool
syrohei May 16, 2023
acf51cb
feat: updated readme
syrohei May 17, 2023
0068c96
feat: update abigo
syrohei May 17, 2023
c3c45c0
feat: added audit with MythxCLI
syrohei May 17, 2023
8866710
feat: fix cmd
syrohei May 17, 2023
b5a0204
feat: fix cmd
syrohei May 17, 2023
3713441
feat: fix ci
syrohei May 17, 2023
fdc1f94
feat: updated task
syrohei May 17, 2023
494e691
feat: update ci
syrohei May 17, 2023
9ca34bc
feat: update ci
syrohei May 17, 2023
60f19c9
feat: fixed audit
syrohei May 23, 2023
ca64c4b
feat: change deep mode
syrohei May 23, 2023
4fe3f05
feat: change deep mode
syrohei May 23, 2023
e154fde
feat: update using recent blocks fort test
syrohei May 23, 2023
95da009
feat: remove unused network
syrohei May 23, 2023
2217f04
feat: standard scan
syrohei May 23, 2023
81681b7
feat: changed mode to quick
syrohei May 30, 2023
d2bcc3a
feat: try deep scan
syrohei May 30, 2023
7cc811d
feat: standard scan
syrohei May 30, 2023
2d74d4d
feat: removed unused event
syrohei May 30, 2023
6aa7f63
feat: update solc
syrohei May 30, 2023
9bd3c7f
Create Security-Audit-Report-31052023.md
syrohei May 30, 2023
48b50cf
Merge pull request #31 from SwingbyProtocol/syrohei-patch-1
syrohei May 30, 2023
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
63 changes: 63 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
version: 2
jobs:
build:
docker:
- image: circleci/python:3.8-node
steps:
- checkout
- run:
name: npm install
command: |
node --version
npm install
- persist_to_workspace:
root: .
paths:
- .

test:
docker:
- image: circleci/python:3.8-node
steps:
- attach_workspace:
at: .
- run:
name: test
command: |
npm run test
- persist_to_workspace:
root: .
paths:
- .

audit:
docker:
- image: circleci/python:3.8-node
steps:
- attach_workspace:
at: .
- run:
name: Setup virtual environment
command: python -m virtualenv venv
- run:
name: Install MythX CLI
command: |
. venv/bin/activate
pip install mythx-cli
- run:
name: Analyze with MythX
command: |
. venv/bin/activate
mythx --yes analyze --mode standard --async --solc-version 0.8.19 --remap-import @openzeppelin/=$(pwd)/node_modules/@openzeppelin/ contracts/

workflows:
version: 2
build_test_audit:
jobs:
- build
- test:
requires:
- build
- audit:
requires:
- test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
node_modules
cache
artifacts
build/*
abigenBindings/bin
.DS_Store
.env
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

56 changes: 32 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
# skybridge-contract-v2
# Skybridge-contract-v3

## Environment
- testrpc (ganache-cli) - v2.4.0
- truffle - v5.1.54
- solc - v0.7.5
- nodejs - v14.8.0
- web3 - v1.2.9
- hardhat (v2.14.0)
- solidity (v0.8.19)

## Deploy contract
There are 2 steps to setup contracts on the ethereum testnet.
1. Deploy SwapContract and LP token contract
```
$ export SEED=<your mnemonic key>
$ truffle migrate --network {development/goerli}
```
2. Change the owner of SwapContract to TSS address
```
$ TSS={The TSS wallet address} truffle exec scripts/moveSCOwner.js --network {development/goerli}
```
## Deployment Order
1. Deploy sbBTCPool nodeRewards contracts
2. Deploy LP token and swap contract (initial liquidiy setup if need)
3. Initialize sbBTCPool and nodeRewards
4. Mint LPT to users (if need)
5. Set old LPT token for convert -- they can convert to new token with burning old token.
6. Transferring owner of new LPT to swap contract

## Build contract
```
$ npn run build
$ npx hardhat compile
```

## Test
You have to start testrpc with 100 accounts and binding port `8545` before doing test
```
$ ganache-cli -a 100 -l 9000000
$ npx hardhat test ./test/testSwapContract.js
```

## Mainnet contracts
```
TBA
```

## Testnet contracts (goerli)
```
SwapContract
https://goerli.etherscan.io/address/0x9e6ba6e811665849f03f56c1f22a8894aebb3993
LPToken
https://goerli.etherscan.io/address/0xb10c6c5a6baf604206867cb229baddab02eea602
SwapRewards
https://goerli.etherscan.io/address/0xf4c381d077272295641f8a53d850d9a8125e0e94
BTCT
https://goerli.etherscan.io/address/0xeb47a21c1fc00d1e863019906df1771b80dbe182
sbBTCPool
https://goerli.etherscan.io/address/0xd60126017fdf906668cfe5327c566c65e7f061ba
Barn
https://goerli.etherscan.io/address/0x009cc14ce70b2e667984c2276490d56ae3234c43
```
$ npm run test
or
$ truffle test --network development
```
Loading