Skip to content

Commit bdb050a

Browse files
committed
Squashed commit of the following:
commit 668aaee7daeda4cfcf9ca76fc263dac74b0224e7 Merge: f1a2037 b10a7a5 Author: χ² <[email protected]> Date: Mon May 2 23:26:01 2022 +0300 Merge pull request #105 from synapsecns/feature/bridge-vault Bridge + Vault commit b10a7a5998a278f92e9f7a980c69dbb7909a00f6 Merge: 4df6831 f1a2037 Author: ChiTimesChi <[email protected]> Date: Mon May 2 23:22:47 2022 +0300 Merge branch 'feature/router' into feature/bridge-vault commit 4df683171aa1b086a38775bd01a900969d23b35b Author: ChiTimesChi <[email protected]> Date: Mon May 2 22:07:57 2022 +0300 tests: rename contracts for consistency commit 6a6a056e9b5903beecca2d7c3d5e257dc829c270 Author: ChiTimesChi <[email protected]> Date: Mon May 2 21:57:48 2022 +0300 tests: unit tests for BridgeQuoter commit 3789cc749b663efd8663069e052d025facf11edb Author: ChiTimesChi <[email protected]> Date: Mon May 2 21:57:07 2022 +0300 tests: move _getBridgeToken into template test commit 656616cf0315b742f8b09677c27802b07f373e68 Author: ChiTimesChi <[email protected]> Date: Mon May 2 21:19:38 2022 +0300 tests: check BridgeRouter gasdropRequested commit 1d3d52eb6045e050d99509b38c465d221a645641 Author: ChiTimesChi <[email protected]> Date: Mon May 2 21:17:13 2022 +0300 tests: BridgeRouter with failed swaps on src chain commit 7f373e9309324de1eb79ff042f75f766801d043f Author: ChiTimesChi <[email protected]> Date: Mon May 2 21:01:17 2022 +0300 tests: check reusing kappas in BridgeRouter tests commit 05bf444ac3c95b89cfa73f69a782793e4d3b7964 Author: ChiTimesChi <[email protected]> Date: Mon May 2 20:56:38 2022 +0300 tests: BridgeRouter tests cases explained commit dde70dbf8ecb387c3c7b03b62513e721a81ee953 Author: ChiTimesChi <[email protected]> Date: Mon May 2 20:41:06 2022 +0300 BridgeRouter: tests for fake tokens/swapParams commit 0eb75427da55953a65f1a8395042b63e608947d5 Author: ChiTimesChi <[email protected]> Date: Mon May 2 20:37:11 2022 +0300 tests: descriptions for each test case commit 4e636fe9ba12bf1ad68ffb13b5e76a1da84e7b42 Author: ChiTimesChi <[email protected]> Date: Mon May 2 19:59:11 2022 +0300 tests: inlcude checking for reusing kappas commit c3b7f5053605abf542ca8ffb44afebeb0c13694f Author: ChiTimesChi <[email protected]> Date: Mon May 2 18:10:36 2022 +0300 BridgeQuoter: rewording into Source + Destination commit 2c7a75acecc219dc9306e731a474627b480fd2a1 Author: ChiTimesChi <[email protected]> Date: Mon May 2 17:40:49 2022 +0300 tests: unit tests for BridgeRouter commit 8f7a752ba6c5c4900d6b8d184f8936408647b63a Author: ChiTimesChi <[email protected]> Date: Mon May 2 17:06:59 2022 +0300 tests: set up initial block.timestamp commit 448c7a2d73fbd5d4e6a97899124e1bb22b8aba76 Author: ChiTimesChi <[email protected]> Date: Mon May 2 14:32:18 2022 +0300 tests: cast to uin256 before left shifting commit 1c376614046a23ee24ebc52156fbbad4d14810a5 Author: ChiTimesChi <[email protected]> Date: Mon May 2 13:13:38 2022 +0300 tests: update totalSupply when dealing tokens commit 03d8fc6906ebdf82f2fa08000a09e6bf923d3b2f Author: ChiTimesChi <[email protected]> Date: Mon May 2 12:30:48 2022 +0300 tests: store token => index mapping commit 9a768e9c4d74d3dcff13990deee88291971d0129 Author: ChiTimesChi <[email protected]> Date: Mon May 2 12:24:15 2022 +0300 tests: move askQuoter into template test commit 7b15c1a1ace68e7a061e852900ed155ffa0a9aad Author: ChiTimesChi <[email protected]> Date: Mon May 2 12:21:27 2022 +0300 tests: use uint8 for test token indexes commit b2fcf931c0c2391a9226a167ae83941a48343f75 Author: ChiTimesChi <[email protected]> Date: Mon May 2 12:14:23 2022 +0300 tests: template for complex Bridge tests commit 729e540a093a18f772919087f76592053318dec0 Author: ChiTimesChi <[email protected]> Date: Mon May 2 11:45:58 2022 +0300 tests: remove extra message in checkRevert commit e742746ba306c1b9a480510a09a3e3bfa1f355c3 Author: ChiTimesChi <[email protected]> Date: Mon May 2 11:38:28 2022 +0300 BridgeRouter: limit bridgeMaxSwaps to [1..4] commit 7e1f6bd60d5473987fde7e3f911b92f8db888593 Author: ChiTimesChi <[email protected]> Date: Mon May 2 11:35:58 2022 +0300 tests: store bridge tokens commit 9269231e1f4fc2af416cde02435a1a221d139758 Author: ChiTimesChi <[email protected]> Date: Mon May 2 11:26:28 2022 +0300 tests: deprecate Hardhat Router-Quoter tests commit c9ac24dc14c145fc78a1165f5ed8bc88d9b1353c Author: ChiTimesChi <[email protected]> Date: Sun May 1 22:57:56 2022 +0300 tests: check if Router can receive ETH commit 244517f9dd5fb88c48b7b3e2ef950f0521e07337 Author: ChiTimesChi <[email protected]> Date: Sun May 1 22:57:21 2022 +0300 tests: Quoter, Router unit tests commit eaa9d3f2d102aaeba9896900c4a7dc294769e17e Author: ChiTimesChi <[email protected]> Date: Sun May 1 22:55:57 2022 +0300 tests: setup fake wETH correctly commit d386772371ef2e9c7455812ee2536e6bfae53f06 Author: ChiTimesChi <[email protected]> Date: Sun May 1 22:54:20 2022 +0300 Quoter: ignore paths with duplicate tokens commit 87552c6420f60c2e2e90bbbeda09b7537e06b596 Author: ChiTimesChi <[email protected]> Date: Sun May 1 20:21:45 2022 +0300 chore: change printWidth to 120 for .t.sol files commit 8794472d64624faaf000cae50260546d995736a3 Author: ChiTimesChi <[email protected]> Date: Sun May 1 20:15:06 2022 +0300 tests: template for Router tests commit d4eb43ce79d4dfecda02885ef1110be36511b8e8 Author: ChiTimesChi <[email protected]> Date: Sun May 1 20:11:42 2022 +0300 Utilities: external functions commit b308db64e5766afc7c76dec34e9754a5dd73aa41 Author: ChiTimesChi <[email protected]> Date: Sun May 1 18:49:55 2022 +0300 amm: adapt pools for solidity 0.8 commit 8589be2947a21b9d5a75be90cd77fe36a0bf3cbd Author: ChiTimesChi <[email protected]> Date: Sat Apr 30 15:05:03 2022 +0300 Vault: checkTokenRequest -> checkWithdrawRequest commit b6c3b28589bb05e4a3ec97d3d6eedc59da2c8c79 Author: ChiTimesChi <[email protected]> Date: Sat Apr 30 15:04:03 2022 +0300 Vault: airdrop gas optimisation commit 284e09463e85cf616dd23bf083ecc4539b30b8a0 Author: ChiTimesChi <[email protected]> Date: Fri Apr 29 20:10:36 2022 +0300 upd forge-std commit 4d492878d38925fc40538ee34d1e65f8b296254c Author: ChiTimesChi <[email protected]> Date: Fri Apr 29 20:09:19 2022 +0300 tests: unit tests for BasicRouter and BasicQuoter commit b56f7fe078433025a8cb4fdfba3c1179ab71876a Author: ChiTimesChi <[email protected]> Date: Fri Apr 29 20:05:24 2022 +0300 Quoter: check maxSwaps in setter commit 3b8400c13bd6d46b393adc77cd037d573beee2e8 Author: ChiTimesChi <[email protected]> Date: Fri Apr 29 18:37:33 2022 +0300 tests: unit tests for Bridge commit ba5b8d780d2f7a4409f645423f11574ad3c8eb7d Author: ChiTimesChi <[email protected]> Date: Fri Apr 29 18:06:10 2022 +0300 Bridge: change of empty "swap params" commit 6c246fe38e83ed259b1363c1437ff569148fae7f Author: ChiTimesChi <[email protected]> Date: Fri Apr 29 17:59:24 2022 +0300 Bridge: consistency in revert msgs commit e387dfd81bf7923158f140254beb1f7a87ed9bc5 Author: ChiTimesChi <[email protected]> Date: Fri Apr 29 17:47:28 2022 +0300 tests: add address labels, move stuff into basic test contract commit 867be90a260558e8fc1a2489316ab4d5518398c2 Author: ChiTimesChi <[email protected]> Date: Thu Apr 28 23:10:10 2022 +0300 unit tests for Vault commit 796912ef7e5dee4cd27366ff24c43d6faeb5b5ba Author: ChiTimesChi <[email protected]> Date: Thu Apr 28 23:05:14 2022 +0300 more consistency in Vault functions commit 83bb9770bae7f629808cc4fae0642e298b53a0c2 Author: ChiTimesChi <[email protected]> Date: Thu Apr 28 18:13:38 2022 +0300 test template for bridge+vault commit ff7bae29f53adae23a295526768016563f39865e Author: ChiTimesChi <[email protected]> Date: Wed Apr 27 15:37:27 2022 +0300 introduce BRIDGE_ROLE in Vault commit b31a03cd0287bbd71e724c3707373b2feea21302 Author: ChiTimesChi <[email protected]> Date: Tue Apr 26 17:20:26 2022 +0300 prepare for Foundry testing commit 65b177f463491733c87232b6c79ebee780656ac5 Author: ChiTimesChi <[email protected]> Date: Tue Apr 26 16:05:32 2022 +0300 forge install: forge-std commit 895e1bf9fa272d00f1fa41b06519fba043073637 Author: ChiTimesChi <[email protected]> Date: Tue Apr 26 16:04:14 2022 +0300 forge install: ds-test commit 55d9ec6a028736dda94cca8e9d6677fd8cc2d429 Author: aureliusbtc <[email protected]> Date: Fri Apr 15 14:14:17 2022 -0400 lint commit 02f6005774c63d2b41cfec14b68438cf7819aba2 Author: aureliusbtc <[email protected]> Date: Fri Apr 15 13:25:36 2022 -0400 Update router deploy to fix minor issues, deploy test single-chain router commit bde9e21af52cadfac1b238aedefa23e7cab75a42 Merge: 9111e8a 1c502a2 Author: χ² <[email protected]> Date: Wed Apr 13 17:07:06 2022 +0300 Merge pull request #113 from synapsecns/feature/bridge-with-config Feature/bridge with config commit 1c502a275fc9d277aaad429c5f482f5a40ae9c47 Author: ChiTimesChi <[email protected]> Date: Wed Apr 13 16:39:10 2022 +0300 test deployment: Router, Quoter, Adapters commit 2abce8cddcedd14f2a9f76a91a37659883c93d44 Author: ChiTimesChi <[email protected]> Date: Wed Apr 13 15:46:31 2022 +0300 update uniswap tests commit 029aae1e6632d9e14da6384663cbb69e520d8aa2 Author: ChiTimesChi <[email protected]> Date: Wed Apr 13 15:45:56 2022 +0300 Global adapters config file commit 5b0ab50080a7ef7b8e6df9892f507f3b48b217d9 Author: ChiTimesChi <[email protected]> Date: Wed Apr 13 15:30:00 2022 +0300 consistenty in Curve constructors commit dfee540562001352603711af5ea8f8df51d20274 Author: ChiTimesChi <[email protected]> Date: Mon Apr 11 18:35:17 2022 +0300 include deadline in router tests commit d45bdec80f24bf45b7b248ac3e848dbc92823c76 Author: ChiTimesChi <[email protected]> Date: Mon Apr 11 16:27:07 2022 +0300 check for deadline on initial chain commit 9c26cfb5491b8bd56ea1b9c5139617b7cf1c7416 Author: ChiTimesChi <[email protected]> Date: Mon Apr 11 16:16:33 2022 +0300 allowance for BridgeRouter is no longer needed commit 0d0d954865aff62a0753f6c5c268537732fc1c09 Author: ChiTimesChi <[email protected]> Date: Mon Apr 11 16:12:26 2022 +0300 implement cap for total bridge fee commit fe287e290d07a02488ec9e273c2350918dce74eb Author: ChiTimesChi <[email protected]> Date: Mon Apr 11 16:01:03 2022 +0300 more power to Bridge Quoter commit 59d926c161c6d9d60b14769e656bd3af73471a19 Author: ChiTimesChi <[email protected]> Date: Mon Apr 11 11:04:00 2022 +0300 remove totally unnecessary underscores commit 9c605eb8b3895e65ea5e662419b877a7e6a893a0 Author: ChiTimesChi <[email protected]> Date: Sat Apr 9 21:41:48 2022 +0300 Separate BridgeConfig from Bridge commit d6d65cfad3d34ddf90efec8875834caad91992f4 Author: ChiTimesChi <[email protected]> Date: Sat Apr 9 18:43:59 2022 +0300 delete given chain's token from all Bridges commit 97287bebf186cef9dbf15ba8f7d5e8226184497f Author: ChiTimesChi <[email protected]> Date: Sat Apr 9 14:41:46 2022 +0300 block.chainid instead of assembly commit ab81b99dc608939d627845bc744cb018647aab50 Author: ChiTimesChi <[email protected]> Date: Sat Apr 9 14:40:19 2022 +0300 views to get bridgeable tokens between two chains commit 1a37a8ea9d7a8ee52c4f059851ed03109ed960cb Author: ChiTimesChi <[email protected]> Date: Sat Apr 9 14:06:04 2022 +0300 add global token map commit 3e4f1a93a892c8f56de5f34bb73b2d0453d2efea Author: ChiTimesChi <[email protected]> Date: Sat Apr 9 13:57:29 2022 +0300 better mapping names, descriptions commit 26d41474253f3b6a9763d55fdf0179ffe9190364 Author: ChiTimesChi <[email protected]> Date: Fri Apr 8 19:25:13 2022 +0300 always send gasdrop to user commit 06aa0918c45189270d916838a3b110ca9e179809 Author: ChiTimesChi <[email protected]> Date: Fri Apr 8 19:11:43 2022 +0300 add some docs commit 42ed0b599f70b7a8912a2f6e7a9b4ca576f25a71 Author: ChiTimesChi <[email protected]> Date: Fri Apr 8 18:23:32 2022 +0300 uint128 doesnt help here commit 4aa0c958d6346e4be63473613545f05dc86662ef Author: ChiTimesChi <[email protected]> Date: Fri Apr 8 17:54:44 2022 +0300 trim revert string heavily (still over 24576) commit cdeb766e400baff3aa77db5ee42c952ec95b14d6 Author: ChiTimesChi <[email protected]> Date: Fri Apr 8 17:32:55 2022 +0300 integrate config into bridge commit 46cca91c333a09e7e8d59ceaea96467eb2c777b1 Author: ChiTimesChi <[email protected]> Date: Thu Apr 7 15:53:37 2022 +0300 add TokenConfig, emit address on dest chain commit 9111e8abbf83cd939a094030cb6bd4ee0f07c550 Author: ChiTimesChi <[email protected]> Date: Wed Apr 6 15:06:24 2022 +0300 Do not emit isMint for Bridge In commit ece8c3d58e708398b9ae97e526e5eea6932ce3da Author: ChiTimesChi <[email protected]> Date: Wed Apr 6 15:04:11 2022 +0300 enable optional gas airdrop commit 41597d74210077d5d75d3fa412cd835cf34a776d Author: ChiTimesChi <[email protected]> Date: Wed Apr 6 13:34:10 2022 +0300 don't do zero gas airdrops commit f781ac1e0228e95197e54680df6eb3458c650876 Author: ChiTimesChi <[email protected]> Date: Wed Apr 6 13:24:41 2022 +0300 emit gas drop amount commit 180c6f4077a72b409f1c9f98669b38369fef36cb Author: ChiTimesChi <[email protected]> Date: Tue Apr 5 17:07:29 2022 +0300 Relayers don't need to know is it mint or withdraw commit 601f3800436e978daa4ca2a71f2a2acdc18c736b Author: ChiTimesChi <[email protected]> Date: Tue Apr 5 16:49:46 2022 +0300 Bridge no longer pulls tokens from caller commit 674601dd9912f0e338ef72f17120be3e6805766f Author: ChiTimesChi <[email protected]> Date: Tue Apr 5 16:12:01 2022 +0300 Store token type for underlying token, not wrapper commit 92ac082671757b904e81ab8059528eae31fee97a Author: ChiTimesChi <[email protected]> Date: Tue Apr 5 15:49:57 2022 +0300 always emit underlying token: this isolates Bridge Wrapper concept into Bridge contract entirely commit c55393ad9d29d9347007e1cc43abfd9ab91643f2 Author: ChiTimesChi <[email protected]> Date: Tue Apr 5 15:20:59 2022 +0300 apparently bridgeMax isn't used anywhere commit 24132804407778219a6f510ef7cfd172471c2a44 Author: ChiTimesChi <[email protected]> Date: Tue Apr 5 14:32:32 2022 +0300 emit whether gas airdrop was given commit 13201da51248a22734e015139db03a0b035a86f6 Author: ChiTimesChi <[email protected]> Date: Tue Apr 5 14:26:14 2022 +0300 Vault should be doing GAS airdrops commit ffdc6e4280cf685d8fbb51ee9d7b756ee1f303d4 Author: ChiTimesChi <[email protected]> Date: Tue Apr 5 14:15:33 2022 +0300 forgot to do this when bridge wrappers -> Bridge commit 7344c224b8144edee0cae21a236a13a9a63315a8 Author: ChiTimesChi <[email protected]> Date: Tue Apr 5 13:41:06 2022 +0300 enforce [to, chainId, token, amount] order commit 4d4c7fd551dd76ea35bc71e2cd54229b4589ced1 Author: ChiTimesChi <[email protected]> Date: Tue Apr 5 10:52:49 2022 +0300 unify "Bridge Out" events commit d9a0bfffb7fc5395698a80a31ac06d225a1aae82 Author: ChiTimesChi <[email protected]> Date: Mon Apr 4 23:51:40 2022 +0300 support for removing bridge token commit 648bb3342b7477c7015e414ac3a2be21cb79ae32 Author: ChiTimesChi <[email protected]> Date: Mon Apr 4 23:41:14 2022 +0300 consolidate deposit, redeem commit 3b165eae95f500d80b89faee38ae6239b971fa9e Author: ChiTimesChi <[email protected]> Date: Mon Apr 4 21:46:32 2022 +0300 move Bridge Wrappers from Router into Bridge commit 72e661ed4467271956485287c18e4a8bb1819077 Author: ChiTimesChi <[email protected]> Date: Mon Apr 4 21:21:05 2022 +0300 update docs commit 2e09e5d257772e4954950556526a6b0fff91d875 Author: ChiTimesChi <[email protected]> Date: Mon Apr 4 21:18:33 2022 +0300 Bridge, Router small fixes commit 0934e1d7e0ec42ef779758ecc13fde9f966f1bc5 Author: ChiTimesChi <[email protected]> Date: Mon Apr 4 19:14:14 2022 +0300 public getters for Bridge Wrappers commit 68119fcb97f3aa93d3c4e167024e3d2857b93a2b Author: ChiTimesChi <[email protected]> Date: Mon Apr 4 19:04:13 2022 +0300 bridgedSwapParams -> destinationSwapParams commit e71a93b9901677cf96e0b430474b9f9ab27eada7 Author: ChiTimesChi <[email protected]> Date: Mon Apr 4 00:13:52 2022 +0300 fix docs commit 217a2daab82704ad0638f675ef69417153c2478b Author: ChiTimesChi <[email protected]> Date: Sun Apr 3 18:37:49 2022 +0300 add bridge quoting doc commit 35249094d0f16400d45efa811dc173d9af224e15 Author: ChiTimesChi <[email protected]> Date: Sun Apr 3 12:21:18 2022 +0300 your mama is too deep commit 7484c1d587319c773d3499168e07826a5cbeff41 Author: ChiTimesChi <[email protected]> Date: Sun Apr 3 12:09:47 2022 +0300 I am a doc writoooor again commit 4cd34e24114c1d58ca576d9a04e32986626198f6 Author: ChiTimesChi <[email protected]> Date: Sun Apr 3 12:04:05 2022 +0300 unify bridgeToken and swapTokenAndBridge into one commit 2d319f66b69f65a5da79435ef64e980e0e760214 Author: ChiTimesChi <[email protected]> Date: Sun Apr 3 11:49:12 2022 +0300 swapParams -> bridgedSwapParams commit f738403e67c7a1b046bc6337552ff31e2fd680ae Author: ChiTimesChi <[email protected]> Date: Sat Apr 2 17:43:34 2022 +0300 a futile attempt at slightly better naming commit 6897101829ffd3c66f82591cdc6fd46757e3e6b5 Author: ChiTimesChi <[email protected]> Date: Sat Apr 2 17:30:11 2022 +0300 dont revert tx if gas drop fails commit efd7ee3816bde41d36dc0cdeb311089fcbbdf69a Author: ChiTimesChi <[email protected]> Date: Sat Apr 2 17:28:34 2022 +0300 bridge in unification commit f4ee521136a4addcc6637c83d0a1644f916a494b Author: ChiTimesChi <[email protected]> Date: Sat Apr 2 16:42:26 2022 +0300 use SwapParams everywhere commit 5cd87b4166e88976fbb756abd89840e7fec0e7fc Author: ChiTimesChi <[email protected]> Date: Sat Apr 2 16:32:10 2022 +0300 remove tokenSpending from Vault for the time being commit 17ccfb36b93c423acafebe7d68e81651d927c254 Author: ChiTimesChi <[email protected]> Date: Sat Apr 2 16:24:06 2022 +0300 big BridgeRouter rework commit 18a9daf5b55198f807f7ad6d3f19fc35684166ec Author: ChiTimesChi <[email protected]> Date: Sat Apr 2 13:28:42 2022 +0300 big Bridge rework commit 7afed705f6acc70691c98cce981274c07933f1a5 Author: ChiTimesChi <[email protected]> Date: Fri Apr 1 21:15:24 2022 +0300 docs for DepositBridgeWrapper commit a73337603dfce067163f9c0a32ba043b2f1841f7 Author: ChiTimesChi <[email protected]> Date: Fri Apr 1 21:13:53 2022 +0300 tokenNative -> nativeToken commit 40bb6c3d1e75f9af023f89088ba126191aea62de Author: ChiTimesChi <[email protected]> Date: Fri Apr 1 21:12:52 2022 +0300 (yet another) MintBurnWrapper rework commit 28943cbe39a5d7e1885302f8aabd1f00316a83cd Author: ChiTimesChi <[email protected]> Date: Fri Apr 1 20:33:02 2022 +0300 docs rework post-merge commit d1d983f5b0245b5dbeb5698f81e01b1af4891755 Author: ChiTimesChi <[email protected]> Date: Fri Apr 1 20:19:15 2022 +0300 Revert "Vault needs to store info about bridge wrappers" This reverts commit f937dcdff8d3646edd51beb5eb3dd5526419fae8. commit 027c09ac4a6820a9b3329a9502a0718c92c16f32 Author: ChiTimesChi <[email protected]> Date: Fri Apr 1 20:18:56 2022 +0300 Revert "bridge wrappers info will be stored in vault" This reverts commit 3922fb6d8860d1dbb0729bebeb0bb04d99259a3b. commit 2f7453fb0422ecbd2c861e5861987c67cf650849 Merge: 71fd83f 3922fb6 Author: ChiTimesChi <[email protected]> Date: Fri Apr 1 17:29:47 2022 +0300 Merge branch 'chisq/adapters-optimising' into feature/bridge-vault commit 3922fb6d8860d1dbb0729bebeb0bb04d99259a3b Author: ChiTimesChi <[email protected]> Date: Thu Mar 31 01:55:30 2022 +0300 bridge wrappers info will be stored in vault commit 71fd83f4966f1bf1c13b59324ca37b4bcc989a09 Author: ChiTimesChi <[email protected]> Date: Thu Mar 31 01:39:00 2022 +0300 BridgeWrapper for deposit assets: JEWEL, etc commit f8d0b398394b7d6f2e5a76e53945242821ac28d4 Author: ChiTimesChi <[email protected]> Date: Wed Mar 30 23:02:46 2022 +0300 remove transfer from MintBurnWrapper commit 1a59d4ed09770a0af07a41866ef18e6d556445a7 Author: ChiTimesChi <[email protected]> Date: Wed Mar 30 22:59:26 2022 +0300 much better documentation commit f937dcdff8d3646edd51beb5eb3dd5526419fae8 Author: ChiTimesChi <[email protected]> Date: Wed Mar 30 20:28:44 2022 +0300 Vault needs to store info about bridge wrappers commit 0d97f250d391394141fd32367d77403d6d63772a Author: ChiTimesChi <[email protected]> Date: Wed Mar 30 19:02:35 2022 +0300 checkTokenRequest is only for spend/withdraw commit 3e98d9e47b9d4a7742ba0716e508fe9ff8ef0e42 Author: ChiTimesChi <[email protected]> Date: Wed Mar 30 18:07:24 2022 +0300 add support for bridge wrappers commit 4ac4fd09fb2252df037a5a65b603adec634c5633 Author: ChiTimesChi <[email protected]> Date: Mon Mar 28 13:17:33 2022 +0300 appropriate synFrax Adapter naming commit 8e8fd1fcb5351454ec6b7b45fc556ecb807de89f Author: ChiTimesChi <[email protected]> Date: Mon Mar 28 12:22:21 2022 +0300 delete gmx "swap" adapter commit 18a35fc95b9a5f9f68d09aeff54b67e356301e75 Merge: e4db8b2 ef38c03 Author: ChiTimesChi <[email protected]> Date: Mon Mar 28 12:00:59 2022 +0300 Merge branch 'feature/bridge-wrapper' into feature/bridge-vault commit ef38c031e550a117dc9cd03347146e96901305cd Author: ChiTimesChi <[email protected]> Date: Mon Mar 28 11:58:41 2022 +0300 docs for MintBurnWrapper commit 9a0a6f1d6682d888ed50652e5099d0fa31bd3c22 Author: ChiTimesChi <[email protected]> Date: Sun Mar 27 22:42:53 2022 +0300 fix burnFrom allowance commit 33e979e2281c9fe9a0eafcd1c794c3fc4e91128b Merge: fa23054 e4db8b2 Author: ChiTimesChi <[email protected]> Date: Sun Mar 27 21:06:30 2022 +0300 Merge branch 'feature/bridge-vault' into feature/bridge-wrapper commit e4db8b22ae694aacc19d29566d47bc41e22a4563 Author: ChiTimesChi <[email protected]> Date: Sun Mar 27 21:05:13 2022 +0300 IERC20 -> IERC20Mintable commit fa2305465d444a33759a33baf0af1aca37420af0 Author: ChiTimesChi <[email protected]> Date: Sun Mar 27 20:57:45 2022 +0300 GMX bridge wrapper token commit 18650e03b2e3ce39f717eea24b72aee492213454 Author: ChiTimesChi <[email protected]> Date: Sun Mar 27 20:57:14 2022 +0300 Uniswap Adapter for wrapper token commit 9f8b8a973b23b05ca44989a90be0b098a42c5ff8 Author: ChiTimesChi <[email protected]> Date: Sun Mar 27 20:56:16 2022 +0300 Bridge wrapper for directly unsupported tokens commit 76deb8f69d6b0fefc0708b52f9114689275efabb Author: ChiTimesChi <[email protected]> Date: Sun Mar 27 18:22:50 2022 +0300 synGMX <> GMX swap Adapter commit 5d86835cbfa01b604eebbf353a269c902cd84dfc Author: ChiTimesChi <[email protected]> Date: Sun Mar 27 17:17:01 2022 +0300 a slightly better modifier naming commit 9d5d0e74c35387e285ec23aeda5fd4bb7deb2d02 Author: ChiTimesChi <[email protected]> Date: Sun Mar 27 17:14:47 2022 +0300 Vault should be the one minting tokens commit e0bf96a510545b9bd6187d57b484308fad67df60 Author: ChiTimesChi <[email protected]> Date: Sun Mar 27 17:02:44 2022 +0300 fix inconsistent naming commit dcc5a43cb5f8273bc842c375212c6c94ba653daa Author: ChiTimesChi <[email protected]> Date: Sun Mar 27 17:01:38 2022 +0300 verify actual burn and deposit amounts commit 17a76caf733feaacf5eaf3a3b74255f2c3929c32 Author: ChiTimesChi <[email protected]> Date: Sun Mar 27 12:27:14 2022 +0300 delete Arbitrum test (this fixes things) commit 52c3ed19cb82adbcddd400a2d8469b4537ddb24c Author: ChiTimesChi <[email protected]> Date: Sat Mar 26 21:27:38 2022 +0300 manual inf allowance for BridgeRouter: useful for some bridge wrappers (convert synAsset -> asset without Adapter) commit d4d4b07d6802bb23ad80c55d03c2d3be2498865a Author: ChiTimesChi <[email protected]> Date: Sat Mar 26 20:15:28 2022 +0300 gmx test for Arbitrum commit 1b3ea56237d38b213990857c229ed16e3567ebc0 Author: ChiTimesChi <[email protected]> Date: Sat Mar 26 20:09:48 2022 +0300 fix broken test commit 1ea6cc8a11958546edac3f1fea1856a853d8f5f3 Author: ChiTimesChi <[email protected]> Date: Sat Mar 26 19:35:34 2022 +0300 add frax adapter commit 1eb13571bfa3e92cc211fc7785537939d7244b80 Author: ChiTimesChi <[email protected]> Date: Sat Mar 26 16:54:14 2022 +0300 add gmx adapter commit f99eacdce7be8c5f16b160abe9efe4a7841577a3 Author: ChiTimesChi <[email protected]> Date: Sat Mar 26 13:18:53 2022 +0300 hushing linter again commit 5bf24d3e52a972a1d6de610e8909b9e86193c30f Author: ChiTimesChi <[email protected]> Date: Sat Mar 26 13:13:48 2022 +0300 organize interfaces commit 27bcdd8e33e3f50bbf219e2379f75976e8b4052b Author: ChiTimesChi <[email protected]> Date: Sat Mar 26 13:03:15 2022 +0300 add Perry the Platypus adapter commit f1a20374057805e3d909c5454c130363354fa9d8 Merge: 07279af 09c64e9 Author: χ² <[email protected]> Date: Sat Mar 26 00:37:57 2022 +0300 Merge pull request #79 from synapsecns/chisq/router-prototype Router prototype commit 4360abd72ada74d119a015cfa211fb03760bb87c Author: ChiTimesChi <[email protected]> Date: Fri Mar 25 21:06:54 2022 +0300 swap() always pulls from msg.sender commit 91e47a6b0099d654ba8b9929a5d6b95d0ef250e9 Author: ChiTimesChi <[email protected]> Date: Fri Mar 25 21:05:19 2022 +0300 uint8 is apparently slower than uin256 in for loop commit 2b4a05a5c9050855e5a30e4acabbf5e78291cfc9 Author: ChiTimesChi <[email protected]> Date: Fri Mar 25 21:04:29 2022 +0300 faster getDepositAddress commit 739b8af696d1b8ae7f8d34bf164f281fe53a0537 Author: ChiTimesChi <[email protected]> Date: Fri Mar 25 19:16:20 2022 +0300 _doChainedSwaps speedup + extra verify commit 09c64e9bb68f8028b8713d33c29d25b19933e4b3 Author: ChiTimesChi <[email protected]> Date: Thu Mar 24 22:22:14 2022 +0300 findBestPathInitialChain moved to Quoter commit df865cc657534dab8da6b1b8215bf6519bac706d Author: ChiTimesChi <[email protected]> Date: Thu Mar 24 20:42:05 2022 +0300 curve base pool gas test commit eed286123ce831563a25fccd3b35f7c5ac58c288 Author: ChiTimesChi <[email protected]> Date: Thu Mar 24 20:39:26 2022 +0300 reduce Curve tests a bit commit 34f7462f6ef838ea45858f1d4fddabcead4c25b5 Author: ChiTimesChi <[email protected]> Date: Thu Mar 24 20:29:01 2022 +0300 direct swap optimisation commit 7140612c7fe1cbce401a62f2efe049fa14e975c9 Author: ChiTimesChi <[email protected]> Date: Thu Mar 24 20:16:16 2022 +0300 add curve description commit 43ad22b3b5e9e9ad88f80081b080c6694defae16 Author: ChiTimesChi <[email protected]> Date: Thu Mar 24 20:09:26 2022 +0300 curve renaming commit 222a817f1aa6787acbb52c837cd315248fb159c0 Author: ChiTimesChi <[email protected]> Date: Thu Mar 24 14:01:29 2022 +0300 fix broken tests (again) commit 02057a4bdfe71b486f2eb9ed1b085b3bb1e7dfc0 Author: ChiTimesChi <[email protected]> Date: Thu Mar 24 13:46:48 2022 +0300 limit gas usage for external Router call commit 0a555955fe295293d47e688d73acc519b83a55f7 Author: ChiTimesChi <[email protected]> Date: Thu Mar 24 13:19:24 2022 +0300 test lint commit 42ec6d9842731e0b6f1237eac75d57edfdb0f301 Author: ChiTimesChi <[email protected]> Date: Thu Mar 24 13:17:14 2022 +0300 reduce tests a bit commit 3f6021e10e167d31ecbcd61fdbc7149ab1b79e5a Author: ChiTimesChi <[email protected]> Date: Thu Mar 24 13:08:47 2022 +0300 move gas tests where they belong commit bc58cb6ac1cba62be4e37d9355ed61c92082b17c Author: ChiTimesChi <[email protected]> Date: Thu Mar 24 13:04:16 2022 +0300 swap rework: don't check allowance every time commit 8610865393bc94f7705c8a4a8d67e5ac8d98b705 Author: ChiTimesChi <[email protected]> Date: Thu Mar 24 00:00:47 2022 +0300 add ftm rpc to workflow commit ee0514caaf1d50afea182fa5645bf4d84d0ad3fe Author: ChiTimesChi <[email protected]> Date: Thu Mar 24 00:00:14 2022 +0300 fix SynapseBaseAdapter naming commit 8dd4c9ac8f895933d8f0ff407d85e518209705a8 Author: ChiTimesChi <[email protected]> Date: Wed Mar 23 23:06:00 2022 +0300 Synapse gas tests commit c73465c7f9e3788ba2f6cf84fabcd28005a285f3 Author: ChiTimesChi <[email protected]> Date: Wed Mar 23 23:05:23 2022 +0300 Synapse adapters rework + speedup commit b9a5b52b4f6cf5ae1970c66a60ac4e4333be6a42 Author: ChiTimesChi <[email protected]> Date: Wed Mar 23 21:28:38 2022 +0300 add solidly adapter commit b1f5d6ef28addcc44ffb4d670d0cedb382816b0b Author: ChiTimesChi <[email protected]> Date: Wed Mar 23 18:54:54 2022 +0300 trim+rework imports commit b10ae10a4e9ddec6d17a207bacd687489df3ad9a Author: ChiTimesChi <[email protected]> Date: Wed Mar 23 18:17:46 2022 +0300 lets not waste gas emitting useless things commit 3b3f2050675346d53a29a7ce64e892749d9557eb Author: ChiTimesChi <[email protected]> Date: Wed Mar 23 18:16:38 2022 +0300 uni fast vs slow commit c95c3b3dca3db665af337e93046125e3973e6635 Author: ChiTimesChi <[email protected]> Date: Wed Mar 23 17:50:25 2022 +0300 update uni tests commit 704ceb71a169caaa7634bcdfbd47e2398a6016f1 Author: ChiTimesChi <[email protected]> Date: Wed Mar 23 17:49:55 2022 +0300 speed up UniV2 adapter commit 4f455f946ba2eca88bcbae80c8c39b08cd493c45 Author: ChiTimesChi <[email protected]> Date: Wed Mar 23 13:53:29 2022 +0300 rip gas long live gas commit 54704c14dbb68195bd17aae21f46911825247456 Author: ChiTimesChi <[email protected]> Date: Mon Mar 21 21:02:27 2022 +0300 +depositMax, redeemMax, redeemV2Max commit 874ac650339618d54b0da8860ec9b0e0fb9fb6ef Author: ChiTimesChi <[email protected]> Date: Mon Mar 21 19:33:37 2022 +0300 Someday I will remember to run tests before pushing. This day is not today. commit ffe901fccbf6e1f1c902949f2ea53d1a47090f40 Author: ChiTimesChi <[email protected]> Date: Mon Mar 21 18:31:06 2022 +0300 more consistency in recovering things commit fb8f445c79249f3fad42657141ac0af1d56ce4b9 Author: ChiTimesChi <[email protected]> Date: Mon Mar 21 18:04:26 2022 +0300 new Bridge, new Vault commit 36b1912e7cdf575e7dbfd25f72b8e75f1b5964b4 Author: ChiTimesChi <[email protected]> Date: Sun Mar 20 21:04:36 2022 +0300 fix typo commit 001b773b6d0aa6b81f3fbbc3b2f8bd883ef38f24 Author: ChiTimesChi <[email protected]> Date: Sun Mar 20 20:58:46 2022 +0300 BridgeQuoter rework + better docs commit a9628351a6882bdb2f360fa803b86877bfa22681 Author: ChiTimesChi <[email protected]> Date: Sun Mar 20 18:41:17 2022 +0300 amounts should be adapters or it wont work commit a15c4f9bedf338e2aacf3a936a8273849a93d951 Author: ChiTimesChi <[email protected]> Date: Sat Mar 19 22:29:53 2022 +0300 first draft for Vault commit 728acdbf904899dd8ff120080eba72f291d1dec1 Author: ChiTimesChi <[email protected]> Date: Sat Mar 19 21:15:44 2022 +0300 cut stress tests in half commit 479c2ab20c53b92cca361181d67d2a12548ccc50 Author: ChiTimesChi <[email protected]> Date: Sat Mar 19 18:18:25 2022 +0300 fix "find best path incl gas costs" + add tests commit 406b58ff35bcf8d0ae41527c354df9953bf89a5c Author: ChiTimesChi <[email protected]> Date: Sat Mar 19 13:32:26 2022 +0300 test: Router can swap thru Quoter's found path commit b19bbc730143d759d294271d0069ac1479bcd6a1 Author: ChiTimesChi <[email protected]> Date: Sat Mar 19 12:04:41 2022 +0300 yay, it compiles now (fix countless zaps) commit 3597a769cb9d854a6d4e838ab71c1a77fb056b01 Author: ChiTimesChi <[email protected]> Date: Sat Mar 19 11:38:11 2022 +0300 fix capitalization commit ada070d15e2607d63bbc72e0ef88f0fc23e3aa48 Merge: 90bce66 eea8f4c Author: aureliusbtc <[email protected]> Date: Fri Mar 18 05:11:37 2022 -0400 Merge pull request #100 from synapsecns/chisq/quoter Add quoter into router-prototype commit eea8f4c366f467670106273fbb67f07ef3ebfb37 Author: ChiTimesChi <[email protected]> Date: Thu Mar 17 21:13:23 2022 +0300 a few more 3-step swap tests commit aa0c969f6ae51683b1f59e964a9b417905d9cdc9 Author: ChiTimesChi <[email protected]> Date: Thu Mar 17 17:35:05 2022 +0300 initial Quoter tests commit 033ea7d41b8478515bcb0487a17789e72803d204 Author: ChiTimesChi <[email protected]> Date: Thu Mar 17 17:34:21 2022 +0300 share data between tests commit e9d4374205a5c4b84aa888f63baa1c21d05d2b39 Author: ChiTimesChi <[email protected]> Date: Thu Mar 17 13:15:23 2022 +0300 increase heap size, pray it works commit f8f5c9e2c4278ef59c279788c03cb4b0d7458ca0 Author: ChiTimesChi <[email protected]> Date: Wed Mar 16 17:27:40 2022 +0300 Router 3-step swap tests commit 619e61671dbce29c294e07d198ae4daf4c49df24 Author: ChiTimesChi <[email protected]> Date: Wed Mar 16 16:43:26 2022 +0300 remove bridgeMaxSwaps from BasicRouter test commit 8bbabefca93abc1d53afac4be62626a17369ed1e Author: ChiTimesChi <[email protected]> Date: Wed Mar 16 15:33:50 2022 +0300 I'm a doc writoooor commit 90b27fdd8ccd976185c2f44091fc9395b22bca83 Author: ChiTimesChi <[email protected]> Date: Wed Mar 16 12:47:54 2022 +0300 linter pls shut up commit 68669885f10abb0975040271a62253f15575700c Author: ChiTimesChi <[email protected]> Date: Wed Mar 16 12:43:25 2022 +0300 separate Bridge-related functions into BridgeRouter, BridgeQuoter commit d879a416c3d66cb9eebd39d54b25c6d2b6f57026 Author: ChiTimesChi <[email protected]> Date: Wed Mar 16 12:03:42 2022 +0300 move checks into _doChainedSwaps commit 8fbdb27767bd0bcc523e855aad762c2c106ec314 Author: ChiTimesChi <[email protected]> Date: Wed Mar 16 12:00:58 2022 +0300 _amountOut consistent naming commit 967dd9a6cab929bdd635f484e8ccbc23a0841d8d Author: ChiTimesChi <[email protected]> Date: Wed Mar 16 00:28:54 2022 +0300 this fixes things, though owner is less rich now commit 6b157b6423a51d1a1ddb50f6d5c41ffc69cf5f32 Author: ChiTimesChi <[email protected]> Date: Tue Mar 15 23:43:11 2022 +0300 2-step swap Router test commit a3e8c857997bad4bb746f0c5d096f6cb67fe50e0 Author: ChiTimesChi <[email protected]> Date: Tue Mar 15 23:03:30 2022 +0300 very tests much complex swaps commit cbef8bd06e80ee7b93061f631167a3edd3805a94 Author: ChiTimesChi <[email protected]> Date: Tue Mar 15 22:54:06 2022 +0300 add missing testing functions to interfaces commit 96d2f422ed8da5226a1d8e188ada0bb7604c20a8 Author: ChiTimesChi <[email protected]> Date: Tue Mar 15 22:53:30 2022 +0300 me not forget licensing, not at all commit 90bce6677ab48b8b69e1566958b047c57c84fec7 Author: ChiTimesChi <[email protected]> Date: Tue Mar 15 17:42:57 2022 +0300 query should not revert commit 340e3a86f590401cc96c1b8ca3c9220239cd1bf0 Author: ChiTimesChi <[email protected]> Date: Tue Mar 15 17:19:00 2022 +0300 naming is slightly less dogshit now commit 3705539d7aaee884ff39d2dda39a9a72cd0903f9 Author: ChiTimesChi <[email protected]> Date: Tue Mar 15 17:16:20 2022 +0300 remove extra checks commit 9e6dcf1ed2b6860b3b2eef95d9826d7f8735a33c Author: ChiTimesChi <[email protected]> Date: Mon Mar 14 21:33:42 2022 +0300 chainId can be fetched via assembly cheaper commit cb3afa74b97481551adb0e6673f1198263c977c1 Author: ChiTimesChi <[email protected]> Date: Mon Mar 14 21:18:57 2022 +0300 add Uniswap code for testing commit 26ff8fd6cd106e3b8b4647f5da01285bf81b82bf Author: ChiTimesChi <[email protected]> Date: Mon Mar 14 17:51:51 2022 +0300 Basic contracts require basic testing commit d7823ccc69e710d204dcd65c7c8abb29ce503f1d Author: ChiTimesChi <[email protected]> Date: Mon Mar 14 17:18:26 2022 +0300 dont allow duplicate adapters/tokens commit 50aefe4454594e41ee1eddec9c7deb2b82f3feb0 Author: ChiTimesChi <[email protected]> Date: Mon Mar 14 15:59:44 2022 +0300 consistent ordering commit 61ae28441fd0461029cc9e205e671366b4beb4b4 Author: ChiTimesChi <[email protected]> Date: Sat Mar 12 14:15:02 2022 +0300 put Offers into a separate library commit abd6cea9018ed31e36bf919054bd8fee987f533d Author: ChiTimesChi <[email protected]> Date: Sat Mar 12 14:03:06 2022 +0300 add missing functions to interface commit fb2950286ad9c0e9e981d6f2dac1c00773d4968f Author: ChiTimesChi <[email protected]> Date: Fri Mar 11 20:48:50 2022 +0300 1. enforce max Swaps for Bridge&Swap txs 2. maxSteps are now maxSwaps 3. some extra comments commit c444576de4aeec74dc8236a30d6f856e19c6e379 Author: ChiTimesChi <[email protected]> Date: Fri Mar 11 10:49:33 2022 +0300 consistent naming commit 17b6292bf83ad632ad5b45fca70aeaba819a250d Author: ChiTimesChi <[email protected]> Date: Fri Mar 11 00:34:36 2022 +0300 return expected amountOut commit 71610086fc73241f333cf19902f5dfa0c6d50f01 Author: ChiTimesChi <[email protected]> Date: Fri Mar 11 00:22:43 2022 +0300 tradeData for single-chain swaps (with slippage) commit 7de1168564c8813d3f8382f9223a7b03d2023d7c Author: ChiTimesChi <[email protected]> Date: Thu Mar 10 23:51:11 2022 +0300 _findBestPathWithGas is slightly more readable commit 3b4fe7e6849e51205796bcedf2f1796436b3d00f Author: ChiTimesChi <[email protected]> Date: Thu Mar 10 23:38:06 2022 +0300 encodeWithSelector to get bridge calldata (WIP) commit 794652b7480035b80fa4843709794dc668d3363c Author: ChiTimesChi <[email protected]> Date: Thu Mar 10 14:51:02 2022 +0300 hush, linter commit e95d2bc76a8dd158bbb4b51ef8ebe3c7fec623d7 Author: ChiTimesChi <[email protected]> Date: Thu Mar 10 14:39:53 2022 +0300 Adapters are now stored in Quoter + cleanup commit fb5468226b1d95000691088bd61a7a33ad86020f Author: ChiTimesChi <[email protected]> Date: Thu Mar 10 13:11:02 2022 +0300 add missing functions to interfaces commit 68100f927ff4fd5da8022a7056b09efee9c74384 Author: ChiTimesChi <[email protected]> Date: Wed Mar 9 21:08:16 2022 +0300 first take at Quoter commit 9d9808d72c7363bd39efe2476be4b9adfcc2a0a3 Author: ChiTimesChi <[email protected]> Date: Wed Mar 9 18:59:42 2022 +0300 max steps for quoter commit 7f0d571a985db0976efab3cfcc77c4b71b7df7a8 Author: ChiTimesChi <[email protected]> Date: Wed Mar 9 18:49:01 2022 +0300 uint256 -> uint8 for index values commit 66e016e8ceb0f553069a83daad5c406d36b25fa0 Author: ChiTimesChi <[email protected]> Date: Wed Mar 9 18:30:27 2022 +0300 i suck at copy pasta commit 330e4f8b1001e9caa3f40f0b44a3a21bd97ab50e Author: ChiTimesChi <[email protected]> Date: Wed Mar 9 18:29:37 2022 +0300 modifiers for checking indexes commit e6bebb52bd2266a18190ecfb9624c57ea70579bb Author: ChiTimesChi <[email protected]> Date: Wed Mar 9 17:51:48 2022 +0300 Basic Quoter commit 251daf8fae910ade5c7452e947fd913e0c7be954 Author: ChiTimesChi <[email protected]> Date: Wed Mar 9 17:57:55 2022 +0300 me break tests, me fix tests commit d8d0566e52f16b57fb1e5feb8444fffb9508b4dd Author: ChiTimesChi <[email protected]> Date: Wed Mar 9 17:15:08 2022 +0300 fix synapse test naming commit 5d6d329940be971387be5eab2b254cebec552dd2 Author: ChiTimesChi <[email protected]> Date: Wed Mar 9 17:13:59 2022 +0300 fix SwapCalculator naming commit db36df0c5431a5c4c3a5d2e4b37bbb611498a3c6 Author: ChiTimesChi <[email protected]> Date: Wed Mar 9 00:09:11 2022 +0300 fix comments commit 57384fac83148a1022c320fa24feb2036d35f1b7 Author: Trajan0x <[email protected]> Date: Tue Mar 8 00:18:55 2022 -0500 functionalize commit 3a161915ada6aa4cffade3f8814dfca2821d7718 Author: Trajan0x <[email protected]> Date: Mon Mar 7 23:58:39 2022 -0500 cleanup uniswap adapters commit 3ea725b6ca6c3d90bbb88ab0d1e9cdf6c57c27d4 Author: Trajan0x <[email protected]> Date: Mon Mar 7 23:53:38 2022 -0500 increase test timeout for parallell test commit e337d7b8d04df171010eaf36157317af4aa10ce8 Author: Trajan0x <[email protected]> Date: Mon Mar 7 22:46:02 2022 -0500 lint commit 61465732b48caa534551fc8720c7802ef670ff9c Merge: 602b11f 07279af Author: Trajan0x <[email protected]> Date: Mon Mar 7 22:45:36 2022 -0500 merge feature commit 602b11f5d984409de2d22498073ff41b006e04e0 Merge: ad9d09e 12a8dc1 Author: trajan0x <[email protected]> Date: Tue Mar 8 00:10:51 2022 +0000 Merge pull request #94 from synapsecns/chisq/adapter-base Add Adapters to Router Prototype commit 12a8dc1eccebe0deb212e2ff852048d48705652a Author: Trajan0x <[email protected]> Date: Mon Mar 7 18:52:22 2022 -0500 silence compiler run warnings by enabling the optimizer commit 37b60b57890abf764f7766795f2ce15923bee623 Author: Trajan0x <[email protected]> Date: Mon Mar 7 18:44:34 2022 -0500 rename workflows commit 4e7fc663725069402125267ab0cac3a5ce3b704b Author: Trajan0x <[email protected]> Date: Mon Mar 7 18:31:31 2022 -0500 ignore mocks in coverage commit fca6048c42f942aa7a121fdfcf264f28bea4a293 Author: Trajan0x <[email protected]> Date: Mon Mar 7 18:23:41 2022 -0500 test adapter swap commit 369912d8877a52ddebe3dad3587159ed2044eb42 Merge: ba93011 01ed460 Author: trajan0x <[email protected]> Date: Mon Mar 7 21:12:41 2022 +0000 Merge pull request #92 from synapsecns/chisq/adapter-curve Adapter/Curve -> Adapter/Base commit 01ed4601dbdd642046038fc85059fa22d283b3ef Author: aureliusbtc <[email protected]> Date: Mon Mar 7 14:40:43 2022 -0500 resolve merge commit ca48d2ab683eaede36e91393173475d8ea885c38 Author: aureliusbtc <[email protected]> Date: Mon Mar 7 13:05:02 2022 -0500 remove .only on tests commit ba9301163828ea5dc43e6519193a12e87e174dc7 Author: ChiTimesChi <[email protected]> Date: Mon Mar 7 20:00:16 2022 +0300 update Synapse adapters to reflect updated Adapter commit 472199a3b19ffcf81ffd51d2ba0c87db097223e6 Author: ChiTimesChi <[email protected]> Date: Mon Mar 7 19:55:31 2022 +0300 check tokenIn != tokenOut in basic Adapter commit dadd85b38cd7520d8dfc513389081fdcdd798ad0 Author: ChiTimesChi <[email protected]> Date: Mon Mar 7 19:33:04 2022 +0300 separate folder for Synapse adapters commit 72f1d4992e77b405030a73c68fe32ade978bda37 Author: ChiTimesChi <[email protected]> Date: Mon Mar 7 18:27:52 2022 +0300 query should never revert commit 53122fbd444349dd228dcb13ea14f63c0c559645 Author: ChiTimesChi <[email protected]> Date: Mon Mar 7 17:58:12 2022 +0300 Curve ETH TriCrypto test commit 33bf67432551fbde92755234c353bb1e3dbb7449 Author: ChiTimesChi <[email protected]> Date: Mon Mar 7 17:51:08 2022 +0300 Curve ETh FRAX test commit e64b068f08b364682113dc3b41c479282201b128 Author: ChiTimesChi <[email protected]> Date: Mon Mar 7 17:27:44 2022 +0300 Curve ETH Avax test commit 50c84380d9c1fb29da328dcd3f8ec765288bfde1 Author: ChiTimesChi <[email protected]> Date: Mon Mar 7 17:21:08 2022 +0300 Curve ETH 3pool test commit ec59bc75d76be0f655b2defca31219a630f92c65 Author: Trajan0x <[email protected]> Date: Sun Mar 6 20:54:17 2022 -0500 make failure language more explicit commit 62748ecd62794b2efd435bdfbe7e79bfe6c55526 Author: aureliusbtc <[email protected]> Date: Sun Mar 6 20:49:54 2022 -0500 TriCrypto ETH Passing commit 881c9d99649c7d1b20888541eb3c1099223343c9 Author: Trajan0x <[email protected]> Date: Sun Mar 6 19:08:23 2022 -0500 fix sanity checks commit dd7a7ae4059aeec951e43591ac0caebad364158b Author: Trajan0x <[email protected]> Date: Sun Mar 6 18:59:21 2022 -0500 fix curvetricrypto (avax) commit 1808c5b04d523b1eadaa6fdfc27355f89e5352cb Author: Trajan0x <[email protected]> Date: Sun Mar 6 18:42:45 2022 -0500 update mocha to fix mochajs/mocha#3090 commit dbe1a678594aad8fb55656b12b899b558c4a653a Merge: 48dd1f2 2cc7153 Author: Trajan0x <[email protected]> Date: Sun Mar 6 18:28:46 2022 -0500 update adapters commit 2cc7153ea83917a34d30dd9cd8a4dd9f9a7da1f8 Merge: a57a4dc ad9d09e Author: Trajan0x <[email protected]> Date: Sun Mar 6 15:42:37 2022 -0500 merge adapters commit 48dd1f27ff4ae5c4cf463e957ec19d610e33729d Merge: f44f083 e39be45 Author: Trajan0x <[email protected]> Date: Sat Mar 5 15:02:27 2022 -0500 Merge branch 'chisq/adapter-curve' of https://github.com/synapsecns/synapse-contracts into chisq/adapter-curve commit f44f08362441f0c12e9b7a387f86425bba28f682 Author: Trajan0x <[email protected]> Date: Sat Mar 5 15:01:28 2022 -0500 push commit e39be4514820d29030e1a8f6d2aedb18aaee9147 Author: aureliusbtc <[email protected]> Date: Sat Mar 5 14:55:07 2022 -0500 Fix aave ETH Adapter commit 9ce227276c691a5458f5b102d283bc676ee7818f Author: aureliusbtc <[email protected]> Date: Sat Mar 5 14:25:32 2022 -0500 add 3pool-specific adapter type commit 1dc5bb8bf01cc21c8b098eae43b9e95a09f5874f Merge: e666816 2fcedb0 Author: aureliusbtc <[email protected]> Date: Sat Mar 5 14:19:00 2022 -0500 Merge branch 'chisq/adapter-curve' of https://github.com/synapsecns/synapse-contracts into chisq/adapter-curve commit e6668168f892f3a38e40a67a3af5ae1dfc26ed9f Author: aureliusbtc <[email protected]> Date: Sat Mar 5 14:18:36 2022 -0500 Clean up eth3pool, break frax again, clean up helper types commit 2fcedb06ff1c38bd64534c2cc0868018522931dd Author: Trajan0x <[email protected]> Date: Sat Mar 5 14:18:02 2022 -0500 new contract addresses commit 8a5c95cd4f93c7d008b2e7650e830ac77502ce0f Author: aureliusbtc <[email protected]> Date: Sat Mar 5 11:47:38 2022 -0500 rm dead function commit 28dba0c5d06e3c87de9d3ede7355cac848a9a3ec Author: aureliusbtc <[email protected]> Date: Fri Mar 4 22:10:39 2022 -0500 Correct context to have all eth3pool tests pass commit 8db710cd18f29e6d3e2987abebfc276a07de0a4e Author: aureliusbtc <[email protected]> Date: Fri Mar 4 21:40:21 2022 -0500 * 3pool Swap Tests Pass * 3pool Sanity Checks Fail * Some types added to helpers.ts commit 2e34db93b8bd66bb8ab6bd0c438367c74812d105 Author: aureliusbtc <[email protected]> Date: Fri Mar 4 21:01:30 2022 -0500 eth 3pool test imrpvoemetns commit a57a4dc826a00a448ea4d5925b426e08df72de4c Merge: 8c6cf3b 08c97d1 Author: aureliusbtc <[email protected]> Date: Fri Mar 4 19:47:08 2022 -0500 Merge pull request #93 from synapsecns/chisq/adapter-aave Adapter/Aave -> Adapter/Base commit 8c6cf3b848af8b28090ccd6fd8d740b521e9f62f Merge: e438e5e 501e4d4 Author: aureliusbtc <[email protected]> Date: Fri Mar 4 19:45:39 2022 -0500 Merge pull request #91 from synapsecns/chisq/adapter-uniswap Adapter/uniswap -> Adapter/base commit f2e8f37243bc65d49d80337fc3e3e0e8f709d770 Merge: edcbfb4 e96eb1b Author: Trajan0x <[email protected]> Date: Fri Mar 4 17:59:16 2022 -0500 Merge branch 'chisq/adapter-curve' of https://github.com/synapsecns/synapse-contracts into chisq/adapter-curve commit edcbfb4a751b3af1c21b4419edb34956162d6ca5 Author: Trajan0x <[email protected]> Date: Fri Mar 4 17:58:57 2022 -0500 more cleanup commit e96eb1b4e3848d9f01fc177b641106b2d459c682 Author: aureliusbtc <[email protected]> Date: Fri Mar 4 17:05:31 2022 -0500 fix imports commit 501e4d4adeb373f48f09b84a5437ab7fe1162373 Author: Trajan0x <[email protected]> Date: Thu Mar 3 21:43:14 2022 -0500 cleanup commit 83843a56fda397f52803c17ad15c2b41d258ba84 Author: Trajan0x <[email protected]> Date: Thu Mar 3 21:40:59 2022 -0500 util cleanup commit 5ccafb18c51b60d6220cdd60af2590a20858b13f Merge: 076e969 d79cac3 Author: Trajan0x <[email protected]> Date: Thu Mar 3 21:39:00 2022 -0500 uniswap merge commit b4ac96bba9f25539e6869d2e4888a2ab2aaea510 Author: Trajan0x <[email protected]> Date: Thu Mar 3 21:07:20 2022 -0500 finish curve tests commit 1e771fa368ebb500349359f18359a2eb3f0ca7b2 Merge: 612d389 d79cac3 Author: Trajan0x <[email protected]> Date: Thu Mar 3 20:54:55 2022 -0500 merge master commit 612d389e3dcd25a031ac6107354ef6d8e73b6292 Author: Trajan0x <[email protected]> Date: Thu Mar 3 00:09:38 2022 -0500 Revert "kill eth tests (to test ci workflow" This reverts commit b402b36d00aca60808b85247de9e653c3ea8abf4. commit b402b36d00aca60808b85247de9e653c3ea8abf4 Author: Trajan0x <[email protected]> Date: Thu Mar 3 00:09:31 2022 -0500 kill eth tests (to test ci workflow commit 2688a1361dd1711c40a050fc2da22113d6248b93 Merge: 90d26e2 9aa7fa3 Author: Trajan0x <[email protected]> Date: Wed Mar 2 23:08:24 2022 -0500 Merge branch 'chisq/adapter-curve' of https://github.com/synapsecns/synapse-contracts into chisq/adapter-curve commit 90d26e22e98668df98264eee4c1bfb1b52a9e755 Author: Trajan0x <[email protected]> Date: Wed Mar 2 23:08:12 2022 -0500 Revert "enable archive data" This reverts commit c523e70ae4ae597484e99d29e116f5d42d996610. commit c523e70ae4ae597484e99d29e116f5d42d996610 Author: Trajan0x <[email protected]> Date: Wed Mar 2 23:08:08 2022 -0500 enable archive data commit 9aa7fa34632603b36ae18a4d6d60b098197f1506 Merge: 8f98637 e438e5e Author: trajan0x <[email protected]> Date: Thu Mar 3 03:41:33 2022 +0000 Merge branch 'chisq/adapter-base' into chisq/adapter-curve commit 8f9863708e283e66c17224c1ac2ba5d71d8a7a04 Author: Trajan0x <[email protected]> Date: Wed Mar 2 22:40:24 2022 -0500 add alchemy secret commit 076e969a3184c8ee55fc5600c35c094a315ad54b Author: Trajan0x <[email protected]> Date: Wed Mar 2 19:59:10 2022 -0500 update uniswap adaptor commit ee00ae926e3647edde0412c0f8b881daae1fd0e4 Author: Trajan0x <[email protected]> Date: Wed Mar 2 19:58:34 2022 -0500 avax api commit e438e5e90fb17ee5df556a3ea67cdba25015d00b Author: Trajan0x <[email protected]> Date: Wed Mar 2 19:57:46 2022 -0500 add enviornment variable to test commit 08c97d1c62e055c855f51c85177a311c5f6ee5cb Author: Trajan0x <[email protected]> Date: Wed Mar 2 19:56:16 2022 -0500 fix tests commit 226721994dc04fa503e745ddb88136331fd38c0b Author: ChiTimesChi <[email protected]> Date: Fri Feb 25 22:18:14 2022 +0300 tests rework intensifies commit a180eeb09c3bc3936468efaf776942cffde1f558 Author: ChiTimesChi <[email protected]> Date: Wed Feb 23 15:07:42 2022 +0300 test rework initiated commit 826b18a55340367e7434e3dda73f61277b68ac5a Author: ChiTimesChi <[email protected]> Date: Wed Feb 23 01:42:02 2022 +0300 curve tests upd and its not even their final form commit 69e7236c1210ffd8343d627c792d85f16e62d378 Author: ChiTimesChi <[email protected]> Date: Wed Feb 23 01:41:08 2022 +0300 helpers for tests commit 74873f9449cb227ec3282803b7866cc89856df9d Author: ChiTimesChi <[email protected]> Date: Wed Feb 23 01:15:31 2022 +0300 remove tests from other branches commit ad9d09eadf32cb4f739df6d927d36eb3edb8dcf2 Author: ChiTimesChi <[email protected]> Date: Tue Feb 22 13:18:18 2022 +0300 refundToAddress reentrancy check removed commit 477ee60555ad29e14aba73d3d19f70c61803bd9e Author: ChiTimesChi <[email protected]> Date: Tue Feb 22 10:14:23 2022 +0300 rework for returning GAS commit 766a7393f446aabcd8b1bbe9d8aee8266a992491 Author: ChiTimesChi <[email protected]> Date: Mon Feb 21 13:00:33 2022 +0300 fix possible reentrancy in refundToAddress commit 0868a8b03fc9f057885ebdb5f5e90550240b9f18 Author: ChiTimesChi <[email protected]> Date: Mon Feb 21 12:53:01 2022 +0300 god bless code spell checker commit 2ed338d9bc000a1bfeb9b22e30b0cd52bfa684e4 Author: aureliusbtc <[email protected]> Date: Sun Feb 20 21:44:56 2022 -0500 recover balance checks, typo fix commit dbaed6fd559502d1587000f0d20dafd819ebd984 Author: ChiSquared <[email protected]> Date: Sun Feb 20 23:53:21 2022 +0300 Split Router into two smaller contracts commit 1c3697b91ef0421552bc8492c8b80c9103214396 Author: chisquared <[email protected]> Date: Sun Feb 20 14:09:18 2022 +0300 trustedTokens -> baseTokens commit 6da25abd2307bdb75de256de46f3d02c18e5ff50 Author: chisquared <[email protected]> Date: Sun Feb 20 13:44:01 2022 +0300 add/remove a single adapter/token commit 0be5ba32ff4369b1c1dd7e45b9db0ebafeb95f03 Author: chisquared <[email protected]> Date: Sun Feb 20 02:40:26 2022 +0300 check msg.value on swapFromGAS commit 539c1dc1c8bfae6dd6792e8be0ec350220d457aa Author: chisquared <[email protected]> Date: Sun Feb 20 00:07:11 2022 +0300 remove extra variable & assert; better comments commit 07279af5d42597867e0c08b0ff9f4076792be8a4 Merge: ed7ba58 f709046 Author: χ² <[email protected]> Date: Sat Feb 19 23:14:23 2022 +0300 Merge pull request #78 from synapsecns/chisq/calc-add-liquidity Calculator for adding liquidity commit 0ba7dcdb9e457d88f9a7ec85874a2289dad2ca11 Author: chisquared <[email protected]> Date: Sat Feb 19 23:10:46 2022 +0300 move basic checks into basic Adapter commit 5a1a9f4da2999c5a216ea42b6ed9ee90420278bb Author: chisquared <[email protected]> Date: Sat Feb 19 23:07:58 2022 +0300 remove contracts from other braches commit 728e73520f46eaa3b75d71bc0db153b9f98f5ece Author: chisquared <[email protected]> Date: Sat Feb 19 23:07:24 2022 +0300 update tests to enable direct swaps commit e4cb17c42b52ba07a88a6a9ba6bb316c575ae47a Author: chisquared <[email protected]> Date: Sat Feb 19 23:06:28 2022 +0300 adapter for Curve triCrypto pool on AVAX commit f5a99403b3ec54c0ec0ea039a1c910a7137b035f Author: chisquared <[email protected]> Date: Sat Feb 19 23:04:37 2022 +0300 restructure logic for Curve adapters commit 1ec561106bf4603704f2968c6804746e33ca6e68 Author: chisquared <[email protected]> Date: Sat Feb 19 23:02:40 2022 +0300 add more functions to Curve interface commit 4915c065dd670e631b4d8eacbfa6497fc39626e5 Author: chisquared <[email protected]> Date: Sat Feb 19 23:00:34 2022 +0300 move basic checks into basic Adapter commit d9fcacd2c5dd6cd860f75e2b8d8e8969400a04af Author: chisquared <[email protected]> Date: Sat Feb 19 20:05:18 2022 +0300 add tests for Curve on AVAX commit 192e6e31e9e8276e8a9cd940caa39c6383d38452 Author: chisquared <[email protected]> Date: Sat Feb 19 19:42:52 2022 +0300 restructure curve tests commit befcca36593d4a33988fc6153d00d77a0de56f12 Author: chisquared <[email protected]> Date: Sat Feb 19 18:44:09 2022 +0300 tests for sushi (avax) commit d51700a8c0feed279603b04e2919016441350543 Author: chisquared <[email protected]> Date: Sat Feb 19 18:11:52 2022 +0300 tests for pangolin commit 97c3e94e30e4853f39a613cbc7e6cd71e3224430 Author: chisquared <[email protected]> Date: Sat Feb 19 17:44:48 2022 +0300 refactor TraderJoe tests commit 23a88c5079d43ddf0bbbab31512727b715f00678 Author: chisquared <[email protected]> Date: Sat Feb 19 16:17:03 2022 +0300 allow arbitrary swap fee commit e27642778c51b88b65ea962530cb0cf424444d21 Author: chisquared <[email protected]> Date: Sat Feb 19 15:19:35 2022 +0300 add triCrypto adapter + tests commit 2e647455ed0e75f374a155796902666d08a21581 Author: chisquared <[email protected]> Date: Sat Feb 19 15:18:44 2022 +0300 separate common logic into abstract curve adapter commit f4bc9de6ff47e58c2a12d89e5618a7c515fd3710 Author: chisquared <[email protected]> Date: Sat Feb 19 14:19:53 2022 +0300 proper naming, restructure commit ed6e8c4f17d62c07afa2986fa9bb126a4c6e75cc Author: chisquared <[email protected]> Date: Sat Feb 19 14:13:38 2022 +0300 restructure things a bit commit f709046372bb5135f092f71d72f821cdd33c1c81 Author: chisquared <[email protected]> Date: Sat Feb 19 13:39:23 2022 +0300 fix different naming commit 8d6b7be3f33d3325634c90eb488a82bb32fc2f57 Author: chisquared <[email protected]> Date: Sat Feb 19 00:45:48 2022 +0300 poolTokens -> public commit 99084665037a56415e07c99a3326e60f97bff63c Author: chisquared <[email protected]> Date: Fri Feb 18 20:47:06 2022 +0300 tests for curve adapters commit 31161814f563d9020306af37d7079e3876162a8a Author: chisquared <[email protected]> Date: Fri Feb 18 20:46:39 2022 +0300 Curve adapters commit 03e2da004f9c6496ba829a63fef44c0ca13b5d32 Author: chisquared <[email protected]> Date: Fri Feb 18 14:07:01 2022 +0300 add 0.8.11 commit 3112c00622e5843fa40a504b3e6ce644d4166b3e Author: chisquared <[email protected]> Date: Fri Feb 18 14:02:10 2022 +0300 router prototype commit a5d2187548a89e897b01eec4de998388adc81333 Author: chisquared <[email protected]> Date: Fri Feb 18 14:01:25 2022 +0300 base contract for adapters commit 31733651456047140fe9275d07c4bc9426097f03 Author: chisquared <[email protected]> Date: Thu Feb 17 22:55:56 2022 +0300 tests for uniswap adapter commit ced77eaf58706ae7ce89702456694ac7a360f2af Author: chisquared <[email protected]> Date: Thu Feb 17 22:55:11 2022 +0300 uniswap adapter commit 81a5474f7bfd1d153a8a7e25b82d64f3b8f629a7 Author: chisquared <[email protected]> Date: Thu Feb 17 13:44:14 2022 +0300 add nETH avWETH pool tests commit 337cc5c853a85475c33aceb4fd934ac3590b5b38 Author: chisquared <[email protected]> Date: Thu Feb 17 12:59:35 2022 +0300 cleanup tests, also moar tests commit db76f9dcb61a7a3881754f2abba3692767055cbc Author: chisquared <[email protected]
1 parent 96abeca commit bdb050a

