Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

30 access smart contract data #46

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions frontend/src/components/profitCell/ProfitCell.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.red {
font-size: inherit;
color: #ffb4ab;
}

.green {
font-size: inherit;
color: #39e193;
}
27 changes: 27 additions & 0 deletions frontend/src/components/profitCell/ProfitCell.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { FC } from 'react';
import styles from './ProfitCell.module.scss';
interface IProfitCell {
total: number;
}

export const ProfitCell: FC<IProfitCell> = ({ total }) => {
const totalNumber = Number(total) as number;
const profit = Math.floor(Math.random() * 7000) - totalNumber;

const profitPercent = () => {
return Math.floor(((profit - totalNumber) / totalNumber) * 100);
};
const isProfitGreater = profit - totalNumber > 0;

const forattedProfitPercent = (isProfitGreater ? '+' : '') + profitPercent() + '%';
const formattedProfit = '$' + Math.abs(profit);
return (
<>
<span className={isProfitGreater ? styles.green : styles.red}>{forattedProfitPercent}</span>
<span> </span>
<span className={isProfitGreater ? styles.green : styles.red}>{formattedProfit}</span>
</>
);
};

export default ProfitCell;
Empty file.
12 changes: 9 additions & 3 deletions frontend/src/components/table/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
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';
import { TokenIconsCell } from '../tokenIconsCell/TokenIconsCell.tsx';
import ProfitCell from 'Components/profitCell/ProfitCell.tsx';

