From 465e394e7609f9a5bf1dbf1934aba5c4a10bd25f Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Tue, 10 Oct 2023 19:52:05 +0300 Subject: [PATCH 01/68] add mock data #7 --- frontend/src/data/mockAvailablePools.json | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 frontend/src/data/mockAvailablePools.json diff --git a/frontend/src/data/mockAvailablePools.json b/frontend/src/data/mockAvailablePools.json new file mode 100644 index 0000000..c842b78 --- /dev/null +++ b/frontend/src/data/mockAvailablePools.json @@ -0,0 +1,29 @@ +[ + { + "address": "0x4681de1e080e889fad73853fa7adaa0be39e433f", + "date":1696954119482, + "anchorCurrency" : "0x6265617665726275696c642e6f7267", + "tokens": ["0x6265617665726275696c642e6f7267","0x6265617665726275696c642e6f7267", "0x6265617665726275696c642e6f7267"], + "operatorFee": 12, + "total": 234500, + "profitPercent": 10 + }, + { + "address": "0x4681de1e080e889fad73853fa7adaa0be39e433f", + "date":1696954119482, + "anchorCurrency" : "0x6265617665726275696c642e6f7267", + "tokens": ["0x6265617665726275696c642e6f7267","0x6265617665726275696c642e6f7267", "0x6265617665726275696c642e6f7267"], + "operatorFee": 12, + "total": 234500, + "profitPercent": 10 + }, + { + "address": "0x4681de1e080e889fad73853fa7adaa0be39e433f", + "date":1696954119482, + "anchorCurrency" : "0x6265617665726275696c642e6f7267", + "tokens": ["0x6265617665726275696c642e6f7267","0x6265617665726275696c642e6f7267", "0x6265617665726275696c642e6f7267"], + "operatorFee": 12, + "total": 234500, + "profitPercent": 10 + } +] \ No newline at end of file From e88a906c1fc078bc7a4a89a0ad323308c4f04afd Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Tue, 10 Oct 2023 20:02:12 +0300 Subject: [PATCH 02/68] add profit field profit #7 --- frontend/src/data/mockAvailablePools.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/src/data/mockAvailablePools.json b/frontend/src/data/mockAvailablePools.json index c842b78..615801b 100644 --- a/frontend/src/data/mockAvailablePools.json +++ b/frontend/src/data/mockAvailablePools.json @@ -6,7 +6,8 @@ "tokens": ["0x6265617665726275696c642e6f7267","0x6265617665726275696c642e6f7267", "0x6265617665726275696c642e6f7267"], "operatorFee": 12, "total": 234500, - "profitPercent": 10 + "profitPercent": 10, + "profit": 3453453 }, { "address": "0x4681de1e080e889fad73853fa7adaa0be39e433f", @@ -15,7 +16,8 @@ "tokens": ["0x6265617665726275696c642e6f7267","0x6265617665726275696c642e6f7267", "0x6265617665726275696c642e6f7267"], "operatorFee": 12, "total": 234500, - "profitPercent": 10 + "profitPercent": 10, + "profit" : 120000 }, { "address": "0x4681de1e080e889fad73853fa7adaa0be39e433f", @@ -24,6 +26,7 @@ "tokens": ["0x6265617665726275696c642e6f7267","0x6265617665726275696c642e6f7267", "0x6265617665726275696c642e6f7267"], "operatorFee": 12, "total": 234500, - "profitPercent": 10 + "profitPercent": 10, + "profit" : 30000 } ] \ No newline at end of file From 6fc59a840e997df83d726a2df101e70392a0ffc1 Mon Sep 17 00:00:00 2001 From: etsvigun Date: Tue, 10 Oct 2023 21:14:15 +0300 Subject: [PATCH 03/68] forge install: safe-contracts v1.3.0 --- .gitmodules | 3 +++ lib/safe-contracts | 1 + 2 files changed, 4 insertions(+) create mode 160000 lib/safe-contracts diff --git a/.gitmodules b/.gitmodules index 888d42d..7a39875 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "lib/forge-std"] path = lib/forge-std url = https://github.com/foundry-rs/forge-std +[submodule "lib/safe-contracts"] + path = lib/safe-contracts + url = https://github.com/safe-global/safe-contracts diff --git a/lib/safe-contracts b/lib/safe-contracts new file mode 160000 index 0000000..186a21a --- /dev/null +++ b/lib/safe-contracts @@ -0,0 +1 @@ +Subproject commit 186a21a74b327f17fc41217a927dea7064f74604 From e6456a08860dedb5b0daea7d99182eb234a8c73a Mon Sep 17 00:00:00 2001 From: etsvigun Date: Tue, 10 Oct 2023 21:18:45 +0300 Subject: [PATCH 04/68] forge install: openzeppelin v5.0.0 --- .gitmodules | 3 +++ lib/openzeppelin | 1 + 2 files changed, 4 insertions(+) create mode 160000 lib/openzeppelin diff --git a/.gitmodules b/.gitmodules index 7a39875..a75a4ba 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "lib/safe-contracts"] path = lib/safe-contracts url = https://github.com/safe-global/safe-contracts +[submodule "lib/openzeppelin"] + path = lib/openzeppelin + url = https://github.com/OpenZeppelin/openzeppelin-contracts diff --git a/lib/openzeppelin b/lib/openzeppelin new file mode 160000 index 0000000..932fddf --- /dev/null +++ b/lib/openzeppelin @@ -0,0 +1 @@ +Subproject commit 932fddf69a699a9a80fd2396fd1a2ab91cdda123 From 7b044fc474dd021d11554d280c49e5f6f188dfb7 Mon Sep 17 00:00:00 2001 From: etsvigun Date: Tue, 10 Oct 2023 23:49:43 +0300 Subject: [PATCH 05/68] Inherit oz vault erc-4626 #10 --- .gitignore | 2 + README.md | 6 +++ remappings.txt | 2 + script/Counter.s.sol | 12 ----- src/Constants.sol | 7 +++ src/ProfitPalsVault.sol | 59 ++++++++++++++++++++++ src/ProfitPalsVaultFactory.sol | 12 +++++ src/interfaces/IProfitPalsVault.sol | 9 ++++ src/interfaces/IProfitPalsVaultFactory.sol | 12 +++++ test/Counter.t.sol | 24 --------- test/DepositAnchorCurrency.t.sol | 39 ++++++++++++++ 11 files changed, 148 insertions(+), 36 deletions(-) create mode 100644 remappings.txt delete mode 100644 script/Counter.s.sol create mode 100644 src/Constants.sol create mode 100644 src/ProfitPalsVault.sol create mode 100644 src/ProfitPalsVaultFactory.sol create mode 100644 src/interfaces/IProfitPalsVault.sol create mode 100644 src/interfaces/IProfitPalsVaultFactory.sol delete mode 100644 test/Counter.t.sol create mode 100644 test/DepositAnchorCurrency.t.sol diff --git a/.gitignore b/.gitignore index 8131f50..3b58347 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.env + # Logs logs *.log diff --git a/README.md b/README.md index c469c01..eead6c6 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,12 @@ Our ETHOnline2023 focus: integration with Uniswap and harnessing Safe smart wall Monorepo setup: smart contracts in root, frontend in its folder. We integrate Foundry/Forge with GitHub Actions for streamlined CI/CD. +## Test in Polygon Mainnet fork +```shell +source .env +forge test --fork-url $POLYGON_RPC_URL +``` + ## Links - **ChainHackers**: [https://chainhackers.xyz/](https://chainhackers.xyz/) - **ProfitPals**: [https://profitpals.chainhackers.xyz/](https://profitpals.chainhackers.xyz/) diff --git a/remappings.txt b/remappings.txt new file mode 100644 index 0000000..2454051 --- /dev/null +++ b/remappings.txt @@ -0,0 +1,2 @@ +@openzeppelin=lib/openzeppelin/contracts +@safe-contracts=lib/safe-contracts/contracts \ No newline at end of file diff --git a/script/Counter.s.sol b/script/Counter.s.sol deleted file mode 100644 index 1a47b40..0000000 --- a/script/Counter.s.sol +++ /dev/null @@ -1,12 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import {Script, console2} from "forge-std/Script.sol"; - -contract CounterScript is Script { - function setUp() public {} - - function run() public { - vm.broadcast(); - } -} diff --git a/src/Constants.sol b/src/Constants.sol new file mode 100644 index 0000000..960fad4 --- /dev/null +++ b/src/Constants.sol @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.13; + +uint256 constant SHARE_DECIMALS = 6; +address constant SAFE_PROXY_FACTORY_130_POLYGON = 0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2; +address constant SAFE_LOGIC_SINGLETON_POLYGON = 0x3E5c63644E683549055b9Be8653de26E0B4CD36E; +address constant USDC_POLYGON = 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174; \ No newline at end of file diff --git a/src/ProfitPalsVault.sol b/src/ProfitPalsVault.sol new file mode 100644 index 0000000..a15325d --- /dev/null +++ b/src/ProfitPalsVault.sol @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "./interfaces/IProfitPalsVault.sol"; +import "@openzeppelin/token/ERC20/extensions/ERC4626.sol"; +import "@safe-contracts/GnosisSafe.sol"; +import "@safe-contracts/proxies/GnosisSafeProxyFactory.sol"; + +/** + * @title ProfitPalsVault + * @dev This contract acts as the primary vault for the ProfitPals project, holding and managing all assets. + * The main asset, or anchor currency, that is managed within this vault can be any ERC20 token. + */ +contract ProfitPalsVault is IProfitPalsVault, ERC4626 { + IERC20 public immutable anchorCurrency; + + /** + * @param anchorCurrency_ - The main or anchor ERC20 token that the vault will manage. + * @param name_ - Name of the shares token + * @param symbol_ - Symbol of the shares token + */ + constructor( + address safeProxyFactory, + address safeLogicSingleton, + IERC20 anchorCurrency_, + string memory name_, + string memory symbol_ + ) + ERC4626(anchorCurrency_) ERC20(name_, symbol_){ + //TODO init safe account + address[] memory owners = new address[](1); + owners[0] = address(this); + + + bytes memory safeAccountSetupData = abi.encodeCall( + GnosisSafe.setup, + (owners, + 1, + address(0), + "", + address(0), + address(0), + 0, + payable(0)) + ); + GnosisSafeProxyFactory(safeProxyFactory).createProxyWithNonce( + safeLogicSingleton, + safeAccountSetupData, + 6661489 + ); + + anchorCurrency = anchorCurrency_; + } + + function totalAssets() public view override(IERC4626, ERC4626) returns (uint256) { + //TODO add overall Uniswap positions here + return anchorCurrency.balanceOf(address(this)); + } +} diff --git a/src/ProfitPalsVaultFactory.sol b/src/ProfitPalsVaultFactory.sol new file mode 100644 index 0000000..0d830cb --- /dev/null +++ b/src/ProfitPalsVaultFactory.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +contract ProfitPalsVaultFactory { + address public immutable safeLogicSingleton; + address public immutable safeProxyFactory; + + constructor(address safeLogicSingleton_, address safeProxyFactory_){ + safeLogicSingleton = safeLogicSingleton_; + safeProxyFactory = safeProxyFactory_; + } +} diff --git a/src/interfaces/IProfitPalsVault.sol b/src/interfaces/IProfitPalsVault.sol new file mode 100644 index 0000000..2c274bc --- /dev/null +++ b/src/interfaces/IProfitPalsVault.sol @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "@openzeppelin/token/ERC20/IERC20.sol"; +import "@openzeppelin/interfaces/IERC4626.sol"; + +interface IProfitPalsVault is IERC4626 { + function anchorCurrency() external view returns (IERC20); +} diff --git a/src/interfaces/IProfitPalsVaultFactory.sol b/src/interfaces/IProfitPalsVaultFactory.sol new file mode 100644 index 0000000..23eed97 --- /dev/null +++ b/src/interfaces/IProfitPalsVaultFactory.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "@openzeppelin/token/ERC20/IERC20.sol"; + +interface IProfitPalsVaultFactory { + function createVault(IERC20 anchorCurrency, string memory name_, string memory symbol_) external returns (address); + + function safeLogicSingleton() external view returns (address); + + function safeProxyFactory() external view returns (address); +} diff --git a/test/Counter.t.sol b/test/Counter.t.sol deleted file mode 100644 index e9b9e6a..0000000 --- a/test/Counter.t.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import {Test, console2} from "forge-std/Test.sol"; -import {Counter} from "../src/Counter.sol"; - -contract CounterTest is Test { - Counter public counter; - - function setUp() public { - counter = new Counter(); - counter.setNumber(0); - } - - function test_Increment() public { - counter.increment(); - assertEq(counter.number(), 1); - } - - function testFuzz_SetNumber(uint256 x) public { - counter.setNumber(x); - assertEq(counter.number(), x); - } -} diff --git a/test/DepositAnchorCurrency.t.sol b/test/DepositAnchorCurrency.t.sol new file mode 100644 index 0000000..7bf3dd3 --- /dev/null +++ b/test/DepositAnchorCurrency.t.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.13; + +import {Test, console2} from "forge-std/Test.sol"; +import {ProfitPalsVault} from "../src/ProfitPalsVault.sol"; +import "@openzeppelin/token/ERC20/IERC20.sol"; +import "forge-std/Test.sol"; +import "../src/Constants.sol"; +import {Script, console2} from "forge-std/Script.sol"; + +contract DepositAnchorCurrencyTest is Test { + + + address USDC_BIG_HOLDER = 0xF977814e90dA44bFA03b6295A0616a897441aceC; + + IERC20 usdc = IERC20(USDC_POLYGON); + + ProfitPalsVault public profitPalsVault; + + function setUp() public { + profitPalsVault = new ProfitPalsVault( + SAFE_PROXY_FACTORY_130_POLYGON, + SAFE_LOGIC_SINGLETON_POLYGON, + usdc, + "testUSDCVault", "tUSDCv"); + + vm.startPrank(USDC_BIG_HOLDER); + usdc.transfer(address(this), 1000 * 10 ** 6); + vm.stopPrank(); + } + + function test_DepositUsdAndGotShares() public { + assertEq(profitPalsVault.balanceOf(address(this)), 0); + usdc.approve(address(profitPalsVault), 100 * 10 ** 6); + profitPalsVault.deposit(100 * 10 ** 6, address(this)); + assertEq(usdc.balanceOf(address(profitPalsVault)), 100 * 10 ** 6); + assertEq(profitPalsVault.balanceOf(address(this)), 100 * 10 ** SHARE_DECIMALS); + } +} From 8cd1bfdf7332a3175666022db8e510345b4405d6 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Wed, 11 Oct 2023 17:11:45 +0300 Subject: [PATCH 06/68] add default paths to configs #9 --- frontend/tsconfig.json | 10 +++++++++- frontend/vite.config.ts | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index 9995662..dae6bc4 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -16,7 +16,15 @@ /* Linting */ "strict": true, - "noFallthroughCasesInSwitch": true + "noFallthroughCasesInSwitch": true, + "baseUrl": "./", + "paths": { + "src/*": [ "./src/*" ], + "Components/*": [ "./src/components/*" ], + "Components": [ "./src/components" ], + "Pages/*": [ "./src/pages/*" ], + "Pages": [ "./src/pages" ] + } }, "include": ["src"], "references": [{ "path": "./tsconfig.node.json" }] diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index bafcd4b..d5f5a44 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -1,10 +1,18 @@ import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; +import * as path from 'path'; // https://vitejs.dev/config/ export default defineConfig({ build: { target: 'es2020', }, + base: './', + resolve: { + alias: { + Components: path.resolve(__dirname, './src/components'), + Pages: path.resolve(__dirname, './src/pages'), + }, + }, plugins: [react()], }); From 40950dd2a0e0241e3b0e87b67740a040920bd65d Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Wed, 11 Oct 2023 17:12:25 +0300 Subject: [PATCH 07/68] add table component #9 --- .../src/components/table/Table.module.scss | 51 ++++++++++++ frontend/src/components/table/Table.tsx | 81 +++++++++++++++++++ frontend/src/components/table/TableProps.ts | 1 + frontend/src/components/table/index.ts | 1 + 4 files changed, 134 insertions(+) create mode 100644 frontend/src/components/table/Table.module.scss create mode 100644 frontend/src/components/table/Table.tsx create mode 100644 frontend/src/components/table/TableProps.ts create mode 100644 frontend/src/components/table/index.ts diff --git a/frontend/src/components/table/Table.module.scss b/frontend/src/components/table/Table.module.scss new file mode 100644 index 0000000..5b34fc4 --- /dev/null +++ b/frontend/src/components/table/Table.module.scss @@ -0,0 +1,51 @@ +@mixin dimmedText { + color: var(--m-3-sys-dark-on-surface-variant, #C3C6CF); + font-family: Noto Sans; + font-size: 16px; + font-style: normal; + font-weight: 400; + line-height: 24px; + letter-spacing: 0.25px; +} + +.tableContainer { + display: flex; + padding: 24px; + width: 100%; + border-radius: 16px; + background: #1B1B1F; + box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.30), 0px 4px 8px 3px rgba(0, 0, 0, 0.15); + table { + width: 100%; + border-collapse: collapse; + border: none; + + thead, tbody { + padding: 24px; + } + + thead { + tr { + border-bottom: 1px solid #A3CDDC;; + } + } + tbody { + tr { + border-bottom: 1px solid #43474E; + } + } + + th { + border: none; + padding: 0 8px 22px; + text-align: left; + + }; + td { + border: none; + padding: 22px 8px; + + } + } +} + diff --git a/frontend/src/components/table/Table.tsx b/frontend/src/components/table/Table.tsx new file mode 100644 index 0000000..267aba0 --- /dev/null +++ b/frontend/src/components/table/Table.tsx @@ -0,0 +1,81 @@ +import { TablePropsI } from './TableProps.ts'; +import styles from './Table.module.scss'; +import { FC } from 'react'; + +export const Table: FC = ({}) => { + const pools = [ + { + address: '0x4681de1e080e889fad73853fa7adaa0be39e433f', + date: 1696954119482, + anchorCurrency: '0x6265617665726275696c642e6f7267', + tokens: [ + '0x6265617665726275696c642e6f7267', + '0x6265617665726275696c642e6f7267', + '0x6265617665726275696c642e6f7267', + ], + operatorFee: 12, + total: 234500, + profitPercent: 10, + profit: 3453453, + }, + { + address: '0x4681de1e080e889fad73853fa7adaa0be39e433z', + date: 1696954119482, + anchorCurrency: '0x6265617665726275696c642e6f7267', + tokens: [ + '0x6265617665726275696c642e6f7267', + '0x6265617665726275696c642e6f7267', + '0x6265617665726275696c642e6f7267', + ], + operatorFee: 12, + total: 234500, + profitPercent: 10, + profit: 120000, + }, + { + address: '0x4681de1e080e889fad73853fa7adaa0be39e433x', + date: 1696954119482, + anchorCurrency: '0x6265617665726275696c642e6f7267', + tokens: [ + '0x6265617665726275696c642e6f7267', + '0x6265617665726275696c642e6f7267', + '0x6265617665726275696c642e6f7267', + ], + operatorFee: 12, + total: 234500, + profitPercent: 10, + profit: 30000, + }, + ]; + + const tableRowMap = { + date: { title: 'Date', component: 'some tsx' }, + operatorFee: { title: 'Operator fee', component: 'some tsx' }, + total: { title: 'Total', component: 'some tsx' }, + profit: { title: 'Profit', component: 'some tsx' }, + }; + + return ( +
+ + + + {Object.entries(tableRowMap).map(([key, value]) => ( + + ))} + + + + {pools.map((pool: any) => ( + + {Object.entries(tableRowMap).map(([key, value]) => ( + + ))} + + ))} + +
{value.title}
{pool[key]}
+
+
+ ); +}; diff --git a/frontend/src/components/table/TableProps.ts b/frontend/src/components/table/TableProps.ts new file mode 100644 index 0000000..4023c15 --- /dev/null +++ b/frontend/src/components/table/TableProps.ts @@ -0,0 +1 @@ +export interface TablePropsI {} diff --git a/frontend/src/components/table/index.ts b/frontend/src/components/table/index.ts new file mode 100644 index 0000000..75193ad --- /dev/null +++ b/frontend/src/components/table/index.ts @@ -0,0 +1 @@ +export * from './Table'; From 01fa1df38b8b4fda8c252648551021ca85f2058d Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Wed, 11 Oct 2023 17:12:43 +0300 Subject: [PATCH 08/68] add pools page #9 --- .../src/pages/PoolsPage/PoolsPage.module.scss | 11 +++++++++++ frontend/src/pages/PoolsPage/PoolsPage.tsx | 15 +++++++++++++++ frontend/src/pages/PoolsPage/PoolsPageProps.ts | 3 +++ frontend/src/pages/PoolsPage/index.ts | 1 + 4 files changed, 30 insertions(+) create mode 100644 frontend/src/pages/PoolsPage/PoolsPage.module.scss create mode 100644 frontend/src/pages/PoolsPage/PoolsPage.tsx create mode 100644 frontend/src/pages/PoolsPage/PoolsPageProps.ts create mode 100644 frontend/src/pages/PoolsPage/index.ts diff --git a/frontend/src/pages/PoolsPage/PoolsPage.module.scss b/frontend/src/pages/PoolsPage/PoolsPage.module.scss new file mode 100644 index 0000000..2a5856e --- /dev/null +++ b/frontend/src/pages/PoolsPage/PoolsPage.module.scss @@ -0,0 +1,11 @@ +.container { + display: flex; + padding: 0 122px; + + .poolsPage { + display: flex; + flex-direction: column; + align-items: flex-start; + width: 100%; + } +} \ No newline at end of file diff --git a/frontend/src/pages/PoolsPage/PoolsPage.tsx b/frontend/src/pages/PoolsPage/PoolsPage.tsx new file mode 100644 index 0000000..64f9587 --- /dev/null +++ b/frontend/src/pages/PoolsPage/PoolsPage.tsx @@ -0,0 +1,15 @@ +import { PoolsPagePropsI } from './PoolsPageProps.ts'; +import styles from './PoolsPage.module.scss'; +import { FC } from 'react'; +import { Table } from 'Components'; + +export const PoolsPage: FC = ({ poolsType }) => { + return ( +
+
+