File tree

159 files changed

+38544
-12226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+38544
-12226
lines changed

.github/workflows/coveralls.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ on: ["push", "pull_request"]
55

66
jobs:
77
coverage:
8-
name: Build
8+
name: Coverage
99
runs-on: ubuntu-18.04
1010
env:
11-
AVAX_API: https://api.avax.network/ext/bc/C/rpc
1211
ALCHEMY_API: ${{ secrets.ALCHEMY_API }}
12+
ARBITRUM_API: ${{ secrets.ARBITRUM_API }}
13+
AVAX_API: https://api.avax.network/ext/bc/C/rpc
14+
FTM_API: https://rpc.fantom.network
1315

1416
steps:
1517
- name: Datadog Agent

.github/workflows/test.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ jobs:
77
hardhat-test:
88
runs-on: ubuntu-latest
99
env:
10-
AVAX_API: https://api.avax.network/ext/bc/C/rpc
1110
ALCHEMY_API: ${{ secrets.ALCHEMY_API }}
11+
ARBITRUM_API: ${{ secrets.ARBITRUM_API }}
12+
AVAX_API: https://api.avax.network/ext/bc/C/rpc
13+
FTM_API: https://rpc.fantom.network
1214
DD_ENV: ci
1315

1416
steps:

.prettierrc.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
semi: false
22
trailingComma: "all"
3+
overrides:
4+
- files: "*.t.sol"
5+
options:
6+
printWidth: 120