export const Table: FC<TablePropsI> = ({ tableData }) => {
return (
Expand All @@ -13,8 +13,10 @@ export const Table: FC<TablePropsI> = ({ tableData }) => {
<thead>
<tr>
{/* <th>Date</th> */}
<th className={styles.right}>Operator fee</th>
<th>Anchor currency / Tokens</th>
<th className={styles.right}>Operator fee</th>
<th className={styles.right}>Total</th>
<th className={styles.right}>Profit</th>
</tr>
</thead>
<tbody>
Expand All @@ -23,7 +25,6 @@ export const Table: FC<TablePropsI> = ({ tableData }) => {
{/* <td> todo
<DateCell cellValue={pool.date} />
</td> */}
<td className={styles.right}>{String(pool.operatorFee) + '%'}</td>
<td>
{pool.anchorCurrency && pool.allowedTokens && (
<TokenIconsCell
Expand All @@ -32,6 +33,11 @@ export const Table: FC<TablePropsI> = ({ tableData }) => {
/>
)}
</td>
<td className={styles.right}>{String(Number(pool.operatorFee) / 100) + '%'}</td>
<td className={styles.right}>{'$' + String(pool.total)}</td>
<td className={styles.right}>
<ProfitCell total={pool.total} />
</td>
</tr>
))}
</tbody>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/table/TableProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export interface TablePropsI {
operatorFee: number;
anchorCurrency: string;
allowedTokens: string[];
total: number;
}[];
}
7 changes: 4 additions & 3 deletions frontend/src/components/tokenIconsCell/TokenIconsCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ export const TokenIconsCell: FC<TokensIconsPropsI> = ({ anchorCurrency, tokens }

const getTokenIcon = (tokenAddress: string) => {
for (const elem of polygonData) {
if (elem.address === tokenAddress) {
if (elem.address.toLowerCase() == tokenAddress.toLowerCase()) {
return elem;
}
}
};

const getAllTokensIcons = () => {
setAnchorCurrencyInfo(getTokenIcon(anchorCurrency));
const test = getTokenIcon(anchorCurrency);
setAnchorCurrencyInfo(test);
const tokensInfoList: ITokenObject[] = tokens
.map((token) => getTokenIcon(token))
.filter((token): token is ITokenObject => {
Expand All @@ -30,7 +31,7 @@ export const TokenIconsCell: FC<TokensIconsPropsI> = ({ anchorCurrency, tokens }
useEffect(() => {
getAllTokensIcons();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}, [anchorCurrency, tokens]);

return (
<>
Expand Down
143 changes: 131 additions & 12 deletions frontend/src/data/abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export const abi = [
{
inputs: [
{ internalType: 'contract IERC20', name: 'anchorCurrency_', type: 'address' },
{ internalType: 'contract IERC20[]', name: 'tokens', type: 'address[]' },
{ internalType: 'address[]', name: 'tokens', type: 'address[]' },
{ internalType: 'uint256', name: 'operatorFee_', type: 'uint256' },
{ internalType: 'string', name: 'name_', type: 'string' },
{ internalType: 'string', name: 'symbol_', type: 'string' },
Expand Down Expand Up @@ -95,12 +95,40 @@ export const abi = [
type: 'error',
},
{ inputs: [], name: 'FailedInnerCall', type: 'error' },
{ inputs: [], name: 'InvalidInitialization', type: 'error' },
{ inputs: [], name: 'MathOverflowedMulDiv', type: 'error' },
{ inputs: [], name: 'NotInitializing', type: 'error' },
{
inputs: [{ internalType: 'address', name: 'token', type: 'address' }],
name: 'SafeERC20FailedOperation',
type: 'error',
},
{
anonymous: false,
inputs: [
{
components: [
{ internalType: 'address', name: 'to', type: 'address' },
{ internalType: 'uint256', name: 'value', type: 'uint256' },
{ internalType: 'bytes', name: 'data', type: 'bytes' },
{ internalType: 'enum Enum.Operation', name: 'operation', type: 'uint8' },
{ internalType: 'uint256', name: 'safeTxGas', type: 'uint256' },
{ internalType: 'uint256', name: 'baseGas', type: 'uint256' },
{ internalType: 'uint256', name: 'gasPrice', type: 'uint256' },
{ internalType: 'address', name: 'gasToken', type: 'address' },
{ internalType: 'address payable', name: 'refundReceiver', type: 'address' },
{ internalType: 'bytes', name: 'signatures', type: 'bytes' },
{ internalType: 'address', name: 'msgSender', type: 'address' },
],
indexed: false,
internalType: 'struct IProfitPalsVault.Action',
name: 'action',
type: 'tuple',
},
],
name: 'ActionLog',
type: 'event',
},
{
anonymous: false,
inputs: [
Expand All @@ -122,6 +150,27 @@ export const abi = [
name: 'Deposit',
type: 'event',
},
{
anonymous: false,
inputs: [
{ indexed: true, internalType: 'uint256', name: 'tokenId', type: 'uint256' },
{ indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
],
name: 'FungibleTokenAcquired',
type: 'event',
},
{
anonymous: false,
inputs: [{ indexed: false, internalType: 'uint64', name: 'version', type: 'uint64' }],
name: 'Initialized',
type: 'event',
},
{
anonymous: false,
inputs: [{ indexed: true, internalType: 'uint256', name: 'tokenId', type: 'uint256' }],
name: 'PositionAcquired',
type: 'event',
},
{
anonymous: false,
inputs: [
Expand All @@ -132,6 +181,36 @@ export const abi = [
name: 'Transfer',
type: 'event',
},
{
anonymous: false,
inputs: [
{ indexed: false, internalType: 'address', name: 'to', type: 'address' },
{ indexed: false, internalType: 'uint256', name: 'value', type: 'uint256' },
{ indexed: false, internalType: 'bytes', name: 'data', type: 'bytes' },
{ indexed: false, internalType: 'enum Enum.Operation', name: 'operation', type: 'uint8' },
{ indexed: false, internalType: 'uint256', name: 'safeTxGas', type: 'uint256' },
{ indexed: false, internalType: 'uint256', name: 'baseGas', type: 'uint256' },
{ indexed: false, internalType: 'uint256', name: 'gasPrice', type: 'uint256' },
{ indexed: false, internalType: 'address', name: 'gasToken', type: 'address' },
{ indexed: false, internalType: 'address payable', name: 'refundReceiver', type: 'address' },
{ indexed: false, internalType: 'bytes', name: 'signatures', type: 'bytes' },
{ indexed: false, internalType: 'address', name: 'msgSender', type: 'address' },
],
name: 'UnauthorizedActionDetected',
type: 'event',
},
{
anonymous: false,
inputs: [{ indexed: false, internalType: 'bytes32', name: 'txHash', type: 'bytes32' }],
name: 'UnauthorizedActionOnlyOneOpenPositionAllowed',
type: 'event',
},
{
anonymous: false,
inputs: [{ indexed: false, internalType: 'bytes32', name: 'txHash', type: 'bytes32' }],
name: 'UnauthorizedActionOperatorMustChangeAnchorBalance',
type: 'event',
},
{
anonymous: false,
inputs: [
Expand All @@ -144,6 +223,7 @@ export const abi = [
name: 'Withdraw',
type: 'event',
},
{ stateMutability: 'nonpayable', type: 'fallback' },
{
inputs: [
{ internalType: 'address', name: 'owner', type: 'address' },
Expand All @@ -157,7 +237,7 @@ export const abi = [
{
inputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
name: 'allowedTokens',
outputs: [{ internalType: 'contract IERC20', name: '', type: 'address' }],
outputs: [{ internalType: 'address', name: '', type: 'address' }],
stateMutability: 'view',
type: 'function',
},
Expand All @@ -171,7 +251,7 @@ export const abi = [
{
inputs: [],
name: 'allowedTokensList',
outputs: [{ internalType: 'contract IERC20[]', name: '', type: 'address[]' }],
outputs: [{ internalType: 'address[]', name: '', type: 'address[]' }],
stateMutability: 'view',
type: 'function',
},
Expand Down Expand Up @@ -206,6 +286,35 @@ export const abi = [
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{ internalType: 'bytes32', name: 'txHash', type: 'bytes32' },
{ internalType: 'bool', name: '', type: 'bool' },
],
name: 'checkAfterExecution',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{ internalType: 'address', name: 'to', type: 'address' },
{ internalType: 'uint256', name: 'value', type: 'uint256' },
{ internalType: 'bytes', name: 'data', type: 'bytes' },
{ internalType: 'enum Enum.Operation', name: 'operation', type: 'uint8' },
{ internalType: 'uint256', name: 'safeTxGas', type: 'uint256' },
{ internalType: 'uint256', name: 'baseGas', type: 'uint256' },
{ internalType: 'uint256', name: 'gasPrice', type: 'uint256' },
{ internalType: 'address', name: 'gasToken', type: 'address' },
{ internalType: 'address payable', name: 'refundReceiver', type: 'address' },
{ internalType: 'bytes', name: 'signatures', type: 'bytes' },
{ internalType: 'address', name: 'msgSender', type: 'address' },
],
name: 'checkTransaction',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [{ internalType: 'uint256', name: 'shares', type: 'uint256' }],
name: 'convertToAssets',
Expand Down Expand Up @@ -238,12 +347,22 @@ export const abi = [
type: 'function',
},
{
inputs: [{ internalType: 'uint256', name: 'amount', type: 'uint256' }],
name: 'deposit',
inputs: [{ internalType: 'contract GnosisSafeL2', name: 'safe_', type: 'address' }],
name: 'initialize',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{ internalType: 'bytes', name: '', type: 'bytes' },
{ internalType: 'bytes', name: '_signature', type: 'bytes' },
],
name: 'isValidSignature',
outputs: [{ internalType: 'bytes4', name: '', type: 'bytes4' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [{ internalType: 'address', name: '', type: 'address' }],
name: 'maxDeposit',
Expand Down Expand Up @@ -343,6 +462,13 @@ export const abi = [
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [],
name: 'safe',
outputs: [{ internalType: 'contract GnosisSafeL2', name: '', type: 'address' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'symbol',
Expand Down Expand Up @@ -386,13 +512,6 @@ export const abi = [
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' },
Expand Down
Loading