{poolsType}

+ + + + ); +}; diff --git a/frontend/src/pages/PoolsPage/PoolsPageProps.ts b/frontend/src/pages/PoolsPage/PoolsPageProps.ts new file mode 100644 index 0000000..68c7ba0 --- /dev/null +++ b/frontend/src/pages/PoolsPage/PoolsPageProps.ts @@ -0,0 +1,3 @@ +export interface PoolsPagePropsI { + poolsType: string; +} diff --git a/frontend/src/pages/PoolsPage/index.ts b/frontend/src/pages/PoolsPage/index.ts new file mode 100644 index 0000000..8a3f173 --- /dev/null +++ b/frontend/src/pages/PoolsPage/index.ts @@ -0,0 +1 @@ +export * from './PoolsPage'; \ No newline at end of file From b85c6a71d3fb7bc1893c8ec664f705a2b0603940 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Wed, 11 Oct 2023 17:12:56 +0300 Subject: [PATCH 09/68] add imports #9 --- frontend/src/components/index.ts | 1 + frontend/src/pages/index.ts | 1 + 2 files changed, 2 insertions(+) create mode 100644 frontend/src/components/index.ts create mode 100644 frontend/src/pages/index.ts diff --git a/frontend/src/components/index.ts b/frontend/src/components/index.ts new file mode 100644 index 0000000..f410ff1 --- /dev/null +++ b/frontend/src/components/index.ts @@ -0,0 +1 @@ +export * from 'Components/table'; diff --git a/frontend/src/pages/index.ts b/frontend/src/pages/index.ts new file mode 100644 index 0000000..5f65636 --- /dev/null +++ b/frontend/src/pages/index.ts @@ -0,0 +1 @@ +export * from 'Pages/PoolsPage'; From 33e965e4715b2535763105b5f9472b5a6f08507b Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Wed, 11 Oct 2023 17:13:16 +0300 Subject: [PATCH 10/68] add react router #9 --- frontend/package.json | 4 +++ frontend/src/App.tsx | 67 ++++++++++--------------------------------- frontend/yarn.lock | 64 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 52 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index a86fc49..77a3b2c 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -20,8 +20,12 @@ "dependencies": { "@rainbow-me/rainbowkit": "^1.1.1", "@vitejs/plugin-react-refresh": "^1.3.6", + "localforage": "^1.10.0", + "match-sorter": "^6.3.1", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-router-dom": "^6.16.0", + "sort-by": "^1.2.0", "viem": "^1.15.4", "wagmi": "^1.4.3" }, diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 97ffbf2..5c23054 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,57 +1,20 @@ -import { useState } from 'react'; -import reactLogo from './assets/react.svg'; -import viteLogo from '/vite.svg'; -import './index.scss'; -import './App.css'; -import '@rainbow-me/rainbowkit/styles.css'; -import { ConnectButton } from '@rainbow-me/rainbowkit'; -import DevModeToggle from './components/devModeToggle/DevModeToggle'; +import { createBrowserRouter, RouterProvider } from 'react-router-dom'; +import { PoolsPage } from 'Pages'; +import Root from 'Pages/root.tsx'; -function App() { - const [count, setCount] = useState(0); - const [devModeState, setDevModeState] = useState(false); - const versionGitTag = import.meta.env.VITE_REACT_APP_GIT_TAG; - const gitDate = import.meta.env.VITE_REACT_APP_GIT_DATE; - - console.log('VITE_REACT_APP_GIT_TAG - ', versionGitTag); - console.log('VITE_REACT_APP_GIT_DATE - ', gitDate); +const router = createBrowserRouter([ + { + path: '/', + element: , + }, + { + path: '/available-pools', + element: , + }, +]); - const handleToggleDevMode = (value: boolean) => { - setDevModeState(value); - }; - - return ( -
- {versionGitTag && gitDate && ( -
- - {devModeState && ( -
-

Version: {versionGitTag}

-

Date: {gitDate}

-
- )} -
- )} - -

New

-
- -

- Edit src/App.tsx and save to test HMR -

-
-

Click on the Vite and React logos to learn more

- -
- ); +function App() { + return ; } export default App; diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 18231e0..ef643fb 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -605,6 +605,11 @@ qrcode "1.5.0" react-remove-scroll "2.5.4" +"@remix-run/router@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.9.0.tgz#9033238b41c4cbe1e961eccb3f79e2c588328cf6" + integrity sha512-bV63itrKBC0zdT27qYm6SDZHlkXwFL1xMBuhkn+X7l0+IIhNaH5wuuvZKp6eKhCD4KFhujhfhCT1YxXW6esUIA== + "@rollup/pluginutils@^4.1.1": version "4.2.1" resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-4.2.1.tgz#e6c6c3aba0744edce3fb2074922d3776c0af2a6d" @@ -2726,6 +2731,11 @@ ignore@^5.2.0, ignore@^5.2.4: resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324" integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ== +immediate@~3.0.5: + version "3.0.6" + resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b" + integrity sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ== + immutable@^4.0.0: version "4.3.4" resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.3.4.tgz#2e07b33837b4bb7662f288c244d1ced1ef65a78f" @@ -2996,6 +3006,13 @@ levn@^0.4.1: prelude-ls "^1.2.1" type-check "~0.4.0" +lie@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/lie/-/lie-3.1.1.tgz#9a436b2cc7746ca59de7a41fa469b3efb76bd87e" + integrity sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw== + dependencies: + immediate "~3.0.5" + lilconfig@2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.1.0.tgz#78e23ac89ebb7e1bfbf25b18043de756548e7f52" @@ -3054,6 +3071,13 @@ lit@2.8.0: lit-element "^3.3.0" lit-html "^2.8.0" +localforage@^1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/localforage/-/localforage-1.10.0.tgz#5c465dc5f62b2807c3a84c0c6a1b1b3212781dd4" + integrity sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg== + dependencies: + lie "3.1.1" + locate-path@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" @@ -3133,6 +3157,14 @@ make-plural@*: resolved "https://registry.yarnpkg.com/make-plural/-/make-plural-7.3.0.tgz#2889dbafca2fb097037c47967d3e3afa7e48a52c" integrity sha512-/K3BC0KIsO+WK2i94LkMPv3wslMrazrQhfi5We9fMbLlLjzoOSJWr7TAdupLlDWaJcWxwoNosBkhFDejiu5VDw== +match-sorter@^6.3.1: + version "6.3.1" + resolved "https://registry.yarnpkg.com/match-sorter/-/match-sorter-6.3.1.tgz#98cc37fda756093424ddf3cbc62bfe9c75b92bda" + integrity sha512-mxybbo3pPNuA+ZuCUhm5bwNkXrJTbsk5VWbR5wiwz/GC6LIiegBGn2w3O08UG/jdbYLinw51fSQ5xNU1U3MgBw== + dependencies: + "@babel/runtime" "^7.12.5" + remove-accents "0.4.2" + media-query-parser@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/media-query-parser/-/media-query-parser-2.0.2.tgz#ff79e56cee92615a304a1c2fa4f2bd056c0a1d29" @@ -3263,6 +3295,11 @@ object-inspect@^1.9.0: resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.3.tgz#ba62dffd67ee256c8c086dfae69e016cd1f198b9" integrity sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g== +object-path@0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/object-path/-/object-path-0.6.0.tgz#b69a7d110937934f336ca561fd9be1ad7b7e0cb7" + integrity sha512-fxrwsCFi3/p+LeLOAwo/wyRMODZxdGBtUlWRzsEpsUVrisZbEfZ21arxLGfaWfcnqb8oHPNihIb4XPE8CQPN5A== + on-exit-leak-free@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/on-exit-leak-free/-/on-exit-leak-free-0.2.0.tgz#b39c9e3bf7690d890f4861558b0d7b90a442d209" @@ -3621,6 +3658,21 @@ react-remove-scroll@2.5.4: use-callback-ref "^1.3.0" use-sidecar "^1.1.2" +react-router-dom@^6.16.0: + version "6.16.0" + resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.16.0.tgz#86f24658da35eb66727e75ecbb1a029e33ee39d9" + integrity sha512-aTfBLv3mk/gaKLxgRDUPbPw+s4Y/O+ma3rEN1u8EgEpLpPe6gNjIsWt9rxushMHHMb7mSwxRGdGlGdvmFsyPIg== + dependencies: + "@remix-run/router" "1.9.0" + react-router "6.16.0" + +react-router@6.16.0: + version "6.16.0" + resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.16.0.tgz#abbf3d5bdc9c108c9b822a18be10ee004096fb81" + integrity sha512-VT4Mmc4jj5YyjpOi5jOf0I+TYzGpvzERy4ckNSvSh2RArv8LLoCxlsZ2D+tc7zgjxcY34oTz2hZaeX5RVprKqA== + dependencies: + "@remix-run/router" "1.9.0" + react-style-singleton@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/react-style-singleton/-/react-style-singleton-2.2.1.tgz#f99e420492b2d8f34d38308ff660b60d0b1205b4" @@ -3663,6 +3715,11 @@ regenerator-runtime@^0.14.0: resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.0.tgz#5e19d68eb12d486f797e15a3c6a918f7cec5eb45" integrity sha512-srw17NI0TUWHuGa5CFGGmhfNIeja30WMBfbslPNhf6JrqQlLN5gcrvig1oqPxiVaXb0oW0XRKtH6Nngs5lKCIA== +remove-accents@0.4.2: + version "0.4.2" + resolved "https://registry.yarnpkg.com/remove-accents/-/remove-accents-0.4.2.tgz#0a43d3aaae1e80db919e07ae254b285d9e1c7bb5" + integrity sha512-7pXIJqJOq5tFgG1A2Zxti3Ht8jJF337m4sowbuHsW30ZnkQFnDzy9qBNhgzX8ZLW4+UBcXiiR7SwR6pokHsxiA== + require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" @@ -3851,6 +3908,13 @@ sonic-boom@^2.2.1: dependencies: atomic-sleep "^1.0.0" +sort-by@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/sort-by/-/sort-by-1.2.0.tgz#ed92bbff9fd2284b41f6503e38496607b225fe6f" + integrity sha512-aRyW65r3xMnf4nxJRluCg0H/woJpksU1dQxRtXYzau30sNBOmf5HACpDd9MZDhKh7ALQ5FgSOfMPwZEtUmMqcg== + dependencies: + object-path "0.6.0" + "source-map-js@>=0.6.2 <2.0.0", source-map-js@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c" From c01970b954d3cc091c1fb20262792bf0963f0037 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Wed, 11 Oct 2023 17:13:36 +0300 Subject: [PATCH 11/68] add root page #9 --- frontend/src/pages/root.tsx | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 frontend/src/pages/root.tsx diff --git a/frontend/src/pages/root.tsx b/frontend/src/pages/root.tsx new file mode 100644 index 0000000..d4281b3 --- /dev/null +++ b/frontend/src/pages/root.tsx @@ -0,0 +1,38 @@ +import { useState } from 'react'; +import '../index.scss'; +import '@rainbow-me/rainbowkit/styles.css'; +import { ConnectButton } from '@rainbow-me/rainbowkit'; +import DevModeToggle from '../components/devModeToggle/DevModeToggle'; + +function Root() { + const [devModeState, setDevModeState] = useState(false); + const versionGitTag = import.meta.env.VITE_REACT_APP_GIT_TAG; + const gitDate = import.meta.env.VITE_REACT_APP_GIT_DATE; + + console.log('VITE_REACT_APP_GIT_TAG - ', versionGitTag); + console.log('VITE_REACT_APP_GIT_DATE - ', gitDate); + + const handleToggleDevMode = (value: boolean) => { + setDevModeState(value); + }; + + return ( + <> +

root page