.solcover.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// this does not work as .solcover.ts
33
module.exports = {
44
norpc: true,
5-
skipFiles: ["mocks/", "interfaces/", "MultisigWallet/", "auxiliary/", "testing/"],
5+
skipFiles: ["bridge/mocks/", "interfaces/", "MultisigWallet/", "auxiliary/", "bridge/testing/", "router/helper/test", "amm/helper/test"],
66
// see: https://github.com/sc-forks/solidity-coverage/blob/57319fae7e021cbe0f9a818100563f68b1fe6739/docs/faq.md
77
configureYulOptimizer: true
88
}

contracts/amm/SwapCalculator.sol

+202
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity 0.6.12;
4+
5+
import "./interfaces/ISwap.sol";
6+
import "./MathUtils.sol";
7+
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
8+
9+
interface IERC20Decimals is IERC20 {
10+
function decimals() external view returns (uint8);
11+
}
12+
13+
contract SwapCalculator {
14+
using SafeMath for uint256;
15+
using MathUtils for uint256;
16+
17+
// Struct storing variables used in calculations in the
18+
// {add,remove}Liquidity functions to avoid stack too deep errors
19+
struct ManageLiquidityInfo {
20+
uint256 d0;
21+
uint256 d1;
22+
uint256 preciseA;
23+
uint256 totalSupply;
24+
uint256[] balances;
25+
uint256[] multipliers;
26+
}
27+
28+
ISwap public immutable pool;
29+
IERC20 public immutable lpToken;
30+
uint256 public immutable numTokens;
31+
uint256 public swapFee;
32+
33+
IERC20[] internal poolTokens;
34+
uint256[] private tokenPrecisionMultipliers;
35+
36+
uint8 private constant POOL_PRECISION_DECIMALS = 18;
37+
uint256 private constant A_PRECISION = 100;
38+
uint256 private constant FEE_DENOMINATOR = 10**10;
39+
40+
constructor(ISwap _pool) public {
41+
pool = _pool;
42+
(, , , , uint256 _swapFee, , address _lpToken) = _pool.swapStorage();
43+
lpToken = IERC20(_lpToken);
44+
numTokens = _setPoolTokens(_pool);
45+
swapFee = _swapFee;
46+
}
47+
48+
function updateSwapFee() external {
49+
(, , , , uint256 _swapFee, , ) = pool.swapStorage();
50+
swapFee = _swapFee;
51+
}
52+
53+
function calculateAddLiquidity(uint256[] memory _amounts)
54+
public
55+
view
56+
returns (uint256)
57+
{
58+
require(
59+
_amounts.length == numTokens,
60+
"Amounts must match pooled tokens"
61+
);
62+
uint256 _numTokens = numTokens;
63+
64+
ManageLiquidityInfo memory v = ManageLiquidityInfo(
65+
0,
66+
0,
67+
pool.getAPrecise(),
68+
lpToken.totalSupply(),
69+
new uint256[](_numTokens),
70+
tokenPrecisionMultipliers
71+
);
72+
73+
uint256[] memory newBalances = new uint256[](_numTokens);
74+
75+
for (uint8 i = 0; i < _numTokens; i++) {
76+
v.balances[i] = ISwap(pool).getTokenBalance(i);
77+
newBalances[i] = v.balances[i].add(_amounts[i]);
78+
}
79+
80+
if (v.totalSupply != 0) {
81+
v.d0 = _getD(_xp(v.balances, v.multipliers), v.preciseA);
82+
} else {
83+
// pool is empty => all amounts must be >0
84+
for (uint8 i = 0; i < _numTokens; i++) {
85+
require(_amounts[i] > 0, "Must supply all tokens in pool");
86+
}
87+
}
88+
89+
// invariant after change
90+
v.d1 = _getD(_xp(newBalances, v.multipliers), v.preciseA);
91+
require(v.d1 > v.d0, "D should increase");
92+
93+
if (v.totalSupply == 0) {
94+
return v.d1;
95+
} else {
96+
uint256 feePerToken = _feePerToken();
97+
for (uint8 i = 0; i < _numTokens; i++) {
98+
uint256 idealBalance = v.d1.mul(v.balances[i]).div(v.d0);
99+
uint256 fees = feePerToken
100+
.mul(idealBalance.difference(newBalances[i]))
101+
.div(FEE_DENOMINATOR);
102+
newBalances[i] = newBalances[i].sub(fees);
103+
}
104+
v.d1 = _getD(_xp(newBalances, v.multipliers), v.preciseA);
105+
return v.d1.sub(v.d0).mul(v.totalSupply).div(v.d0);
106+
}
107+
}
108+
109+
function _setPoolTokens(ISwap _pool) internal returns (uint256) {
110+
for (uint8 i = 0; true; i++) {
111+
try _pool.getToken(i) returns (IERC20 token) {
112+
_addPoolToken(token, i);
113+
} catch {
114+
break;
115+
}
116+
}
117+
return tokenPrecisionMultipliers.length;
118+
}
119+
120+
/// @dev add custom logic in child contracts,
121+
/// if they need to store more info on the tokens
122+
function _addPoolToken(IERC20 token, uint8) internal virtual {
123+
IERC20Decimals _token = IERC20Decimals(address(token));
124+
tokenPrecisionMultipliers.push(
125+
10**uint256(POOL_PRECISION_DECIMALS - _token.decimals())
126+
);
127+
poolTokens.push(token);
128+
}
129+
130+
/**
131+
* @notice Get fee applied to each token when adding
132+
* or removing assets weighted differently from the pool
133+
*/
134+
function _feePerToken() internal view returns (uint256) {
135+
return swapFee.mul(numTokens).div(numTokens.sub(1).mul(4));
136+
}
137+
138+
/**
139+
* @notice Get pool balances adjusted, as if all tokens had 18 decimals
140+
*/
141+
function _xp(
142+
uint256[] memory balances,
143+
uint256[] memory precisionMultipliers
144+
) internal pure returns (uint256[] memory) {
145+
uint256 _numTokens = balances.length;
146+
require(
147+
_numTokens == precisionMultipliers.length,
148+
"Balances must match multipliers"
149+
);
150+
uint256[] memory xp = new uint256[](_numTokens);
151+
for (uint256 i = 0; i < _numTokens; i++) {
152+
xp[i] = balances[i].mul(precisionMultipliers[i]);
153+
}
154+
return xp;
155+
}
156+
157+
/**
158+
* @notice Get D: pool invariant
159+
*/
160+
function _getD(uint256[] memory xp, uint256 a)
161+
internal
162+
pure
163+
returns (uint256)
164+
{
165+
uint256 _numTokens = xp.length;
166+
uint256 s;
167+
for (uint256 i = 0; i < _numTokens; i++) {
168+
s = s.add(xp[i]);
169+
}
170+
if (s == 0) {
171+
return 0;
172+
}
173+
174+
uint256 prevD;
175+
uint256 d = s;
176+
uint256 nA = a.mul(_numTokens);
177+
178+
for (uint256 i = 0; i < 256; i++) {
179+
uint256 dP = d;
180+
for (uint256 j = 0; j < _numTokens; j++) {
181+
dP = dP.mul(d).div(xp[j].mul(_numTokens));
182+
// If we were to protect the division loss we would have to keep the denominator separate
183+
// and divide at the end. However this leads to overflow with large numTokens or/and D.
184+
// dP = dP * D * D * D * ... overflow!
185+
}
186+
prevD = d;
187+
d = nA.mul(s).div(A_PRECISION).add(dP.mul(_numTokens)).mul(d).div(
188+
nA.sub(A_PRECISION).mul(d).div(A_PRECISION).add(
189+
_numTokens.add(1).mul(dP)
190+
)
191+
);
192+
if (d.within1(prevD)) {
193+
return d;
194+
}
195+
}
196+
197+
// Convergence should occur in 4 loops or less. If this is reached, there may be something wrong
198+
// with the pool. If this were to occur repeatedly, LPs should withdraw via `removeLiquidity()`
199+
// function which does not rely on D.
200+
revert("D does not converge");
201+
}
202+
}

