From a50a0cd19a081cb97f1f28df76a1ec7686eec203 Mon Sep 17 00:00:00 2001 From: Derek Matter <81758129+dharkmattr@users.noreply.github.com> Date: Mon, 14 Aug 2023 15:33:42 +0300 Subject: [PATCH] Development (#202) * feat: add maintenance mode for convert page (#199) * SOV-1309: reward manager integration (#168) * testing * added receive amount to field * fixed destination token * minor fix to mock * added reward or penalty label * fixed liter comments * testing * lint * testing * fixed review comments * added percentage to incentive display * removed print * removed print * fixed many tiny compilation errors * SOV-2245: Fix staking duration (#191) * Fix method for generating staking dates * Trigger deploy * Fix tests * Make stakeEndDate argument optional * SOV-2196: Add a link to the latest GH release (#192) * Add a link to the latest release * Update README * added kludge to access node directly for incentive estimate * some refactoring * Update src/pages/Aggregator/AggregatorInfo/AggregatorInfo.component.tsx Co-authored-by: tiltom * removed unnecessary config * fix linter * prettier * fixed bool to string bug * fixed bugs * added form validation * linter and prettier * fixed slippage calculation * fixed slippage logic * fixed slippage logic * fixed some merge related errors and a review comment * fixed penalty added to receive amount * review comments * fixed ro;unding of incentive * removed console.logs * fixed underflow bug * fixed bridge transaction bug * Update src/store/aggregator/sagas/withdrawTokens.ts Co-authored-by: tiltom * Update src/store/aggregator/sagas/withdrawTokens.ts Co-authored-by: tiltom * review comment * review comment * natural number bug * disabled slippage slider for now * penalty -> conversion fee * subtract bridge fee from receive amount * subtract bridge fee from receive amount * fixed race condition on fees * fixed a few bugs * fixed a few bugs * fixed a few bugs * fixed a few bugs * new reward manager * new tokens for testing * new tokens for testing * new reward manager * new address --------- Co-authored-by: tiltom * added inivisible version indication --------- Co-authored-by: soulBit Co-authored-by: tiltom --- .eslintrc | 1 + package.json | 10 +- .../Dropdown/Dropdown.controlled.tsx | 21 +- src/components/Header/Header.component.tsx | 1 + src/config/contracts.ts | 3 + src/config/pools.ts | 3 +- src/config/tokens.ts | 56 +- src/contracts/abi/MassetV3.json | 569 --- src/contracts/abi/MassetV4.json | 974 +++++ src/contracts/abi/RewardManager.json | 335 ++ src/pages/Aggregator/Aggregator.component.tsx | 72 +- src/pages/Aggregator/Aggregator.container.tsx | 112 +- src/pages/Aggregator/Aggregator.fields.ts | 9 +- src/pages/Aggregator/Aggregator.hooks.ts | 21 +- src/pages/Aggregator/Aggregator.types.ts | 3 + src/pages/Aggregator/Aggregator.utils.ts | 84 + .../AggregatorInfo.component.tsx | 56 +- .../AggregatorInfo.container.tsx | 30 +- .../AggregatorInfo/AggregatorInfo.types.ts | 9 +- .../AggregatorInfoError.component.tsx | 22 + .../AggregatorInfoSwitch.component.tsx | 31 + .../InfoRowWithPerc.component.tsx | 64 + .../SlippageSlider.component.tsx | 34 + .../SlippageSlider.controlled.tsx | 24 + .../SlippageSlider/SlippageSlider.types.ts | 33 + src/store/aggregator/aggregator.mock.ts | 6 +- src/store/aggregator/aggregator.sagas.ts | 183 +- src/store/aggregator/aggregator.selectors.ts | 37 +- src/store/aggregator/aggregator.slice.ts | 58 + src/store/aggregator/aggregator.state.ts | 22 + src/store/aggregator/getIncentive.ts | 76 + src/store/aggregator/sagas/depositTokens.ts | 19 +- .../aggregator/sagas/rewardManagerAbis.ts | 58 + .../aggregator/sagas/withdrawTokens.test.ts | 18 +- src/store/aggregator/sagas/withdrawTokens.ts | 19 +- src/store/app/app.selectors.test.ts | 2 +- src/store/app/app.selectors.ts | 5 + src/store/utils/utils.math.ts | 11 + yarn.lock | 3390 +++++++++++++---- 39 files changed, 5062 insertions(+), 1419 deletions(-) delete mode 100644 src/contracts/abi/MassetV3.json create mode 100644 src/contracts/abi/MassetV4.json create mode 100644 src/contracts/abi/RewardManager.json create mode 100644 src/pages/Aggregator/AggregatorInfo/AggregatorInfoError.component.tsx create mode 100644 src/pages/Aggregator/AggregatorInfo/AggregatorInfoSwitch.component.tsx create mode 100644 src/pages/Aggregator/AggregatorInfo/InfoRowWithPerc.component.tsx create mode 100644 src/pages/Aggregator/SlippageSlider/SlippageSlider.component.tsx create mode 100644 src/pages/Aggregator/SlippageSlider/SlippageSlider.controlled.tsx create mode 100644 src/pages/Aggregator/SlippageSlider/SlippageSlider.types.ts create mode 100644 src/store/aggregator/getIncentive.ts create mode 100644 src/store/aggregator/sagas/rewardManagerAbis.ts create mode 100644 src/store/utils/utils.math.ts diff --git a/.eslintrc b/.eslintrc index 7a1e48bd..ea239be8 100644 --- a/.eslintrc +++ b/.eslintrc @@ -13,6 +13,7 @@ "parser": "@typescript-eslint/parser" }, "rules": { + "arrow-body-style": "off", "no-plusplus": "off", "no-undef": "off", "no-param-reassign": "off", diff --git a/package.json b/package.json index 70961d6c..d7da8157 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "deploy": "./start.sh", "lint": "eslint .", "prettier": "prettier --config .prettierrc --check .", + "prettier:fix": "prettier --config .prettierrc --write .", "test": "jest --verbose", "preview": "vite preview", "check-types": "tsc --noEmit", @@ -30,7 +31,7 @@ "@sovryn/onboard-hw-common": "1.0.1", "@sovryn/onboard-injected": "1.0.0", "@sovryn/onboard-ledger": "1.0.1", - "@sovryn/onboard-react": "1.0.2", + "@sovryn/onboard-react": "1.0.3", "@sovryn/onboard-trezor": "1.0.1", "@sovryn/ui": "1.0.6", "@typechain/ethers-v5": "9.0.0", @@ -42,7 +43,7 @@ "graphql-request": "4.1.0", "react": "17.0.2", "react-dom": "17.0.2", - "react-hook-form": "7.27.0", + "react-hook-form": "7.43.1", "react-redux": "7.2.6", "react-router-dom": "6.2.1", "reactjs-localstorage": "1.0.1", @@ -51,7 +52,10 @@ "rxjs": "7.8.1", "subscription-client": "0.9.15", "ts-node": "10.5.0", - "typed-redux-saga": "1.4.0" + "typed-redux-saga": "1.5.0", + "typescript-http-client": "0.10.4", + "web3": "1.9.0", + "web3-utils": "1.10.0" }, "devDependencies": { "@ethersproject/providers": "5.5.1", diff --git a/src/components/Dropdown/Dropdown.controlled.tsx b/src/components/Dropdown/Dropdown.controlled.tsx index edfcb7d0..3f539ced 100644 --- a/src/components/Dropdown/Dropdown.controlled.tsx +++ b/src/components/Dropdown/Dropdown.controlled.tsx @@ -1,11 +1,6 @@ import Box from '@mui/material/Box'; -import React, { Ref, useCallback } from 'react'; -import { - Controller, - Path, - PathValue, - UnpackNestedValue, -} from 'react-hook-form'; +import { Ref, useCallback } from 'react'; +import { Controller, Path, PathValue } from 'react-hook-form'; import { FieldErrorMessage } from '../FieldErrorMessage/FieldErrorMessage.component'; import { DropdownOptions } from './Dropdown.component'; @@ -27,15 +22,9 @@ export const ControlledDropdown = < }) => { const setValueWhenOneOption = useCallback(() => { if (options.length === 1) { - setValue( - name, - options[0].id as unknown as UnpackNestedValue< - PathValue> - >, - { - shouldValidate: true, - } - ); + setValue(name, options[0].id as PathValue>, { + shouldValidate: true, + }); } }, [name, options, setValue]); diff --git a/src/components/Header/Header.component.tsx b/src/components/Header/Header.component.tsx index 5a923f97..08c973a5 100644 --- a/src/components/Header/Header.component.tsx +++ b/src/components/Header/Header.component.tsx @@ -17,5 +17,6 @@ export const Header = () => ( + version: incentive-curve ); diff --git a/src/config/contracts.ts b/src/config/contracts.ts index cfc5d278..c49e206b 100644 --- a/src/config/contracts.ts +++ b/src/config/contracts.ts @@ -11,6 +11,7 @@ export type ContractsForNetwork = { swapNetwork: string; multicall: string; XUSDMassetProxy: string; + rewardManager: string; }; export type ContractsAddresses = Record< @@ -30,6 +31,7 @@ export const contractsAddresses: ContractsAddresses = { feeSharingProxy: '0x12B1B0C67d9A771EB5Db7726d23fdc6848fd93ef', vestingRegistry: '0x036ab2DB0a3d1574469a4a7E09887Ed76fB56C41', XUSDMassetProxy: '0x1440d19436bEeaF8517896bffB957a88EC95a00F', + rewardManager: '0xd2508d45ff30f920178ce88b3a5c7207c534558d', }, [ChainEnum.RSK_TESTNET]: { staking: '0x34a01F53432e2105B7361Aee031F3De629eb7211', @@ -42,5 +44,6 @@ export const contractsAddresses: ContractsAddresses = { feeSharingProxy: '0xBF56E401e3CbE1ddF3d8fEee770d9A3a19076751', vestingRegistry: '0xEB0AAD069b452563628CE539df0Da531E2313148', XUSDMassetProxy: '0x1572D7E4a78A8AD14AE722E6fE5f5600a2c7A149', + rewardManager: '0xd7D4236adEa1fFE9C1C6b4A31Ac3d37AE146906D', }, }; diff --git a/src/config/pools.ts b/src/config/pools.ts index 41d172c4..0db7c233 100644 --- a/src/config/pools.ts +++ b/src/config/pools.ts @@ -36,7 +36,8 @@ export const mainnetPool = { const testnetBaseChains: BaseChainType[] = [ { ...chains[ChainEnum.RSK_TESTNET], - bassets: [tokens.DOC, tokens.RDOC, tokens.RUSDT, tokens.ZUSD, tokens.DLLR], + bassets: [tokens.DOC, tokens.RDOC, tokens.RUSDT, tokens.ZUSD, + tokens.DLLR, tokens.TST1, tokens.TST2, tokens.TST3, tokens.TST4, tokens.TST6], }, { ...chains[ChainEnum.ETH_TESTNET], diff --git a/src/config/tokens.ts b/src/config/tokens.ts index 3789f791..96d157cf 100644 --- a/src/config/tokens.ts +++ b/src/config/tokens.ts @@ -21,6 +21,11 @@ export enum TokenEnum { RUSDT = 'RUSDT', ZUSD = 'ZUSD', DLLR = 'DLLR', + TST1 = 'TST1', + TST2 = 'TST2', + TST3 = 'TST3', + TST4 = 'TST4', + TST6 = 'TST6' } export interface TokenTypeBase { @@ -58,15 +63,15 @@ export const tokenOnChain = { }, [TokenEnum.RDOC]: { [ChainEnum.RSK]: '0x2d919f19d4892381d58edebeca66d5642cef1a1f', - [ChainEnum.RSK_TESTNET]: '0xC3De9f38581F83e281F260D0ddBAac0E102Ff9F8', + [ChainEnum.RSK_TESTNET]: '0xdbdc2d486c10c23902a46a17bec1f7de64075257', }, [TokenEnum.DOC]: { [ChainEnum.RSK]: '0xe700691da7b9851f2f35f8b8182c69c53ccad9db', - [ChainEnum.RSK_TESTNET]: '0xCb46C0DdC60d18eFEB0e586c17AF6Ea36452DaE0', + [ChainEnum.RSK_TESTNET]: '0xad0d0d04ec0cf442204908fc2cc18503ead06d3e', }, [TokenEnum.RUSDT]: { [ChainEnum.RSK]: '0xEf213441a85DF4d7acBdAe0Cf78004E1e486BB96', - [ChainEnum.RSK_TESTNET]: '0x4d5A316d23EBe168D8f887b4447BF8DBfA4901cc', + [ChainEnum.RSK_TESTNET]: '0x71e14cb1d752b88215782f2d6af01327cb483a0e', }, [TokenEnum.ZUSD]: { [ChainEnum.RSK]: '0xdB107FA69E33f05180a4C2cE9c2E7CB481645C2d', @@ -76,6 +81,21 @@ export const tokenOnChain = { [ChainEnum.RSK]: '0x007b3AA69A846cB1f76b60b3088230A52D2A83AC', // TODO: Change it once we have mainnet deployment, this is a testnet address [ChainEnum.RSK_TESTNET]: '0x007b3AA69A846cB1f76b60b3088230A52D2A83AC', }, + [TokenEnum.TST1]: { + [ChainEnum.RSK_TESTNET]: '0x9552f2e86b38b6545f7a3ff871b1f3e0023fa841', + }, + [TokenEnum.TST2]: { + [ChainEnum.RSK_TESTNET]: '0x36f737dcaf6b2480f3163602c7cf85c9661527d4', + }, + [TokenEnum.TST3]: { + [ChainEnum.RSK_TESTNET]: '0xf177355fffbf1096436c43354b6b653c08ff75ee', + }, + [TokenEnum.TST4]: { + [ChainEnum.RSK_TESTNET]: '0x12aff942bafc1394acc3fdef28f41fd3f008b32d', + }, + [TokenEnum.TST6]: { + [ChainEnum.RSK_TESTNET]: '0xd1179afa75dcdeaa5bd6c0da705e67d268a2d7c3', + }, } as const; type TokensType = Record, TokenTypeBase>; @@ -147,4 +167,34 @@ export const tokens: TokensType = { icon: dllrIcon, addresses: tokenOnChain.DLLR, }, + [TokenEnum.TST1]: { + id: TokenEnum.TST1, + name: TokenEnum.TST1, + icon: dllrIcon, + addresses: tokenOnChain.TST1, + }, + [TokenEnum.TST2]: { + id: TokenEnum.TST2, + name: TokenEnum.TST2, + icon: dllrIcon, + addresses: tokenOnChain.TST2, + }, + [TokenEnum.TST3]: { + id: TokenEnum.TST3, + name: TokenEnum.TST3, + icon: dllrIcon, + addresses: tokenOnChain.TST3, + }, + [TokenEnum.TST4]: { + id: TokenEnum.TST4, + name: TokenEnum.TST4, + icon: dllrIcon, + addresses: tokenOnChain.TST4, + }, + [TokenEnum.TST6]: { + id: TokenEnum.TST6, + name: TokenEnum.TST6, + icon: dllrIcon, + addresses: tokenOnChain.TST6, + }, } as const; diff --git a/src/contracts/abi/MassetV3.json b/src/contracts/abi/MassetV3.json deleted file mode 100644 index 8326ab26..00000000 --- a/src/contracts/abi/MassetV3.json +++ /dev/null @@ -1,569 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "minter", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "massetQuantity", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "bAsset", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "bassetQuantity", - "type": "uint256" - } - ], - "name": "Minted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "redeemer", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "massetQuantity", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "bAsset", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "bassetQuantity", - "type": "uint256" - } - ], - "name": "Redeemed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "orderAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "tokenAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "userData", - "type": "bytes" - } - ], - "name": "onTokensMintedCalled", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "operator", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "userData", - "type": "bytes" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "operatorData", - "type": "bytes" - } - ], - "name": "onTokensReceivedCalled", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "getBasketManager", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getToken", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getVersion", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_basketManagerAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "_tokenAddress", - "type": "address" - }, - { - "internalType": "bool", - "name": "_registerAsERC777RecipientFlag", - "type": "bool" - } - ], - "name": "initialize", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "isOwner", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_bAsset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_bAssetQuantity", - "type": "uint256" - } - ], - "name": "mint", - "outputs": [ - { - "internalType": "uint256", - "name": "massetMinted", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_bAsset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_bAssetQuantity", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_recipient", - "type": "address" - } - ], - "name": "mintTo", - "outputs": [ - { - "internalType": "uint256", - "name": "massetMinted", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint256", - "name": "_orderAmount", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_tokenAddress", - "type": "address" - }, - { - "internalType": "bytes", - "name": "_userData", - "type": "bytes" - } - ], - "name": "onTokensMinted", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_bAsset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_massetQuantity", - "type": "uint256" - } - ], - "name": "redeem", - "outputs": [ - { - "internalType": "uint256", - "name": "massetRedeemed", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_bAsset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_massetQuantity", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_recipient", - "type": "address" - } - ], - "name": "redeemTo", - "outputs": [ - { - "internalType": "uint256", - "name": "massetRedeemed", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_basset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_massetQuantity", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_recipient", - "type": "address" - }, - { - "internalType": "address", - "name": "_bridgeAddress", - "type": "address" - } - ], - "name": "redeemToBridge", - "outputs": [ - { - "internalType": "uint256", - "name": "massetRedeemed", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_basset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_massetQuantity", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_recipient", - "type": "address" - } - ], - "name": "redeemToBridge", - "outputs": [ - { - "internalType": "uint256", - "name": "massetRedeemed", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_operator", - "type": "address" - }, - { - "internalType": "address", - "name": "_from", - "type": "address" - }, - { - "internalType": "address", - "name": "_to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "_userData", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "_operatorData", - "type": "bytes" - } - ], - "name": "tokensReceived", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_basketManagerAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "_tokenAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "_feesVaultAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "_feesManagerAddress", - "type": "address" - } - ], - "name": "upgradeToV3", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/src/contracts/abi/MassetV4.json b/src/contracts/abi/MassetV4.json new file mode 100644 index 00000000..f694fe18 --- /dev/null +++ b/src/contracts/abi/MassetV4.json @@ -0,0 +1,974 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "massetQuantity", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "bAsset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bassetQuantity", + "type": "uint256" + } + ], + "name": "Minted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "massetQuantity", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "bAsset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bassetQuantity", + "type": "uint256" + } + ], + "name": "Redeemed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "basset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "penalty", + "type": "uint256" + } + ], + "name": "onPenaltyPaid", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "basset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "reward", + "type": "uint256" + } + ], + "name": "onRewardPaid", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "oldBasketManager", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newBaskManager", + "type": "address" + } + ], + "name": "onSetBasketManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "oldPauseManager", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newPauseManager", + "type": "address" + } + ], + "name": "onSetPauseManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "oldRewardManager", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newRewardManager", + "type": "address" + } + ], + "name": "onSetRewardManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "oldToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newToken", + "type": "address" + } + ], + "name": "onSetToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "oldTokenOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newTokenOwner", + "type": "address" + } + ], + "name": "onSetTokenOwner", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "orderAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "userData", + "type": "bytes" + } + ], + "name": "onTokensMintedCalled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "userData", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "operatorData", + "type": "bytes" + } + ], + "name": "onTokensReceivedCalled", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "getBasketManager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getPauseManager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getRewardManager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getVersion", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_basketManagerAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "_registerAsERC777RecipientFlag", + "type": "bool" + } + ], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isOwner", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "migrateToV4", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_bAsset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_bAssetQuantity", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "massetMinted", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_bAsset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_bAssetQuantity", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_recipient", + "type": "address" + } + ], + "name": "mintTo", + "outputs": [ + { + "internalType": "uint256", + "name": "massetMinted", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_bAsset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_bAssetQuantity", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_minimumReward", + "type": "uint256" + } + ], + "name": "mintToWithMinimumReward", + "outputs": [ + { + "internalType": "uint256", + "name": "massetMinted", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_bAsset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_bAssetQuantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_minimumReward", + "type": "uint256" + } + ], + "name": "mintWithMinimumReward", + "outputs": [ + { + "internalType": "uint256", + "name": "massetMinted", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "_orderAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_userData", + "type": "bytes" + } + ], + "name": "onTokensMinted", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_bAsset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_massetQuantity", + "type": "uint256" + } + ], + "name": "redeem", + "outputs": [ + { + "internalType": "uint256", + "name": "massetRedeemed", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_bAsset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_massetQuantity", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_recipient", + "type": "address" + } + ], + "name": "redeemTo", + "outputs": [ + { + "internalType": "uint256", + "name": "massetRedeemed", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_basset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_massetQuantity", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_recipient", + "type": "address" + } + ], + "name": "redeemToBridge", + "outputs": [ + { + "internalType": "uint256", + "name": "massetRedeemed", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_basset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_massetQuantity", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_maximumPenalty", + "type": "uint256" + } + ], + "name": "redeemToBridgeWithMaximumPenalty", + "outputs": [ + { + "internalType": "uint256", + "name": "massetRedeemed", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_bAsset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_massetQuantity", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_maximumPenalty", + "type": "uint256" + } + ], + "name": "redeemToWithMaximumPenalty", + "outputs": [ + { + "internalType": "uint256", + "name": "massetRedeemed", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_bAsset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_massetQuantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_maximumPenalty", + "type": "uint256" + } + ], + "name": "redeemWithMaximumPenalty", + "outputs": [ + { + "internalType": "uint256", + "name": "massetRedeemed", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_basketManagerAddress", + "type": "address" + } + ], + "name": "setBasketManager", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_newPauseManager", + "type": "address" + } + ], + "name": "setPauseManager", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_newRewardManager", + "type": "address" + } + ], + "name": "setRewardManager", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + } + ], + "name": "setToken", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_newOwner", + "type": "address" + } + ], + "name": "setTokenOwner", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_userData", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "_operatorData", + "type": "bytes" + } + ], + "name": "tokensReceived", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ] \ No newline at end of file diff --git a/src/contracts/abi/RewardManager.json b/src/contracts/abi/RewardManager.json new file mode 100644 index 00000000..136ce32f --- /dev/null +++ b/src/contracts/abi/RewardManager.json @@ -0,0 +1,335 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_massetAddress", + "type": "address" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newFactor", + "type": "uint256" + } + ], + "name": "onFactorChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newTargetWeight", + "type": "uint256" + } + ], + "name": "onTargetWeightChanged", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "getFactor", + "outputs": [ + { + "internalType": "uint256", + "name": "factor", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getMassetAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_bassetAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_sum", + "type": "uint256" + } + ], + "name": "getPenaltyForWithdrawal", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_bassetAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_sum", + "type": "uint256" + } + ], + "name": "getRewardForDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + } + ], + "name": "getTargetWeight", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getTargetWeights", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getTokens", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isOwner", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_bassetAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_sum", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_minimum", + "type": "uint256" + } + ], + "name": "sendRewardForDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "_factor", + "type": "uint256" + } + ], + "name": "setFactor", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address[]", + "name": "_tokenAddresses", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_targetWeights", + "type": "uint256[]" + } + ], + "name": "setTargetWeights", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/src/pages/Aggregator/Aggregator.component.tsx b/src/pages/Aggregator/Aggregator.component.tsx index 5f8307fb..f68b28d9 100644 --- a/src/pages/Aggregator/Aggregator.component.tsx +++ b/src/pages/Aggregator/Aggregator.component.tsx @@ -28,6 +28,10 @@ import { AggregatorInfoContainer } from './AggregatorInfo/AggregatorInfo.contain import { SendAmount } from './SendAmount/SendAmount.container'; import { flowStateSelector } from '../../store/aggregator/aggregator.selectors'; import { fieldsErrors, UrlNames } from '../../constants'; +import { ControlledSlider } from './SlippageSlider/SlippageSlider.controlled'; +import { ChainEnum } from '../../config/chains'; + +import { useIsFormValid } from './Aggregator.utils'; const PageViewTitle: React.FC = ({ children }) => ( ( ); +const slippageSliderValues = [0, 5, 10, 15, 20]; +const slippageSliderMarks = slippageSliderValues.map((v) => ({ + value: v, + label: `${v}%`, +})); + export const AggregatorComponent = ({ onSubmit, + onStartingChainChange, onDestinationChainChange, onStartingTokenChange, onDestinationTokenChange, isStartingTokenPaused, + onSendAmountChange, + receiveAmount, }: AggregatorComponentProps) => { const flowState = useSelector(flowStateSelector); @@ -57,7 +70,6 @@ export const AggregatorComponent = ({ setError, clearErrors, control, - formState: { isValid }, } = useForm({ mode: 'onChange', defaultValues: aggregatorDefaultValues, @@ -119,10 +131,14 @@ export const AggregatorComponent = ({ } }, [clearErrors, isStartingTokenPaused, setError]); + useEffect(() => { + setValue(AggregatorInputs.ReceiveAmount, receiveAmount ?? '0.0'); + }, [receiveAmount, setValue]); + useEffect(() => { checkTokenPauseState(); onStartingTokenChange(startingToken || undefined); - }, [startingToken, onStartingTokenChange, checkTokenPauseState]); + }, [startingToken, onStartingTokenChange]); useEffect(() => { if (destinationChain) { @@ -130,15 +146,19 @@ export const AggregatorComponent = ({ } }, [destinationChain, onDestinationChainChange]); + useEffect(() => { + if (startingChain) { + onStartingChainChange(startingChain); + } + }, [startingChain, onStartingChainChange]); + useEffect(() => { onDestinationTokenChange(destinationToken || undefined); }, [destinationToken, onDestinationTokenChange]); useEffect(() => { - if (amount) { - setValue(AggregatorInputs.ReceiveAmount, amount); // TODO: This will change in the future once we have an incentive curve algorithm - } - }, [amount, setValue]); + onSendAmountChange(amount); + }, [amount, onSendAmountChange]); useEffect(() => { if (isAddressDisclaimerChecked && !receivingAddress) { @@ -148,7 +168,6 @@ export const AggregatorComponent = ({ useEffect(() => { resetField(AggregatorInputs.SendAmount); - resetField(AggregatorInputs.ReceiveAmount); }, [flowState, resetField]); const handleAddressDisclaimerClick = useCallback( @@ -156,11 +175,28 @@ export const AggregatorComponent = ({ [] ); + + const isSubmitAllowed = useIsFormValid({ + startingToken, + destinationToken, + startingChain: startingChain as ChainEnum, + destinationChain: destinationChain as ChainEnum, + isAddressDisclaimerChecked, + isStartingTokenPaused, + amount, + receivingAddress, + }); + const shouldAllowTokensSelection = useMemo( () => !!startingChain && !!destinationChain, [destinationChain, startingChain] ); + + let slippageProtectionAvailable = startingChain === destinationChain; + // disable for now + slippageProtectionAvailable = false; + return ( <> @@ -218,6 +254,17 @@ export const AggregatorComponent = ({ control={control} setValue={setValue} /> +