+ {versionGitTag && gitDate && ( +
+ + {devModeState && ( +
+

Version: {versionGitTag}

+

Date: {gitDate}

+
+ )} +
+ )} + + + ); +} + +export default Root; From 1ed1bf17c3c22651644d1ca832077cf4f7c9ef31 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Wed, 11 Oct 2023 17:14:08 +0300 Subject: [PATCH 12/68] remove App.css #9 --- frontend/src/App.css | 47 -------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 frontend/src/App.css diff --git a/frontend/src/App.css b/frontend/src/App.css deleted file mode 100644 index 2e85a64..0000000 --- a/frontend/src/App.css +++ /dev/null @@ -1,47 +0,0 @@ -.appBox { - height: 100vh; - gap: 15px 0; -} -.logoBox, -.appBox { - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; -} -.logo { - width: auto; - height: 6em; - padding: 1.5em; - will-change: filter; - transition: filter 300ms; -} -.logo:hover { - filter: drop-shadow(0 0 2em #646cffaa); -} -.logo.react:hover { - filter: drop-shadow(0 0 2em #61dafbaa); -} - -@keyframes logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} - -@media (prefers-reduced-motion: no-preference) { - a:nth-of-type(2) .logo { - animation: logo-spin infinite 20s linear; - } -} - -.card { - padding: 2em; -} - -.read-the-docs { - color: #888; -} From 1e5c3dea4f3b39d5b9491ad2bd6a63350bc001f5 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Thu, 12 Oct 2023 16:23:52 +0300 Subject: [PATCH 13/68] add imports --- frontend/src/components/index.ts | 1 + frontend/src/components/tableCells/dateCell/index.ts | 1 + frontend/src/components/tableCells/index.ts | 1 + 3 files changed, 3 insertions(+) create mode 100644 frontend/src/components/tableCells/dateCell/index.ts create mode 100644 frontend/src/components/tableCells/index.ts diff --git a/frontend/src/components/index.ts b/frontend/src/components/index.ts index f410ff1..efe91bd 100644 --- a/frontend/src/components/index.ts +++ b/frontend/src/components/index.ts @@ -1 +1,2 @@ export * from 'Components/table'; +export * from 'Components/tableCells'; diff --git a/frontend/src/components/tableCells/dateCell/index.ts b/frontend/src/components/tableCells/dateCell/index.ts new file mode 100644 index 0000000..e6db39c --- /dev/null +++ b/frontend/src/components/tableCells/dateCell/index.ts @@ -0,0 +1 @@ +export * from './dateCell'; diff --git a/frontend/src/components/tableCells/index.ts b/frontend/src/components/tableCells/index.ts new file mode 100644 index 0000000..e6db39c --- /dev/null +++ b/frontend/src/components/tableCells/index.ts @@ -0,0 +1 @@ +export * from './dateCell'; From c8c6c9b13db83c41ed6d84e205f20e227abccbd4 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Thu, 12 Oct 2023 16:24:05 +0300 Subject: [PATCH 14/68] add dateCell --- .../components/tableCells/dateCell/dateCell.module.scss | 0 frontend/src/components/tableCells/dateCell/dateCell.tsx | 7 +++++++ .../src/components/tableCells/dateCell/dateCellProps.ts | 1 + 3 files changed, 8 insertions(+) create mode 100644 frontend/src/components/tableCells/dateCell/dateCell.module.scss create mode 100644 frontend/src/components/tableCells/dateCell/dateCell.tsx create mode 100644 frontend/src/components/tableCells/dateCell/dateCellProps.ts diff --git a/frontend/src/components/tableCells/dateCell/dateCell.module.scss b/frontend/src/components/tableCells/dateCell/dateCell.module.scss new file mode 100644 index 0000000..e69de29 diff --git a/frontend/src/components/tableCells/dateCell/dateCell.tsx b/frontend/src/components/tableCells/dateCell/dateCell.tsx new file mode 100644 index 0000000..4f86654 --- /dev/null +++ b/frontend/src/components/tableCells/dateCell/dateCell.tsx @@ -0,0 +1,7 @@ +import { FC } from 'react'; +import styles from './dateCell.module.scss'; +import { DateCellPropsI } from './dateCellProps'; + +export const DateCell: FC = () => { + return
dateCell
; +}; diff --git a/frontend/src/components/tableCells/dateCell/dateCellProps.ts b/frontend/src/components/tableCells/dateCell/dateCellProps.ts new file mode 100644 index 0000000..61791f9 --- /dev/null +++ b/frontend/src/components/tableCells/dateCell/dateCellProps.ts @@ -0,0 +1 @@ +export interface DateCellPropsI {} From 26d9f06827e54f985d038f23dccc1dc14aedc69b Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Thu, 12 Oct 2023 16:24:39 +0300 Subject: [PATCH 15/68] fix ts error --- frontend/src/components/table/Table.tsx | 40 ++++++++++++++++++++----- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/table/Table.tsx b/frontend/src/components/table/Table.tsx index 267aba0..e4cb1a9 100644 --- a/frontend/src/components/table/Table.tsx +++ b/frontend/src/components/table/Table.tsx @@ -1,9 +1,9 @@ import { TablePropsI } from './TableProps.ts'; import styles from './Table.module.scss'; -import { FC } from 'react'; +import { FC, useState } from 'react'; -export const Table: FC = ({}) => { - const pools = [ +export const Table: FC = () => { + const [pools, setPools] = useState([ { address: '0x4681de1e080e889fad73853fa7adaa0be39e433f', date: 1696954119482, @@ -46,7 +46,7 @@ export const Table: FC = ({}) => { profitPercent: 10, profit: 30000, }, - ]; + ]); const tableRowMap = { date: { title: 'Date', component: 'some tsx' }, @@ -54,22 +54,46 @@ export const Table: FC = ({}) => { total: { title: 'Total', component: 'some tsx' }, profit: { title: 'Profit', component: 'some tsx' }, }; + //todo: combine tokens and anchorCurrency for Anchor currency / Tokens + // const combineTokens = (pools: any) => { + // const result = pools.map((pool: any) => { + // return (pool = { + // ...pool, + // allTokens: { anchorCurrency: pool.anchorCurrency, tokens: pool.tokens }, + // }); + // }); + // setPools(result); + // }; + // useEffect(() => { + // combineTokens(pools); + // }, [pools]); + //todo: find proper place for interfaces and types + type PoolT = { + address: string; + date: number; + anchorCurrency: string; + tokens: string[]; + operatorFee: number; + total: number; + profitPercent: number; + profit: number; + }; return (
{Object.entries(tableRowMap).map(([key, value]) => ( - + ))} - {pools.map((pool: any) => ( + {pools.map((pool) => ( - {Object.entries(tableRowMap).map(([key, value]) => ( - + {Object.keys(tableRowMap).map((key) => ( + ))} ))} From da40ff9c8b05b4f26c40866d198e0f67bf251f54 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Thu, 12 Oct 2023 16:26:33 +0300 Subject: [PATCH 16/68] fix indent --- frontend/src/pages/root.tsx | 50 ++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/frontend/src/pages/root.tsx b/frontend/src/pages/root.tsx index d4281b3..f695882 100644 --- a/frontend/src/pages/root.tsx +++ b/frontend/src/pages/root.tsx @@ -5,34 +5,34 @@ import { ConnectButton } from '@rainbow-me/rainbowkit'; import DevModeToggle from '../components/devModeToggle/DevModeToggle'; function Root() { - const [devModeState, setDevModeState] = useState(false); - const versionGitTag = import.meta.env.VITE_REACT_APP_GIT_TAG; - const gitDate = import.meta.env.VITE_REACT_APP_GIT_DATE; + const [devModeState, setDevModeState] = useState(false); + const versionGitTag = import.meta.env.VITE_REACT_APP_GIT_TAG; + const gitDate = import.meta.env.VITE_REACT_APP_GIT_DATE; - console.log('VITE_REACT_APP_GIT_TAG - ', versionGitTag); - console.log('VITE_REACT_APP_GIT_DATE - ', gitDate); + console.log('VITE_REACT_APP_GIT_TAG - ', versionGitTag); + console.log('VITE_REACT_APP_GIT_DATE - ', gitDate); - const handleToggleDevMode = (value: boolean) => { - setDevModeState(value); - }; + const handleToggleDevMode = (value: boolean) => { + setDevModeState(value); + }; - return ( - <> -

root page

- {versionGitTag && gitDate && ( -
- - {devModeState && ( -
-

Version: {versionGitTag}

-

Date: {gitDate}

-
- )} -
- )} - - - ); + return ( + <> +

root page

+ {versionGitTag && gitDate && ( +
+ + {devModeState && ( +
+

Version: {versionGitTag}

+

Date: {gitDate}

+
+ )} +
+ )} + + + ); } export default Root; From 23d3d1d454670ffd351749a5119dd1be218f27f3 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Thu, 12 Oct 2023 16:30:17 +0300 Subject: [PATCH 17/68] fix eslint errors --- frontend/src/components/table/Table.tsx | 6 +++--- frontend/src/components/tableCells/dateCell/dateCell.tsx | 2 +- frontend/src/pages/PoolsPage/index.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/table/Table.tsx b/frontend/src/components/table/Table.tsx index e4cb1a9..2f53ebc 100644 --- a/frontend/src/components/table/Table.tsx +++ b/frontend/src/components/table/Table.tsx @@ -1,9 +1,9 @@ import { TablePropsI } from './TableProps.ts'; import styles from './Table.module.scss'; -import { FC, useState } from 'react'; +import { FC } from 'react'; export const Table: FC = () => { - const [pools, setPools] = useState([ + const pools = [ { address: '0x4681de1e080e889fad73853fa7adaa0be39e433f', date: 1696954119482, @@ -46,7 +46,7 @@ export const Table: FC = () => { profitPercent: 10, profit: 30000, }, - ]); + ]; const tableRowMap = { date: { title: 'Date', component: 'some tsx' }, diff --git a/frontend/src/components/tableCells/dateCell/dateCell.tsx b/frontend/src/components/tableCells/dateCell/dateCell.tsx index 4f86654..b77d47f 100644 --- a/frontend/src/components/tableCells/dateCell/dateCell.tsx +++ b/frontend/src/components/tableCells/dateCell/dateCell.tsx @@ -1,5 +1,5 @@ import { FC } from 'react'; -import styles from './dateCell.module.scss'; +// import styles from './dateCell.module.scss'; import { DateCellPropsI } from './dateCellProps'; export const DateCell: FC = () => { diff --git a/frontend/src/pages/PoolsPage/index.ts b/frontend/src/pages/PoolsPage/index.ts index 8a3f173..f74905b 100644 --- a/frontend/src/pages/PoolsPage/index.ts +++ b/frontend/src/pages/PoolsPage/index.ts @@ -1 +1 @@ -export * from './PoolsPage'; \ No newline at end of file +export * from './PoolsPage'; From a64b46615e35633f161d74285289904f167af2af Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Thu, 12 Oct 2023 20:00:15 +0300 Subject: [PATCH 18/68] add utils to path --- frontend/tsconfig.json | 4 +++- frontend/vite.config.ts | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index dae6bc4..ba22b41 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -23,7 +23,9 @@ "Components/*": [ "./src/components/*" ], "Components": [ "./src/components" ], "Pages/*": [ "./src/pages/*" ], - "Pages": [ "./src/pages" ] + "Pages": [ "./src/pages" ], + "Utils/*": [ "./src/utils/*" ], + "Utils": [ "./src/utils" ], } }, "include": ["src"], diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index d5f5a44..597de25 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -12,6 +12,7 @@ export default defineConfig({ alias: { Components: path.resolve(__dirname, './src/components'), Pages: path.resolve(__dirname, './src/pages'), + Utils: path.resolve(__dirname, './src/utils'), }, }, plugins: [react()], From 832bd3426a85157a6c794bf17a3fd04bbb7cc57c Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Thu, 12 Oct 2023 20:00:26 +0300 Subject: [PATCH 19/68] add utils --- frontend/src/utils/dateFromTimestamp.ts | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 frontend/src/utils/dateFromTimestamp.ts diff --git a/frontend/src/utils/dateFromTimestamp.ts b/frontend/src/utils/dateFromTimestamp.ts new file mode 100644 index 0000000..37639bc --- /dev/null +++ b/frontend/src/utils/dateFromTimestamp.ts @@ -0,0 +1,7 @@ +export const dateFromTimestamp = (timestamp: number) => { + const date = new Date(timestamp); + const day = date.getDate().toString().padStart(2, '0'); + const month = (date.getMonth() + 1).toString().padStart(2, '0'); + const year = date.getFullYear().toString().slice(-2); + return `${day}/${month}/${year}`; +}; From e6ee83a1375ebb35a20182526c1755d72193dceb Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Thu, 12 Oct 2023 20:00:34 +0300 Subject: [PATCH 20/68] add imports --- frontend/src/components/tableCells/dateCell/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/tableCells/dateCell/index.ts b/frontend/src/components/tableCells/dateCell/index.ts index e6db39c..3d393ec 100644 --- a/frontend/src/components/tableCells/dateCell/index.ts +++ b/frontend/src/components/tableCells/dateCell/index.ts @@ -1 +1 @@ -export * from './dateCell'; +export * from './DateCell'; From 0dd7088af7dd4f3d3b6a2bd9b2ff7fd0bcb393b1 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Thu, 12 Oct 2023 20:01:12 +0300 Subject: [PATCH 21/68] add date to dateCell --- .../components/tableCells/dateCell/dateCell.module.scss | 0 frontend/src/components/tableCells/dateCell/dateCell.tsx | 9 +++++---- .../src/components/tableCells/dateCell/dateCellProps.ts | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) delete mode 100644 frontend/src/components/tableCells/dateCell/dateCell.module.scss diff --git a/frontend/src/components/tableCells/dateCell/dateCell.module.scss b/frontend/src/components/tableCells/dateCell/dateCell.module.scss deleted file mode 100644 index e69de29..0000000 diff --git a/frontend/src/components/tableCells/dateCell/dateCell.tsx b/frontend/src/components/tableCells/dateCell/dateCell.tsx index b77d47f..f9d93c7 100644 --- a/frontend/src/components/tableCells/dateCell/dateCell.tsx +++ b/frontend/src/components/tableCells/dateCell/dateCell.tsx @@ -1,7 +1,8 @@ import { FC } from 'react'; -// import styles from './dateCell.module.scss'; -import { DateCellPropsI } from './dateCellProps'; +import { DateCellPropsI } from './DateCellProps'; +import { dateFromTimestamp } from 'Utils/dateFromTimestamp'; -export const DateCell: FC = () => { - return
dateCell
; +export const DateCell: FC = ({ cellValue }) => { + const formattedDate = dateFromTimestamp(cellValue); + return
{formattedDate}
; }; diff --git a/frontend/src/components/tableCells/dateCell/dateCellProps.ts b/frontend/src/components/tableCells/dateCell/dateCellProps.ts index 61791f9..6db5bef 100644 --- a/frontend/src/components/tableCells/dateCell/dateCellProps.ts +++ b/frontend/src/components/tableCells/dateCell/dateCellProps.ts @@ -1 +1,3 @@ -export interface DateCellPropsI {} +export interface DateCellPropsI { + cellValue: number; +} From e4722ba14ac9af871e9e6885c4303917ecaf39f4 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Thu, 12 Oct 2023 20:01:24 +0300 Subject: [PATCH 22/68] add cellDate to table --- frontend/src/components/table/Table.tsx | 28 ++++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/table/Table.tsx b/frontend/src/components/table/Table.tsx index 2f53ebc..a0aa57c 100644 --- a/frontend/src/components/table/Table.tsx +++ b/frontend/src/components/table/Table.tsx @@ -1,12 +1,13 @@ import { TablePropsI } from './TableProps.ts'; import styles from './Table.module.scss'; import { FC } from 'react'; +import { DateCell } from '../index.ts'; export const Table: FC = () => { const pools = [ { address: '0x4681de1e080e889fad73853fa7adaa0be39e433f', - date: 1696954119482, + date: 1697123492289, anchorCurrency: '0x6265617665726275696c642e6f7267', tokens: [ '0x6265617665726275696c642e6f7267', @@ -20,7 +21,7 @@ export const Table: FC = () => { }, { address: '0x4681de1e080e889fad73853fa7adaa0be39e433z', - date: 1696954119482, + date: 1697123492289, anchorCurrency: '0x6265617665726275696c642e6f7267', tokens: [ '0x6265617665726275696c642e6f7267', @@ -34,7 +35,7 @@ export const Table: FC = () => { }, { address: '0x4681de1e080e889fad73853fa7adaa0be39e433x', - date: 1696954119482, + date: 1697123492289, anchorCurrency: '0x6265617665726275696c642e6f7267', tokens: [ '0x6265617665726275696c642e6f7267', @@ -49,10 +50,10 @@ export const Table: FC = () => { ]; const tableRowMap = { - date: { title: 'Date', component: 'some tsx' }, - operatorFee: { title: 'Operator fee', component: 'some tsx' }, - total: { title: 'Total', component: 'some tsx' }, - profit: { title: 'Profit', component: 'some tsx' }, + date: { title: 'Date', component: 'DateCell' }, + // operatorFee: { title: 'Operator fee', component: 'some tsx' }, + // total: { title: 'Total', component: 'DateCell' }, + // profit: { title: 'Profit', component: 'some tsx' }, }; //todo: combine tokens and anchorCurrency for Anchor currency / Tokens // const combineTokens = (pools: any) => { @@ -79,6 +80,8 @@ export const Table: FC = () => { profitPercent: number; profit: number; }; + const cells = { DateCell }; + type CellsT = typeof cells; return (
{value.title}{value.title}
{pool[key]}{pool[key as keyof PoolT]}
@@ -92,9 +95,14 @@ export const Table: FC = () => { {pools.map((pool) => ( - {Object.keys(tableRowMap).map((key) => ( - - ))} + {Object.entries(tableRowMap).map(([key, value]) => { + const TagName = cells[value.component as CellsT]; + return ( + + ); + })} ))} From 137a1e4fb3a4a4da3f37e3e21c2f96e08d3cce37 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Thu, 12 Oct 2023 20:14:25 +0300 Subject: [PATCH 23/68] change root page --- frontend/src/App.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 5c23054..dac9977 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,11 +1,11 @@ import { createBrowserRouter, RouterProvider } from 'react-router-dom'; import { PoolsPage } from 'Pages'; -import Root from 'Pages/root.tsx'; +// import Root from 'Pages/root.tsx'; const router = createBrowserRouter([ { path: '/', - element: , + element: , }, { path: '/available-pools', From 261e8bebc926dab11aa13a6bbebcceee8d5d44e6 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Thu, 12 Oct 2023 20:14:41 +0300 Subject: [PATCH 24/68] temp type fix --- frontend/src/components/table/Table.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/table/Table.tsx b/frontend/src/components/table/Table.tsx index a0aa57c..0a23248 100644 --- a/frontend/src/components/table/Table.tsx +++ b/frontend/src/components/table/Table.tsx @@ -96,10 +96,10 @@ export const Table: FC = () => { {pools.map((pool) => ( {Object.entries(tableRowMap).map(([key, value]) => { - const TagName = cells[value.component as CellsT]; + const TagName = cells[value.component as keyof CellsT]; return ( ); })} From 0f25aba841a878ee27dff9231a671fb55fc11360 Mon Sep 17 00:00:00 2001 From: dk Date: Thu, 12 Oct 2023 23:13:22 +0300 Subject: [PATCH 25/68] add safeguard test (doesn't work yet) --- .gitignore | 2 + lib/safe-global | 1 + src/UniswapOnlyGuard.sol | 30 ++++++++++++++ test/SetupSafeGuard.t.sol | 87 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 120 insertions(+) create mode 160000 lib/safe-global create mode 100644 src/UniswapOnlyGuard.sol create mode 100644 test/SetupSafeGuard.t.sol diff --git a/.gitignore b/.gitignore index 3b58347..09b63ac 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,8 @@ out/ # Docs docs/ +broadcast/ + # Dotenv file .env diff --git a/lib/safe-global b/lib/safe-global new file mode 160000 index 0000000..75da71d --- /dev/null +++ b/lib/safe-global @@ -0,0 +1 @@ +Subproject commit 75da71dfc3859664807e81e48ebb0508a8f54737 diff --git a/src/UniswapOnlyGuard.sol b/src/UniswapOnlyGuard.sol new file mode 100644 index 0000000..d919e83 --- /dev/null +++ b/src/UniswapOnlyGuard.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.0; + +import "@safe-contracts/base/GuardManager.sol"; + +contract UniswapOnlyGuard is Guard { + constructor(){ + + } + + function checkTransaction( + address to, + uint256 value, + bytes memory data, + Enum.Operation operation, + uint256 safeTxGas, + uint256 baseGas, + uint256 gasPrice, + address gasToken, + address payable refundReceiver, + bytes memory signatures, + address msgSender + ) external override { + require(to == address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D), "Only Uniswap transactions allowed"); + } + + function checkAfterExecution(bytes32 txHash, bool success) external override { + // Nothing to do + } +} diff --git a/test/SetupSafeGuard.t.sol b/test/SetupSafeGuard.t.sol new file mode 100644 index 0000000..f62b507 --- /dev/null +++ b/test/SetupSafeGuard.t.sol @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.0; + +import { Test, console2 } from "forge-std/Test.sol"; +import "@openzeppelin/token/ERC20/IERC20.sol"; +import {GnosisSafe} from "@safe-contracts/GnosisSafe.sol"; +import {GnosisSafeL2} from "@safe-contracts/GnosisSafeL2.sol"; +import {GnosisSafeProxy} from "@safe-contracts/proxies/GnosisSafeProxy.sol"; +import {GnosisSafeProxyFactory} from "@safe-contracts/proxies/GnosisSafeProxyFactory.sol"; +import {Enum} from "@safe-contracts/common/Enum.sol"; +import {GuardManager} from "@safe-contracts/base/GuardManager.sol"; +import "../src/Constants.sol"; +import {UniswapOnlyGuard} from "../src/UniswapOnlyGuard.sol"; + +contract SetupSafeGuard is Test { + + address constant SINGLETON_ADDRESS = 0x3E5c63644E683549055b9Be8653de26E0B4CD36E; + address constant SAFE_PROXY_FACTORY = 0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2; + address USDC_BIG_HOLDER = 0xF977814e90dA44bFA03b6295A0616a897441aceC; + IERC20 usdc = IERC20(USDC_POLYGON); + + GnosisSafeProxy proxy; + + function setUp() public { + + address[] memory owners = new address[](1); + owners[0] = address(this); + + bytes memory data = abi.encodeCall( + GnosisSafe.setup, + (owners, + 1, + address(0), + "", + address(0), + address(0), + 0, + payable(0)) + ); + GnosisSafeProxy proxy = GnosisSafeProxyFactory(SAFE_PROXY_FACTORY).createProxyWithNonce( + SINGLETON_ADDRESS, + data, + 1234567 + ); + + vm.startPrank(USDC_BIG_HOLDER); + usdc.transfer(address(this), 1000 * 10 ** 6); + + payable(address(this)).transfer(10**18); + vm.stopPrank(); + } + +// function execTransaction( +// address to, +// uint256 value, +// bytes calldata data, +// Enum.Operation operation, +// uint256 safeTxGas, +// uint256 baseGas, +// uint256 gasPrice, +// address gasToken, +// address payable refundReceiver, +// bytes memory signatures +// ) + + function test_deploySafeAndAddGuard() public { + UniswapOnlyGuard guard = new UniswapOnlyGuard(); + // GuardManager.setGuard(address guard) + bytes memory setGuardCallData = abi.encodeCall( + GuardManager.setGuard, + (address(guard)) + ); + bool success = GnosisSafe(payable(proxy)).execTransaction( + address(proxy), + 0, + setGuardCallData, + Enum.Operation.Call, + 0, + 0, + 0, + address(0), + payable(0), + "" + ); + assertTrue(success, "setGuard should succeed"); + } +} From 3595ac566cca9e378b74cb9638c7d2f837b16532 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Fri, 13 Oct 2023 14:47:56 +0300 Subject: [PATCH 26/68] add logo #9 --- frontend/public/Logo.avif | Bin 0 -> 2021 bytes frontend/public/vite.svg | 1 - 2 files changed, 1 deletion(-) create mode 100644 frontend/public/Logo.avif delete mode 100644 frontend/public/vite.svg diff --git a/frontend/public/Logo.avif b/frontend/public/Logo.avif new file mode 100644 index 0000000000000000000000000000000000000000..7c8cbc6f8a9acdddf803df80a5fe35e1a74cb2bd GIT binary patch literal 2021 zcmZuxc{r5o8~(;JgNW=Q>xr^wnV54hgF%+aaYo6~G)wb2GiEThFxgVd64{TXMB*e% zwiF?x&_Wu8gdA(u2#1_+bh&>2{GRuEpXGku_qy-*`QrruK#t4|Vc-KnG5{GT(m?Vt z8i43J6NEntv00I75Wr?Nx?T+o6H_5|Q` zAmfStnZeEW5ZGM^HUdGPT^YOQC7^=z^CCx>?lI2I|AA0v4`hQ3KL*sS1Q`T66vYU1 zs-F*m8obL4kANUSeBd#QNI(us0ddfuLE(fm=+8ITI%{X$T9Duc2+rk^Z|yQ2Rei^v`eHyI* z_U6k4z<45K5mx~&o+$2^%TQMa^dtQo2c!>Tqe9PtaRvrIMkC^xqJRKg`jFCQ>n*)C zz5|MUino^ZI!vF$1zbEi7&V6WA~4;m?>Dd(T@!Q_R}eiUAiFw!YGVp#=ql3|fIp0y zxt{SYZnelC6!uI|nyDQN9kI=il2)~Lo14s8=H*F0(sxpJ#wFX-#^HgJY4utbB_T>c zFL$F>aRf0`v?-~GN+MBIs+!Uen^{_yUKon|sy^w$HmUb zHC(z=ELj`KUm@jf=qdgE=~v4o{5VEW>}ceVB>h1b9wyS*b47a-q^$c36&NN4GbwVS zg?;?ePtb)+?-fmr5LV)XtP;uP6;DL+sft=G+2_>}8eXw8n}+%^sh<+mL}@tA1~{?!E6fscy(=9F8P^rb*|aOqsk7!!9QQ> zs`M>~rT7gB+x1;@`>jrG$75I-d6^Y~RQ^#{oY7rrg_AjaMcq`^TVLbeJA8A#;C3mf za8fltCBKC&R;u*W(DadVMB}G6=|OVq_XFGq-!C*`aPq^e)N2!+iOUu8uN?ay3Z4Gw zJVpsy^~OGrYGQz|RfwWNoqd}sI$a`Ha^YPIWS1adAwZiEo>OBzZ^=K69d2wdQg^+n z5_#inn0-BX1yQ*l|CstG`eQz+}@XD(H)e9| z7K*p))9CG%lCf<4c_~4%z`+ z3x~(9Q?_s&#P*KY&2W$NQ`04n3oKy8gH&{6CSTV@?(Z{~W8F@4md#*`s9!I9xh)vc zI`>DoOAEaUd6KOSzI8N43t#r>y-WYhwd6~_otr!B0yFDvLl!%ioT_1-m59`AauSGE zR)*s*DM-K7C2B|Vw$~3@+TunKMoS;6qY=1KQjc7m@65JrXp6A8BIANP+=bJRw2;U)ZYCShQM34Mjdoi0mt}{Ptp!TV| zEKYr3=Y1TqCNE1i(7QyWM>O_CHyEZE`@_Za{)Z6yviiHa?}F8)!Iuz{;`fdV9&ek5 zH^>|HYFIi9CYMQ;(_Yz%7p^iR^urIVRUDP7s6Y2tzU$aSFN$?c8Kxlp@B7SlM>T(k zMd%CSH{yIjJUl{*dgXn4WjFbB2rc__V z6Jei@d)v(hFE`tD*u$2qRsJ6NhVJBx;Lb+BB>B|$pZjY%%sq6xjdBiFuDdTN-+pCq z)Lf8IEt2D}Fp^M!a_r^`u3}9|7oyQzSw;HX^FQVn6Ao``Y2@zcg-FZ-M_PFGvGwbOPjcNq0Bhh4c)A-iD3vEk*J!OUm{`(eXaYmKPwDZiVWsV`l=sKvN=UhH`~0;)ivZnvU@J% KQ~#!SNbElqzfu4I literal 0 HcmV?d00001 diff --git a/frontend/public/vite.svg b/frontend/public/vite.svg deleted file mode 100644 index e7b8dfb..0000000 --- a/frontend/public/vite.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file From 05d02f1a314aa70cbc7bc453a14464e09aa70dca Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Fri, 13 Oct 2023 14:48:38 +0300 Subject: [PATCH 27/68] add icons to path #9 --- frontend/tsconfig.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index ba22b41..f42ed05 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -26,6 +26,8 @@ "Pages": [ "./src/pages" ], "Utils/*": [ "./src/utils/*" ], "Utils": [ "./src/utils" ], + "Icons/*": [ "./src/icons/*" ], + "Icons": [ "./src/icons" ], } }, "include": ["src"], From 63081104c2eee66d8ccc6cd5da675cec2a0d5287 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Fri, 13 Oct 2023 14:48:56 +0300 Subject: [PATCH 28/68] add imports #9 --- frontend/src/components/header/index.ts | 1 + frontend/src/components/icons/NavigateFirst/index.ts | 1 + frontend/src/components/icons/NavigatePrevious/index.ts | 1 + frontend/src/components/icons/index.ts | 2 ++ frontend/src/components/index.ts | 2 ++ frontend/src/components/pagination/index.ts | 1 + 6 files changed, 8 insertions(+) create mode 100644 frontend/src/components/header/index.ts create mode 100644 frontend/src/components/icons/NavigateFirst/index.ts create mode 100644 frontend/src/components/icons/NavigatePrevious/index.ts create mode 100644 frontend/src/components/icons/index.ts create mode 100644 frontend/src/components/pagination/index.ts diff --git a/frontend/src/components/header/index.ts b/frontend/src/components/header/index.ts new file mode 100644 index 0000000..266dec8 --- /dev/null +++ b/frontend/src/components/header/index.ts @@ -0,0 +1 @@ +export * from './Header'; diff --git a/frontend/src/components/icons/NavigateFirst/index.ts b/frontend/src/components/icons/NavigateFirst/index.ts new file mode 100644 index 0000000..ce4425d --- /dev/null +++ b/frontend/src/components/icons/NavigateFirst/index.ts @@ -0,0 +1 @@ +export * from './NavigateFirst'; diff --git a/frontend/src/components/icons/NavigatePrevious/index.ts b/frontend/src/components/icons/NavigatePrevious/index.ts new file mode 100644 index 0000000..5fe1060 --- /dev/null +++ b/frontend/src/components/icons/NavigatePrevious/index.ts @@ -0,0 +1 @@ +export * from './NavigatePrevious'; diff --git a/frontend/src/components/icons/index.ts b/frontend/src/components/icons/index.ts new file mode 100644 index 0000000..88dfe17 --- /dev/null +++ b/frontend/src/components/icons/index.ts @@ -0,0 +1,2 @@ +export * from './NavigateFirst'; +export * from './NavigatePrevious'; diff --git a/frontend/src/components/index.ts b/frontend/src/components/index.ts index efe91bd..be2bfd1 100644 --- a/frontend/src/components/index.ts +++ b/frontend/src/components/index.ts @@ -1,2 +1,4 @@ export * from 'Components/table'; export * from 'Components/tableCells'; +export * from 'Components/pagination'; +export * from 'Components/header'; diff --git a/frontend/src/components/pagination/index.ts b/frontend/src/components/pagination/index.ts new file mode 100644 index 0000000..e016c96 --- /dev/null +++ b/frontend/src/components/pagination/index.ts @@ -0,0 +1 @@ +export * from './Pagination'; From e3cc74fb812995b471cb6904fa6f9526648a4863 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Fri, 13 Oct 2023 14:51:34 +0300 Subject: [PATCH 29/68] add pagination layout #9 --- .../pagination/Pagination.module.scss | 29 +++++++++++++++ .../src/components/pagination/Pagination.tsx | 36 +++++++++++++++++++ .../components/pagination/PaginationPropsI.ts | 1 + 3 files changed, 66 insertions(+) create mode 100644 frontend/src/components/pagination/Pagination.module.scss create mode 100644 frontend/src/components/pagination/Pagination.tsx create mode 100644 frontend/src/components/pagination/PaginationPropsI.ts diff --git a/frontend/src/components/pagination/Pagination.module.scss b/frontend/src/components/pagination/Pagination.module.scss new file mode 100644 index 0000000..1ddcd2a --- /dev/null +++ b/frontend/src/components/pagination/Pagination.module.scss @@ -0,0 +1,29 @@ +.pagination { + display: flex; + gap: 24px; + padding: 16px 20px; + justify-content: flex-end; + align-items: center; + .rowsCount { + display: flex; + gap: 8px; + align-items: center; + } + .pages { + display: flex; + gap: 4px; + align-items: center; + span { + font-size: 16px; + } + } + .icons { + display: flex; + gap: 24px; + align-items: center; + + .rotateRight { + transform: rotate(180deg); + } + } +} diff --git a/frontend/src/components/pagination/Pagination.tsx b/frontend/src/components/pagination/Pagination.tsx new file mode 100644 index 0000000..6270f92 --- /dev/null +++ b/frontend/src/components/pagination/Pagination.tsx @@ -0,0 +1,36 @@ +import { FC } from 'react'; +import styles from './Pagination.module.scss'; +import { PaginationPropsI } from './PaginationPropsI'; +import { NavigateFirst, NavigatePrevious } from 'Components/icons'; + +export const Pagination: FC = () => { + return ( +
+
+ Rows per page: + {/* todo: add drop down menu */} + + 10 + +
+
+ {/* todo: display current page and pages length */} + 1 + of + 1 +
+
+ + +
+ +
+
+ +
+
+
+ ); +}; diff --git a/frontend/src/components/pagination/PaginationPropsI.ts b/frontend/src/components/pagination/PaginationPropsI.ts new file mode 100644 index 0000000..469e211 --- /dev/null +++ b/frontend/src/components/pagination/PaginationPropsI.ts @@ -0,0 +1 @@ +export interface PaginationPropsI {} From 381fa66c2a8333938a32510bb75326c64b4bf42a Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Fri, 13 Oct 2023 14:51:59 +0300 Subject: [PATCH 30/68] add header #9 --- .../src/components/header/Header.module.scss | 29 +++++++++++++++++++ frontend/src/components/header/Header.tsx | 23 +++++++++++++++ .../icons/NavigateFirst/NavigateFirst.tsx | 20 +++++++++++++ .../NavigatePrevious.module.scss | 8 +++++ .../NavigatePrevious/NavigatePrevious.tsx | 20 +++++++++++++ 5 files changed, 100 insertions(+) create mode 100644 frontend/src/components/header/Header.module.scss create mode 100644 frontend/src/components/header/Header.tsx create mode 100644 frontend/src/components/icons/NavigateFirst/NavigateFirst.tsx create mode 100644 frontend/src/components/icons/NavigatePrevious/NavigatePrevious.module.scss create mode 100644 frontend/src/components/icons/NavigatePrevious/NavigatePrevious.tsx diff --git a/frontend/src/components/header/Header.module.scss b/frontend/src/components/header/Header.module.scss new file mode 100644 index 0000000..455db9e --- /dev/null +++ b/frontend/src/components/header/Header.module.scss @@ -0,0 +1,29 @@ +.header { + display: flex; + padding: 24px; + align-items: center; + align-self: stretch; + background: #1b1b1f; + box-shadow: + 0px 1px 2px 0px rgba(0, 0, 0, 0.3), + 0px 2px 6px 2px rgba(0, 0, 0, 0.15); + nav { + display: flex; + align-items: center; + gap: 10px; + margin-left: 96px; + margin-right: auto; + a { + padding: 8px; + border-radius: 4px; + background: var(--m-3-sys-dark-surface-container-high, #1b1b1f); + padding: 8px; + color: #c3c6cf; + + &.active { + background-color: #292a2d; + color: #a3cddc; + } + } + } +} diff --git a/frontend/src/components/header/Header.tsx b/frontend/src/components/header/Header.tsx new file mode 100644 index 0000000..ac1d224 --- /dev/null +++ b/frontend/src/components/header/Header.tsx @@ -0,0 +1,23 @@ +import { FC } from 'react'; +import styles from './Header.module.scss'; +import { Link, useLocation } from 'react-router-dom'; +import { ConnectButton } from '@rainbow-me/rainbowkit'; + +export const Header: FC = () => { + const location = useLocation(); + const currentPath = location.pathname; + + return ( +
+ + + + + +
+ ); +}; diff --git a/frontend/src/components/icons/NavigateFirst/NavigateFirst.tsx b/frontend/src/components/icons/NavigateFirst/NavigateFirst.tsx new file mode 100644 index 0000000..854cdfa --- /dev/null +++ b/frontend/src/components/icons/NavigateFirst/NavigateFirst.tsx @@ -0,0 +1,20 @@ +import { FC } from 'react'; +import styles from './NavigateFirst.module.scss'; + +export const NavigateFirst: FC = () => { + return ( + + + + ); +}; diff --git a/frontend/src/components/icons/NavigatePrevious/NavigatePrevious.module.scss b/frontend/src/components/icons/NavigatePrevious/NavigatePrevious.module.scss new file mode 100644 index 0000000..3727aa1 --- /dev/null +++ b/frontend/src/components/icons/NavigatePrevious/NavigatePrevious.module.scss @@ -0,0 +1,8 @@ +.icon { + cursor: pointer; + &:hover { + path { + fill: #808080; + } + } +} diff --git a/frontend/src/components/icons/NavigatePrevious/NavigatePrevious.tsx b/frontend/src/components/icons/NavigatePrevious/NavigatePrevious.tsx new file mode 100644 index 0000000..4d87a6a --- /dev/null +++ b/frontend/src/components/icons/NavigatePrevious/NavigatePrevious.tsx @@ -0,0 +1,20 @@ +import { FC } from 'react'; +import styles from './NavigatePrevious.module.scss'; + +export const NavigatePrevious: FC = () => { + return ( + + + + ); +}; From ecc83136be98b4e6fa5391f0c90312e9525f29d6 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Fri, 13 Oct 2023 14:52:29 +0300 Subject: [PATCH 31/68] icon styles #9 --- .../icons/NavigateFirst/NavigateFirst.module.scss | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 frontend/src/components/icons/NavigateFirst/NavigateFirst.module.scss diff --git a/frontend/src/components/icons/NavigateFirst/NavigateFirst.module.scss b/frontend/src/components/icons/NavigateFirst/NavigateFirst.module.scss new file mode 100644 index 0000000..3727aa1 --- /dev/null +++ b/frontend/src/components/icons/NavigateFirst/NavigateFirst.module.scss @@ -0,0 +1,8 @@ +.icon { + cursor: pointer; + &:hover { + path { + fill: #808080; + } + } +} From 1f2c47dbfac8a6debd684a1b907042d12857df06 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Fri, 13 Oct 2023 14:53:16 +0300 Subject: [PATCH 32/68] improve table page styles and change mock data #9 --- .../src/components/table/Table.module.scss | 47 +++++++++--- frontend/src/components/table/Table.tsx | 74 +++++++++---------- .../src/pages/PoolsPage/PoolsPage.module.scss | 15 +++- frontend/src/pages/PoolsPage/PoolsPage.tsx | 17 +++-- 4 files changed, 94 insertions(+), 59 deletions(-) diff --git a/frontend/src/components/table/Table.module.scss b/frontend/src/components/table/Table.module.scss index 5b34fc4..800cadc 100644 --- a/frontend/src/components/table/Table.module.scss +++ b/frontend/src/components/table/Table.module.scss @@ -1,5 +1,5 @@ @mixin dimmedText { - color: var(--m-3-sys-dark-on-surface-variant, #C3C6CF); + color: #c3c6cf; font-family: Noto Sans; font-size: 16px; font-style: normal; @@ -8,30 +8,45 @@ letter-spacing: 0.25px; } +@mixin text { + color: #fff; + text-align: right; + font-family: Noto Sans; + font-size: 16px; + font-style: normal; + font-weight: 600; + line-height: 24px; + letter-spacing: 0.25px; +} + .tableContainer { display: flex; - padding: 24px; + flex-direction: column; + padding: 0 24px; width: 100%; border-radius: 16px; - background: #1B1B1F; - box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.30), 0px 4px 8px 3px rgba(0, 0, 0, 0.15); + background: #1b1b1f; + box-shadow: + 0px 1px 3px 0px rgba(0, 0, 0, 0.3), + 0px 4px 8px 3px rgba(0, 0, 0, 0.15); table { width: 100%; border-collapse: collapse; border: none; - thead, tbody { + thead, + tbody { padding: 24px; } thead { tr { - border-bottom: 1px solid #A3CDDC;; + border-bottom: 1px solid #a3cddc; } } tbody { tr { - border-bottom: 1px solid #43474E; + border-bottom: 1px solid #43474e; } } @@ -39,13 +54,25 @@ border: none; padding: 0 8px 22px; text-align: left; - - }; + } td { border: none; padding: 22px 8px; + } + + .center { + text-align: center; + } + .left { + text-align: left; + } + .right { + text-align: right; + } + .tableFooter { + display: flex; + width: 100%; } } } - diff --git a/frontend/src/components/table/Table.tsx b/frontend/src/components/table/Table.tsx index 0a23248..5e07e86 100644 --- a/frontend/src/components/table/Table.tsx +++ b/frontend/src/components/table/Table.tsx @@ -1,7 +1,8 @@ import { TablePropsI } from './TableProps.ts'; import styles from './Table.module.scss'; import { FC } from 'react'; -import { DateCell } from '../index.ts'; +import { DateCell } from 'Components'; +import { Pagination } from 'Components'; export const Table: FC = () => { const pools = [ @@ -14,10 +15,10 @@ export const Table: FC = () => { '0x6265617665726275696c642e6f7267', '0x6265617665726275696c642e6f7267', ], - operatorFee: 12, - total: 234500, + operatorFee: '12%', + total: '$234500', profitPercent: 10, - profit: 3453453, + profit: '+10% $3460', }, { address: '0x4681de1e080e889fad73853fa7adaa0be39e433z', @@ -28,10 +29,10 @@ export const Table: FC = () => { '0x6265617665726275696c642e6f7267', '0x6265617665726275696c642e6f7267', ], - operatorFee: 12, - total: 234500, + operatorFee: '12%', + total: '$234500', profitPercent: 10, - profit: 120000, + profit: '+10% $3460', }, { address: '0x4681de1e080e889fad73853fa7adaa0be39e433x', @@ -42,19 +43,19 @@ export const Table: FC = () => { '0x6265617665726275696c642e6f7267', '0x6265617665726275696c642e6f7267', ], - operatorFee: 12, - total: 234500, + operatorFee: '12%', + total: '$234500', profitPercent: 10, - profit: 30000, + profit: '+10% $3460', }, ]; - const tableRowMap = { - date: { title: 'Date', component: 'DateCell' }, - // operatorFee: { title: 'Operator fee', component: 'some tsx' }, - // total: { title: 'Total', component: 'DateCell' }, - // profit: { title: 'Profit', component: 'some tsx' }, - }; + // const tableRowMap = { + // date: { title: 'Date', component: 'DateCell' }, + // operatorFee: { title: 'Operator fee', component: 'some tsx' }, + // total: { title: 'Total', component: 'DateCell' }, + // profit: { title: 'Profit', component: 'some tsx' }, + // }; //todo: combine tokens and anchorCurrency for Anchor currency / Tokens // const combineTokens = (pools: any) => { // const result = pools.map((pool: any) => { @@ -65,49 +66,42 @@ export const Table: FC = () => { // }); // setPools(result); // }; - // useEffect(() => { // combineTokens(pools); // }, [pools]); - //todo: find proper place for interfaces and types - type PoolT = { - address: string; - date: number; - anchorCurrency: string; - tokens: string[]; - operatorFee: number; - total: number; - profitPercent: number; - profit: number; - }; - const cells = { DateCell }; - type CellsT = typeof cells; + return (
{pool[key as keyof PoolT]} + +
- +
+ + + + + + {/* {Object.entries(tableRowMap).map(([key, value]) => ( ))} - + */} {pools.map((pool) => ( - {Object.entries(tableRowMap).map(([key, value]) => { - const TagName = cells[value.component as keyof CellsT]; - return ( - - ); - })} + + + + ))}
DateOperator FeeTotalProfit
{value.title}
- - + + {pool.operatorFee}{pool.total}{pool.profit}
-
+
+ +
); }; diff --git a/frontend/src/pages/PoolsPage/PoolsPage.module.scss b/frontend/src/pages/PoolsPage/PoolsPage.module.scss index 2a5856e..7f5d052 100644 --- a/frontend/src/pages/PoolsPage/PoolsPage.module.scss +++ b/frontend/src/pages/PoolsPage/PoolsPage.module.scss @@ -1,4 +1,4 @@ -.container { +.poolPageContainer { display: flex; padding: 0 122px; @@ -7,5 +7,16 @@ flex-direction: column; align-items: flex-start; width: 100%; + + h1 { + margin-top: 32px; + margin-bottom: 24px; + color: #c7c6ca; + font-size: 16px; + font-style: normal; + font-weight: 600; + line-height: 24px; + letter-spacing: 0.25px; + } } -} \ No newline at end of file +} diff --git a/frontend/src/pages/PoolsPage/PoolsPage.tsx b/frontend/src/pages/PoolsPage/PoolsPage.tsx index 64f9587..5b1391c 100644 --- a/frontend/src/pages/PoolsPage/PoolsPage.tsx +++ b/frontend/src/pages/PoolsPage/PoolsPage.tsx @@ -1,15 +1,18 @@ import { PoolsPagePropsI } from './PoolsPageProps.ts'; import styles from './PoolsPage.module.scss'; import { FC } from 'react'; -import { Table } from 'Components'; +import { Header, Table } from 'Components'; export const PoolsPage: FC = ({ poolsType }) => { return ( -
-
-

{poolsType}

- - - + <> +
+
+
+

{poolsType}

+
+ + + ); }; From 252f2f998244ef06c55ab374adb4049c9a607a3a Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Fri, 13 Oct 2023 14:53:35 +0300 Subject: [PATCH 33/68] default app styles #9 --- frontend/src/App.tsx | 3 ++- frontend/src/index.scss | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index dac9977..360cc42 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,6 +1,7 @@ import { createBrowserRouter, RouterProvider } from 'react-router-dom'; import { PoolsPage } from 'Pages'; -// import Root from 'Pages/root.tsx'; +import './index.scss'; +import '@rainbow-me/rainbowkit/styles.css'; const router = createBrowserRouter([ { diff --git a/frontend/src/index.scss b/frontend/src/index.scss index 04ae9f5..8720bdc 100644 --- a/frontend/src/index.scss +++ b/frontend/src/index.scss @@ -29,6 +29,7 @@ body { font-weight: 400; line-height: 1.25; font-size: 16px; + background-color: #131316; } #root { From 31a09afb0408466d80452f5f23f53134be43da1d Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Fri, 13 Oct 2023 15:04:39 +0300 Subject: [PATCH 34/68] fix imports #9 --- frontend/src/components/index.ts | 1 + frontend/vite.config.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/frontend/src/components/index.ts b/frontend/src/components/index.ts index be2bfd1..e3e39fb 100644 --- a/frontend/src/components/index.ts +++ b/frontend/src/components/index.ts @@ -2,3 +2,4 @@ export * from 'Components/table'; export * from 'Components/tableCells'; export * from 'Components/pagination'; export * from 'Components/header'; +export * from 'Components/tableCells'; diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 597de25..7977cdc 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -13,6 +13,7 @@ export default defineConfig({ Components: path.resolve(__dirname, './src/components'), Pages: path.resolve(__dirname, './src/pages'), Utils: path.resolve(__dirname, './src/utils'), + Icons: path.resolve(__dirname, './src/icons'), }, }, plugins: [react()], From 27d8a205ac59d005c57654e9b780d8eb947c2e01 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Fri, 13 Oct 2023 15:09:41 +0300 Subject: [PATCH 35/68] fix import #9 --- frontend/src/components/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/index.ts b/frontend/src/components/index.ts index e3e39fb..b34e00e 100644 --- a/frontend/src/components/index.ts +++ b/frontend/src/components/index.ts @@ -2,4 +2,4 @@ export * from 'Components/table'; export * from 'Components/tableCells'; export * from 'Components/pagination'; export * from 'Components/header'; -export * from 'Components/tableCells'; +export * from 'Components/tableCells/dateCell'; From a4a7080d21342530aa2e89e0cd656be384bc54f2 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Fri, 13 Oct 2023 16:14:34 +0300 Subject: [PATCH 36/68] fix imports #9 --- frontend/src/components/{tableCells => }/dateCell/dateCell.tsx | 0 .../src/components/{tableCells => }/dateCell/dateCellProps.ts | 0 frontend/src/components/{tableCells => }/dateCell/index.ts | 0 frontend/src/components/index.ts | 3 +-- frontend/src/components/tableCells/index.ts | 1 - 5 files changed, 1 insertion(+), 3 deletions(-) rename frontend/src/components/{tableCells => }/dateCell/dateCell.tsx (100%) rename frontend/src/components/{tableCells => }/dateCell/dateCellProps.ts (100%) rename frontend/src/components/{tableCells => }/dateCell/index.ts (100%) delete mode 100644 frontend/src/components/tableCells/index.ts diff --git a/frontend/src/components/tableCells/dateCell/dateCell.tsx b/frontend/src/components/dateCell/dateCell.tsx similarity index 100% rename from frontend/src/components/tableCells/dateCell/dateCell.tsx rename to frontend/src/components/dateCell/dateCell.tsx diff --git a/frontend/src/components/tableCells/dateCell/dateCellProps.ts b/frontend/src/components/dateCell/dateCellProps.ts similarity index 100% rename from frontend/src/components/tableCells/dateCell/dateCellProps.ts rename to frontend/src/components/dateCell/dateCellProps.ts diff --git a/frontend/src/components/tableCells/dateCell/index.ts b/frontend/src/components/dateCell/index.ts similarity index 100% rename from frontend/src/components/tableCells/dateCell/index.ts rename to frontend/src/components/dateCell/index.ts diff --git a/frontend/src/components/index.ts b/frontend/src/components/index.ts index b34e00e..935b4ff 100644 --- a/frontend/src/components/index.ts +++ b/frontend/src/components/index.ts @@ -1,5 +1,4 @@ export * from 'Components/table'; -export * from 'Components/tableCells'; export * from 'Components/pagination'; export * from 'Components/header'; -export * from 'Components/tableCells/dateCell'; +export * from 'Components/dateCell'; diff --git a/frontend/src/components/tableCells/index.ts b/frontend/src/components/tableCells/index.ts deleted file mode 100644 index e6db39c..0000000 --- a/frontend/src/components/tableCells/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './dateCell'; From e0bd53e95ff0d743e743247df45223dd8f9ace67 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Fri, 13 Oct 2023 16:18:46 +0300 Subject: [PATCH 37/68] fix imports #9 --- frontend/src/components/dateCell/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/dateCell/index.ts b/frontend/src/components/dateCell/index.ts index 3d393ec..e6db39c 100644 --- a/frontend/src/components/dateCell/index.ts +++ b/frontend/src/components/dateCell/index.ts @@ -1 +1 @@ -export * from './DateCell'; +export * from './dateCell'; From e74d2bd04ed9241542ce5312ae634ee657d10d48 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Fri, 13 Oct 2023 16:20:36 +0300 Subject: [PATCH 38/68] fix imports #9 --- frontend/src/components/dateCell/dateCell.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/dateCell/dateCell.tsx b/frontend/src/components/dateCell/dateCell.tsx index f9d93c7..3f1f99f 100644 --- a/frontend/src/components/dateCell/dateCell.tsx +++ b/frontend/src/components/dateCell/dateCell.tsx @@ -1,5 +1,5 @@ import { FC } from 'react'; -import { DateCellPropsI } from './DateCellProps'; +import { DateCellPropsI } from './dateCellProps'; import { dateFromTimestamp } from 'Utils/dateFromTimestamp'; export const DateCell: FC = ({ cellValue }) => { From eed9c1f2703309c1e642f166e0fc6e7da1a61945 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Fri, 13 Oct 2023 16:30:42 +0300 Subject: [PATCH 39/68] fix logo path --- frontend/public/{ => assets}/Logo.avif | Bin frontend/src/components/header/Header.tsx | 2 +- frontend/vite.config.ts | 3 +++ 3 files changed, 4 insertions(+), 1 deletion(-) rename frontend/public/{ => assets}/Logo.avif (100%) diff --git a/frontend/public/Logo.avif b/frontend/public/assets/Logo.avif similarity index 100% rename from frontend/public/Logo.avif rename to frontend/public/assets/Logo.avif diff --git a/frontend/src/components/header/Header.tsx b/frontend/src/components/header/Header.tsx index ac1d224..dda2c0b 100644 --- a/frontend/src/components/header/Header.tsx +++ b/frontend/src/components/header/Header.tsx @@ -10,7 +10,7 @@ export const Header: FC = () => { return (
- +
- - - - + + + + {/* {Object.entries(tableRowMap).map(([key, value]) => ( @@ -99,9 +99,6 @@ export const Table: FC = () => { ))}
DateOperator FeeTotalProfitDateOperator FeeTotalProfit
-
- -
); }; From 43a29661474a9a02effdceb729fd3779c148b972 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Sun, 15 Oct 2023 14:04:25 +0300 Subject: [PATCH 49/68] cleanup #9 --- frontend/src/components/table/Table.tsx | 27 ------------------------- 1 file changed, 27 deletions(-) diff --git a/frontend/src/components/table/Table.tsx b/frontend/src/components/table/Table.tsx index 77b469a..cbe33cc 100644 --- a/frontend/src/components/table/Table.tsx +++ b/frontend/src/components/table/Table.tsx @@ -2,7 +2,6 @@ import { TablePropsI } from './TableProps.ts'; import styles from './Table.module.scss'; import { FC } from 'react'; import { DateCell } from 'Components'; -import { Pagination } from 'Components'; export const Table: FC = () => { const pools = [ @@ -49,27 +48,6 @@ export const Table: FC = () => { profit: '+10% $3460', }, ]; - - // const tableRowMap = { - // date: { title: 'Date', component: 'DateCell' }, - // operatorFee: { title: 'Operator fee', component: 'some tsx' }, - // total: { title: 'Total', component: 'DateCell' }, - // profit: { title: 'Profit', component: 'some tsx' }, - // }; - //todo: combine tokens and anchorCurrency for Anchor currency / Tokens - // const combineTokens = (pools: any) => { - // const result = pools.map((pool: any) => { - // return (pool = { - // ...pool, - // allTokens: { anchorCurrency: pool.anchorCurrency, tokens: pool.tokens }, - // }); - // }); - // setPools(result); - // }; - // useEffect(() => { - // combineTokens(pools); - // }, [pools]); - return (
@@ -80,11 +58,6 @@ export const Table: FC = () => { - {/* - {Object.entries(tableRowMap).map(([key, value]) => ( - - ))} - */} {pools.map((pool) => ( From 37d172a69763a009cbdbd9601bab9aa8ab87e5f9 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Sun, 15 Oct 2023 15:31:21 +0300 Subject: [PATCH 50/68] cleanup --- frontend/src/pages/root.tsx | 38 ------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 frontend/src/pages/root.tsx diff --git a/frontend/src/pages/root.tsx b/frontend/src/pages/root.tsx deleted file mode 100644 index f695882..0000000 --- a/frontend/src/pages/root.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import { useState } from 'react'; -import '../index.scss'; -import '@rainbow-me/rainbowkit/styles.css'; -import { ConnectButton } from '@rainbow-me/rainbowkit'; -import DevModeToggle from '../components/devModeToggle/DevModeToggle'; - -function Root() { - const [devModeState, setDevModeState] = useState(false); - const versionGitTag = import.meta.env.VITE_REACT_APP_GIT_TAG; - const gitDate = import.meta.env.VITE_REACT_APP_GIT_DATE; - - console.log('VITE_REACT_APP_GIT_TAG - ', versionGitTag); - console.log('VITE_REACT_APP_GIT_DATE - ', gitDate); - - const handleToggleDevMode = (value: boolean) => { - setDevModeState(value); - }; - - return ( - <> -

root page

- {versionGitTag && gitDate && ( -
- - {devModeState && ( -
-

Version: {versionGitTag}

-

Date: {gitDate}

-
- )} -
- )} - - - ); -} - -export default Root; From 3e9dd948f382a1862fc0d7275b1df045f566b416 Mon Sep 17 00:00:00 2001 From: dk Date: Sun, 15 Oct 2023 17:50:27 +0300 Subject: [PATCH 51/68] add allowedTokensCount param --- src/ProfitPalsVault.sol | 4 ++++ src/interfaces/IProfitPalsVault.sol | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/ProfitPalsVault.sol b/src/ProfitPalsVault.sol index 402ef61..953224d 100644 --- a/src/ProfitPalsVault.sol +++ b/src/ProfitPalsVault.sol @@ -55,4 +55,8 @@ contract ProfitPalsVault is IProfitPalsVault, ERC4626 { function unpause() external { } + + function allowedTokensCount() external view override returns (uint256) { + return allowedTokens.length; + } } diff --git a/src/interfaces/IProfitPalsVault.sol b/src/interfaces/IProfitPalsVault.sol index 0a019a0..c906a24 100644 --- a/src/interfaces/IProfitPalsVault.sol +++ b/src/interfaces/IProfitPalsVault.sol @@ -13,6 +13,8 @@ interface IProfitPalsVault is IERC4626 { function allowedTokens(uint256 index) external view returns (IERC20); + function allowedTokensCount() external view returns (uint256); + function deposit(uint256 amount) external; function withdraw(uint256 amount) external; From 1067eb8059eff9c23a7d73051b472ef5fa8e04c9 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Sun, 15 Oct 2023 17:54:17 +0300 Subject: [PATCH 52/68] change wagmi config --- frontend/src/wagmiConfig.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/frontend/src/wagmiConfig.ts b/frontend/src/wagmiConfig.ts index 8fb2803..205e4cb 100644 --- a/frontend/src/wagmiConfig.ts +++ b/frontend/src/wagmiConfig.ts @@ -1,16 +1,12 @@ import { publicProvider } from 'wagmi/providers/public'; -import { configureChains, createConfig, mainnet } from 'wagmi'; +import { configureChains, createConfig } from 'wagmi'; import { polygon } from '@wagmi/core/chains'; import { getDefaultWallets } from '@rainbow-me/rainbowkit'; -import { arbitrum, base, optimism, zora } from 'viem/chains'; import { PROJECT_ID } from './constants/constants'; console.log('walletConnect PROJECT_ID: ', PROJECT_ID); -export const { chains, publicClient } = configureChains( - [mainnet, polygon, optimism, arbitrum, base, zora], - [publicProvider()] -); +export const { chains, publicClient } = configureChains([polygon], [publicProvider()]); const { connectors } = getDefaultWallets({ appName: 'profitpals', From 8662d5ae4c9fbc2f3be84afdaf46cf06599a8f2a Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Sun, 15 Oct 2023 17:56:26 +0300 Subject: [PATCH 53/68] add read contract --- frontend/src/pages/PoolsPage/PoolsPage.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/frontend/src/pages/PoolsPage/PoolsPage.tsx b/frontend/src/pages/PoolsPage/PoolsPage.tsx index 5b1391c..b470e7e 100644 --- a/frontend/src/pages/PoolsPage/PoolsPage.tsx +++ b/frontend/src/pages/PoolsPage/PoolsPage.tsx @@ -2,8 +2,18 @@ import { PoolsPagePropsI } from './PoolsPageProps.ts'; import styles from './PoolsPage.module.scss'; import { FC } from 'react'; import { Header, Table } from 'Components'; +import { erc20ABI, useAccount, useContractRead } from 'wagmi'; export const PoolsPage: FC = ({ poolsType }) => { + const { address } = useAccount(); + const { data } = useContractRead({ + address: '0xCa9c4a7949e6f9dc8343b565E34C493E4970c1AB', + abi: erc20ABI, + functionName: 'balanceOf', + args: [address!], + watch: true, + }); + return ( <>
From 81e2318ddb5f664114cc09bdbcff9987bbd559ed Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Mon, 16 Oct 2023 07:37:56 +0300 Subject: [PATCH 54/68] add publicClientViem #9 --- frontend/src/wagmiConfig.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frontend/src/wagmiConfig.ts b/frontend/src/wagmiConfig.ts index 205e4cb..5e7fd3b 100644 --- a/frontend/src/wagmiConfig.ts +++ b/frontend/src/wagmiConfig.ts @@ -3,10 +3,15 @@ import { configureChains, createConfig } from 'wagmi'; import { polygon } from '@wagmi/core/chains'; import { getDefaultWallets } from '@rainbow-me/rainbowkit'; import { PROJECT_ID } from './constants/constants'; +import { createPublicClient, http } from 'viem'; console.log('walletConnect PROJECT_ID: ', PROJECT_ID); export const { chains, publicClient } = configureChains([polygon], [publicProvider()]); +export const publicClientViem = createPublicClient({ + chain: polygon, + transport: http(), +}); const { connectors } = getDefaultWallets({ appName: 'profitpals', From c6ce96a04d65686763315f740093daf8ccba8335 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Mon, 16 Oct 2023 07:38:10 +0300 Subject: [PATCH 55/68] remove base #9 --- frontend/vite.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index c435f1c..116610d 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -10,7 +10,7 @@ export default defineConfig({ assetsDir: 'assets', }, - base: './', + // base: './', resolve: { alias: { Components: path.resolve(__dirname, './src/components'), From 365a0f85850d7061755bc7b7257e312ca7641494 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Mon, 16 Oct 2023 07:38:31 +0300 Subject: [PATCH 56/68] remove favicon #9 --- frontend/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/index.html b/frontend/index.html index b3a18a5..460ff8e 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -2,7 +2,6 @@ - From d02e16cc337223604f8b6658cc90088482419af4 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Mon, 16 Oct 2023 07:39:00 +0300 Subject: [PATCH 57/68] remove unused route #9 --- frontend/src/App.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 360cc42..44f34c7 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -8,10 +8,6 @@ const router = createBrowserRouter([ path: '/', element: , }, - { - path: '/available-pools', - element: , - }, ]); function App() { From d00c55a75483c987233e7b879c21ef5a62fde8ee Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Mon, 16 Oct 2023 07:39:33 +0300 Subject: [PATCH 58/68] get contract name #9 --- frontend/src/pages/PoolsPage/PoolsPage.tsx | 50 ++++++++++++++++++---- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/frontend/src/pages/PoolsPage/PoolsPage.tsx b/frontend/src/pages/PoolsPage/PoolsPage.tsx index b470e7e..4231ed3 100644 --- a/frontend/src/pages/PoolsPage/PoolsPage.tsx +++ b/frontend/src/pages/PoolsPage/PoolsPage.tsx @@ -1,18 +1,50 @@ import { PoolsPagePropsI } from './PoolsPageProps.ts'; import styles from './PoolsPage.module.scss'; -import { FC } from 'react'; +import { FC, useEffect } from 'react'; import { Header, Table } from 'Components'; -import { erc20ABI, useAccount, useContractRead } from 'wagmi'; +import { useContractRead } from 'wagmi'; +import { abi } from '../../data/abi.ts'; +// import { publicClientViem } from 'src/wagmiConfig.ts'; +const contract = '0xCa9c4a7949e6f9dc8343b565E34C493E4970c1AB'; export const PoolsPage: FC = ({ poolsType }) => { - const { address } = useAccount(); - const { data } = useContractRead({ - address: '0xCa9c4a7949e6f9dc8343b565E34C493E4970c1AB', - abi: erc20ABI, - functionName: 'balanceOf', - args: [address!], - watch: true, + const { data, isSuccess } = useContractRead({ + address: contract, + abi: abi, + functionName: 'name', + watch: false, }); + useEffect(() => { + if (isSuccess) { + console.log(data); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [isSuccess]); + + // const wagmiContract = { + // address: contract, + // abi: abi, + // functionName: 'name', + // } as const; + + // const getPools = async () => { + // const results = await publicClientViem.multicall({ + // contracts: [ + // { + // ...wagmiContract, + // }, + // { + // ...wagmiContract, + // functionName: 'ownerOf', + // args: [69420n], + // }, + // { + // ...wagmiContract, + // functionName: 'mint', + // }, + // ], + // }); + // }; return ( <> From 02a991cecbcf9de9ef638a9eca934f06a99131e5 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Mon, 16 Oct 2023 23:56:00 +0300 Subject: [PATCH 59/68] get pool data --- frontend/src/pages/PoolsPage/PoolsPage.tsx | 82 ++++++++++++---------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/frontend/src/pages/PoolsPage/PoolsPage.tsx b/frontend/src/pages/PoolsPage/PoolsPage.tsx index 4231ed3..5d9c647 100644 --- a/frontend/src/pages/PoolsPage/PoolsPage.tsx +++ b/frontend/src/pages/PoolsPage/PoolsPage.tsx @@ -1,50 +1,58 @@ import { PoolsPagePropsI } from './PoolsPageProps.ts'; import styles from './PoolsPage.module.scss'; -import { FC, useEffect } from 'react'; +import { FC, useEffect, useState } from 'react'; import { Header, Table } from 'Components'; import { useContractRead } from 'wagmi'; import { abi } from '../../data/abi.ts'; -// import { publicClientViem } from 'src/wagmiConfig.ts'; -const contract = '0xCa9c4a7949e6f9dc8343b565E34C493E4970c1AB'; +import { publicClientViem } from '../../wagmiConfig.ts'; +export type TPool = { + allowedTokens: string; + anchorCurrency: string; + operatorFee: number; +}; export const PoolsPage: FC = ({ poolsType }) => { - const { data, isSuccess } = useContractRead({ + const contract = '0xCa9c4a7949e6f9dc8343b565E34C493E4970c1AB'; + + useEffect(() => { + getPools(); + }, []); + + const wagmiContract = { address: contract, abi: abi, - functionName: 'name', - watch: false, - }); - useEffect(() => { - if (isSuccess) { - console.log(data); - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [isSuccess]); + } as const; + + const [tableData, setTableData] = useState(null); - // const wagmiContract = { - // address: contract, - // abi: abi, - // functionName: 'name', - // } as const; + const getPools = async () => { + const results = await publicClientViem.multicall({ + contracts: [ + { + ...wagmiContract, + functionName: 'allowedTokens', + args: [0], + }, + { + ...wagmiContract, + functionName: 'anchorCurrency', + }, + { + ...wagmiContract, + functionName: 'operatorFee', + }, + ], + }); + const pool = { + allowedTokens: results[0].result, + anchorCurrency: results[1].result, + operatorFee: results[2].result, + }; + setTableData([pool]); + console.log(pool); - // const getPools = async () => { - // const results = await publicClientViem.multicall({ - // contracts: [ - // { - // ...wagmiContract, - // }, - // { - // ...wagmiContract, - // functionName: 'ownerOf', - // args: [69420n], - // }, - // { - // ...wagmiContract, - // functionName: 'mint', - // }, - // ], - // }); - // }; + // return [pool]; + }; return ( <> @@ -52,7 +60,7 @@ export const PoolsPage: FC = ({ poolsType }) => {

{poolsType}

-
Total Profit
{value.title}
+ {tableData &&
} From 247d68f8b6e50650a8e0e4ee9d14c9be608f7bdc Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Mon, 16 Oct 2023 23:56:24 +0300 Subject: [PATCH 60/68] show table data --- frontend/src/components/table/Table.tsx | 69 ++++----------------- frontend/src/components/table/TableProps.ts | 8 ++- 2 files changed, 20 insertions(+), 57 deletions(-) diff --git a/frontend/src/components/table/Table.tsx b/frontend/src/components/table/Table.tsx index cbe33cc..89d269c 100644 --- a/frontend/src/components/table/Table.tsx +++ b/frontend/src/components/table/Table.tsx @@ -1,73 +1,30 @@ import { TablePropsI } from './TableProps.ts'; import styles from './Table.module.scss'; import { FC } from 'react'; -import { DateCell } from 'Components'; +// import { DateCell } from 'Components'; +// import { TPool } from 'src/pages/index.ts'; -export const Table: FC = () => { - const pools = [ - { - address: '0x4681de1e080e889fad73853fa7adaa0be39e433f', - date: 1697123492289, - anchorCurrency: '0x6265617665726275696c642e6f7267', - tokens: [ - '0x6265617665726275696c642e6f7267', - '0x6265617665726275696c642e6f7267', - '0x6265617665726275696c642e6f7267', - ], - operatorFee: '12%', - total: '$234500', - profitPercent: 10, - profit: '+10% $3460', - }, - { - address: '0x4681de1e080e889fad73853fa7adaa0be39e433z', - date: 1697123492289, - anchorCurrency: '0x6265617665726275696c642e6f7267', - tokens: [ - '0x6265617665726275696c642e6f7267', - '0x6265617665726275696c642e6f7267', - '0x6265617665726275696c642e6f7267', - ], - operatorFee: '12%', - total: '$234500', - profitPercent: 10, - profit: '+10% $3460', - }, - { - address: '0x4681de1e080e889fad73853fa7adaa0be39e433x', - date: 1697123492289, - anchorCurrency: '0x6265617665726275696c642e6f7267', - tokens: [ - '0x6265617665726275696c642e6f7267', - '0x6265617665726275696c642e6f7267', - '0x6265617665726275696c642e6f7267', - ], - operatorFee: '12%', - total: '$234500', - profitPercent: 10, - profit: '+10% $3460', - }, - ]; +export const Table: FC = ({ tableData }) => { return (
- + {/* */} - - + + - {pools.map((pool) => ( - - + {/* - - - + */} + + + ))} diff --git a/frontend/src/components/table/TableProps.ts b/frontend/src/components/table/TableProps.ts index 4023c15..22b6f46 100644 --- a/frontend/src/components/table/TableProps.ts +++ b/frontend/src/components/table/TableProps.ts @@ -1 +1,7 @@ -export interface TablePropsI {} +export interface TablePropsI { + tableData: { + operatorFee: number; + anchorCurrency: string; + allowedTokens: string; + }[]; +} From 392ada0d23f6019ec7fdecd9452a587a7bedde30 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Mon, 16 Oct 2023 23:56:30 +0300 Subject: [PATCH 61/68] add abi --- frontend/src/data/abi.ts | 415 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 415 insertions(+) create mode 100644 frontend/src/data/abi.ts diff --git a/frontend/src/data/abi.ts b/frontend/src/data/abi.ts new file mode 100644 index 0000000..03465b2 --- /dev/null +++ b/frontend/src/data/abi.ts @@ -0,0 +1,415 @@ +export const abi = [ + { + inputs: [ + { internalType: 'contract IERC20', name: 'anchorCurrency_', type: 'address' }, + { internalType: 'contract IERC20[]', name: 'tokens', type: 'address[]' }, + { internalType: 'uint256', name: 'operatorFee_', type: 'uint256' }, + { internalType: 'string', name: 'name_', type: 'string' }, + { internalType: 'string', name: 'symbol_', type: 'string' }, + { internalType: 'address', name: 'safeProxyFactory', type: 'address' }, + { internalType: 'address', name: 'safeLogicSingleton', type: 'address' }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + inputs: [{ internalType: 'address', name: 'target', type: 'address' }], + name: 'AddressEmptyCode', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'account', type: 'address' }], + name: 'AddressInsufficientBalance', + type: 'error', + }, + { + inputs: [ + { internalType: 'address', name: 'spender', type: 'address' }, + { internalType: 'uint256', name: 'allowance', type: 'uint256' }, + { internalType: 'uint256', name: 'needed', type: 'uint256' }, + ], + name: 'ERC20InsufficientAllowance', + type: 'error', + }, + { + inputs: [ + { internalType: 'address', name: 'sender', type: 'address' }, + { internalType: 'uint256', name: 'balance', type: 'uint256' }, + { internalType: 'uint256', name: 'needed', type: 'uint256' }, + ], + name: 'ERC20InsufficientBalance', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'approver', type: 'address' }], + name: 'ERC20InvalidApprover', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'receiver', type: 'address' }], + name: 'ERC20InvalidReceiver', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'sender', type: 'address' }], + name: 'ERC20InvalidSender', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'spender', type: 'address' }], + name: 'ERC20InvalidSpender', + type: 'error', + }, + { + inputs: [ + { internalType: 'address', name: 'receiver', type: 'address' }, + { internalType: 'uint256', name: 'assets', type: 'uint256' }, + { internalType: 'uint256', name: 'max', type: 'uint256' }, + ], + name: 'ERC4626ExceededMaxDeposit', + type: 'error', + }, + { + inputs: [ + { internalType: 'address', name: 'receiver', type: 'address' }, + { internalType: 'uint256', name: 'shares', type: 'uint256' }, + { internalType: 'uint256', name: 'max', type: 'uint256' }, + ], + name: 'ERC4626ExceededMaxMint', + type: 'error', + }, + { + inputs: [ + { internalType: 'address', name: 'owner', type: 'address' }, + { internalType: 'uint256', name: 'shares', type: 'uint256' }, + { internalType: 'uint256', name: 'max', type: 'uint256' }, + ], + name: 'ERC4626ExceededMaxRedeem', + type: 'error', + }, + { + inputs: [ + { internalType: 'address', name: 'owner', type: 'address' }, + { internalType: 'uint256', name: 'assets', type: 'uint256' }, + { internalType: 'uint256', name: 'max', type: 'uint256' }, + ], + name: 'ERC4626ExceededMaxWithdraw', + type: 'error', + }, + { inputs: [], name: 'FailedInnerCall', type: 'error' }, + { inputs: [], name: 'MathOverflowedMulDiv', type: 'error' }, + { + inputs: [{ internalType: 'address', name: 'token', type: 'address' }], + name: 'SafeERC20FailedOperation', + type: 'error', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'owner', type: 'address' }, + { indexed: true, internalType: 'address', name: 'spender', type: 'address' }, + { indexed: false, internalType: 'uint256', name: 'value', type: 'uint256' }, + ], + name: 'Approval', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'sender', type: 'address' }, + { indexed: true, internalType: 'address', name: 'owner', type: 'address' }, + { indexed: false, internalType: 'uint256', name: 'assets', type: 'uint256' }, + { indexed: false, internalType: 'uint256', name: 'shares', type: 'uint256' }, + ], + name: 'Deposit', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'vault', type: 'address' }, + { indexed: true, internalType: 'address', name: 'anchorCurrency', type: 'address' }, + { indexed: true, internalType: 'address', name: 'operator', type: 'address' }, + { indexed: false, internalType: 'uint256', name: 'operatorFee', type: 'uint256' }, + { indexed: false, internalType: 'string', name: 'name', type: 'string' }, + { indexed: false, internalType: 'string', name: 'symbol', type: 'string' }, + ], + name: 'ProfitPalsVaultCreated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'from', type: 'address' }, + { indexed: true, internalType: 'address', name: 'to', type: 'address' }, + { indexed: false, internalType: 'uint256', name: 'value', type: 'uint256' }, + ], + name: 'Transfer', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'sender', type: 'address' }, + { indexed: true, internalType: 'address', name: 'receiver', type: 'address' }, + { indexed: true, internalType: 'address', name: 'owner', type: 'address' }, + { indexed: false, internalType: 'uint256', name: 'assets', type: 'uint256' }, + { indexed: false, internalType: 'uint256', name: 'shares', type: 'uint256' }, + ], + name: 'Withdraw', + type: 'event', + }, + { + inputs: [ + { internalType: 'address', name: 'owner', type: 'address' }, + { internalType: 'address', name: 'spender', type: 'address' }, + ], + name: 'allowance', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + name: 'allowedTokens', + outputs: [{ internalType: 'contract IERC20', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'anchorCurrency', + outputs: [{ internalType: 'contract IERC20', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'spender', type: 'address' }, + { internalType: 'uint256', name: 'value', type: 'uint256' }, + ], + name: 'approve', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'asset', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'account', type: 'address' }], + name: 'balanceOf', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'shares', type: 'uint256' }], + name: 'convertToAssets', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'assets', type: 'uint256' }], + name: 'convertToShares', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'decimals', + outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'assets', type: 'uint256' }, + { internalType: 'address', name: 'receiver', type: 'address' }, + ], + name: 'deposit', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'amount', type: 'uint256' }], + name: 'deposit', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'maxDeposit', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'maxMint', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'owner', type: 'address' }], + name: 'maxRedeem', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'owner', type: 'address' }], + name: 'maxWithdraw', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'shares', type: 'uint256' }, + { internalType: 'address', name: 'receiver', type: 'address' }, + ], + name: 'mint', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'name', + outputs: [{ internalType: 'string', name: '', type: 'string' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'operator', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'operatorFee', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { inputs: [], name: 'pause', outputs: [], stateMutability: 'nonpayable', type: 'function' }, + { + inputs: [{ internalType: 'uint256', name: 'assets', type: 'uint256' }], + name: 'previewDeposit', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'shares', type: 'uint256' }], + name: 'previewMint', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'shares', type: 'uint256' }], + name: 'previewRedeem', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'assets', type: 'uint256' }], + name: 'previewWithdraw', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'shares', type: 'uint256' }, + { internalType: 'address', name: 'receiver', type: 'address' }, + { internalType: 'address', name: 'owner', type: 'address' }, + ], + name: 'redeem', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'safeAccount', + outputs: [{ internalType: 'contract GnosisSafeProxy', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'symbol', + outputs: [{ internalType: 'string', name: '', type: 'string' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalAssets', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalSupply', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'uint256', name: 'value', type: 'uint256' }, + ], + name: 'transfer', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'from', type: 'address' }, + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'uint256', name: 'value', type: 'uint256' }, + ], + name: 'transferFrom', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { inputs: [], name: 'unpause', outputs: [], stateMutability: 'nonpayable', type: 'function' }, + { + inputs: [{ internalType: 'uint256', name: 'amount', type: 'uint256' }], + name: 'withdraw', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'assets', type: 'uint256' }, + { internalType: 'address', name: 'receiver', type: 'address' }, + { internalType: 'address', name: 'owner', type: 'address' }, + ], + name: 'withdraw', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'nonpayable', + type: 'function', + }, +]; From eb175d144aba141c7c4daa783906c087b0856833 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Tue, 17 Oct 2023 22:47:16 +0300 Subject: [PATCH 62/68] add axios --- frontend/package.json | 5 +- frontend/src/components/table/Table.tsx | 7 +- frontend/yarn.lock | 93 ++++++++++++++++++++----- 3 files changed, 82 insertions(+), 23 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index fc23b68..7298487 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -20,14 +20,15 @@ "dependencies": { "@rainbow-me/rainbowkit": "^1.1.1", "@vitejs/plugin-react-refresh": "^1.3.6", + "axios": "^1.5.1", + "classnames": "^2.3.2", "localforage": "^1.10.0", "match-sorter": "^6.3.1", - "classnames": "^2.3.2", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.16.0", - "sort-by": "^1.2.0", "react-transition-group": "^4.4.5", + "sort-by": "^1.2.0", "viem": "^1.15.4", "wagmi": "^1.4.3" }, diff --git a/frontend/src/components/table/Table.tsx b/frontend/src/components/table/Table.tsx index 89d269c..b63bade 100644 --- a/frontend/src/components/table/Table.tsx +++ b/frontend/src/components/table/Table.tsx @@ -1,6 +1,7 @@ import { TablePropsI } from './TableProps.ts'; import styles from './Table.module.scss'; import { FC } from 'react'; +// import axios from 'axios'; // import { DateCell } from 'Components'; // import { TPool } from 'src/pages/index.ts'; @@ -18,11 +19,11 @@ export const Table: FC = ({ tableData }) => { {tableData.map((pool) => ( - - {/* + {/* */} - + diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 02111ea..94829dd 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -593,9 +593,9 @@ tslib "^2.6.0" "@rainbow-me/rainbowkit@^1.1.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@rainbow-me/rainbowkit/-/rainbowkit-1.1.1.tgz#be2b4ed95943d9d0ec1af4bb780bbb2663203d9e" - integrity sha512-6NGeH2SpJYolstt9RXU6XwmvyL29XKc6OYZtctvdM83F/WNkRX+ywwBrfNNES9BAS6QNdOnPa7nIu+ghtFBgnQ== + version "1.1.2" + resolved "https://registry.yarnpkg.com/@rainbow-me/rainbowkit/-/rainbowkit-1.1.2.tgz#733a2c864dd7dd3625ed54440a1ccb18b0636c72" + integrity sha512-yWxKDfHL4xDZJW34APGkmO2SkxjHwrEeAfvx6+137hWLttQwHcalG9nj4II8roYV2/2XJPmQsbEs7TM0rC0fOg== dependencies: "@vanilla-extract/css" "1.9.1" "@vanilla-extract/dynamic" "2.0.2" @@ -936,9 +936,9 @@ integrity sha512-xPSg0jm4mqgEkNhowKgZFBNtwoEwF6gJ4Dhww+GFpm3IgtNseHQZ5IqdNwnquZEoANxyDAKDRAdVo4Z72VvD/g== "@types/node@*": - version "20.8.5" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.8.5.tgz#13352ae1f80032171616910e8aba2e3e52e57d96" - integrity sha512-SPlobFgbidfIeOYlzXiEjSYeIJiOCthv+9tSQVpvk4PAdIIc+2SmjNVzWXk9t0Y7dl73Zdf+OgXKHX9XtkqUpw== + version "20.8.6" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.8.6.tgz#0dbd4ebcc82ad0128df05d0e6f57e05359ee47fa" + integrity sha512-eWO4K2Ji70QzKUqRy6oyJWUeB7+g2cRagT3T/nxYibYcT4y2BDL8lqolRXjTHmkZCdJfIPaY73KbJAZmcryxTQ== dependencies: undici-types "~5.25.1" @@ -1695,6 +1695,11 @@ async-mutex@^0.2.6: dependencies: tslib "^2.0.0" +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== + atomic-sleep@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/atomic-sleep/-/atomic-sleep-1.0.0.tgz#eb85b77a601fc932cfe432c5acd364a9e2c9075b" @@ -1705,6 +1710,15 @@ available-typed-arrays@^1.0.5: resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7" integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw== +axios@^1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.5.1.tgz#11fbaa11fc35f431193a9564109c88c1f27b585f" + integrity sha512-Q28iYCWzNHjAm+yEAot5QaAMxhMghWLFVf7rRdwhUI+c2jix2DUXjAHXVi+s1ibs3mjPO/cCgbA++3BjD0vP/A== + dependencies: + follow-redirects "^1.15.0" + form-data "^4.0.0" + proxy-from-env "^1.1.0" + balanced-match@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" @@ -1818,9 +1832,9 @@ buffer@6.0.3, buffer@^6.0.3, buffer@~6.0.3: ieee754 "^1.2.1" bufferutil@^4.0.1: - version "4.0.7" - resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.7.tgz#60c0d19ba2c992dd8273d3f73772ffc894c153ad" - integrity sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw== + version "4.0.8" + resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.8.tgz#1de6a71092d65d7766c4d8a522b261a6e787e8ea" + integrity sha512-4T53u4PdgsXqKaIctwF8ifXlRTTmEPJ8iEPWFdGZvcf7sbwYo6FKFEX9eNNAnzFZ7EzJAQ3CJeOtCRA4rDp7Pw== dependencies: node-gyp-build "^4.3.0" @@ -1850,9 +1864,9 @@ camelcase@^5.0.0: integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== caniuse-lite@^1.0.30001541: - version "1.0.30001547" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001547.tgz#d4f92efc488aab3c7f92c738d3977c2a3180472b" - integrity sha512-W7CrtIModMAxobGhz8iXmDfuJiiKg1WADMO/9x7/CLNin5cpSbuBjooyoIUVB5eyCc36QuTVlkVa1iB2S5+/eA== + version "1.0.30001549" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001549.tgz#7d1a3dce7ea78c06ed72c32c2743ea364b3615aa" + integrity sha512-qRp48dPYSCYaP+KurZLhDYdVE+yEyht/3NlmcJgVQ2VMGt6JL36ndQ/7rgspdZsJuxDPFIo/OzBT2+GmIJ53BA== chalk@5.3.0: version "5.3.0" @@ -1970,6 +1984,13 @@ colorette@^2.0.20: resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a" integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w== +combined-stream@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== + dependencies: + delayed-stream "~1.0.0" + commander@11.0.0: version "11.0.0" resolved "https://registry.yarnpkg.com/commander/-/commander-11.0.0.tgz#43e19c25dbedc8256203538e8d7e9346877a6f67" @@ -2093,6 +2114,11 @@ delay@^5.0.0: resolved "https://registry.yarnpkg.com/delay/-/delay-5.0.0.tgz#137045ef1b96e5071060dd5be60bf9334436bd1d" integrity sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw== +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== + detect-browser@5.3.0, detect-browser@^5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/detect-browser/-/detect-browser-5.3.0.tgz#9705ef2bddf46072d0f7265a1fe300e36fe7ceca" @@ -2151,9 +2177,9 @@ eastasianwidth@^0.2.0: integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== electron-to-chromium@^1.4.535: - version "1.4.553" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.553.tgz#56fd65afddbd713c52f0e95d0223b3368f520865" - integrity sha512-HiRdtyKS2+VhiXvjhMvvxiMC33FJJqTA5EB2YHgFZW6v7HkK4Q9Ahv2V7O2ZPgAjw+MyCJVMQvigj13H8t+wvA== + version "1.4.554" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.554.tgz#04e09c2ee31dc0f1546174033809b54cc372740b" + integrity sha512-Q0umzPJjfBrrj8unkONTgbKQXzXRrH7sVV7D9ea2yBV3Oaogz991yhbpfvo2LMNkJItmruXTEzVpP9cp7vaIiQ== emoji-regex@^8.0.0: version "8.0.0" @@ -2549,6 +2575,11 @@ flatted@^3.2.9: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.9.tgz#7eb4c67ca1ba34232ca9d2d93e9886e611ad7daf" integrity sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ== +follow-redirects@^1.15.0: + version "1.15.3" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a" + integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q== + for-each@^0.3.3: version "0.3.3" resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e" @@ -2556,6 +2587,15 @@ for-each@^0.3.3: dependencies: is-callable "^1.1.3" +form-data@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" + integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" @@ -3210,6 +3250,18 @@ micromatch@4.0.5, micromatch@^4.0.4: braces "^3.0.2" picomatch "^2.3.1" +mime-db@1.52.0: + version "1.52.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== + +mime-types@^2.1.12: + version "2.1.35" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== + dependencies: + mime-db "1.52.0" + mimic-fn@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" @@ -3316,9 +3368,9 @@ object-assign@^4.1.1: integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== object-inspect@^1.9.0: - version "1.12.3" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.3.tgz#ba62dffd67ee256c8c086dfae69e016cd1f198b9" - integrity sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g== + version "1.13.0" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.0.tgz#42695d3879e1cd5bda6df5062164d80c996e23e2" + integrity sha512-HQ4J+ic8hKrgIt3mqk6cVOVrW2ozL4KdvHlqpBv9vDYWx9ysAgENAdvy4FoGF+KFdhR7nQTNm5J0ctAeOwn+3g== object-path@0.6.0: version "0.6.0" @@ -3586,6 +3638,11 @@ proxy-compare@2.5.1: resolved "https://registry.yarnpkg.com/proxy-compare/-/proxy-compare-2.5.1.tgz#17818e33d1653fbac8c2ec31406bce8a2966f600" integrity sha512-oyfc0Tx87Cpwva5ZXezSp5V9vht1c7dZBhvuV/y3ctkgMVUmiAGDVeeB0dKhGSyT0v1ZTEQYpe/RXlBVBNuCLA== +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + punycode@^2.1.0: version "2.3.0" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f" From c24cb6cb561794411b392d2b1a6ea5457e892eab Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Tue, 17 Oct 2023 22:47:43 +0300 Subject: [PATCH 63/68] new abi #9 --- frontend/src/data/abi.ts | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/frontend/src/data/abi.ts b/frontend/src/data/abi.ts index 03465b2..243d2a0 100644 --- a/frontend/src/data/abi.ts +++ b/frontend/src/data/abi.ts @@ -6,8 +6,6 @@ export const abi = [ { internalType: 'uint256', name: 'operatorFee_', type: 'uint256' }, { internalType: 'string', name: 'name_', type: 'string' }, { internalType: 'string', name: 'symbol_', type: 'string' }, - { internalType: 'address', name: 'safeProxyFactory', type: 'address' }, - { internalType: 'address', name: 'safeLogicSingleton', type: 'address' }, ], stateMutability: 'nonpayable', type: 'constructor', @@ -124,19 +122,6 @@ export const abi = [ name: 'Deposit', type: 'event', }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'address', name: 'vault', type: 'address' }, - { indexed: true, internalType: 'address', name: 'anchorCurrency', type: 'address' }, - { indexed: true, internalType: 'address', name: 'operator', type: 'address' }, - { indexed: false, internalType: 'uint256', name: 'operatorFee', type: 'uint256' }, - { indexed: false, internalType: 'string', name: 'name', type: 'string' }, - { indexed: false, internalType: 'string', name: 'symbol', type: 'string' }, - ], - name: 'ProfitPalsVaultCreated', - type: 'event', - }, { anonymous: false, inputs: [ @@ -176,6 +161,20 @@ export const abi = [ stateMutability: 'view', type: 'function', }, + { + inputs: [], + name: 'allowedTokensCount', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'allowedTokensList', + outputs: [{ internalType: 'contract IERC20[]', name: '', type: 'address[]' }], + stateMutability: 'view', + type: 'function', + }, { inputs: [], name: 'anchorCurrency', @@ -344,13 +343,6 @@ export const abi = [ stateMutability: 'nonpayable', type: 'function', }, - { - inputs: [], - name: 'safeAccount', - outputs: [{ internalType: 'contract GnosisSafeProxy', name: '', type: 'address' }], - stateMutability: 'view', - type: 'function', - }, { inputs: [], name: 'symbol', From 2f79ae5c1a9c00038ca53ed5a743bdd93cff7c04 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Tue, 17 Oct 2023 22:48:01 +0300 Subject: [PATCH 64/68] add contract address #9 --- frontend/src/components/table/TableProps.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/table/TableProps.ts b/frontend/src/components/table/TableProps.ts index 22b6f46..636c9ed 100644 --- a/frontend/src/components/table/TableProps.ts +++ b/frontend/src/components/table/TableProps.ts @@ -1,7 +1,8 @@ export interface TablePropsI { tableData: { + address: string; operatorFee: number; anchorCurrency: string; - allowedTokens: string; + allowedTokens: string[]; }[]; } From 9984dd7f78744109b616ea78f2ffa8eab2ff80df Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Tue, 17 Oct 2023 22:48:54 +0300 Subject: [PATCH 65/68] hardcode cotract data #9 --- frontend/src/pages/PoolsPage/PoolsPage.tsx | 106 +++++++++++++-------- 1 file changed, 64 insertions(+), 42 deletions(-) diff --git a/frontend/src/pages/PoolsPage/PoolsPage.tsx b/frontend/src/pages/PoolsPage/PoolsPage.tsx index 5d9c647..90dca61 100644 --- a/frontend/src/pages/PoolsPage/PoolsPage.tsx +++ b/frontend/src/pages/PoolsPage/PoolsPage.tsx @@ -1,58 +1,80 @@ import { PoolsPagePropsI } from './PoolsPageProps.ts'; import styles from './PoolsPage.module.scss'; -import { FC, useEffect, useState } from 'react'; +import { FC } from 'react'; import { Header, Table } from 'Components'; -import { useContractRead } from 'wagmi'; -import { abi } from '../../data/abi.ts'; -import { publicClientViem } from '../../wagmiConfig.ts'; +// import { abi } from '../../data/abi.ts'; +// import { publicClientViem } from '../../wagmiConfig.ts'; +// import { useContractRead } from 'wagmi'; export type TPool = { - allowedTokens: string; + address: string; + allowedTokens: string[]; anchorCurrency: string; operatorFee: number; }; + export const PoolsPage: FC = ({ poolsType }) => { - const contract = '0xCa9c4a7949e6f9dc8343b565E34C493E4970c1AB'; + const tableData: TPool[] = [ + { + address: '0', + allowedTokens: ['12312', '1231231', 'asdas'], + anchorCurrency: 'sdfsdfsd', + operatorFee: 10, + }, + { + address: '1', + allowedTokens: ['12312', '1231231', 'asdas'], + anchorCurrency: 'sdfsdfsd', + operatorFee: 10, + }, + ]; + + //todo: improve the acquisition of contract data + // const contract = '0x606279b2c388ed37d0e5e52ea0d75eb2b539a57e'; + // const contractsList = [contract]; + + // useEffect(() => { + // // eslint-disable-next-line react-hooks/exhaustive-deps + // }, []); - useEffect(() => { - getPools(); - }, []); + // const abi2 = [ + // 'function allowedTokensList() view returns (IERC20[] memory)', + // 'function anchorCurrency() view returns (IERC20)', + // 'function operatorFee() view returns (uint256);', + // ]; + // const wagmiContract = { + // address: contract, + // abi: abi2, + // } as const; - const wagmiContract = { - address: contract, - abi: abi, - } as const; + // const [tableData, setTableData] = useState(null); - const [tableData, setTableData] = useState(null); + // const getAllowedTokens = async () => { + // const { data } = useContractRead({ + // address: contract, + // abi: abi2, + // functionName: 'allowedTokensList', + // }); + // // return result[0].address; + // }; - const getPools = async () => { - const results = await publicClientViem.multicall({ - contracts: [ - { - ...wagmiContract, - functionName: 'allowedTokens', - args: [0], - }, - { - ...wagmiContract, - functionName: 'anchorCurrency', - }, - { - ...wagmiContract, - functionName: 'operatorFee', - }, - ], - }); - const pool = { - allowedTokens: results[0].result, - anchorCurrency: results[1].result, - operatorFee: results[2].result, - }; - setTableData([pool]); - console.log(pool); + // const getAnchorCurrency = async () => { + // const result = contractsList.map((contract: string) => ({ + // address: contract, + // abi: abi2, + // functionName: 'anchorCurrency', + // })); + // return result[0].address; + // }; - // return [pool]; - }; + // const getOperatorFee = async () => { + // const result = contractsList.map((contract: string) => ({ + // address: contract, + // abi: abi2, + // functionName: 'operatorFee', + // })); + // }; + // const getPools = async () => {}; return ( <> @@ -60,7 +82,7 @@ export const PoolsPage: FC = ({ poolsType }) => {

{poolsType}

- {tableData &&
DateDateOperator FeeTotalProfitanchorCurrencyallowedTokens
+ {tableData.map((pool) => ( +
- {pool.operatorFee}{pool.total}{pool.profit}{String(pool.operatorFee)}{String(pool.anchorCurrency)}{String(pool.allowedTokens)}
+
todo {String(pool.operatorFee)}{String(pool.operatorFee) + '%'} {String(pool.anchorCurrency)} {String(pool.allowedTokens)}
} + {tableData &&
} From c8f333216f04cd820f270a4df265d0398cea0461 Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Tue, 17 Oct 2023 23:03:34 +0300 Subject: [PATCH 66/68] restore changes #9 --- FLOW.md | 51 ------------- README.md | 6 -- lib/safe-global | 1 - remappings.txt | 2 - script/Counter.s.sol | 12 +++ script/CreateSafeAccount.s.sol | 44 ----------- script/ProfitPalsVaultDeploy.s.sol | 37 --------- src/Constants.sol | 17 ----- src/ProfitPalsVault.sol | 62 --------------- src/ProfitPalsVaultFactory.sol | 77 ------------------- src/UniswapOnlyGuard.sol | 44 ----------- src/interfaces/IProfitPalsVault.sol | 25 ------- src/interfaces/IProfitPalsVaultFactory.sol | 19 ----- test/Counter.t.sol | 24 ++++++ test/DepositAnchorCurrency.t.sol | 45 ----------- test/SetupSafeGuard.t.sol | 87 ---------------------- 16 files changed, 36 insertions(+), 517 deletions(-) delete mode 100644 FLOW.md delete mode 160000 lib/safe-global delete mode 100644 remappings.txt create mode 100644 script/Counter.s.sol delete mode 100644 script/CreateSafeAccount.s.sol delete mode 100644 script/ProfitPalsVaultDeploy.s.sol delete mode 100644 src/Constants.sol delete mode 100644 src/ProfitPalsVault.sol delete mode 100644 src/ProfitPalsVaultFactory.sol delete mode 100644 src/UniswapOnlyGuard.sol delete mode 100644 src/interfaces/IProfitPalsVault.sol delete mode 100644 src/interfaces/IProfitPalsVaultFactory.sol create mode 100644 test/Counter.t.sol delete mode 100644 test/DepositAnchorCurrency.t.sol delete mode 100644 test/SetupSafeGuard.t.sol diff --git a/FLOW.md b/FLOW.md deleted file mode 100644 index ac4dfe2..0000000 --- a/FLOW.md +++ /dev/null @@ -1,51 +0,0 @@ -```plantuml -@startuml -actor Operator -actor InvestorA -actor InvestorB - - -entity "Pool_1" as p1 -entity "SafeWallet\nSmartAccount" as SA -participant Uniswap -participant "ProfitPals\nFactory" as factory - - -group Operator Creates Pool -Operator -> factory : createPool(anchorCurrency: USDC, tokenWhitelist:[ETH, AAVE, 1Inch], fee: 0.1%) -factory -> p1 : create -p1 -> SA : create -p1 -> SA : setup SafeGuard filters -Operator <-- factory: p1 ( you created Pool 1 ) -Operator <-- p1: SA ( you can manage SmartAccount ) -end - -group Investors Deposit -InvestorA -> p1: deposit(1M USDC) -p1 -> SA: 1M USDC -InvestorA <-- SA: mint(1M shares) - -InvestorB -> SA: deposit(2M USDC) -p1 -> SA: 2M USDC -InvestorB <-- SA: mint(2M shares) -end - -group Operator swaps tokens and provides liquidity to Uniswap -Operator -> SA: connect(pool_1) - -Operator -> SA: swap(USDC, ETH, 500k) -SA -> Uniswap: swap(USDC, ETH, 500k) -Operator -> SA: addLiquidity(USDC/ETH) -SA <-- Uniswap: UniV3 position NFT -end - -=== SmartAccount of Pool 1 accumulates profits === - -group InvestorA withdraws -InvestorA -> p1: withdraw(1M shares) -p1 -> SA: transferFrom(SA, InvestorA, 1.15M USDC) -InvestorA <-- p1: burn(1M shares) -InvestorA <-- SA: 1.15M USDC -end -@enduml -``` \ No newline at end of file diff --git a/README.md b/README.md index eead6c6..c469c01 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,6 @@ Our ETHOnline2023 focus: integration with Uniswap and harnessing Safe smart wall Monorepo setup: smart contracts in root, frontend in its folder. We integrate Foundry/Forge with GitHub Actions for streamlined CI/CD. -## Test in Polygon Mainnet fork -```shell -source .env -forge test --fork-url $POLYGON_RPC_URL -``` - ## Links - **ChainHackers**: [https://chainhackers.xyz/](https://chainhackers.xyz/) - **ProfitPals**: [https://profitpals.chainhackers.xyz/](https://profitpals.chainhackers.xyz/) diff --git a/lib/safe-global b/lib/safe-global deleted file mode 160000 index 75da71d..0000000 --- a/lib/safe-global +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 75da71dfc3859664807e81e48ebb0508a8f54737 diff --git a/remappings.txt b/remappings.txt deleted file mode 100644 index 2454051..0000000 --- a/remappings.txt +++ /dev/null @@ -1,2 +0,0 @@ -@openzeppelin=lib/openzeppelin/contracts -@safe-contracts=lib/safe-contracts/contracts \ No newline at end of file diff --git a/script/Counter.s.sol b/script/Counter.s.sol new file mode 100644 index 0000000..1a47b40 --- /dev/null +++ b/script/Counter.s.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import {Script, console2} from "forge-std/Script.sol"; + +contract CounterScript is Script { + function setUp() public {} + + function run() public { + vm.broadcast(); + } +} diff --git a/script/CreateSafeAccount.s.sol b/script/CreateSafeAccount.s.sol deleted file mode 100644 index ca2d42d..0000000 --- a/script/CreateSafeAccount.s.sol +++ /dev/null @@ -1,44 +0,0 @@ -pragma solidity ^0.8.13; - -import {Script, console2} from "forge-std/Script.sol"; -import {GnosisSafe} from "safe-contracts/GnosisSafe.sol"; -import {GnosisSafeL2} from "safe-contracts/GnosisSafeL2.sol"; -import {GnosisSafeProxyFactory} from "safe-contracts/proxies/GnosisSafeProxyFactory.sol"; - -address constant SINGLETON_ADDRESS = 0x3E5c63644E683549055b9Be8653de26E0B4CD36E; -address constant SAFE_PROXY_FACTORY = 0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2; -address constant OWNER_ADDRESS = 0x01e36D100DbA45e62924307adf7c42c9c60d6214; - -contract CreateSafeAccountScript is Script { - function setUp() public {} - - function run() public { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - address deployerAddr = vm.addr(deployerPrivateKey); - - address[] memory owners = new address[](1); - owners[0] = OWNER_ADDRESS; - - - vm.startBroadcast(deployerPrivateKey); - - bytes memory data = abi.encodeCall( - GnosisSafe.setup, - (owners, - 1, - address(0), - "", - address(0), - address(0), - 0, - payable(0)) - ); - GnosisSafeProxyFactory(SAFE_PROXY_FACTORY).createProxyWithNonce( - SINGLETON_ADDRESS, - data, - 6661491 - ); - - vm.stopBroadcast(); - } -} \ No newline at end of file diff --git a/script/ProfitPalsVaultDeploy.s.sol b/script/ProfitPalsVaultDeploy.s.sol deleted file mode 100644 index 0c687fe..0000000 --- a/script/ProfitPalsVaultDeploy.s.sol +++ /dev/null @@ -1,37 +0,0 @@ -pragma solidity ^0.8.0; - -import {Script, console2} from "forge-std/Script.sol"; - -import {ProfitPalsVault} from "../src/ProfitPalsVault.sol"; -import {IERC20} from "@openzeppelin/token/ERC20/IERC20.sol"; -import "../src/ProfitPalsVaultFactory.sol"; - -contract ProfitPalsVaultDeploy is Script { - IERC20[] public allowedTokens; - - function run() public { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - address deployerAddr = vm.addr(deployerPrivateKey); - - - allowedTokens.push(IERC20(USDC_POLYGON)); - allowedTokens.push(IERC20(WBTC_POLYGON)); - - vm.startBroadcast(deployerPrivateKey); - - ProfitPalsVaultFactory factory = new ProfitPalsVaultFactory( - SAFE_LOGIC_SINGLETON_POLYGON, - SAFE_PROXY_FACTORY_130_POLYGON - ); - - factory.createVault( - IERC20(USDC_POLYGON), - allowedTokens, - 100, - "PP_USD_BTC_VAULT", - "PPV" - ); - - vm.stopBroadcast(); - } -} \ No newline at end of file diff --git a/src/Constants.sol b/src/Constants.sol deleted file mode 100644 index bce5b4c..0000000 --- a/src/Constants.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.13; - -uint256 constant SHARE_DECIMALS = 6; -address constant SAFE_PROXY_FACTORY_130_POLYGON = 0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2; -address constant SAFE_LOGIC_SINGLETON_POLYGON = 0x3E5c63644E683549055b9Be8653de26E0B4CD36E; -address constant USDC_POLYGON = 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174; -address constant WBTC_POLYGON = 0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6; - -address constant UNISWAP_PERMIT2_POLYGON = 0x000000000022D473030F116dDEE9F6B43aC78BA3; - -//Goerli -address constant GOERLI_SAFE_PROXY_FACTORY = 0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2; -address constant GOERLI_SAFE_LOGIC_SINGLETON = 0x3E5c63644E683549055b9Be8653de26E0B4CD36E; -address constant GOERLI_USDC_ADDRESS = 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174; -address constant GOERLI_WBTC_ADDRESS = 0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6; -address constant GOERLI_WETH_ADDRESS = 0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619; diff --git a/src/ProfitPalsVault.sol b/src/ProfitPalsVault.sol deleted file mode 100644 index 953224d..0000000 --- a/src/ProfitPalsVault.sol +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import "./interfaces/IProfitPalsVault.sol"; -import "@openzeppelin/token/ERC20/extensions/ERC4626.sol"; -import "@safe-contracts/GnosisSafe.sol"; -import "@safe-contracts/proxies/GnosisSafeProxyFactory.sol"; - -/** - * @title ProfitPalsVault - * @dev This contract acts as the primary vault for the ProfitPals project, holding and managing all assets. - * The main asset, or anchor currency, that is managed within this vault can be any ERC20 token. - */ -contract ProfitPalsVault is IProfitPalsVault, ERC4626 { - IERC20 public immutable anchorCurrency; - address public immutable operator; - uint256 public immutable operatorFee; - IERC20[] public allowedTokens; - /** - * @param anchorCurrency_ - The main or anchor ERC20 token that the vault will manage. - * @param name_ - Name of the shares token - * @param symbol_ - Symbol of the shares token - */ - constructor( - IERC20 anchorCurrency_, - IERC20[] memory tokens, - uint256 operatorFee_, - string memory name_, - string memory symbol_ - ) - ERC4626(anchorCurrency_) ERC20(name_, symbol_){ - operator = tx.origin; //TODO think about this - anchorCurrency = anchorCurrency_; - operatorFee = operatorFee_; - allowedTokens = tokens; - } - - function totalAssets() public view override(IERC4626, ERC4626) returns (uint256) { - //TODO add overall Uniswap positions here - return anchorCurrency.balanceOf(address(this)); - } - - function deposit(uint256 amount) external { - - } - - function withdraw(uint256 amount) external { - - } - - function pause() external { - - } - - function unpause() external { - - } - - function allowedTokensCount() external view override returns (uint256) { - return allowedTokens.length; - } -} diff --git a/src/ProfitPalsVaultFactory.sol b/src/ProfitPalsVaultFactory.sol deleted file mode 100644 index 0accea4..0000000 --- a/src/ProfitPalsVaultFactory.sol +++ /dev/null @@ -1,77 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import "./interfaces/IProfitPalsVaultFactory.sol"; -import "./ProfitPalsVault.sol"; -import "./Constants.sol"; -import {GnosisSafeProxyFactory} from "@safe-contracts/proxies/GnosisSafeProxyFactory.sol"; -import {GnosisSafeProxy} from "@safe-contracts/proxies/GnosisSafeProxy.sol"; -import "./UniswapOnlyGuard.sol"; -import "@safe-contracts/GnosisSafeL2.sol"; -import "@safe-contracts/examples/guards/ReentrancyTransactionGuard.sol"; - -contract ProfitPalsVaultFactory is IProfitPalsVaultFactory { - address public immutable safeLogicSingleton; - address public immutable safeProxyFactory; - - constructor(address safeLogicSingleton_, address safeProxyFactory_){ - safeLogicSingleton = safeLogicSingleton_; - safeProxyFactory = safeProxyFactory_; - } - - /** - @dev create a new ProfitPalsVault - @dev create a new Safe account with the ProfitPalsVault as the owner - @dev create a new Guard with allowlist of tokens, and set it as the guard for the safe - @dev give the operator the ability to manage the safe - @param anchorCurrency - The main or anchor ERC20 token that the vault will manage. - @param tokens - The list of tokens that the vault will allow to be deposited. - @param operatorFee - percentage of profit that will be accumulated as Operator's share of the vault - @param name - Name of the shares token - @param symbol - Symbol of the shares token - */ - function createVault( - IERC20 anchorCurrency, - IERC20[] calldata tokens, - uint256 operatorFee, - string memory name, - string memory symbol - ) external returns (IProfitPalsVault) { - ProfitPalsVault vault = new ProfitPalsVault( - anchorCurrency, - tokens, - operatorFee, - name, - symbol - ); - - - address[] memory owners = new address[](2); - owners[0] = address(vault); - owners[1] = tx.origin; //TODO think about this - - - // UniswapOnlyGuard guard = new UniswapOnlyGuard(UNISWAP_PERMIT2_POLYGON, tokens); - // ReentrancyTransactionGuard guard = new ReentrancyTransactionGuard(); - - bytes memory safeInitializerData = abi.encodeCall( - GnosisSafe.setup, - (owners, - 1, - address(0), //TODO predict address of proxy to send to self - "", //abi.encodeCall(GnosisSafe.setGuard,(guard)), - address(0), - address(0), - 0, - payable(0)) - ); - GnosisSafeProxy proxy = GnosisSafeProxyFactory(SAFE_PROXY_FACTORY_130_POLYGON).createProxyWithNonce( - SAFE_LOGIC_SINGLETON_POLYGON, - safeInitializerData, - 983123411112131982431234 //owners[0] is always a new contract, don't need to worry about nonce - ); - GnosisSafeL2 safe = GnosisSafeL2(payable(address(proxy))); - - return vault; - } -} diff --git a/src/UniswapOnlyGuard.sol b/src/UniswapOnlyGuard.sol deleted file mode 100644 index 49ae213..0000000 --- a/src/UniswapOnlyGuard.sol +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import "@safe-contracts/base/GuardManager.sol"; -import "@openzeppelin/token/ERC20/IERC20.sol"; -import "./Constants.sol"; - -contract UniswapOnlyGuard is Guard { - address public immutable permit2; - IERC20[] public allowedTokens; - IERC20 usdc = IERC20(USDC_POLYGON); - - constructor(address permit2_, IERC20[] memory allowedTokens_){ - permit2 = permit2_; - allowedTokens = allowedTokens_; - } - - // TODO not sure, experimenting, consider removing this - // solhint-disable-next-line payable-fallback - fallback() external { - // We don't revert on fallback to avoid issues in case of a Safe upgrade - // E.g. The expected check method might change and then the Safe would be locked. - } - function checkTransaction( - address to, - uint256 value, - bytes memory data, - Enum.Operation operation, - uint256 safeTxGas, - uint256 baseGas, - uint256 gasPrice, - address gasToken, - address payable refundReceiver, - bytes memory signatures, - address msgSender - ) external override { -// require(to == address(usdc), "Only approvals to Uniswap Permit2 allowed"); //TODO iterate over allowed tokens -// require(to == permit2, "Only approvals to Uniswap Permit2 allowed"); - } - - function checkAfterExecution(bytes32 txHash, bool success) external override { - // Nothing to do - } -} diff --git a/src/interfaces/IProfitPalsVault.sol b/src/interfaces/IProfitPalsVault.sol deleted file mode 100644 index c906a24..0000000 --- a/src/interfaces/IProfitPalsVault.sol +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import "@openzeppelin/token/ERC20/IERC20.sol"; -import "@openzeppelin/interfaces/IERC4626.sol"; - -interface IProfitPalsVault is IERC4626 { - function operator() external view returns (address); - - function operatorFee() external view returns (uint256); - - function anchorCurrency() external view returns (IERC20); - - function allowedTokens(uint256 index) external view returns (IERC20); - - function allowedTokensCount() external view returns (uint256); - - function deposit(uint256 amount) external; - - function withdraw(uint256 amount) external; - - function pause() external; - - function unpause() external; -} diff --git a/src/interfaces/IProfitPalsVaultFactory.sol b/src/interfaces/IProfitPalsVaultFactory.sol deleted file mode 100644 index 9d2d619..0000000 --- a/src/interfaces/IProfitPalsVaultFactory.sol +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import "@openzeppelin/token/ERC20/IERC20.sol"; -import "./IProfitPalsVault.sol"; - -interface IProfitPalsVaultFactory { - function createVault( - IERC20 anchorCurrency, - IERC20[] calldata tokens, - uint256 operatorFee, - string memory name_, - string memory symbol_ - ) external returns (IProfitPalsVault); - - function safeLogicSingleton() external view returns (address); - - function safeProxyFactory() external view returns (address); -} diff --git a/test/Counter.t.sol b/test/Counter.t.sol new file mode 100644 index 0000000..e9b9e6a --- /dev/null +++ b/test/Counter.t.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import {Test, console2} from "forge-std/Test.sol"; +import {Counter} from "../src/Counter.sol"; + +contract CounterTest is Test { + Counter public counter; + + function setUp() public { + counter = new Counter(); + counter.setNumber(0); + } + + function test_Increment() public { + counter.increment(); + assertEq(counter.number(), 1); + } + + function testFuzz_SetNumber(uint256 x) public { + counter.setNumber(x); + assertEq(counter.number(), x); + } +} diff --git a/test/DepositAnchorCurrency.t.sol b/test/DepositAnchorCurrency.t.sol deleted file mode 100644 index ec61c43..0000000 --- a/test/DepositAnchorCurrency.t.sol +++ /dev/null @@ -1,45 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.13; - -import {Test, console2} from "forge-std/Test.sol"; -import {ProfitPalsVault} from "../src/ProfitPalsVault.sol"; -import "@openzeppelin/token/ERC20/IERC20.sol"; -import "forge-std/Test.sol"; -import "../src/Constants.sol"; -import {Script, console2} from "forge-std/Script.sol"; - -contract DepositAnchorCurrencyTest is Test { - - - address USDC_BIG_HOLDER = 0xF977814e90dA44bFA03b6295A0616a897441aceC; - - IERC20 usdc = IERC20(USDC_POLYGON); - IERC20 wbtc = IERC20(WBTC_POLYGON); - - IERC20[] tokens = new IERC20[](1); - ProfitPalsVault public profitPalsVault; - - function setUp() public { - tokens.push(usdc); - - profitPalsVault = new ProfitPalsVault( - usdc, - tokens, - 2000, - - "testUSDCVault", "tUSDCv" - ); - - vm.startPrank(USDC_BIG_HOLDER); - usdc.transfer(address(this), 1000 * 10 ** 6); - vm.stopPrank(); - } - - function test_DepositUsdAndGotShares() public { - assertEq(profitPalsVault.balanceOf(address(this)), 0); - usdc.approve(address(profitPalsVault), 100 * 10 ** 6); - profitPalsVault.deposit(100 * 10 ** 6, address(this)); - assertEq(usdc.balanceOf(address(profitPalsVault)), 100 * 10 ** 6); - assertEq(profitPalsVault.balanceOf(address(this)), 100 * 10 ** SHARE_DECIMALS); - } -} diff --git a/test/SetupSafeGuard.t.sol b/test/SetupSafeGuard.t.sol deleted file mode 100644 index 328d060..0000000 --- a/test/SetupSafeGuard.t.sol +++ /dev/null @@ -1,87 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {Test, console2} from "forge-std/Test.sol"; -import "@openzeppelin/token/ERC20/IERC20.sol"; -import {GnosisSafe} from "@safe-contracts/GnosisSafe.sol"; -import {GnosisSafeL2} from "@safe-contracts/GnosisSafeL2.sol"; -import {GnosisSafeProxy} from "@safe-contracts/proxies/GnosisSafeProxy.sol"; -import {GnosisSafeProxyFactory} from "@safe-contracts/proxies/GnosisSafeProxyFactory.sol"; -import {Enum} from "@safe-contracts/common/Enum.sol"; -import {GuardManager} from "@safe-contracts/base/GuardManager.sol"; -import "../src/Constants.sol"; -import {UniswapOnlyGuard} from "../src/UniswapOnlyGuard.sol"; - -contract SetupSafeGuard is Test { - - address constant SINGLETON_ADDRESS = 0x3E5c63644E683549055b9Be8653de26E0B4CD36E; - address constant SAFE_PROXY_FACTORY = 0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2; - address USDC_BIG_HOLDER = 0xF977814e90dA44bFA03b6295A0616a897441aceC; - IERC20 usdc = IERC20(USDC_POLYGON); - - GnosisSafeProxy proxy; - - function setUp() public { - - address[] memory owners = new address[](1); - owners[0] = address(this); - - bytes memory data = abi.encodeCall( - GnosisSafe.setup, - (owners, - 1, - address(0), - "", - address(0), - address(0), - 0, - payable(0)) - ); - proxy = GnosisSafeProxyFactory(SAFE_PROXY_FACTORY).createProxyWithNonce( - SINGLETON_ADDRESS, - data, - 1234567 - ); - - vm.startPrank(USDC_BIG_HOLDER); - usdc.transfer(address(this), 1000 * 10 ** 6); - - payable(address(this)).transfer(10 ** 18); - vm.stopPrank(); - } - -// function execTransaction( -// address to, -// uint256 value, -// bytes calldata data, -// Enum.Operation operation, -// uint256 safeTxGas, -// uint256 baseGas, -// uint256 gasPrice, -// address gasToken, -// address payable refundReceiver, -// bytes memory signatures -// ) - - function test_deploySafeAndAddGuard() public { - UniswapOnlyGuard guard = new UniswapOnlyGuard(UNISWAP_PERMIT2_POLYGON, new IERC20[](0)); - // GuardManager.setGuard(address guard) - bytes memory setGuardCallData = abi.encodeCall( - GuardManager.setGuard, - (address(guard)) - ); - bool success = GnosisSafe(payable(proxy)).execTransaction( - address(proxy), - 0, - setGuardCallData, - Enum.Operation.Call, - 0, - 0, - 0, - address(0), - payable(0), - "" - ); - assertTrue(success, "setGuard should succeed"); - } -} From 3447e544b63f819eab0442404cd804c02b497abf Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Tue, 17 Oct 2023 23:06:49 +0300 Subject: [PATCH 67/68] change hardcode data #9 --- frontend/src/components/table/Table.tsx | 6 +++--- frontend/src/pages/PoolsPage/PoolsPage.tsx | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/table/Table.tsx b/frontend/src/components/table/Table.tsx index b63bade..fece28c 100644 --- a/frontend/src/components/table/Table.tsx +++ b/frontend/src/components/table/Table.tsx @@ -12,9 +12,9 @@ export const Table: FC = ({ tableData }) => { {/* */} - - - + + + diff --git a/frontend/src/pages/PoolsPage/PoolsPage.tsx b/frontend/src/pages/PoolsPage/PoolsPage.tsx index 90dca61..cdff087 100644 --- a/frontend/src/pages/PoolsPage/PoolsPage.tsx +++ b/frontend/src/pages/PoolsPage/PoolsPage.tsx @@ -17,15 +17,15 @@ export const PoolsPage: FC = ({ poolsType }) => { const tableData: TPool[] = [ { address: '0', - allowedTokens: ['12312', '1231231', 'asdas'], - anchorCurrency: 'sdfsdfsd', + allowedTokens: ['0x606279b2c388ed37d0e5e52ea0d75eb2b539a57e'], + anchorCurrency: '0x606279b2c388ed37d0e5e52ea0d75eb2b539a57e', operatorFee: 10, }, { address: '1', - allowedTokens: ['12312', '1231231', 'asdas'], - anchorCurrency: 'sdfsdfsd', - operatorFee: 10, + allowedTokens: ['0x606279b2c388ed37d0e5e52ea0d75eb2b539a57e'], + anchorCurrency: '0x606279b2c388ed37d0e5e52ea0d75eb2b539a57e', + operatorFee: 15, }, ]; From 7a3f70d84c9f9b3fcc4a6c5bef527f9cccacd88b Mon Sep 17 00:00:00 2001 From: Joe Prime <101joe.prime@gmail.com> Date: Wed, 18 Oct 2023 14:08:17 +0300 Subject: [PATCH 68/68] revert changes #9 --- .gitmodules | 6 ------ lib/openzeppelin | 1 - lib/safe-contracts | 1 - 3 files changed, 8 deletions(-) delete mode 160000 lib/openzeppelin delete mode 160000 lib/safe-contracts diff --git a/.gitmodules b/.gitmodules index a75a4ba..888d42d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,3 @@ [submodule "lib/forge-std"] path = lib/forge-std url = https://github.com/foundry-rs/forge-std -[submodule "lib/safe-contracts"] - path = lib/safe-contracts - url = https://github.com/safe-global/safe-contracts -[submodule "lib/openzeppelin"] - path = lib/openzeppelin - url = https://github.com/OpenZeppelin/openzeppelin-contracts diff --git a/lib/openzeppelin b/lib/openzeppelin deleted file mode 160000 index 932fddf..0000000 --- a/lib/openzeppelin +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 932fddf69a699a9a80fd2396fd1a2ab91cdda123 diff --git a/lib/safe-contracts b/lib/safe-contracts deleted file mode 160000 index 186a21a..0000000 --- a/lib/safe-contracts +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 186a21a74b327f17fc41217a927dea7064f74604
DateOperator FeeanchorCurrencyallowedTokensOperator feeanchor currencyAllowed Tokens