contracts/amm/interfaces/ISwap.sol

+15
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,24 @@ pragma solidity 0.6.12;
55
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
66

77
interface ISwap {
8+
function swapStorage()
9+
external
10+
view
11+
returns (
12+
uint256 initialA,
13+
uint256 futureA,
14+
uint256 initialATime,
15+
uint256 futureATime,
16+
uint256 swapFee,
17+
uint256 adminFee,
18+
address lpToken
19+
);
20+
821
// pool data view functions
922
function getA() external view returns (uint256);
1023

24+
function getAPrecise() external view returns (uint256);
25+
1126
function getToken(uint8 index) external view returns (IERC20);
1227

1328
function getTokenIndex(address tokenAddress) external view returns (uint8);

contracts/amm08/LPToken08.sol

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity 0.8.11;
4+
5+
import "@openzeppelin/contracts-upgradeable-solc8/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";
6+
import "@openzeppelin/contracts-upgradeable-solc8/access/OwnableUpgradeable.sol";
7+
8+
/**
9+
* @title Liquidity Provider Token
10+
* @notice This token is an ERC20 detailed token with added capability to be minted by the owner.
11+
* It is used to represent user's shares when providing liquidity to swap contracts.
12+
* @dev Only Swap contracts should initialize and own LPToken contracts.
13+
*/
14+
contract LPToken08 is ERC20BurnableUpgradeable, OwnableUpgradeable {
15+
/**
16+
* @notice Initializes this LPToken contract with the given _name and _symbol
17+
* @dev The caller of this function will become the owner. A Swap contract should call this
18+
* in its initializer function.
19+
* @param _name _name of this token
20+
* @param _symbol _symbol of this token
21+
*/
22+
function initialize(string memory _name, string memory _symbol)
23+
external
24+
initializer
25+
returns (bool)
26+
{
27+
__Context_init_unchained();
28+
__ERC20_init_unchained(_name, _symbol);
29+
__Ownable_init_unchained();
30+
return true;
31+
}
32+
33+
/**
34+
* @notice Mints the given amount of LPToken to the recipient.
35+
* @dev only owner can call this mint function
36+
* @param recipient address of account to receive the tokens
37+
* @param amount amount of tokens to mint
38+
*/
39+
function mint(address recipient, uint256 amount) external onlyOwner {
40+
require(amount != 0, "LPToken: cannot mint 0");
41+
_mint(recipient, amount);
42+
}
43+
44+
/**
45+
* @dev Overrides ERC20._beforeTokenTransfer() which get called on every transfers including
46+
* minting and burning. * This assumes the owner is set to a Swap contract's address.
47+
*/
48+
function _beforeTokenTransfer(
49+
address from,
50+
address to,
51+
uint256 amount
52+
) internal virtual override(ERC20Upgradeable) {
53+
super._beforeTokenTransfer(from, to, amount);
54+
require(to != address(this), "LPToken: cannot send to itself");
55+
}
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity 0.8.11;
4+
5+
import "@openzeppelin/contracts-upgradeable-solc8/access/OwnableUpgradeable.sol";
6+
import "@openzeppelin/contracts-upgradeable-solc8/security/PausableUpgradeable.sol";
7+
8+
/**
9+
* @title OwnerPausable
10+
* @notice An ownable contract allows the owner to pause and unpause the
11+
* contract without a delay.
12+
* @dev Only methods using the provided modifiers will be paused.
13+
*/
14+
abstract contract OwnerPausableUpgradeable08 is
15+
OwnableUpgradeable,
16+
PausableUpgradeable
17+
{
18+
function __OwnerPausable_init() internal onlyInitializing {
19+
__Context_init_unchained();
20+
__Ownable_init_unchained();
21+
__Pausable_init_unchained();
22+
}
23+
24+
/**
25+
* @notice Pause the contract. Revert if already paused.
26+
*/
27+
function pause() external onlyOwner {
28+
PausableUpgradeable._pause();
29+
}
30+
31+
/**
32+
* @notice Unpause the contract. Revert if already unpaused.
33+
*/
34+
function unpause() external onlyOwner {
35+
PausableUpgradeable._unpause();
36+
}
37+
}

0 commit comments

Comments
 (0)