From 6a6ee6df0fd091a32c1d579a502f65eb16bc3074 Mon Sep 17 00:00:00 2001 From: tomjeatt <40243778+tomjeatt@users.noreply.github.com> Date: Tue, 26 Sep 2023 10:39:58 +0100 Subject: [PATCH] [release] Kintsugi 2.38.1 (#1568) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: redirect when access from forbidden country is detected (#1209) * Feature/updated transfer UI (#876) * refactor: use updated tab component * refactor: duplicated form titles * refactor: remove redundant hook calls * refactor: prefer title case * wip: XCM transfer form UI * wip: updated form UI * wip: account selector placeholder component * wip: account selector modal * wip: modal open and close actions * wip: update modal type * wip: get accounts * wip: add identicon and rename component for consistency * wip: account input component * fix: remove redundant icons prop * feat: implement with SelectTrigger * wip: styling and account selection value * wip: handle setting account data * refactor: better naming * wip: address list styling * refactor: rename defaultAccount * wip: chain selector placeholder component * wip: duplicate account component and rename * chore: delete redundant legacy component * wip: logic for fetching and rendering chain ids * wip: chain item styling * wip: selected chain styling * chore: add comment * refactor: pass through native token to icon component * feature: add chain icon component * chore: add comment * chore: correct file name casing * refactor: improve folder structure * wip: form layout styling * chore: add arrow icon * chore: add logos and correct svg titles * chore: remove redundant svg prop * chore: rename arrow icon * chore: consistent use of styled components * refactor: remove padding from modal body * wip: formik integration work * wip: extend useXCMBridge to return available chains and utility methods * chore: move Chain and Chains types to types directory * feat: layout and form implementation * feat: add schema * feat: final * wip: refactor useXCMBridge hook * refactor: add endpoints type * refactor: wrap methods in useCallback * refactor: fix bug in hook method * chore: bump bridge version * wip: set originating and destination chain values * refactor: set from chain value on field change * wip: set originating chain value * refactor: mergeProps to set field value * refactor: handle setting origin/destination chain values * wip: get tokens method * wip: first iteration of balances function * wip: handle tokens array * wip: set token value * wip: get token balances * wip: return token and balances in single method * wip: mapped tokens * refactor: handle default chain values * refactor: better organised function order * wip: handle change events * wip: handle setting tokens * wip: handle fetching tokens and balances * wip: convert input configs * wip: handle token change * wip: get token USD price * Trigger Build * chore: remove unused import * chore: correct eslintignore syntax * wip: handle breaking changes * wip: disable token input when select items value is 1 * chore: set first token item as variable * wip: handle setting and changing values * chire: add loading spinner * refactor: add loading state * refactor: filter destination chains * chore: remove console log * chore: bump XCM bridge version * chore: update config * refactor: configure validation * chore: revert change to useForm hook * wip: form validation * wip: working form validation * wip: undefined validation parameters * refactor: return dest fee estimate from bridge hook * feature: show fees and fee estimates * chore: conditional operators * refactor: handle ticker change correctly * wip: sendTransaction method * Revert "wip: sendTransaction method" This reverts commit 3ade26dda26c7cc14f9db9e7c005b66863fa9139. * fix: USD amounts * wip: send transactions * refactor: bump bridge and use getNativeToken method * chore: bump bridge * refactor: move submit logic to useMutation hook * fix: type mismatches * refactor: white space/comments * refactor: add transaction fee validation * chore: typo * chore: remove console log * refactor: remove duplicated monetary conversion * refactor: remove duplicate code * Revert "refactor: remove duplicate code" This reverts commit bd29f8c5661e327c5285d1020c534dab2deae806. * Revert "refactor: remove duplicated monetary conversion" This reverts commit 5fd3d645eb7d8edc00cfe8ced186d4e2432af9fc. * refactor: use monetaryAmount when constructing transaction * refactor: remove duplicated code for fetching tokens * refactor: default XCM origin * Revert "refactor: remove duplicated code for fetching tokens" This reverts commit 8f31ee8667adcd49f5aaebb7db2f205afb5e9725. * chore: remove comment * chore: fix errors * fix: set default value to empty string to prevent React error * refactor: removed unwanted force validation parameters * refactor: remove redundant method * refactor: add method return type * refactor: add method return type * refactor: correct type error * refactor: fix destFee type error * refactor: remove fees validation and revert destFee return value * chore: remove console log * refactor: remove redundant method * refactor: disable validation on change * chore: remove commented out code * wip: use select component for chain selector * fix: handle chain select functions * refactor: type chain id as ChainName * Revert "refactor: type chain id as ChainName" This reverts commit d05e0128cb4b5ac1d00ac07808ebdf9858739165. * chore: remove unused component files * refactor: remove duplicated transaction logic * fix: make to/from field types more specific * fix: revert yup.custom changes and cast validation * fix: set correct destination chain * refator: handle token data * refactor: add use callback * fix: correct rendering logic * fix: update dependencies * chore: delete unused styles * chore: fix merge issue with transfer form * fix: change validation handling * Revert "fix: change validation handling" This reverts commit c0cb3062aad3540b2afad7d375024d872924a62c. * refactor: only display transfer amount if amount has been entered * chore: config changes * chore: add missing icons * chore: Hydra chain icon * fix: add error text to CTA * Tom/xcm fixes (#1213) * refactor: specify endpoints and remove unnecessary logic * fix: save file before committing * fix: disable refetch * chore: update endpoints * chore: remove log * chore: rename file * chore: add additional acala/karura endpoints --------- Co-authored-by: Rui Simão * chore: release v2.32.0 * Update API healthchecks (#778) * Chore - add vault healthcheck * Chore - add vault healthcheck * Chore - add vault healthcheck * [earn strategies] placeholder page, nav and feature flag (#1216) * chore: bump icons dependency * feature: earn strategies placeholder page and feature flag * feat: add useTransaction (#1189) * chore: update monetary to latest 0.7.3 (#1214) * chore: update monetary to latest 0.7.3 * chore: update lib * chore: bump lib and bridge (#1219) * chore: release v2.32.1 * fix: add missing icons and remove erroring RPC (#1222) * fix: add missing icons and remove erroring RPC * Update src/pages/Transfer/CrossChainTransferForm/components/ChainIcon/icons/Acala.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * Update src/pages/Transfer/CrossChainTransferForm/components/ChainIcon/icons/Astar.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * Update src/pages/Transfer/CrossChainTransferForm/components/ChainIcon/icons/Parallel.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> --------- Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * chore: release v2.32.2 * fix: compare input configs with method not operator (#1225) * refactor: reset selected account on account change (#1226) * chore: release v2.32.3 * feature: add geoblock feature flag (#1230) * chore: release v2.32.4 * chore: bump bridge (#1233) * chore: release v2.32.5 * Peter/earn strategies feat deposit withdraw form (#1229) * chore: update monetary to latest 0.7.3 * wip * feat(earn-strategies): add deposit and withdrawal form components * refactor: add padding under tabs in earn strategy forms * chore(earn-strategies): change file structure * feat: add Popover, Underlay and ProgressBar. Changes to Dialog, Modal and Overlay. (#1236) * fix: Dialog, Modal and Popover (#1245) * chore: rename strategies feature (#1247) * chore: release v2.32.6 * Fix: back button behaviour from bridge page (#1246) * fix: use history replace instead of push to fix looping of bridge page * chore: clean up and bump version --------- Co-authored-by: tomjeatt <40243778+tomjeatt@users.noreply.github.com> * feat: add transaction notifications (#1177) * chore: remove console.log (#1262) * fix(TokenInput): adorment ticker (#1257) * fix: get vesting data (#1264) * Peter/chore update lib 2.3.0 (#1267) * chore: update monetary to latest 0.7.3 * chore: update lib version * fix: sort notifications (#1270) * fix: transaction none (#1271) * fix(Loans): apy label (#1275) * Peter/loans fix subsidy rewards (#1276) * chore: update monetary to latest 0.7.3 * fix(loans): display correct subsidy rewards accrued amount and APY * chore: console log cleanup * chore: replace GOVERNANCE_TOKEN_SYMBOL with GOVERNANCE_TOKEN.ticker * Peter/fix loans incentive apr computation (#1256) * chore: update monetary to latest 0.7.3 * fix: convert incentives apr computation to percentage * fix: change loans incentives annualized return to have label APR * chore: release v2.33.0 * Peter/chore update lib 2.3.3 (#1282) * chore: update monetary to latest 0.7.3 * chore: update lib to 2.3.3. * fix: enable faucet on Interlay testnet (#1289) * fix: enable faucet on Interlay testnet * fix: prefer governance token ticker to symbol * chore: bump bridge (#1285) * fix(Swap): update trade object on each block (#1297) * api: use diadata as main datasource (#1277) * api: use diadata as main datasource * api: add header to select price source --------- Co-authored-by: tomjeatt <40243778+tomjeatt@users.noreply.github.com> * Peter/fix interlay issues (#1300) * chore: update monetary to latest 0.7.3 * fix: add missing translation and fix lend APY display * refactor: bring back formatting with 0 amount case covered * refactor: code review * refactor: code review * api: select price source via query param and ticker renaming (#1307) * api: fix tether label for dia (#1309) * chore: release v2.34.0 * chore: update XCM RPCs (#1324) * chore: release v2.34.1 * fix: correct wallet balance (#1334) * api: switch to coingecko pro url (#1321) * Peter/feat tx fee with swapped currency (#1340) * chore: update monetary to latest 0.7.3 * feat: refactor Transfer and theme (#1244) * wip: initial changes to move table * chore: remove unused component * Revert "chore: remove unused component" This reverts commit 0db71a15538b776c73b752a98d2e825d890d2ea1. * chore: remove unused component * chore: use translation file * fix: add missing p tags * wip * feat: refactor Transfer and theme (#1244) * feat(Bridge): revamp Issue and Redeem (#1279) * wip * feat(TransactionDetails): extend component to support fee selector (#1292) * feat: add tx fee estimation and swap for tx fee payment integration * fix: remove impossible condition * feat: integrate use-transaction with TransactionFeeDetails (#1294) * feat: integrate use-transaction with TransactionFeeDetails * fix: code review * refactor: code review * feat: add fee estimate loading state * Rui/fee estimate transfer form (#1296) * feat: add fee estimate to transfer form * Update src/pages/Transfer/TransferForms/components/TransferForm/TransferForm.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> --------- Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * Feature/UI updates/navigation styling (#1293) * wip: initial navigation styling * refactor: remove icons from secondary navigation items * refactor: split navigation into primary/secondary * fix: add bg colour to nav to prevent problems on small screens * refactor: update accordion styles * refactor: remove redundant code and console log * refactor: change Kintsugi background colour * fix: show navigation item names * fix: remove redundant conditional * fix: code * fix: changes to list style and disable 0 balance fee tokens * feat(bringyourownfee): add check for existing trade path * Update src/utils/hooks/transaction/use-transaction.ts Co-authored-by: Dominik Harz * Update src/utils/hooks/transaction/use-transaction.ts Co-authored-by: Dominik Harz * refactor: move multiplier to constant * feat: add fee validation and other improvements to form validation (#1303) * Peter/feat griefing collateral multicurrency (#1310) * feat: add selectable griefing collateral currency to issue request form * feat: add oracle currency hook and wrap up griefing collateral work * feat(Swap): add custom fee (#1315) * Peter/feat byof bridge page (#1328) * wip * refactor: issue page with griefing collateral select * feat(bringyourownfees): redeem form * refactor: renaming * feat: add redeem request to getActionAmount * feat(Pools): add fee estimate (#1322) * feat(Loans): add fee estimate (#1332) * feat(Vaults): add fee estimate to vault creation (#1333) * fix(Redeem): add missing BTC address validation (#1336) * fix: redeem getActionAmount type mismatch * Tom/UI updates/minor changes (#1308) * refactor: add vault table background colour * fix: typo * refactor: styled card for vault selector * refactor: wrap vault transaction tables in card component * fix: typo * refactor: add shadowed prop to card component * refactor: use card component for transactions table * refactor: move request id in legacy issue/request modal * refactor: use request id dictionary item * chore: update Interlay logo * refactor: update icon and logo colours * feature: add bg image * wip: add background image to Layout component * refactor: add Wrapper component * wip: initial values for background image position * refactor: minor styling changes * refactor: revert unneeded change * refactor: move and rename Transaction component * feat: sort currencies by balance (#1338) --------- Co-authored-by: Peter Co-authored-by: Thomas Jeatt Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> Co-authored-by: tomjeatt <40243778+tomjeatt@users.noreply.github.com> Co-authored-by: Dominik Harz * chore: release v2.35.0 * Tom/feature/wallet buttons (#1346) * refactor: add tab props * feature: add bridge button to assets table * refactor: don't show buy button for wrapped token * [wallet] add default currencies to wallet (#1335) * refactor: add default currencies to wallet * refactor: use NATIVE_CURRENCIES * chore: update navigation (#1344) * refatctor: remove LBANK configuration and assets (#1355) * feature: add LDOT icon (#1356) * Peter/refactor fetch oracle status from chain (#1359) * chore: update monetary to latest 0.7.3 * refactor: fetch oracle status from chain * chore: remove commented-out code * Peter/fix add wrapped currency as security deposit option (#1360) * chore: update monetary to latest 0.7.3 * fix: add wrapped token to useGetOracleCurrencies result * chore: update price impact warning copy (#1358) * [transfer/bridge] open correct tab (#1366) * fix: bridge query parameter * fix: revert to previous tab name * refactor: close redeem modal (#1367) * refactor: close redeem modal * fix: correct user messaging copy * fix: remove unnecessary translation * fix: correct copy * feat: change LoadingSpinner styles and CTA loading spinner (#1372) * feat: replace legacy toast with new notification toast (#1370) * fix: UI styling bugs (#1371) * fix: change broken gradient id ref * refactor: add opacity value to navigation separator * fix: update padding * fix: border opacity * fix: use transaction details component * refactor: change how padding is set * Peter/fix bridge dust value validation (#1374) * chore: update monetary to latest 0.7.3 * fix: dust value calculation * feat(Wallet): add USDT and change switch label (#1363) * fix(Modal): prevent user from clicking when closed (#1364) * fix(Swap): handle when schema params are undefined (#1375) * feat(Wallet): add welcome banner (#1337) * fix: correct subscan link (#1378) * fix: select token modal list style (#1382) * fix: improve issue form insufficient funds notice (#1380) * feature: add tooltip to asset cell (#1345) * feature: add tooltip to asset cell * fix: typo * wip: ReactNode tooltip so that we can pass in link * feature: add fee asset tooltip * update text link component * fix: revert changes to text links * revert changes to text links * fix: maintain compatibility with existing text links * use correct location variable * fix: remove log * fix: tooltip const * Onboarding page (#1373) * feat: add draft of onboarding page * chore: update t&c links * feat: add guided tour through app * fix: typos and eslint warnings * restrict width of onboarding cards * feat: replace UI faucet with discord link * feat: improve CTA * feat: add link to onboarding page --------- Co-authored-by: Thomas Jeatt * fix: disable fetch on focus (#1386) * fix(Onboarding): improve styles, semantics and file structure (#1387) Co-authored-by: Dominik Harz * fix: typo (#1392) * Peter/feat pools trading fee apr (#1389) * chore: update monetary to latest 0.7.3 * feat(pools): add trading fee APR * refactor: clean-up naming * Peter/ choreupdate lib 2.3.5 (#1393) * chore: update monetary to latest 0.7.3 * chore: update lib to 2.3.5 * chore: release v2.35.1 * fix: onboarding and empty fee selector (#1396) * Onboarding feature flag (#1398) * refactor: add feature flag * fix: update dependencies * add onboarding to env file * chore: release v2.35.2 * api: add dia asset ids to market data endpoint (#1400) * chore: release v2.35.3 * api: add dia asset ids to market data endpoint (#1403) * chore: release v2.35.4 * fix(Wallet): add missing guide link (#1406) * fix(Wallet): add missing guide link * Update WelcomeBanner.tsx * feat(Wallet): update welcome banner svg (#1407) * wip: add T&Cs version (#1409) * chore: release v2.35.5 * api: add support for multiple version of terms and conditions (#1411) * api: add support for multiple version of terms and conditions * api: add support for multiple version of terms and conditions * chore: release v2.35.6 * feat: add parity signer companion for polkadot vault support (#1417) * Tom/xcm copy changes (#1391) * fix: typos * refactor: pass chain data to transaction instead of chain id * refactor: remove unused feature foags (#1402) * Peter/fix pools daily volumes (#1421) * chore: update monetary to latest 0.7.3 * fix: change pools fetching query to work when first record is younger than requested period * fix(Pools): deposit validation (#1419) * fix: various issues picked up from testing (#1414) * fix: prefetching fee scenarios (#1384) * fix: hide onboarding button when onboarding disabled (#1418) * chore: release v2.35.7 * apply hotfix (#1428) * Peter/fix byof not working (#1430) * chore: update monetary to latest 0.7.3 * fix(byof): use correct field props getter for fee token select * chore: release v2.35.8 * api: add support ethereum and karura (#1435) * Tom/updated directory names (#1434) * refactor: rename Bridge -> BTC * refactor: transfer -> send and receive * fix: rename Transfer component * revert change to tab name * refactor: update translation references * update schemas * update directory and file casing * casing * casing * casing * casing * casing * chore: split AMM pages into seperate folders (#1436) * feat: check signature version (#1429) * Fix Storybook (#1443) * fix display name syntax * disable snapshots * Trigger build * Update routes (#1442) * update routes * redirect crossChainTransfer query parameter * fix redirect syntax * fix redirect syntax * redirect cross chain transfer * tab redirects * correct redirect syntax * Peter/fix q token vaults support (#1445) * chore: update monetary to latest 0.7.3 * wip * wip: update lib version * chore: install deps * chore: fix test pipelines (#1379) * fix(Redeem): redeem limit when there is not capcity (#1451) * fix(Redeem): premium redeem (#1454) * Peter/feat loans q token handle edge cases (#1449) * chore: update monetary to latest 0.7.3 * feat(loans): handle lend position when qToken is used as vault collateral * chore: update lib * add nova wallet (#1453) * add nova wallet * delete unused config and update polkadot name * move constant and delete redundant file * feat: add query params handling (#1347) * feat: add estimate fee hook and action amount deduction (#1433) * Update number of wallets in test (#1462) * Update number of wallets in test * fix: remove parentheses from wallet name * Support Banxa on Interlay (#1458) * refactor: remove redundant env variable and UI component * refactor: remove redundant URL parameter * update translation file * revert change to wallet parameter * update translation parameter * fix: missed file save * chore: release v2.36.0 * fix(Swap): add missing scenario for re-computing trade obj (#1464) * fix: use correct value for vault capacity indicator (#1465) * fix: use correct value for vault capacity indicator * fix: capacity ratio when there are no backed tokens * revert version bump * chore: release v2.36.0 * api: add fallback to coingecko for missing assets on dia (#1467) * revert version bump * chore: release v2.36.0 * fix: fee affecting action amount calculation (#1472) * chore: release v2.36.1 * feat(Strategies): add landing page (#1466) * feat(Strategies): add landing page * fix: code review * chore: improve translactions (#1447) * feat: add tooltip to pools and refactor loans tooltip (#1424) * feat: add tooltip to pools and refactor loans tooltip * fix: code review * fix: code reivew --------- Co-authored-by: Thomas Jeatt * fix(Loans): simplify form and hook (#1476) * Rui/loans modals lose close animation due to conditional render (#1460) * wip * feat: continue * fix: code review * fix:merge --------- Co-authored-by: Thomas Jeatt * fix: loan tests (#1425) * Tom/update bg image (#1481) * update bg svg * swap file * minify * Tom/xcm updates (#1480) * wip: refactor account select * refactor: update component names * Revert "refactor: update component names" This reverts commit c80ca13d04cec92a5405479ccafc65f069cb93ca. * fix: rename components without breaking feature * disable all data refetching * wip: render xcm form when no wallet connected * remove redundant legacy component * workaround for account selection issue * Tidying up * handle TODO relating to SelectObject * remove comment * casing * selected styling * improvements * Add comment * fix: organize files (#1483) * refactor: Layout and MainContainer (#1489) * refactor: add block height, parachain status and locked tokens hooks (#1486) * refactor: replace old faucet approach with use-faucet (#1484) * Peter/feat dry running (#1499) * chore: update monetary to latest 0.7.3 * feat(transaction): dry-run transaction before submission and revert execution if dry-running fails * test: mock submittable extrinsic * refactor: rename to dryRun and document functionality * refactor: move submission code to separate folder * Peter/feat simple passive income strategy page (#1473) * chore: update monetary to latest 0.7.3 * wip: feat(strategies): add simple BTC strategy * refactor(strategies): merge landing page with strategy page * wip: strategy page infographics * feat(loans): add earned amount to lend positions * feat: changes to loans and strategies (#1498) --------- Co-authored-by: Daniel Simão * fix(Strategies): improve responsiveness and add form link (#1503) * fix: correct feature flag name (#1504) * chore: release v2.36.2 * feat(Slider): add component (#1502) * fix: use route instead of redirect (#1507) * chore: release v2.37.0 * feat: add breadcrumbs component and add it to strategies (#1505) * Peter/chore lib update 2.4.0 (#1512) * chore: update monetary to latest 0.7.3 * chore: handle 2.4.0 upgrade * fix: conditional check for amount (#1516) * fix: conditional check for amount * fix: revert slice change * docs: roadmap item (#1519) * feat: add roadmap items to roadmap but not backlog (#1521) * feat: zero slippage option (#1497) * chore: bump lib (#1523) * Bump bridge and revert hotfix (#1104) * chore: bump bridge and revert hotfix * chore: bump bridge * chore: bump bridge version * Release/kintsugi/2.29.1 (#1107) * chore: add resolutions for various polkadot packages (#1089) * Fix input field width issue (#1090) * fix: input field width * fix: rename max weeks to total weeks * chore: bump ui version * chore: bump XCM bridge (#1093) * feat(Wallet): add page (#1001) * feat(Wallet): add page * feat: add WalletIcon * feat: copy address * wip * feat: staking table * feat: refactor and add lending * refactor: clean up code * wip * feat: add List card * continue * fix: continue * feat: continue * feat(CTALink): improve * feat: add responsiveness and swap handling * feat: final * feat: add responsive prop * fix: clean up List and Divider * feat: add tests * feat: add final tests * fix: code review * feat: add vesting and tests * fix: code review * Tom/bug/burn form collateral tokens (#1042) * refactor: loop collateral to get burnable tokens * refactor: revert previous change and simplify * refactor: add function to filter tokens * refactor: fetch collateral currencies and render token values * wip: form layout and translation * wip: set data and selected collateral * chore: remove console log * refactor: remove single collateral code * chore: comment * fix: incorrect USD value * chore: remove testing code * refactor: remove native token import * refactor: add BurnableCollateral type * refactor: add fullWidth prop and label to token selector * refactor: collateral icon * chore: add dictionary item * chore: remove unnecessary conditional operators * refactor: handle callback * refactor: fix failing test * chore: remove unused code * refactor: add success notification to burn form * Add CORS to market data (#1096) * chore: add env variables to config * chore: add cors to market data api --------- Co-authored-by: ns212 * fix: revert to using 0.2.x version of the bridge (#1095) * chore: improve price impact warning copy * chore: release v2.29.0 * fix(amm): use correct hooks dependencies (#1105) * fix: update useGetCurrencies callbacks dependency arrays (#1108) * chore: release v2.29.1 --------- Co-authored-by: Brendon Votteler Co-authored-by: Chanakya888 Co-authored-by: Daniel Simão Co-authored-by: ns212 Co-authored-by: Dominik Harz Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * Tom/release/kintsugi/2.29.2 (#1116) * chore: add resolutions for various polkadot packages (#1089) * Fix input field width issue (#1090) * fix: input field width * fix: rename max weeks to total weeks * chore: bump ui version * chore: bump XCM bridge (#1093) * feat(Wallet): add page (#1001) * feat(Wallet): add page * feat: add WalletIcon * feat: copy address * wip * feat: staking table * feat: refactor and add lending * refactor: clean up code * wip * feat: add List card * continue * fix: continue * feat: continue * feat(CTALink): improve * feat: add responsiveness and swap handling * feat: final * feat: add responsive prop * fix: clean up List and Divider * feat: add tests * feat: add final tests * fix: code review * feat: add vesting and tests * fix: code review * Tom/bug/burn form collateral tokens (#1042) * refactor: loop collateral to get burnable tokens * refactor: revert previous change and simplify * refactor: add function to filter tokens * refactor: fetch collateral currencies and render token values * wip: form layout and translation * wip: set data and selected collateral * chore: remove console log * refactor: remove single collateral code * chore: comment * fix: incorrect USD value * chore: remove testing code * refactor: remove native token import * refactor: add BurnableCollateral type * refactor: add fullWidth prop and label to token selector * refactor: collateral icon * chore: add dictionary item * chore: remove unnecessary conditional operators * refactor: handle callback * refactor: fix failing test * chore: remove unused code * refactor: add success notification to burn form * Add CORS to market data (#1096) * chore: add env variables to config * chore: add cors to market data api --------- Co-authored-by: ns212 * fix: revert to using 0.2.x version of the bridge (#1095) * chore: improve price impact warning copy * chore: release v2.29.0 * fix(amm): use correct hooks dependencies (#1105) * fix: update useGetCurrencies callbacks dependency arrays (#1108) * chore: release v2.29.1 * [wallet] improve wallet balance (#1109) * wip: correct wallet balance * refactor: account for borrow and lend positions when calculating total balance * refactor: add total liquidity balance * fix: typo * chore: add TODO * refactor: remove unnecessary toString call * refactor: redirect home route to wallet if enabled, defaulting to bridge if not * refactor: remove duplicated calculations * refactor: return liquidity pools calculation from hook * chore: release v2.29.2 --------- Co-authored-by: Brendon Votteler Co-authored-by: Chanakya888 Co-authored-by: Daniel Simão Co-authored-by: ns212 Co-authored-by: Dominik Harz Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * Tom/release/kintsugi/2.9.3 (#1121) * chore: add resolutions for various polkadot packages (#1089) * Fix input field width issue (#1090) * fix: input field width * fix: rename max weeks to total weeks * chore: bump ui version * chore: bump XCM bridge (#1093) * feat(Wallet): add page (#1001) * feat(Wallet): add page * feat: add WalletIcon * feat: copy address * wip * feat: staking table * feat: refactor and add lending * refactor: clean up code * wip * feat: add List card * continue * fix: continue * feat: continue * feat(CTALink): improve * feat: add responsiveness and swap handling * feat: final * feat: add responsive prop * fix: clean up List and Divider * feat: add tests * feat: add final tests * fix: code review * feat: add vesting and tests * fix: code review * Tom/bug/burn form collateral tokens (#1042) * refactor: loop collateral to get burnable tokens * refactor: revert previous change and simplify * refactor: add function to filter tokens * refactor: fetch collateral currencies and render token values * wip: form layout and translation * wip: set data and selected collateral * chore: remove console log * refactor: remove single collateral code * chore: comment * fix: incorrect USD value * chore: remove testing code * refactor: remove native token import * refactor: add BurnableCollateral type * refactor: add fullWidth prop and label to token selector * refactor: collateral icon * chore: add dictionary item * chore: remove unnecessary conditional operators * refactor: handle callback * refactor: fix failing test * chore: remove unused code * refactor: add success notification to burn form * Add CORS to market data (#1096) * chore: add env variables to config * chore: add cors to market data api --------- Co-authored-by: ns212 * fix: revert to using 0.2.x version of the bridge (#1095) * chore: improve price impact warning copy * chore: release v2.29.0 * fix(amm): use correct hooks dependencies (#1105) * fix: update useGetCurrencies callbacks dependency arrays (#1108) * chore: release v2.29.1 * [wallet] improve wallet balance (#1109) * wip: correct wallet balance * refactor: account for borrow and lend positions when calculating total balance * refactor: add total liquidity balance * fix: typo * chore: add TODO * refactor: remove unnecessary toString call * refactor: redirect home route to wallet if enabled, defaulting to bridge if not * refactor: remove duplicated calculations * refactor: return liquidity pools calculation from hook * chore: release v2.29.2 * refactor: use current block when calculating lock time extension (#1118) * Tom/hotfix/use correct xcm names (#1119) * refactor: use display value for chain names * refactor: use correct display value for XCM channels * chore: release v2.29.3 --------- Co-authored-by: Brendon Votteler Co-authored-by: Chanakya888 Co-authored-by: Daniel Simão Co-authored-by: ns212 Co-authored-by: Dominik Harz Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * [release] Kintsugi 2.9.5 (#1127) * chore: add resolutions for various polkadot packages (#1089) * Fix input field width issue (#1090) * fix: input field width * fix: rename max weeks to total weeks * chore: bump ui version * chore: bump XCM bridge (#1093) * feat(Wallet): add page (#1001) * feat(Wallet): add page * feat: add WalletIcon * feat: copy address * wip * feat: staking table * feat: refactor and add lending * refactor: clean up code * wip * feat: add List card * continue * fix: continue * feat: continue * feat(CTALink): improve * feat: add responsiveness and swap handling * feat: final * feat: add responsive prop * fix: clean up List and Divider * feat: add tests * feat: add final tests * fix: code review * feat: add vesting and tests * fix: code review * Tom/bug/burn form collateral tokens (#1042) * refactor: loop collateral to get burnable tokens * refactor: revert previous change and simplify * refactor: add function to filter tokens * refactor: fetch collateral currencies and render token values * wip: form layout and translation * wip: set data and selected collateral * chore: remove console log * refactor: remove single collateral code * chore: comment * fix: incorrect USD value * chore: remove testing code * refactor: remove native token import * refactor: add BurnableCollateral type * refactor: add fullWidth prop and label to token selector * refactor: collateral icon * chore: add dictionary item * chore: remove unnecessary conditional operators * refactor: handle callback * refactor: fix failing test * chore: remove unused code * refactor: add success notification to burn form * Add CORS to market data (#1096) * chore: add env variables to config * chore: add cors to market data api --------- Co-authored-by: ns212 * fix: revert to using 0.2.x version of the bridge (#1095) * chore: improve price impact warning copy * chore: release v2.29.0 * fix(amm): use correct hooks dependencies (#1105) * fix: update useGetCurrencies callbacks dependency arrays (#1108) * chore: release v2.29.1 * [wallet] improve wallet balance (#1109) * wip: correct wallet balance * refactor: account for borrow and lend positions when calculating total balance * refactor: add total liquidity balance * fix: typo * chore: add TODO * refactor: remove unnecessary toString call * refactor: redirect home route to wallet if enabled, defaulting to bridge if not * refactor: remove duplicated calculations * refactor: return liquidity pools calculation from hook * chore: release v2.29.2 * refactor: use current block when calculating lock time extension (#1118) * Tom/hotfix/use correct xcm names (#1119) * refactor: use display value for chain names * refactor: use correct display value for XCM channels * chore: release v2.29.3 * fix: correct apy calculation (#1123) * fix: correct apy calculation * refactor: set extension time as variable * chore: release v2.29.4 * fix: prevent rewards estimate from being called when user has insufficient balance (#1126) * chore: release v2.29.5 --------- Co-authored-by: Brendon Votteler Co-authored-by: Chanakya888 Co-authored-by: Daniel Simão Co-authored-by: ns212 Co-authored-by: Dominik Harz Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * fix: revert change which blocks rewards calculation * chore: update coingecko api endpoint * [release] Kintsugi 2.32.0 (#1215) * feat: redirect when access from forbidden country is detected (#1209) * Feature/updated transfer UI (#876) * refactor: use updated tab component * refactor: duplicated form titles * refactor: remove redundant hook calls * refactor: prefer title case * wip: XCM transfer form UI * wip: updated form UI * wip: account selector placeholder component * wip: account selector modal * wip: modal open and close actions * wip: update modal type * wip: get accounts * wip: add identicon and rename component for consistency * wip: account input component * fix: remove redundant icons prop * feat: implement with SelectTrigger * wip: styling and account selection value * wip: handle setting account data * refactor: better naming * wip: address list styling * refactor: rename defaultAccount * wip: chain selector placeholder component * wip: duplicate account component and rename * chore: delete redundant legacy component * wip: logic for fetching and rendering chain ids * wip: chain item styling * wip: selected chain styling * chore: add comment * refactor: pass through native token to icon component * feature: add chain icon component * chore: add comment * chore: correct file name casing * refactor: improve folder structure * wip: form layout styling * chore: add arrow icon * chore: add logos and correct svg titles * chore: remove redundant svg prop * chore: rename arrow icon * chore: consistent use of styled components * refactor: remove padding from modal body * wip: formik integration work * wip: extend useXCMBridge to return available chains and utility methods * chore: move Chain and Chains types to types directory * feat: layout and form implementation * feat: add schema * feat: final * wip: refactor useXCMBridge hook * refactor: add endpoints type * refactor: wrap methods in useCallback * refactor: fix bug in hook method * chore: bump bridge version * wip: set originating and destination chain values * refactor: set from chain value on field change * wip: set originating chain value * refactor: mergeProps to set field value * refactor: handle setting origin/destination chain values * wip: get tokens method * wip: first iteration of balances function * wip: handle tokens array * wip: set token value * wip: get token balances * wip: return token and balances in single method * wip: mapped tokens * refactor: handle default chain values * refactor: better organised function order * wip: handle change events * wip: handle setting tokens * wip: handle fetching tokens and balances * wip: convert input configs * wip: handle token change * wip: get token USD price * Trigger Build * chore: remove unused import * chore: correct eslintignore syntax * wip: handle breaking changes * wip: disable token input when select items value is 1 * chore: set first token item as variable * wip: handle setting and changing values * chire: add loading spinner * refactor: add loading state * refactor: filter destination chains * chore: remove console log * chore: bump XCM bridge version * chore: update config * refactor: configure validation * chore: revert change to useForm hook * wip: form validation * wip: working form validation * wip: undefined validation parameters * refactor: return dest fee estimate from bridge hook * feature: show fees and fee estimates * chore: conditional operators * refactor: handle ticker change correctly * wip: sendTransaction method * Revert "wip: sendTransaction method" This reverts commit 3ade26dda26c7cc14f9db9e7c005b66863fa9139. * fix: USD amounts * wip: send transactions * refactor: bump bridge and use getNativeToken method * chore: bump bridge * refactor: move submit logic to useMutation hook * fix: type mismatches * refactor: white space/comments * refactor: add transaction fee validation * chore: typo * chore: remove console log * refactor: remove duplicated monetary conversion * refactor: remove duplicate code * Revert "refactor: remove duplicate code" This reverts commit bd29f8c5661e327c5285d1020c534dab2deae806. * Revert "refactor: remove duplicated monetary conversion" This reverts commit 5fd3d645eb7d8edc00cfe8ced186d4e2432af9fc. * refactor: use monetaryAmount when constructing transaction * refactor: remove duplicated code for fetching tokens * refactor: default XCM origin * Revert "refactor: remove duplicated code for fetching tokens" This reverts commit 8f31ee8667adcd49f5aaebb7db2f205afb5e9725. * chore: remove comment * chore: fix errors * fix: set default value to empty string to prevent React error * refactor: removed unwanted force validation parameters * refactor: remove redundant method * refactor: add method return type * refactor: add method return type * refactor: correct type error * refactor: fix destFee type error * refactor: remove fees validation and revert destFee return value * chore: remove console log * refactor: remove redundant method * refactor: disable validation on change * chore: remove commented out code * wip: use select component for chain selector * fix: handle chain select functions * refactor: type chain id as ChainName * Revert "refactor: type chain id as ChainName" This reverts commit d05e0128cb4b5ac1d00ac07808ebdf9858739165. * chore: remove unused component files * refactor: remove duplicated transaction logic * fix: make to/from field types more specific * fix: revert yup.custom changes and cast validation * fix: set correct destination chain * refator: handle token data * refactor: add use callback * fix: correct rendering logic * fix: update dependencies * chore: delete unused styles * chore: fix merge issue with transfer form * fix: change validation handling * Revert "fix: change validation handling" This reverts commit c0cb3062aad3540b2afad7d375024d872924a62c. * refactor: only display transfer amount if amount has been entered * chore: config changes * chore: add missing icons * chore: Hydra chain icon * fix: add error text to CTA * Tom/xcm fixes (#1213) * refactor: specify endpoints and remove unnecessary logic * fix: save file before committing * fix: disable refetch * chore: update endpoints * chore: remove log * chore: rename file * chore: add additional acala/karura endpoints --------- Co-authored-by: Rui Simão * chore: release v2.32.0 --------- Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> Co-authored-by: Rui Simão * [release] Kintsugi 2.32.2 (#1223) * feat: redirect when access from forbidden country is detected (#1209) * Feature/updated transfer UI (#876) * refactor: use updated tab component * refactor: duplicated form titles * refactor: remove redundant hook calls * refactor: prefer title case * wip: XCM transfer form UI * wip: updated form UI * wip: account selector placeholder component * wip: account selector modal * wip: modal open and close actions * wip: update modal type * wip: get accounts * wip: add identicon and rename component for consistency * wip: account input component * fix: remove redundant icons prop * feat: implement with SelectTrigger * wip: styling and account selection value * wip: handle setting account data * refactor: better naming * wip: address list styling * refactor: rename defaultAccount * wip: chain selector placeholder component * wip: duplicate account component and rename * chore: delete redundant legacy component * wip: logic for fetching and rendering chain ids * wip: chain item styling * wip: selected chain styling * chore: add comment * refactor: pass through native token to icon component * feature: add chain icon component * chore: add comment * chore: correct file name casing * refactor: improve folder structure * wip: form layout styling * chore: add arrow icon * chore: add logos and correct svg titles * chore: remove redundant svg prop * chore: rename arrow icon * chore: consistent use of styled components * refactor: remove padding from modal body * wip: formik integration work * wip: extend useXCMBridge to return available chains and utility methods * chore: move Chain and Chains types to types directory * feat: layout and form implementation * feat: add schema * feat: final * wip: refactor useXCMBridge hook * refactor: add endpoints type * refactor: wrap methods in useCallback * refactor: fix bug in hook method * chore: bump bridge version * wip: set originating and destination chain values * refactor: set from chain value on field change * wip: set originating chain value * refactor: mergeProps to set field value * refactor: handle setting origin/destination chain values * wip: get tokens method * wip: first iteration of balances function * wip: handle tokens array * wip: set token value * wip: get token balances * wip: return token and balances in single method * wip: mapped tokens * refactor: handle default chain values * refactor: better organised function order * wip: handle change events * wip: handle setting tokens * wip: handle fetching tokens and balances * wip: convert input configs * wip: handle token change * wip: get token USD price * Trigger Build * chore: remove unused import * chore: correct eslintignore syntax * wip: handle breaking changes * wip: disable token input when select items value is 1 * chore: set first token item as variable * wip: handle setting and changing values * chire: add loading spinner * refactor: add loading state * refactor: filter destination chains * chore: remove console log * chore: bump XCM bridge version * chore: update config * refactor: configure validation * chore: revert change to useForm hook * wip: form validation * wip: working form validation * wip: undefined validation parameters * refactor: return dest fee estimate from bridge hook * feature: show fees and fee estimates * chore: conditional operators * refactor: handle ticker change correctly * wip: sendTransaction method * Revert "wip: sendTransaction method" This reverts commit 3ade26dda26c7cc14f9db9e7c005b66863fa9139. * fix: USD amounts * wip: send transactions * refactor: bump bridge and use getNativeToken method * chore: bump bridge * refactor: move submit logic to useMutation hook * fix: type mismatches * refactor: white space/comments * refactor: add transaction fee validation * chore: typo * chore: remove console log * refactor: remove duplicated monetary conversion * refactor: remove duplicate code * Revert "refactor: remove duplicate code" This reverts commit bd29f8c5661e327c5285d1020c534dab2deae806. * Revert "refactor: remove duplicated monetary conversion" This reverts commit 5fd3d645eb7d8edc00cfe8ced186d4e2432af9fc. * refactor: use monetaryAmount when constructing transaction * refactor: remove duplicated code for fetching tokens * refactor: default XCM origin * Revert "refactor: remove duplicated code for fetching tokens" This reverts commit 8f31ee8667adcd49f5aaebb7db2f205afb5e9725. * chore: remove comment * chore: fix errors * fix: set default value to empty string to prevent React error * refactor: removed unwanted force validation parameters * refactor: remove redundant method * refactor: add method return type * refactor: add method return type * refactor: correct type error * refactor: fix destFee type error * refactor: remove fees validation and revert destFee return value * chore: remove console log * refactor: remove redundant method * refactor: disable validation on change * chore: remove commented out code * wip: use select component for chain selector * fix: handle chain select functions * refactor: type chain id as ChainName * Revert "refactor: type chain id as ChainName" This reverts commit d05e0128cb4b5ac1d00ac07808ebdf9858739165. * chore: remove unused component files * refactor: remove duplicated transaction logic * fix: make to/from field types more specific * fix: revert yup.custom changes and cast validation * fix: set correct destination chain * refator: handle token data * refactor: add use callback * fix: correct rendering logic * fix: update dependencies * chore: delete unused styles * chore: fix merge issue with transfer form * fix: change validation handling * Revert "fix: change validation handling" This reverts commit c0cb3062aad3540b2afad7d375024d872924a62c. * refactor: only display transfer amount if amount has been entered * chore: config changes * chore: add missing icons * chore: Hydra chain icon * fix: add error text to CTA * Tom/xcm fixes (#1213) * refactor: specify endpoints and remove unnecessary logic * fix: save file before committing * fix: disable refetch * chore: update endpoints * chore: remove log * chore: rename file * chore: add additional acala/karura endpoints --------- Co-authored-by: Rui Simão * chore: release v2.32.0 * Update API healthchecks (#778) * Chore - add vault healthcheck * Chore - add vault healthcheck * Chore - add vault healthcheck * [earn strategies] placeholder page, nav and feature flag (#1216) * chore: bump icons dependency * feature: earn strategies placeholder page and feature flag * feat: add useTransaction (#1189) * chore: update monetary to latest 0.7.3 (#1214) * chore: update monetary to latest 0.7.3 * chore: update lib * chore: bump lib and bridge (#1219) * chore: release v2.32.1 * fix: add missing icons and remove erroring RPC (#1222) * fix: add missing icons and remove erroring RPC * Update src/pages/Transfer/CrossChainTransferForm/components/ChainIcon/icons/Acala.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * Update src/pages/Transfer/CrossChainTransferForm/components/ChainIcon/icons/Astar.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * Update src/pages/Transfer/CrossChainTransferForm/components/ChainIcon/icons/Parallel.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> --------- Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * chore: release v2.32.2 --------- Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> Co-authored-by: Rui Simão Co-authored-by: ns212 <73105077+ns212@users.noreply.github.com> * [release] Kintsugi 2.32.3 (#1228) * feat: redirect when access from forbidden country is detected (#1209) * Feature/updated transfer UI (#876) * refactor: use updated tab component * refactor: duplicated form titles * refactor: remove redundant hook calls * refactor: prefer title case * wip: XCM transfer form UI * wip: updated form UI * wip: account selector placeholder component * wip: account selector modal * wip: modal open and close actions * wip: update modal type * wip: get accounts * wip: add identicon and rename component for consistency * wip: account input component * fix: remove redundant icons prop * feat: implement with SelectTrigger * wip: styling and account selection value * wip: handle setting account data * refactor: better naming * wip: address list styling * refactor: rename defaultAccount * wip: chain selector placeholder component * wip: duplicate account component and rename * chore: delete redundant legacy component * wip: logic for fetching and rendering chain ids * wip: chain item styling * wip: selected chain styling * chore: add comment * refactor: pass through native token to icon component * feature: add chain icon component * chore: add comment * chore: correct file name casing * refactor: improve folder structure * wip: form layout styling * chore: add arrow icon * chore: add logos and correct svg titles * chore: remove redundant svg prop * chore: rename arrow icon * chore: consistent use of styled components * refactor: remove padding from modal body * wip: formik integration work * wip: extend useXCMBridge to return available chains and utility methods * chore: move Chain and Chains types to types directory * feat: layout and form implementation * feat: add schema * feat: final * wip: refactor useXCMBridge hook * refactor: add endpoints type * refactor: wrap methods in useCallback * refactor: fix bug in hook method * chore: bump bridge version * wip: set originating and destination chain values * refactor: set from chain value on field change * wip: set originating chain value * refactor: mergeProps to set field value * refactor: handle setting origin/destination chain values * wip: get tokens method * wip: first iteration of balances function * wip: handle tokens array * wip: set token value * wip: get token balances * wip: return token and balances in single method * wip: mapped tokens * refactor: handle default chain values * refactor: better organised function order * wip: handle change events * wip: handle setting tokens * wip: handle fetching tokens and balances * wip: convert input configs * wip: handle token change * wip: get token USD price * Trigger Build * chore: remove unused import * chore: correct eslintignore syntax * wip: handle breaking changes * wip: disable token input when select items value is 1 * chore: set first token item as variable * wip: handle setting and changing values * chire: add loading spinner * refactor: add loading state * refactor: filter destination chains * chore: remove console log * chore: bump XCM bridge version * chore: update config * refactor: configure validation * chore: revert change to useForm hook * wip: form validation * wip: working form validation * wip: undefined validation parameters * refactor: return dest fee estimate from bridge hook * feature: show fees and fee estimates * chore: conditional operators * refactor: handle ticker change correctly * wip: sendTransaction method * Revert "wip: sendTransaction method" This reverts commit 3ade26dda26c7cc14f9db9e7c005b66863fa9139. * fix: USD amounts * wip: send transactions * refactor: bump bridge and use getNativeToken method * chore: bump bridge * refactor: move submit logic to useMutation hook * fix: type mismatches * refactor: white space/comments * refactor: add transaction fee validation * chore: typo * chore: remove console log * refactor: remove duplicated monetary conversion * refactor: remove duplicate code * Revert "refactor: remove duplicate code" This reverts commit bd29f8c5661e327c5285d1020c534dab2deae806. * Revert "refactor: remove duplicated monetary conversion" This reverts commit 5fd3d645eb7d8edc00cfe8ced186d4e2432af9fc. * refactor: use monetaryAmount when constructing transaction * refactor: remove duplicated code for fetching tokens * refactor: default XCM origin * Revert "refactor: remove duplicated code for fetching tokens" This reverts commit 8f31ee8667adcd49f5aaebb7db2f205afb5e9725. * chore: remove comment * chore: fix errors * fix: set default value to empty string to prevent React error * refactor: removed unwanted force validation parameters * refactor: remove redundant method * refactor: add method return type * refactor: add method return type * refactor: correct type error * refactor: fix destFee type error * refactor: remove fees validation and revert destFee return value * chore: remove console log * refactor: remove redundant method * refactor: disable validation on change * chore: remove commented out code * wip: use select component for chain selector * fix: handle chain select functions * refactor: type chain id as ChainName * Revert "refactor: type chain id as ChainName" This reverts commit d05e0128cb4b5ac1d00ac07808ebdf9858739165. * chore: remove unused component files * refactor: remove duplicated transaction logic * fix: make to/from field types more specific * fix: revert yup.custom changes and cast validation * fix: set correct destination chain * refator: handle token data * refactor: add use callback * fix: correct rendering logic * fix: update dependencies * chore: delete unused styles * chore: fix merge issue with transfer form * fix: change validation handling * Revert "fix: change validation handling" This reverts commit c0cb3062aad3540b2afad7d375024d872924a62c. * refactor: only display transfer amount if amount has been entered * chore: config changes * chore: add missing icons * chore: Hydra chain icon * fix: add error text to CTA * Tom/xcm fixes (#1213) * refactor: specify endpoints and remove unnecessary logic * fix: save file before committing * fix: disable refetch * chore: update endpoints * chore: remove log * chore: rename file * chore: add additional acala/karura endpoints --------- Co-authored-by: Rui Simão * chore: release v2.32.0 * Update API healthchecks (#778) * Chore - add vault healthcheck * Chore - add vault healthcheck * Chore - add vault healthcheck * [earn strategies] placeholder page, nav and feature flag (#1216) * chore: bump icons dependency * feature: earn strategies placeholder page and feature flag * feat: add useTransaction (#1189) * chore: update monetary to latest 0.7.3 (#1214) * chore: update monetary to latest 0.7.3 * chore: update lib * chore: bump lib and bridge (#1219) * chore: release v2.32.1 * fix: add missing icons and remove erroring RPC (#1222) * fix: add missing icons and remove erroring RPC * Update src/pages/Transfer/CrossChainTransferForm/components/ChainIcon/icons/Acala.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * Update src/pages/Transfer/CrossChainTransferForm/components/ChainIcon/icons/Astar.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * Update src/pages/Transfer/CrossChainTransferForm/components/ChainIcon/icons/Parallel.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> --------- Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * chore: release v2.32.2 * fix: compare input configs with method not operator (#1225) * refactor: reset selected account on account change (#1226) * chore: release v2.32.3 --------- Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> Co-authored-by: Rui Simão Co-authored-by: ns212 <73105077+ns212@users.noreply.github.com> * [release] Kintsugi 2.32.4 (#1232) * feat: redirect when access from forbidden country is detected (#1209) * Feature/updated transfer UI (#876) * refactor: use updated tab component * refactor: duplicated form titles * refactor: remove redundant hook calls * refactor: prefer title case * wip: XCM transfer form UI * wip: updated form UI * wip: account selector placeholder component * wip: account selector modal * wip: modal open and close actions * wip: update modal type * wip: get accounts * wip: add identicon and rename component for consistency * wip: account input component * fix: remove redundant icons prop * feat: implement with SelectTrigger * wip: styling and account selection value * wip: handle setting account data * refactor: better naming * wip: address list styling * refactor: rename defaultAccount * wip: chain selector placeholder component * wip: duplicate account component and rename * chore: delete redundant legacy component * wip: logic for fetching and rendering chain ids * wip: chain item styling * wip: selected chain styling * chore: add comment * refactor: pass through native token to icon component * feature: add chain icon component * chore: add comment * chore: correct file name casing * refactor: improve folder structure * wip: form layout styling * chore: add arrow icon * chore: add logos and correct svg titles * chore: remove redundant svg prop * chore: rename arrow icon * chore: consistent use of styled components * refactor: remove padding from modal body * wip: formik integration work * wip: extend useXCMBridge to return available chains and utility methods * chore: move Chain and Chains types to types directory * feat: layout and form implementation * feat: add schema * feat: final * wip: refactor useXCMBridge hook * refactor: add endpoints type * refactor: wrap methods in useCallback * refactor: fix bug in hook method * chore: bump bridge version * wip: set originating and destination chain values * refactor: set from chain value on field change * wip: set originating chain value * refactor: mergeProps to set field value * refactor: handle setting origin/destination chain values * wip: get tokens method * wip: first iteration of balances function * wip: handle tokens array * wip: set token value * wip: get token balances * wip: return token and balances in single method * wip: mapped tokens * refactor: handle default chain values * refactor: better organised function order * wip: handle change events * wip: handle setting tokens * wip: handle fetching tokens and balances * wip: convert input configs * wip: handle token change * wip: get token USD price * Trigger Build * chore: remove unused import * chore: correct eslintignore syntax * wip: handle breaking changes * wip: disable token input when select items value is 1 * chore: set first token item as variable * wip: handle setting and changing values * chire: add loading spinner * refactor: add loading state * refactor: filter destination chains * chore: remove console log * chore: bump XCM bridge version * chore: update config * refactor: configure validation * chore: revert change to useForm hook * wip: form validation * wip: working form validation * wip: undefined validation parameters * refactor: return dest fee estimate from bridge hook * feature: show fees and fee estimates * chore: conditional operators * refactor: handle ticker change correctly * wip: sendTransaction method * Revert "wip: sendTransaction method" This reverts commit 3ade26dda26c7cc14f9db9e7c005b66863fa9139. * fix: USD amounts * wip: send transactions * refactor: bump bridge and use getNativeToken method * chore: bump bridge * refactor: move submit logic to useMutation hook * fix: type mismatches * refactor: white space/comments * refactor: add transaction fee validation * chore: typo * chore: remove console log * refactor: remove duplicated monetary conversion * refactor: remove duplicate code * Revert "refactor: remove duplicate code" This reverts commit bd29f8c5661e327c5285d1020c534dab2deae806. * Revert "refactor: remove duplicated monetary conversion" This reverts commit 5fd3d645eb7d8edc00cfe8ced186d4e2432af9fc. * refactor: use monetaryAmount when constructing transaction * refactor: remove duplicated code for fetching tokens * refactor: default XCM origin * Revert "refactor: remove duplicated code for fetching tokens" This reverts commit 8f31ee8667adcd49f5aaebb7db2f205afb5e9725. * chore: remove comment * chore: fix errors * fix: set default value to empty string to prevent React error * refactor: removed unwanted force validation parameters * refactor: remove redundant method * refactor: add method return type * refactor: add method return type * refactor: correct type error * refactor: fix destFee type error * refactor: remove fees validation and revert destFee return value * chore: remove console log * refactor: remove redundant method * refactor: disable validation on change * chore: remove commented out code * wip: use select component for chain selector * fix: handle chain select functions * refactor: type chain id as ChainName * Revert "refactor: type chain id as ChainName" This reverts commit d05e0128cb4b5ac1d00ac07808ebdf9858739165. * chore: remove unused component files * refactor: remove duplicated transaction logic * fix: make to/from field types more specific * fix: revert yup.custom changes and cast validation * fix: set correct destination chain * refator: handle token data * refactor: add use callback * fix: correct rendering logic * fix: update dependencies * chore: delete unused styles * chore: fix merge issue with transfer form * fix: change validation handling * Revert "fix: change validation handling" This reverts commit c0cb3062aad3540b2afad7d375024d872924a62c. * refactor: only display transfer amount if amount has been entered * chore: config changes * chore: add missing icons * chore: Hydra chain icon * fix: add error text to CTA * Tom/xcm fixes (#1213) * refactor: specify endpoints and remove unnecessary logic * fix: save file before committing * fix: disable refetch * chore: update endpoints * chore: remove log * chore: rename file * chore: add additional acala/karura endpoints --------- Co-authored-by: Rui Simão * chore: release v2.32.0 * Update API healthchecks (#778) * Chore - add vault healthcheck * Chore - add vault healthcheck * Chore - add vault healthcheck * [earn strategies] placeholder page, nav and feature flag (#1216) * chore: bump icons dependency * feature: earn strategies placeholder page and feature flag * feat: add useTransaction (#1189) * chore: update monetary to latest 0.7.3 (#1214) * chore: update monetary to latest 0.7.3 * chore: update lib * chore: bump lib and bridge (#1219) * chore: release v2.32.1 * fix: add missing icons and remove erroring RPC (#1222) * fix: add missing icons and remove erroring RPC * Update src/pages/Transfer/CrossChainTransferForm/components/ChainIcon/icons/Acala.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * Update src/pages/Transfer/CrossChainTransferForm/components/ChainIcon/icons/Astar.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * Update src/pages/Transfer/CrossChainTransferForm/components/ChainIcon/icons/Parallel.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> --------- Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * chore: release v2.32.2 * fix: compare input configs with method not operator (#1225) * refactor: reset selected account on account change (#1226) * chore: release v2.32.3 * feature: add geoblock feature flag (#1230) * chore: release v2.32.4 --------- Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> Co-authored-by: Rui Simão Co-authored-by: ns212 <73105077+ns212@users.noreply.github.com> * [release] Kintsugi 2.32.5 (#1234) * feat: redirect when access from forbidden country is detected (#1209) * Feature/updated transfer UI (#876) * refactor: use updated tab component * refactor: duplicated form titles * refactor: remove redundant hook calls * refactor: prefer title case * wip: XCM transfer form UI * wip: updated form UI * wip: account selector placeholder component * wip: account selector modal * wip: modal open and close actions * wip: update modal type * wip: get accounts * wip: add identicon and rename component for consistency * wip: account input component * fix: remove redundant icons prop * feat: implement with SelectTrigger * wip: styling and account selection value * wip: handle setting account data * refactor: better naming * wip: address list styling * refactor: rename defaultAccount * wip: chain selector placeholder component * wip: duplicate account component and rename * chore: delete redundant legacy component * wip: logic for fetching and rendering chain ids * wip: chain item styling * wip: selected chain styling * chore: add comment * refactor: pass through native token to icon component * feature: add chain icon component * chore: add comment * chore: correct file name casing * refactor: improve folder structure * wip: form layout styling * chore: add arrow icon * chore: add logos and correct svg titles * chore: remove redundant svg prop * chore: rename arrow icon * chore: consistent use of styled components * refactor: remove padding from modal body * wip: formik integration work * wip: extend useXCMBridge to return available chains and utility methods * chore: move Chain and Chains types to types directory * feat: layout and form implementation * feat: add schema * feat: final * wip: refactor useXCMBridge hook * refactor: add endpoints type * refactor: wrap methods in useCallback * refactor: fix bug in hook method * chore: bump bridge version * wip: set originating and destination chain values * refactor: set from chain value on field change * wip: set originating chain value * refactor: mergeProps to set field value * refactor: handle setting origin/destination chain values * wip: get tokens method * wip: first iteration of balances function * wip: handle tokens array * wip: set token value * wip: get token balances * wip: return token and balances in single method * wip: mapped tokens * refactor: handle default chain values * refactor: better organised function order * wip: handle change events * wip: handle setting tokens * wip: handle fetching tokens and balances * wip: convert input configs * wip: handle token change * wip: get token USD price * Trigger Build * chore: remove unused import * chore: correct eslintignore syntax * wip: handle breaking changes * wip: disable token input when select items value is 1 * chore: set first token item as variable * wip: handle setting and changing values * chire: add loading spinner * refactor: add loading state * refactor: filter destination chains * chore: remove console log * chore: bump XCM bridge version * chore: update config * refactor: configure validation * chore: revert change to useForm hook * wip: form validation * wip: working form validation * wip: undefined validation parameters * refactor: return dest fee estimate from bridge hook * feature: show fees and fee estimates * chore: conditional operators * refactor: handle ticker change correctly * wip: sendTransaction method * Revert "wip: sendTransaction method" This reverts commit 3ade26dda26c7cc14f9db9e7c005b66863fa9139. * fix: USD amounts * wip: send transactions * refactor: bump bridge and use getNativeToken method * chore: bump bridge * refactor: move submit logic to useMutation hook * fix: type mismatches * refactor: white space/comments * refactor: add transaction fee validation * chore: typo * chore: remove console log * refactor: remove duplicated monetary conversion * refactor: remove duplicate code * Revert "refactor: remove duplicate code" This reverts commit bd29f8c5661e327c5285d1020c534dab2deae806. * Revert "refactor: remove duplicated monetary conversion" This reverts commit 5fd3d645eb7d8edc00cfe8ced186d4e2432af9fc. * refactor: use monetaryAmount when constructing transaction * refactor: remove duplicated code for fetching tokens * refactor: default XCM origin * Revert "refactor: remove duplicated code for fetching tokens" This reverts commit 8f31ee8667adcd49f5aaebb7db2f205afb5e9725. * chore: remove comment * chore: fix errors * fix: set default value to empty string to prevent React error * refactor: removed unwanted force validation parameters * refactor: remove redundant method * refactor: add method return type * refactor: add method return type * refactor: correct type error * refactor: fix destFee type error * refactor: remove fees validation and revert destFee return value * chore: remove console log * refactor: remove redundant method * refactor: disable validation on change * chore: remove commented out code * wip: use select component for chain selector * fix: handle chain select functions * refactor: type chain id as ChainName * Revert "refactor: type chain id as ChainName" This reverts commit d05e0128cb4b5ac1d00ac07808ebdf9858739165. * chore: remove unused component files * refactor: remove duplicated transaction logic * fix: make to/from field types more specific * fix: revert yup.custom changes and cast validation * fix: set correct destination chain * refator: handle token data * refactor: add use callback * fix: correct rendering logic * fix: update dependencies * chore: delete unused styles * chore: fix merge issue with transfer form * fix: change validation handling * Revert "fix: change validation handling" This reverts commit c0cb3062aad3540b2afad7d375024d872924a62c. * refactor: only display transfer amount if amount has been entered * chore: config changes * chore: add missing icons * chore: Hydra chain icon * fix: add error text to CTA * Tom/xcm fixes (#1213) * refactor: specify endpoints and remove unnecessary logic * fix: save file before committing * fix: disable refetch * chore: update endpoints * chore: remove log * chore: rename file * chore: add additional acala/karura endpoints --------- Co-authored-by: Rui Simão * chore: release v2.32.0 * Update API healthchecks (#778) * Chore - add vault healthcheck * Chore - add vault healthcheck * Chore - add vault healthcheck * [earn strategies] placeholder page, nav and feature flag (#1216) * chore: bump icons dependency * feature: earn strategies placeholder page and feature flag * feat: add useTransaction (#1189) * chore: update monetary to latest 0.7.3 (#1214) * chore: update monetary to latest 0.7.3 * chore: update lib * chore: bump lib and bridge (#1219) * chore: release v2.32.1 * fix: add missing icons and remove erroring RPC (#1222) * fix: add missing icons and remove erroring RPC * Update src/pages/Transfer/CrossChainTransferForm/components/ChainIcon/icons/Acala.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * Update src/pages/Transfer/CrossChainTransferForm/components/ChainIcon/icons/Astar.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * Update src/pages/Transfer/CrossChainTransferForm/components/ChainIcon/icons/Parallel.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> --------- Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * chore: release v2.32.2 * fix: compare input configs with method not operator (#1225) * refactor: reset selected account on account change (#1226) * chore: release v2.32.3 * feature: add geoblock feature flag (#1230) * chore: release v2.32.4 * chore: bump bridge (#1233) * chore: release v2.32.5 --------- Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> Co-authored-by: Rui Simão Co-authored-by: ns212 <73105077+ns212@users.noreply.github.com> * [release] Kintsugi 2.32.6 (#1249) * feat: redirect when access from forbidden country is detected (#1209) * Feature/updated transfer UI (#876) * refactor: use updated tab component * refactor: duplicated form titles * refactor: remove redundant hook calls * refactor: prefer title case * wip: XCM transfer form UI * wip: updated form UI * wip: account selector placeholder component * wip: account selector modal * wip: modal open and close actions * wip: update modal type * wip: get accounts * wip: add identicon and rename component for consistency * wip: account input component * fix: remove redundant icons prop * feat: implement with SelectTrigger * wip: styling and account selection value * wip: handle setting account data * refactor: better naming * wip: address list styling * refactor: rename defaultAccount * wip: chain selector placeholder component * wip: duplicate account component and rename * chore: delete redundant legacy component * wip: logic for fetching and rendering chain ids * wip: chain item styling * wip: selected chain styling * chore: add comment * refactor: pass through native token to icon component * feature: add chain icon component * chore: add comment * chore: correct file name casing * refactor: improve folder structure * wip: form layout styling * chore: add arrow icon * chore: add logos and correct svg titles * chore: remove redundant svg prop * chore: rename arrow icon * chore: consistent use of styled components * refactor: remove padding from modal body * wip: formik integration work * wip: extend useXCMBridge to return available chains and utility methods * chore: move Chain and Chains types to types directory * feat: layout and form implementation * feat: add schema * feat: final * wip: refactor useXCMBridge hook * refactor: add endpoints type * refactor: wrap methods in useCallback * refactor: fix bug in hook method * chore: bump bridge version * wip: set originating and destination chain values * refactor: set from chain value on field change * wip: set originating chain value * refactor: mergeProps to set field value * refactor: handle setting origin/destination chain values * wip: get tokens method * wip: first iteration of balances function * wip: handle tokens array * wip: set token value * wip: get token balances * wip: return token and balances in single method * wip: mapped tokens * refactor: handle default chain values * refactor: better organised function order * wip: handle change events * wip: handle setting tokens * wip: handle fetching tokens and balances * wip: convert input configs * wip: handle token change * wip: get token USD price * Trigger Build * chore: remove unused import * chore: correct eslintignore syntax * wip: handle breaking changes * wip: disable token input when select items value is 1 * chore: set first token item as variable * wip: handle setting and changing values * chire: add loading spinner * refactor: add loading state * refactor: filter destination chains * chore: remove console log * chore: bump XCM bridge version * chore: update config * refactor: configure validation * chore: revert change to useForm hook * wip: form validation * wip: working form validation * wip: undefined validation parameters * refactor: return dest fee estimate from bridge hook * feature: show fees and fee estimates * chore: conditional operators * refactor: handle ticker change correctly * wip: sendTransaction method * Revert "wip: sendTransaction method" This reverts commit 3ade26dda26c7cc14f9db9e7c005b66863fa9139. * fix: USD amounts * wip: send transactions * refactor: bump bridge and use getNativeToken method * chore: bump bridge * refactor: move submit logic to useMutation hook * fix: type mismatches * refactor: white space/comments * refactor: add transaction fee validation * chore: typo * chore: remove console log * refactor: remove duplicated monetary conversion * refactor: remove duplicate code * Revert "refactor: remove duplicate code" This reverts commit bd29f8c5661e327c5285d1020c534dab2deae806. * Revert "refactor: remove duplicated monetary conversion" This reverts commit 5fd3d645eb7d8edc00cfe8ced186d4e2432af9fc. * refactor: use monetaryAmount when constructing transaction * refactor: remove duplicated code for fetching tokens * refactor: default XCM origin * Revert "refactor: remove duplicated code for fetching tokens" This reverts commit 8f31ee8667adcd49f5aaebb7db2f205afb5e9725. * chore: remove comment * chore: fix errors * fix: set default value to empty string to prevent React error * refactor: removed unwanted force validation parameters * refactor: remove redundant method * refactor: add method return type * refactor: add method return type * refactor: correct type error * refactor: fix destFee type error * refactor: remove fees validation and revert destFee return value * chore: remove console log * refactor: remove redundant method * refactor: disable validation on change * chore: remove commented out code * wip: use select component for chain selector * fix: handle chain select functions * refactor: type chain id as ChainName * Revert "refactor: type chain id as ChainName" This reverts commit d05e0128cb4b5ac1d00ac07808ebdf9858739165. * chore: remove unused component files * refactor: remove duplicated transaction logic * fix: make to/from field types more specific * fix: revert yup.custom changes and cast validation * fix: set correct destination chain * refator: handle token data * refactor: add use callback * fix: correct rendering logic * fix: update dependencies * chore: delete unused styles * chore: fix merge issue with transfer form * fix: change validation handling * Revert "fix: change validation handling" This reverts commit c0cb3062aad3540b2afad7d375024d872924a62c. * refactor: only display transfer amount if amount has been entered * chore: config changes * chore: add missing icons * chore: Hydra chain icon * fix: add error text to CTA * Tom/xcm fixes (#1213) * refactor: specify endpoints and remove unnecessary logic * fix: save file before committing * fix: disable refetch * chore: update endpoints * chore: remove log * chore: rename file * chore: add additional acala/karura endpoints --------- Co-authored-by: Rui Simão * chore: release v2.32.0 * Update API healthchecks (#778) * Chore - add vault healthcheck * Chore - add vault healthcheck * Chore - add vault healthcheck * [earn strategies] placeholder page, nav and feature flag (#1216) * chore: bump icons dependency * feature: earn strategies placeholder page and feature flag * feat: add useTransaction (#1189) * chore: update monetary to latest 0.7.3 (#1214) * chore: update monetary to latest 0.7.3 * chore: update lib * chore: bump lib and bridge (#1219) * chore: release v2.32.1 * fix: add missing icons and remove erroring RPC (#1222) * fix: add missing icons and remove erroring RPC * Update src/pages/Transfer/CrossChainTransferForm/components/ChainIcon/icons/Acala.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * Update src/pages/Transfer/CrossChainTransferForm/components/ChainIcon/icons/Astar.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * Update src/pages/Transfer/CrossChainTransferForm/components/ChainIcon/icons/Parallel.tsx Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> --------- Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> * chore: release v2.32.2 * fix: compare input configs with method not operator (#1225) * refactor: reset selected account on account change (#1226) * chore: release v2.32.3 * feature: add geoblock feature flag (#1230) * chore: release v2.32.4 * chore: bump bridge (#1233) * chore: release v2.32.5 * Peter/earn strategies feat deposit withdraw form (#1229) * chore: update monetary to latest 0.7.3 * wip * feat(earn-strategies): add deposit and withdrawal form components * refactor: add padding under tabs in earn strategy forms * chore(earn-strategies): change file structure * feat: add Popover, Underlay and ProgressBar. Changes to Dialog, Modal and Overlay. (#1236) * fix: Dialog, Modal and Popover (#1245) * chore: rename strategies feature (#1247) * chore: release v2.32.6 --------- Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> Co-authored-by: Rui Simão Co-authored-by: ns212 <73105077+ns212@users.noreply.github.com> * hotffix kintusgi: add percentage conversion (#1255) * fix: add percentage conversion * fix: change loans incentives annualized return to have label APR * [release] Kintsugi 2.33.0 (#1280) * feat: redirect when access from forbidden country is detected (#1209) * Feature/updated transfer UI (#876) * refactor: use updated tab component * refactor: duplicated form titles * refactor: remove redundant hook calls * refactor: prefer title case * wip: XCM transfer form UI * wip: updated form UI * wip: account selector placeholder component * wip: account selector modal * wip: modal open and close actions * wip: update modal type * wip: get accounts * wip: add identicon and rename component for consistency * wip: account input component * fix: remove redundant icons prop * feat: implement with SelectTrigger * wip: styling and account selection value * wip: handle setting account data * refactor: better naming * wip: address list styling * refactor: rename defaultAccount * wip: chain selector placeholder component * wip: duplicate account component and rename * chore: delete redundant legacy component * wip: logic for fetching and rendering chain ids * wip: chain item styling * wip: selected chain styling * chore: add comment * refactor: pass through native token to icon component * feature: add chain icon component * chore: add comment * chore: correct file name casing * refactor: improve folder structure * wip: form layout styling * chore: add arrow icon * chore: add logos and correct svg titles * chore: remove redundant svg prop * chore: rename arrow icon * chore: consistent use of styled components * refactor: remove padding from modal body * wip: formik integration work * wip: extend useXCMBridge to return available chains and utility methods * chore: move Chain and Chains types to types directory * feat: layout and form implementation * feat: add schema * feat: final * wip: refactor useXCMBridge hook * refactor: add endpoints type * refactor: wrap methods in useCallback * refactor: fix bug in hook method * chore: bump bridge version * wip: set originating and destination chain values * refactor: set from chain value on field change * wip: set originating chain value * refactor: mergeProps to set field value * refactor: handle setting origin/destination chain values * wip: get tokens method * wip: first iteration of balances function * wip: handle tokens array * wip: set token value * wip: get token balances * wip: return token and balances in single method * wip: mapped tokens * refactor: han… * Peter/fix staking limit bug (#1515) * chore: update monetary to latest 0.7.3 * fix: use maximum stakable amount fetched from rpc * delete stray comment --------- Co-authored-by: Thomas Jeatt * Revert "Peter/fix staking limit bug (#1515)" This reverts commit a89625963c7fd542a213e04d81bbce6b9e4ae9c1. * chore: release v2.38.0 * fix: use redirect in route (#1533) * Peter/fix q token vaults volumes fetching (#1535) * chore: update monetary to latest 0.7.3 * fix: update vaults dashboard volumes query to include qToken vaults correctly * fix: only add projects with roadmap label (#1536) * fix: use-get-dex-volumes hook (#1534) * fix(SendAndReceive): remove dry-run from xcm (#1540) * fix(Pools): remove ratio customization (#1541) * wip: update resolutions * update resolutions * Revert "update resolutions" This reverts commit 8af4d732aa7a344bdbd7958bd2fa7b7388127acc. * Revert "wip: update resolutions" This reverts commit 3295e63471169206ca1d67b0b0fe9e7a6d053ed3. * Tom/site information component (#1552) * refactor: remove legacy testnet banner component * feature: add site information component * fix: whitespace * chore: update default env variable * refactor: extend main container * refactor: add information component to main container * rename const * refactor: update alert styling * fix: bold link styling * Peter/refactor usd price formatting (#1553) * chore: update monetary to latest 0.7.3 * refactor: show 3 decimal places in usd price if amount is below 1 cent * fix: correct exchange rate (#1555) * fix: correct exchange rate * remove redundant optional chaining * refactor: simplify exchange rate display --------- Co-authored-by: Peter * fix: formatting (#1556) * Peter/fix vault dashboard volumes hook (#1557) * chore: update monetary to latest 0.7.3 * fix: show all collateral currencies on locked collateral card * Peter/strategy feat proxy account (#1539) * chore: update monetary to latest 0.7.3 * feat(strategies): use proxy accounts * wip: write into identity pallet to keep track of strategy-proxy mapping * feat(strategies): use proxy accounts saved into identity pallet * chore: cleanup * refactor: code review * feat: add proxy account deposit field to transaction details, repay on withdraw-all * refactor: code review * chore: remove Karura dwellir node (#1558) * wip: try setting node options in package (#1559) * wip: try setting node options in package * Trigger build * api: add voucher-dot and other tokents (#1566) * chore: release v2.38.1 --------- Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com> Co-authored-by: Rui Simão Co-authored-by: ns212 <73105077+ns212@users.noreply.github.com> Co-authored-by: Chanakya Kilaru Co-authored-by: Peter Co-authored-by: Dominik Harz Co-authored-by: sander2 Co-authored-by: Brendon Votteler Co-authored-by: ns212 --- .env.dev | 4 +- .github/workflows/projects.yml | 2 +- api/market_data.py | 7 +- package.json | 6 +- src/App.tsx | 23 +--- src/assets/locales/en/translation.json | 8 +- src/common/utils/utils.ts | 3 +- src/component-library/Alert/Alert.style.tsx | 4 +- src/component-library/Alert/Alert.tsx | 2 +- src/component-library/utils/format.ts | 3 +- .../MainContainer/MainContainer.tsx | 14 ++- .../SiteInformation/SiteInformation.tsx | 21 ++++ src/components/SiteInformation/index.tsx | 1 + src/components/index.tsx | 1 + .../use-get-account-lending-statistics.tsx | 5 +- .../use-get-account-positions-earnings.tsx | 10 +- .../api/loans/use-get-account-positions.tsx | 41 ++++--- .../loans/use-get-loan-available-amounts.tsx | 6 +- src/hooks/api/use-get-dex-volume.tsx | 10 +- src/hooks/api/xcm/xcm-endpoints.ts | 3 +- src/hooks/transaction/extrinsics/lib.ts | 111 +++++++++++++++++- src/hooks/transaction/types/index.ts | 1 + src/hooks/transaction/types/strategies.ts | 20 +++- src/hooks/transaction/utils/description.ts | 6 +- src/hooks/transaction/utils/fee.ts | 10 +- ...all-cumulative-vault-collateral-volumes.ts | 25 ++++ src/hooks/use-feature-flag.ts | 6 +- src/legacy-components/TestnetBanner/index.tsx | 14 --- src/lib/form/schemas/strategies.ts | 34 +++++- .../cards/OracleStatusCard/index.tsx | 17 ++- .../Home/LockedCollateralsCard/index.tsx | 65 +++------- src/pages/Strategies/Strategy/Strategy.tsx | 5 +- .../StrategyForm/StrategyDepositForm.tsx | 100 ++++++++++++---- .../StrategyFormTransactionFees.tsx | 108 +++++++++++++++++ .../StrategyForm/StrategyWithdrawalForm.tsx | 94 +++++++++++---- .../use-get-strategy-available-amounts.ts | 6 +- .../hooks/use-get-strategy-position.ts | 8 +- .../hooks/use-get-strategy-proxy-account.ts | 92 +++++++++++++++ .../IssueRedeemForm/IssueRedeemForm.tsx | 5 +- ...lative-vault-collateral-volumes-fetcher.ts | 80 +++++++++++++ .../fetchers/cumulative-volumes-fetcher.ts | 39 ++---- src/utils/constants/account.ts | 10 +- src/utils/helpers/extrinsic.ts | 9 ++ 43 files changed, 792 insertions(+), 247 deletions(-) create mode 100644 src/components/SiteInformation/SiteInformation.tsx create mode 100644 src/components/SiteInformation/index.tsx create mode 100644 src/hooks/use-all-cumulative-vault-collateral-volumes.ts delete mode 100644 src/legacy-components/TestnetBanner/index.tsx create mode 100644 src/pages/Strategies/components/StrategyForm/StrategyFormTransactionFees.tsx create mode 100644 src/pages/Strategies/hooks/use-get-strategy-proxy-account.ts create mode 100644 src/services/fetchers/cumulative-vault-collateral-volumes-fetcher.ts create mode 100644 src/utils/helpers/extrinsic.ts diff --git a/.env.dev b/.env.dev index c6f126c259..4508afb933 100644 --- a/.env.dev +++ b/.env.dev @@ -2,7 +2,6 @@ /* FEATURE FLAGS */ REACT_APP_FEATURE_FLAG_STRATEGIES=enabled REACT_APP_FEATURE_FLAG_ONBOARDING=enabled -REACT_APP_FEATURE_FLAG_GLOBAL_WARNING=enabled /* DEVELOPMENT */ @@ -15,6 +14,9 @@ REACT_APP_FAUCET_URL="http://localhost:3035" REACT_APP_RELAY_CHAIN_NAME="kusama" DOCKER_RELAY_CHAIN_CURRENCY="KSM" REACT_APP_MARKET_DATA_URL="https://api.coingecko.com/api/v3/simple/price?vs_currencies=usd" +REACT_APP_SITE_INFORMATION_MESSAGE="This is an informational message that will be shown on every page of the application." +REACT_APP_SITE_INFORMATION_LINK="https://gobob.xyz" + // Kintsugi testnet diff --git a/.github/workflows/projects.yml b/.github/workflows/projects.yml index c9b7209f64..7883a3c60f 100644 --- a/.github/workflows/projects.yml +++ b/.github/workflows/projects.yml @@ -21,4 +21,4 @@ jobs: project-url: https://github.com/orgs/interlay/projects/4 github-token: ${{ secrets.PROJECTS }} label: roadmap - label-operator: OR + label-operator: AND diff --git a/api/market_data.py b/api/market_data.py index 42e5b9698f..6c2c7eeae3 100644 --- a/api/market_data.py +++ b/api/market_data.py @@ -23,7 +23,12 @@ "kintsugi": "/Kintsugi/Token:KINT", "acala-dollar": "/Acala/Token:AUSD", "karura": "/Bifrost/518", - "tether": "/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7" + "tether": "/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7", + "voucher-dot": "/Bifrost-polkadot/2304", + "binancecoin": "/Ethereum/0xB8c77482e45F1F44dE1745F52C74426C631bDD52", + "bnb": "/Ethereum/0xB8c77482e45F1F44dE1745F52C74426C631bDD52", + "tbtc": "/Ethereum/0x18084fbA666a33d37592fA2633fD49a74DD93a88", + "dai": "/Ethereum/0x6B175474E89094C44Da98b954EedeAC495271d0F", } @app.after_request diff --git a/package.json b/package.json index 37a070c783..4bb28ed380 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "interbtc-ui", - "version": "2.38.0", + "version": "2.38.1", "private": true, "dependencies": { "@craco/craco": "^6.1.1", @@ -158,7 +158,7 @@ "@polkadot/util-crypto": "^10.2.4" }, "scripts": { - "start": "craco start", + "start": "NODE_OPTIONS=--openssl-legacy-provider craco start", "start-regtest": "cross-env REACT_APP_BITCOIN_NETWORK=regtest yarn start", "start-testnet": "cross-env REACT_APP_BITCOIN_NETWORK=testnet yarn start", "generate:defs": "ts-node --skip-project node_modules/.bin/polkadot-types-from-defs --package sample-polkadotjs-typegen/interfaces --input ./src/interfaces", @@ -168,7 +168,7 @@ "type-check": "tsc", "format": "yarn prettier --write src", "setup": "yarn generate:defs && yarn generate:meta", - "build": "REACT_APP_VERSION=$npm_package_version craco build", + "build": "NODE_OPTIONS=--openssl-legacy-provider REACT_APP_VERSION=$npm_package_version craco build", "build-with-webpack-bundle-analysis": "yarn build --stats && webpack-bundle-analyzer build/bundle-stats.json -m static -r build/bundle-stats.html -O", "lint-and-type-check": "yarn lint && yarn type-check", "eject": "react-scripts eject", diff --git a/src/App.tsx b/src/App.tsx index 46094ae3bd..84a8e033ab 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,23 +5,20 @@ import * as React from 'react'; import { useErrorHandler, withErrorBoundary } from 'react-error-boundary'; import { useQuery } from 'react-query'; import { useDispatch, useSelector } from 'react-redux'; -import { Route, Switch } from 'react-router-dom'; +import { Redirect, Route, Switch } from 'react-router-dom'; import { isVaultClientLoaded } from '@/common/actions/general.actions'; import { StoreType } from '@/common/types/util.types'; -import { Alert, TextLink } from '@/component-library'; +import { Layout, TransactionModal } from '@/components'; import ErrorFallback from '@/legacy-components/ErrorFallback'; import FullLoadingSpinner from '@/legacy-components/FullLoadingSpinner'; import { useSubstrate, useSubstrateSecureState } from '@/lib/substrate'; import graphqlFetcher, { GRAPHQL_FETCHER, GraphqlReturn } from '@/services/fetchers/graphql-fetcher'; import vaultsByAccountIdQuery from '@/services/queries/vaults-by-accountId-query'; -import { BitcoinNetwork } from '@/types/bitcoin'; import { PAGES } from '@/utils/constants/links'; -import { Layout, TransactionModal } from './components'; import * as constants from './constants'; import { FeatureFlags, useFeatureFlag } from './hooks/use-feature-flag'; -import TestnetBanner from './legacy-components/TestnetBanner'; const BTC = React.lazy(() => import(/* webpackChunkName: 'btc' */ '@/pages/BTC')); const Strategies = React.lazy(() => import(/* webpackChunkName: 'strategies' */ '@/pages/Strategies')); @@ -49,7 +46,6 @@ const App = (): JSX.Element => { const dispatch = useDispatch(); const isStrategiesEnabled = useFeatureFlag(FeatureFlags.STRATEGIES); const isOnboardingEnabled = useFeatureFlag(FeatureFlags.ONBOARDING); - const isGlobalWarningEnabled = useFeatureFlag(FeatureFlags.GLOBAL_WARNING); // Detects if the connected account is a vault operator const { error: vaultsError } = useQuery, Error>( @@ -82,16 +78,6 @@ const App = (): JSX.Element => { return ( - {isGlobalWarningEnabled && ( - - Kusama parachains, including Kintsugi, have stopped producing blocks due to{' '} - - an ongoing issue on Kusama - - . The relay chain is continuing to produce blocks as per normal. - - )} - {process.env.REACT_APP_BITCOIN_NETWORK === BitcoinNetwork.Testnet && } ( }> @@ -130,7 +116,7 @@ const App = (): JSX.Element => { - + {isStrategiesEnabled && ( @@ -151,6 +137,9 @@ const App = (): JSX.Element => { + + + diff --git a/src/assets/locales/en/translation.json b/src/assets/locales/en/translation.json index 9d245c5770..d20252b086 100644 --- a/src/assets/locales/en/translation.json +++ b/src/assets/locales/en/translation.json @@ -667,7 +667,8 @@ }, "strategy": { "withdraw_rewards_in_wrapped": "Withdraw rewards in {{wrappedCurrencySymbol}}:", - "update_position": "Update position" + "update_position": "Update position", + "initialize": "Initialize strategy" }, "transaction": { "recent_transactions": "Recent transactions", @@ -779,6 +780,9 @@ "low_risk_approach_generate_passive_income": "Discover a straightforward and low-risk approach to generate passive income. This strategy lends out deposited {{ticker}} to borrowers, allowing you to earn interest effortlessly", "how_does_it_work": "How does it work?", "what_are_the_risk": "What are the risks?", - "discover_fundamental_origins": "Discover the fundamental origins of the position, potential risks involved, the allocation of your capital, and other pertinent details in the docs section." + "discover_fundamental_origins": "Discover the fundamental origins of the position, potential risks involved, the allocation of your capital, and other pertinent details in the docs section.", + "proxy_deposit": "{{currency}} Proxy Deposit", + "proxy_deposit_tooltip": "This amount will be locked while the strategy is active. When you fully exit strategy deposit will be returned.", + "proxy_deposit_insufficient_funds": "Insufficient funds: 26 {{currency}} is required for proxy deposit locking." } } diff --git a/src/common/utils/utils.ts b/src/common/utils/utils.ts index 37bd09e264..693636ce3f 100644 --- a/src/common/utils/utils.ts +++ b/src/common/utils/utils.ts @@ -78,7 +78,8 @@ const formatUSD = (amount: number, options?: { compact?: boolean }): string => { const { format } = new Intl.NumberFormat(undefined, { style: 'currency', currency: 'USD', - notation: options?.compact ? getFormatUSDNotation(amount) : undefined + notation: options?.compact ? getFormatUSDNotation(amount) : undefined, + minimumFractionDigits: amount > 0 && amount < 0.01 ? 3 : undefined }); return format(amount); diff --git a/src/component-library/Alert/Alert.style.tsx b/src/component-library/Alert/Alert.style.tsx index 01f03865af..2940f4b8b6 100644 --- a/src/component-library/Alert/Alert.style.tsx +++ b/src/component-library/Alert/Alert.style.tsx @@ -12,14 +12,14 @@ interface StyledAlertProps { const StyledAlert = styled(Flex)` padding: ${theme.spacing.spacing2}; - color: ${({ $status }) => theme.alert.status[$status]}; border: 1px solid ${({ $status }) => theme.alert.status[$status]}; background-color: ${({ $status }) => theme.alert.bg[$status]}; border-radius: ${theme.rounded.md}; font-size: ${theme.text.xs}; `; -const StyledWarningIcon = styled(WarningIcon)` +const StyledWarningIcon = styled(WarningIcon)` + color: ${({ $status }) => theme.alert.status[$status]}; width: ${theme.spacing.spacing5}; height: ${theme.spacing.spacing5}; flex-shrink: 0; diff --git a/src/component-library/Alert/Alert.tsx b/src/component-library/Alert/Alert.tsx index 2b58cfecf6..aac2b7c679 100644 --- a/src/component-library/Alert/Alert.tsx +++ b/src/component-library/Alert/Alert.tsx @@ -12,7 +12,7 @@ type AlertProps = Props & InheritAttrs; const Alert = ({ status = 'success', children, ...props }: AlertProps): JSX.Element => ( - +
{children}
); diff --git a/src/component-library/utils/format.ts b/src/component-library/utils/format.ts index 8f520ada3f..505d55414b 100644 --- a/src/component-library/utils/format.ts +++ b/src/component-library/utils/format.ts @@ -8,7 +8,8 @@ const formatUSD = (amount: number, options?: { compact?: boolean }): string => { const { format } = new Intl.NumberFormat(undefined, { style: 'currency', currency: 'USD', - notation: options?.compact ? getFormatUSDNotation(amount) : undefined + notation: options?.compact ? getFormatUSDNotation(amount) : undefined, + minimumFractionDigits: amount > 0 && amount < 0.01 ? 3 : undefined }); return format(amount); diff --git a/src/components/MainContainer/MainContainer.tsx b/src/components/MainContainer/MainContainer.tsx index d32ae26b10..773a413f72 100644 --- a/src/components/MainContainer/MainContainer.tsx +++ b/src/components/MainContainer/MainContainer.tsx @@ -1,11 +1,19 @@ import { FlexProps } from '@/component-library'; +import { SiteInformation } from '@/components'; import { StyledContainer } from './MainContainer.styles'; type MainContainerProps = FlexProps; -const MainContainer = ({ direction = 'column', gap = 'spacing8', ...props }: MainContainerProps): JSX.Element => ( - -); +const MainContainer = ({ direction = 'column', gap = 'spacing8', ...props }: MainContainerProps): JSX.Element => { + const showSiteInformationMessage = !!process.env.REACT_APP_SITE_INFORMATION_MESSAGE; + + return ( + + {showSiteInformationMessage && } + {props.children} + + ); +}; export { MainContainer }; diff --git a/src/components/SiteInformation/SiteInformation.tsx b/src/components/SiteInformation/SiteInformation.tsx new file mode 100644 index 0000000000..6610025083 --- /dev/null +++ b/src/components/SiteInformation/SiteInformation.tsx @@ -0,0 +1,21 @@ +import { Alert, TextLink } from '@/component-library'; + +const SiteInformation = (): JSX.Element => { + const hasLink = !!process.env.REACT_APP_SITE_INFORMATION_LINK; + + return ( + + {process.env.REACT_APP_SITE_INFORMATION_MESSAGE} + {hasLink && ( + <> + {' '} + + More information + + + )} + + ); +}; + +export { SiteInformation }; diff --git a/src/components/SiteInformation/index.tsx b/src/components/SiteInformation/index.tsx new file mode 100644 index 0000000000..a614215aa9 --- /dev/null +++ b/src/components/SiteInformation/index.tsx @@ -0,0 +1 @@ +export { SiteInformation } from './SiteInformation'; diff --git a/src/components/index.tsx b/src/components/index.tsx index 6069e639c8..800c588f63 100644 --- a/src/components/index.tsx +++ b/src/components/index.tsx @@ -27,6 +27,7 @@ export { PlusDivider } from './PlusDivider'; export type { PoolsTableProps } from './PoolsTable'; export { PoolsTable } from './PoolsTable'; export { ReceivableAssets } from './ReceivableAssets'; +export { SiteInformation } from './SiteInformation'; export type { SlippageManagerProps } from './SlippageManager'; export { SlippageManager } from './SlippageManager'; export type { ToastContainerProps } from './ToastContainer'; diff --git a/src/hooks/api/loans/use-get-account-lending-statistics.tsx b/src/hooks/api/loans/use-get-account-lending-statistics.tsx index 88d750d77f..b56c5cce1a 100644 --- a/src/hooks/api/loans/use-get-account-lending-statistics.tsx +++ b/src/hooks/api/loans/use-get-account-lending-statistics.tsx @@ -1,4 +1,5 @@ import { TickerToData } from '@interlay/interbtc-api'; +import { AccountId } from '@polkadot/types/interfaces'; import Big from 'big.js'; import { useMemo } from 'react'; @@ -92,11 +93,11 @@ const getAccountPositionsStats = ( }; }; -const useGetAccountLendingStatistics = (): UseGetAccountLendingStatistics => { +const useGetAccountLendingStatistics = (proxyAccount?: AccountId): UseGetAccountLendingStatistics => { const { data: { lendPositions, borrowPositions }, refetch: positionsRefetch - } = useGetAccountPositions(); + } = useGetAccountPositions(proxyAccount); const { data: loanAssets, refetch: loanAssetsRefetch } = useGetLoanAssets(); const prices = useGetPrices(); diff --git a/src/hooks/api/loans/use-get-account-positions-earnings.tsx b/src/hooks/api/loans/use-get-account-positions-earnings.tsx index fe59c2173d..66fffb92a1 100644 --- a/src/hooks/api/loans/use-get-account-positions-earnings.tsx +++ b/src/hooks/api/loans/use-get-account-positions-earnings.tsx @@ -1,5 +1,6 @@ import { CurrencyExt, newMonetaryAmount, TickerToData } from '@interlay/interbtc-api'; import { MonetaryAmount } from '@interlay/monetary-js'; +import { AccountId } from '@polkadot/types/interfaces'; import Big from 'big.js'; import { gql, GraphQLClient } from 'graphql-request'; import { useCallback } from 'react'; @@ -68,12 +69,15 @@ type UseGetAccountPositionsEarningsResult = { }; const useGetAccountPositionsEarnings = ( - lendPositions: CollateralPosition[] | undefined + lendPositions: CollateralPosition[] | undefined, + proxyAccount?: AccountId ): UseGetAccountPositionsEarningsResult => { - const { account } = useWallet(); + const { account: primaryAccount } = useWallet(); + + const account = proxyAccount || primaryAccount; const { refetch, isLoading, data, error } = useQuery({ - queryKey: ['loan-earnings', account], + queryKey: ['loan-earnings', account, proxyAccount], queryFn: () => lendPositions && account && getEarnedAmountByTicker(account.toString(), lendPositions), enabled: !!lendPositions && !!account, refetchOnWindowFocus: false, diff --git a/src/hooks/api/loans/use-get-account-positions.tsx b/src/hooks/api/loans/use-get-account-positions.tsx index 6b745db598..895d1425fd 100644 --- a/src/hooks/api/loans/use-get-account-positions.tsx +++ b/src/hooks/api/loans/use-get-account-positions.tsx @@ -4,10 +4,10 @@ import { useCallback } from 'react'; import { useErrorHandler } from 'react-error-boundary'; import { useQuery } from 'react-query'; +import { useWallet } from '@/hooks/use-wallet'; import { BorrowPosition, CollateralPosition } from '@/types/loans'; import { BLOCKTIME_REFETCH_INTERVAL } from '@/utils/constants/api'; -import useAccountId from '../../use-account-id'; import { useGetAccountPositionsEarnings } from './use-get-account-positions-earnings'; const getLendPositionsOfAccount = async (accountId: AccountId): Promise> => @@ -19,13 +19,15 @@ interface UseGetLendPositionsOfAccountResult { refetch: () => void; } -const useGetLendPositionsOfAccount = (): UseGetLendPositionsOfAccountResult => { - const accountId = useAccountId(); +const useGetLendPositionsOfAccount = (proxyAccount?: AccountId): UseGetLendPositionsOfAccountResult => { + const { account: primaryAccount } = useWallet(); + + const account = proxyAccount || primaryAccount; const { data, error, refetch, isLoading } = useQuery({ - queryKey: ['getLendPositionsOfAccount', accountId], - queryFn: () => accountId && getLendPositionsOfAccount(accountId), - enabled: !!accountId, + queryKey: ['getLendPositionsOfAccount', account?.toString(), proxyAccount], + queryFn: () => account && getLendPositionsOfAccount(account), + enabled: !!account, refetchInterval: BLOCKTIME_REFETCH_INTERVAL }); @@ -40,19 +42,15 @@ interface UseGetBorrowPositionsOfAccountResult { refetch: () => void; } -const useGetBorrowPositionsOfAccount = (): UseGetBorrowPositionsOfAccountResult => { - const accountId = useAccountId(); +const useGetBorrowPositionsOfAccount = (proxyAccount?: AccountId): UseGetBorrowPositionsOfAccountResult => { + const { account: primaryAccount } = useWallet(); - const { data, error, refetch, isLoading } = useQuery({ - queryKey: ['getBorrowPositionsOfAccount', accountId], - queryFn: async () => { - if (!accountId) { - throw new Error('Something went wrong!'); - } + const account = proxyAccount || primaryAccount; - return await window.bridge.loans.getBorrowPositionsOfAccount(accountId); - }, - enabled: !!accountId, + const { data, error, refetch, isLoading } = useQuery({ + queryKey: ['getBorrowPositionsOfAccount', account?.toString()], + queryFn: () => account && window.bridge.loans.getBorrowPositionsOfAccount(account), + enabled: !!account, refetchInterval: BLOCKTIME_REFETCH_INTERVAL }); @@ -76,21 +74,22 @@ type UseGetAccountPositionsResult = { refetch: () => void; }; -const useGetAccountPositions = (): UseGetAccountPositionsResult => { +const useGetAccountPositions = (proxyAccount?: AccountId): UseGetAccountPositionsResult => { const { data: lendPositionsWithoutEarnings, isLoading: isLendPositionsLoading, refetch: lendPositionsRefetch - } = useGetLendPositionsOfAccount(); + } = useGetLendPositionsOfAccount(proxyAccount); const { data: borrowPositions, isLoading: isBorrowPositionsLoading, refetch: borrowPositionsRefetch - } = useGetBorrowPositionsOfAccount(); + } = useGetBorrowPositionsOfAccount(proxyAccount); const { getPositionEarnings, isLoading: isAccountEarningsLoading } = useGetAccountPositionsEarnings( - lendPositionsWithoutEarnings + lendPositionsWithoutEarnings, + proxyAccount ); const lendPositions: CollateralPosition[] | undefined = lendPositionsWithoutEarnings?.map((position) => ({ diff --git a/src/hooks/api/loans/use-get-loan-available-amounts.tsx b/src/hooks/api/loans/use-get-loan-available-amounts.tsx index a35a261b19..5457668bb6 100644 --- a/src/hooks/api/loans/use-get-loan-available-amounts.tsx +++ b/src/hooks/api/loans/use-get-loan-available-amounts.tsx @@ -1,5 +1,6 @@ import { CurrencyExt, newMonetaryAmount } from '@interlay/interbtc-api'; import { MonetaryAmount } from '@interlay/monetary-js'; +import { AccountId } from '@polkadot/types/interfaces'; import { useCallback } from 'react'; import { useGetAccountLendingStatistics } from '@/hooks/api/loans/use-get-account-lending-statistics'; @@ -138,10 +139,11 @@ type UseGetLoanAvailableAmountsResult = { const useGetLoanAvailableAmounts = ( action: BorrowAction | LendAction, asset: LoanAsset, - position?: CollateralPosition | BorrowPosition + position?: CollateralPosition | BorrowPosition, + proxyAccount?: AccountId | undefined ): UseGetLoanAvailableAmountsResult => { const { getAvailableBalance } = useGetBalances(); - const { data: statistics } = useGetAccountLendingStatistics(); + const { data: statistics } = useGetAccountLendingStatistics(proxyAccount); const maxCalculatedAmount = getMaxCalculatedAmount(action, asset, position, statistics); diff --git a/src/hooks/api/use-get-dex-volume.tsx b/src/hooks/api/use-get-dex-volume.tsx index 82ce60870b..4d494d20f3 100644 --- a/src/hooks/api/use-get-dex-volume.tsx +++ b/src/hooks/api/use-get-dex-volume.tsx @@ -57,7 +57,11 @@ const GET_DEX_VOLUMES = gql` ...AmountFields } } - endVolumes: cumulativeDexTradingVolumes(limit: 1, orderBy: tillTimestamp_DESC, where: { tillTimestamp_lte: $end }) { + endVolumes: cumulativeDexTradingVolumes( + limit: 1 + orderBy: tillTimestamp_DESC + where: { tillTimestamp_lte: $end, tillTimestamp_gte: $start } + ) { tillTimestamp amounts { ...AmountFields @@ -95,6 +99,10 @@ const useGetDexVolumes = (range: DateRangeVolume): UseGetCurrenciesResult => { const data = await graphQLClient.request(GET_DEX_VOLUMES, { start, end }); + if (!data.startVolumes.length || !data.endVolumes.length) { + return {}; + } + const [startVolumes] = data.startVolumes; const [endVolumes] = data.endVolumes; diff --git a/src/hooks/api/xcm/xcm-endpoints.ts b/src/hooks/api/xcm/xcm-endpoints.ts index 73fbbe80c7..7f40bd7a80 100644 --- a/src/hooks/api/xcm/xcm-endpoints.ts +++ b/src/hooks/api/xcm/xcm-endpoints.ts @@ -13,8 +13,7 @@ const XCMEndpoints: XCMEndpointsRecord = { 'wss://karura-rpc-0.aca-api.network', 'wss://karura-rpc-1.aca-api.network', 'wss://karura-rpc-2.aca-api.network/ws', - 'wss://karura-rpc-3.aca-api.network/ws', - 'wss://karura-rpc.dwellir.com' + 'wss://karura-rpc-3.aca-api.network/ws' ], kintsugi: ['wss://api-kusama.interlay.io/parachain'], kusama: ['wss://kusama-rpc.polkadot.io', 'wss://kusama-rpc.dwellir.com'], diff --git a/src/hooks/transaction/extrinsics/lib.ts b/src/hooks/transaction/extrinsics/lib.ts index 04950ac7a6..4e8d09ad4f 100644 --- a/src/hooks/transaction/extrinsics/lib.ts +++ b/src/hooks/transaction/extrinsics/lib.ts @@ -1,5 +1,8 @@ import { ExtrinsicData } from '@interlay/interbtc-api'; +import { DEFAULT_PROXY_ACCOUNT_AMOUNT, PROXY_ACCOUNT_RESERVE_AMOUNT } from '@/utils/constants/account'; +import { proxifyExtrinsic } from '@/utils/helpers/extrinsic'; + import { LibActions, Transaction } from '../types'; const getLibExtrinsic = async (params: LibActions): Promise => { @@ -67,13 +70,109 @@ const getLibExtrinsic = async (params: LibActions): Promise => { /* END - LOANS */ /* START - STRATEGIES */ - case Transaction.STRATEGIES_DEPOSIT: - return window.bridge.loans.lend(...params.args); - case Transaction.STRATEGIES_WITHDRAW: - return window.bridge.loans.withdraw(...params.args); + case Transaction.STRATEGIES_INITIALIZE_PROXY: { + // Initialize 10 proxy accounts and then if we deposit for the first time, the proxy + // account will be assigned and stored in identity pallet. + const createProxiesExtrinsics = [...Array(DEFAULT_PROXY_ACCOUNT_AMOUNT).keys()].map((index) => + window.bridge.api.tx.proxy.createPure('Any', 0, index) + ); + const batchedExtrinsics = window.bridge.transaction.buildBatchExtrinsic(createProxiesExtrinsics); + + return { extrinsic: batchedExtrinsics }; + } + // Since we use proxy accounts for strategies, first argument is always proxy account for which + // the action should be performed - this account must be passed. + // Second argument is always boolean denoting if the proxy account identity was set or not. + case Transaction.STRATEGIES_DEPOSIT: { + const [strategyType, proxyAccount, isIdentitySet, ...args] = params.args; + const [, depositAmount] = args; + + const transferExtrinsic = window.bridge.tokens.transfer(proxyAccount.toString(), depositAmount); + + const strategyDepositExtrinsic = (await window.bridge.loans.lend(...args)).extrinsic; + const proxiedStrategyDepositExtrinsic = proxifyExtrinsic(proxyAccount, strategyDepositExtrinsic); + + if (isIdentitySet) { + const batchedExtrinsics = window.bridge.transaction.buildBatchExtrinsic([ + transferExtrinsic.extrinsic, + proxiedStrategyDepositExtrinsic + ]); + + return { extrinsic: batchedExtrinsics }; + } else { + const identityLockAmountTransferExtrinsic = window.bridge.tokens.transfer( + proxyAccount.toString(), + PROXY_ACCOUNT_RESERVE_AMOUNT + ); + const strategyAccountIdentity = { + additional: [[{ Raw: 'strategyType' }, { Raw: strategyType }]] + }; + const setIdentityExtrinsic = window.bridge.api.tx.identity.setIdentity(strategyAccountIdentity); + const proxiedSetIdentityExtrinsic = proxifyExtrinsic(proxyAccount, setIdentityExtrinsic); + + const batchedExtrinsicsWithIdentity = window.bridge.transaction.buildBatchExtrinsic([ + identityLockAmountTransferExtrinsic.extrinsic, + proxiedSetIdentityExtrinsic, + transferExtrinsic.extrinsic, + proxiedStrategyDepositExtrinsic + ]); + + return { extrinsic: batchedExtrinsicsWithIdentity }; + } + } + + case Transaction.STRATEGIES_WITHDRAW: { + const primaryAccount = window.bridge.account; + if (!primaryAccount) { + throw new Error('Strategy primary account not found.'); + } + + const [, proxyAccount, ...args] = params.args; + const [, withdrawalAmount] = args; + + const strategyWithdrawalExtrinsic = (await window.bridge.loans.withdraw(...args)).extrinsic; + const proxiedStrategyWithdrawExtrinsic = proxifyExtrinsic(proxyAccount, strategyWithdrawalExtrinsic); + + const transferExtrinsic = window.bridge.tokens.transfer(primaryAccount.toString(), withdrawalAmount).extrinsic; + const proxiedTransferExtrinsic = proxifyExtrinsic(proxyAccount, transferExtrinsic); + + const batchExtrinsic = window.bridge.transaction.buildBatchExtrinsic([ + proxiedStrategyWithdrawExtrinsic, + proxiedTransferExtrinsic + ]); + + return { extrinsic: batchExtrinsic }; + } + case Transaction.STRATEGIES_ALL_WITHDRAW: { - const [underlyingCurrency] = params.args; - return window.bridge.loans.withdrawAll(underlyingCurrency); + const primaryAccount = window.bridge.account; + if (!primaryAccount) { + throw new Error('Primary account not found.'); + } + + const [, proxyAccount, underlyingCurrency, withdrawalAmount] = params.args; + + const clearIdentityExtrinsic = window.bridge.api.tx.identity.clearIdentity(); + + const transferIdentityReserveAmount = window.bridge.tokens.transfer( + primaryAccount.toString(), + PROXY_ACCOUNT_RESERVE_AMOUNT + ).extrinsic; + + const strategyWithdrawalExtrinsic = (await window.bridge.loans.withdrawAll(underlyingCurrency)).extrinsic; + + const transferExtrinsic = window.bridge.tokens.transfer(primaryAccount.toString(), withdrawalAmount).extrinsic; + + const batchExtrinsic = window.bridge.transaction.buildBatchExtrinsic([ + clearIdentityExtrinsic, + transferIdentityReserveAmount, + strategyWithdrawalExtrinsic, + transferExtrinsic + ]); + + const proxiedBatchExtrinsic = proxifyExtrinsic(proxyAccount, batchExtrinsic); + + return { extrinsic: proxiedBatchExtrinsic }; } /* END - STRATEGIES */ diff --git a/src/hooks/transaction/types/index.ts b/src/hooks/transaction/types/index.ts index cbacc3a1a9..0e755769c3 100644 --- a/src/hooks/transaction/types/index.ts +++ b/src/hooks/transaction/types/index.ts @@ -51,6 +51,7 @@ enum Transaction { LOANS_REPAY = 'LOANS_REPAY', LOANS_REPAY_ALL = 'LOANS_REPAY_ALL', // Stategies + STRATEGIES_INITIALIZE_PROXY = 'STRATEGIES_INITIALIZE_PROXY', STRATEGIES_DEPOSIT = 'STRATEGIES_DEPOSIT', STRATEGIES_WITHDRAW = 'STRATEGIES_WITHDRAW', STRATEGIES_ALL_WITHDRAW = 'STRATEGIES_ALL_WITHDRAW', diff --git a/src/hooks/transaction/types/strategies.ts b/src/hooks/transaction/types/strategies.ts index aaf0703b4b..be8319c512 100644 --- a/src/hooks/transaction/types/strategies.ts +++ b/src/hooks/transaction/types/strategies.ts @@ -1,22 +1,34 @@ import { InterBtcApi } from '@interlay/interbtc-api'; +import { AccountId } from '@polkadot/types/interfaces'; + +import { StrategyType } from '@/pages/Strategies/types'; import { Transaction } from '.'; +interface StrategiesInitializeProxyAction { + type: Transaction.STRATEGIES_INITIALIZE_PROXY; + args: [StrategyType]; +} + interface StrategiesDepositAction { type: Transaction.STRATEGIES_DEPOSIT; - args: Parameters; + args: [StrategyType, AccountId, boolean, ...Parameters]; } interface StrategiesWithdrawAction { type: Transaction.STRATEGIES_WITHDRAW; - args: Parameters; + args: [StrategyType, AccountId, ...Parameters]; } interface StrategiesWithdrawAllAction { type: Transaction.STRATEGIES_ALL_WITHDRAW; - args: Parameters; + args: [StrategyType, AccountId, ...Parameters]; } -type StrategiesActions = StrategiesDepositAction | StrategiesWithdrawAction | StrategiesWithdrawAllAction; +type StrategiesActions = + | StrategiesInitializeProxyAction + | StrategiesDepositAction + | StrategiesWithdrawAction + | StrategiesWithdrawAllAction; export type { StrategiesActions }; diff --git a/src/hooks/transaction/utils/description.ts b/src/hooks/transaction/utils/description.ts index 8aebc07828..d2f5ffb5ed 100644 --- a/src/hooks/transaction/utils/description.ts +++ b/src/hooks/transaction/utils/description.ts @@ -251,7 +251,7 @@ const getTranslationArgs = ( /* START - STRATEGIES */ case Transaction.STRATEGIES_DEPOSIT: { - const [currency, amount] = params.args; + const [, , , currency, amount] = params.args; return { key: isPast ? 'transaction.deposited_amount' : 'transaction.depositing_amount', @@ -262,7 +262,7 @@ const getTranslationArgs = ( }; } case Transaction.STRATEGIES_WITHDRAW: { - const [currency, amount] = params.args; + const [, , currency, amount] = params.args; return { key: isPast ? 'transaction.withdrew_amount' : 'transaction.withdrawing_amount', @@ -273,7 +273,7 @@ const getTranslationArgs = ( }; } case Transaction.STRATEGIES_ALL_WITHDRAW: { - const [currency] = params.args; + const [, , currency] = params.args; return { key: isPast ? 'transaction.withdrew' : 'transaction.withdrawing', diff --git a/src/hooks/transaction/utils/fee.ts b/src/hooks/transaction/utils/fee.ts index c68ea72701..fdb3e311e8 100644 --- a/src/hooks/transaction/utils/fee.ts +++ b/src/hooks/transaction/utils/fee.ts @@ -12,6 +12,7 @@ import { MonetaryAmount } from '@interlay/monetary-js'; import { SubmittableExtrinsic } from '@polkadot/api/types'; import { GOVERNANCE_TOKEN } from '@/config/relay-chains'; +import { PROXY_ACCOUNT_RESERVE_AMOUNT } from '@/utils/constants/account'; import { getExtrinsic } from '../extrinsics'; import { Actions, Transaction } from '../types'; @@ -62,6 +63,7 @@ const getTxFeeSwapData = async ( reverseDirectionTrade.outputAmount.toString(true), baseExtrinsic ); + const withSwapTxFee = await window.bridge.transaction.getFeeEstimate(reverseDirectionExtrinsic); const { inputAmount, path } = getOptimalTradeForTxFeeSwap( withSwapTxFee.mul(OUTPUT_AMOUNT_SAFE_OFFSET_MULTIPLIER), @@ -158,8 +160,11 @@ const getAmount = (params: Actions): MonetaryAmount[] | undefined = } /* END - LOANS */ case Transaction.STRATEGIES_DEPOSIT: { - const [, amount] = params.args; - return [amount]; + const [, , isIdentitySet, , amount] = params.args; + if (isIdentitySet) { + return [amount]; + } + return [amount, PROXY_ACCOUNT_RESERVE_AMOUNT]; } case Transaction.VAULTS_REGISTER_NEW_COLLATERAL: { const [amount] = params.args; @@ -177,6 +182,7 @@ const getAmount = (params: Actions): MonetaryAmount[] | undefined = case Transaction.LOANS_DISABLE_COLLATERAL: case Transaction.STRATEGIES_ALL_WITHDRAW: case Transaction.STRATEGIES_WITHDRAW: + case Transaction.STRATEGIES_INITIALIZE_PROXY: case Transaction.AMM_CLAIM_REWARDS: return undefined; } diff --git a/src/hooks/use-all-cumulative-vault-collateral-volumes.ts b/src/hooks/use-all-cumulative-vault-collateral-volumes.ts new file mode 100644 index 0000000000..993a3725fe --- /dev/null +++ b/src/hooks/use-all-cumulative-vault-collateral-volumes.ts @@ -0,0 +1,25 @@ +import { TickerToData } from '@interlay/interbtc-api'; +import { useQuery, UseQueryResult } from 'react-query'; + +import cumulativeVaultCollateralVolumesFetcher, { + CUMULATIVE_VAULT_COLLATERALVOLUMES_FETCHER +} from '@/services/fetchers/cumulative-vault-collateral-volumes-fetcher'; +import { VolumeDataPoint } from '@/services/fetchers/cumulative-volumes-fetcher'; + +import { useGetCollateralCurrencies } from './api/use-get-collateral-currencies'; + +const useAllCumulativeVaultCollateralVolumes = ( + cutoffTimestamps: Array +): UseQueryResult>, Error> => { + const { data: collateralCurrencies } = useGetCollateralCurrencies(true); + + return useQuery>, Error>( + [CUMULATIVE_VAULT_COLLATERALVOLUMES_FETCHER, cutoffTimestamps, collateralCurrencies], + cumulativeVaultCollateralVolumesFetcher, + { + enabled: !!collateralCurrencies + } + ); +}; + +export default useAllCumulativeVaultCollateralVolumes; diff --git a/src/hooks/use-feature-flag.ts b/src/hooks/use-feature-flag.ts index bb3ca981b5..c5d356ac2c 100644 --- a/src/hooks/use-feature-flag.ts +++ b/src/hooks/use-feature-flag.ts @@ -1,15 +1,13 @@ enum FeatureFlags { STRATEGIES = 'strategies', GEOBLOCK = 'geoblock', - ONBOARDING = 'onboarding', - GLOBAL_WARNING = 'global_warning' + ONBOARDING = 'onboarding' } const featureFlags: Record = { [FeatureFlags.STRATEGIES]: process.env.REACT_APP_FEATURE_FLAG_STRATEGIES, [FeatureFlags.GEOBLOCK]: process.env.REACT_APP_FEATURE_FLAG_GEOBLOCK, - [FeatureFlags.ONBOARDING]: process.env.REACT_APP_FEATURE_FLAG_ONBOARDING, - [FeatureFlags.GLOBAL_WARNING]: process.env.REACT_APP_FEATURE_FLAG_GLOBAL_WARNING + [FeatureFlags.ONBOARDING]: process.env.REACT_APP_FEATURE_FLAG_ONBOARDING }; const useFeatureFlag = (feature: FeatureFlags): boolean => featureFlags[feature] === 'enabled'; diff --git a/src/legacy-components/TestnetBanner/index.tsx b/src/legacy-components/TestnetBanner/index.tsx deleted file mode 100644 index abd3c37836..0000000000 --- a/src/legacy-components/TestnetBanner/index.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import clsx from 'clsx'; - -import WarningBanner from '../WarningBanner'; - -const TestnetBanner = (): JSX.Element => ( - -

- Thanks for trying out the testnet! The testnet might be reset at any point to make sure we can get the latest - version of our software to you. -

-
-); - -export default TestnetBanner; diff --git a/src/lib/form/schemas/strategies.ts b/src/lib/form/schemas/strategies.ts index 324546a18e..8bfe5e2faf 100644 --- a/src/lib/form/schemas/strategies.ts +++ b/src/lib/form/schemas/strategies.ts @@ -1,3 +1,10 @@ +import { CurrencyExt, newMonetaryAmount } from '@interlay/interbtc-api'; +import { MonetaryAmount } from '@interlay/monetary-js'; +import { TFunction } from 'i18next'; + +import { GOVERNANCE_TOKEN } from '@/config/relay-chains'; +import { PROXY_ACCOUNT_RESERVE_AMOUNT } from '@/utils/constants/account'; + import yup, { MaxAmountValidationParams, MinAmountValidationParams } from '../yup.custom'; const STRATEGY_DEPOSIT_AMOUNT_FIELD = 'strategy-deposit-amount'; @@ -8,11 +15,32 @@ type StrategyDepositFormData = { [STRATEGY_DEPOSIT_FEE_TOKEN_FIELD]?: string; }; -type StrategyDepositValidationParams = MaxAmountValidationParams & MinAmountValidationParams; +type StrategyDepositValidationParams = MaxAmountValidationParams & + MinAmountValidationParams & { + governanceBalance: MonetaryAmount; + requireProxyDeposit: boolean; + }; -const strategyDepositSchema = (action: string, params: StrategyDepositValidationParams): yup.ObjectSchema => { +const strategyDepositSchema = ( + action: string, + params: StrategyDepositValidationParams, + t: TFunction +): yup.ObjectSchema => { return yup.object().shape({ - [STRATEGY_DEPOSIT_AMOUNT_FIELD]: yup.string().requiredAmount(action).maxAmount(params).minAmount(params, action), + [STRATEGY_DEPOSIT_AMOUNT_FIELD]: yup + .string() + .requiredAmount(action) + .maxAmount(params) + .minAmount(params, action) + .fees( + { + transactionFee: params.requireProxyDeposit + ? PROXY_ACCOUNT_RESERVE_AMOUNT + : newMonetaryAmount(0, GOVERNANCE_TOKEN), + governanceBalance: params.governanceBalance + }, + t('strategies.proxy_deposit_insufficient_funds', { currency: GOVERNANCE_TOKEN.ticker }) + ), [STRATEGY_DEPOSIT_FEE_TOKEN_FIELD]: yup.string().required() }); }; diff --git a/src/pages/Dashboard/cards/OracleStatusCard/index.tsx b/src/pages/Dashboard/cards/OracleStatusCard/index.tsx index fcb27215e6..3d241d7c6c 100644 --- a/src/pages/Dashboard/cards/OracleStatusCard/index.tsx +++ b/src/pages/Dashboard/cards/OracleStatusCard/index.tsx @@ -1,9 +1,8 @@ -import { CurrencyExt } from '@interlay/interbtc-api'; -import { Bitcoin, ExchangeRate } from '@interlay/monetary-js'; import clsx from 'clsx'; import { withErrorBoundary } from 'react-error-boundary'; import { useTranslation } from 'react-i18next'; +import { formatNumber } from '@/common/utils/utils'; import { RELAY_CHAIN_NATIVE_TOKEN, RELAY_CHAIN_NATIVE_TOKEN_SYMBOL } from '@/config/relay-chains'; import { OracleStatus, useGetOracleStatus } from '@/hooks/api/oracle/use-get-oracle-status'; import { useGetExchangeRate } from '@/hooks/api/use-get-exchange-rate'; @@ -33,15 +32,11 @@ const OracleStatusCard = ({ hasLinks }: Props): JSX.Element => { return <>Loading...; } - const exchangeRate = relayChainExchangeRate - ? new ExchangeRate(Bitcoin, RELAY_CHAIN_NATIVE_TOKEN, relayChainExchangeRate.toBig(), 0, 0) - : 0; - const oracleOnline = oracleStatus && oracleStatus === OracleStatus.ONLINE; let statusText; let statusCircleText; - if (exchangeRate === undefined) { + if (relayChainExchangeRate === undefined) { statusText = t('dashboard.oracles.not_available'); statusCircleText = t('unavailable'); } else if (oracleOnline === true) { @@ -88,9 +83,13 @@ const OracleStatusCard = ({ hasLinks }: Props): JSX.Element => { > {statusCircleText} - {exchangeRate && ( + {relayChainExchangeRate && ( - {exchangeRate.toHuman(5)} {RELAY_CHAIN_NATIVE_TOKEN_SYMBOL} + {formatNumber(Number(relayChainExchangeRate.toHuman(5)), { + minimumFractionDigits: 5, + maximumFractionDigits: 5 + })}{' '} + {RELAY_CHAIN_NATIVE_TOKEN_SYMBOL} )} diff --git a/src/pages/Dashboard/sub-pages/Home/LockedCollateralsCard/index.tsx b/src/pages/Dashboard/sub-pages/Home/LockedCollateralsCard/index.tsx index c74c10068c..617d95f1f7 100644 --- a/src/pages/Dashboard/sub-pages/Home/LockedCollateralsCard/index.tsx +++ b/src/pages/Dashboard/sub-pages/Home/LockedCollateralsCard/index.tsx @@ -4,14 +4,8 @@ import { useTranslation } from 'react-i18next'; import { convertMonetaryAmountToValueInUSD, formatUSD, getLastMidnightTimestamps } from '@/common/utils/utils'; import { COUNT_OF_DATES_FOR_CHART } from '@/config/charts'; -import { - GOVERNANCE_TOKEN, - GOVERNANCE_TOKEN_SYMBOL, - RELAY_CHAIN_NATIVE_TOKEN, - RELAY_CHAIN_NATIVE_TOKEN_SYMBOL -} from '@/config/relay-chains'; import { useGetPrices } from '@/hooks/api/use-get-prices'; -import useCumulativeCollateralVolumes from '@/hooks/use-cumulative-collateral-volumes'; +import useAllCumulativeVaultCollateralVolumes from '@/hooks/use-all-cumulative-vault-collateral-volumes'; import ErrorFallback from '@/legacy-components/ErrorFallback'; import { INTERLAY_DENIM, KINTSUGI_SUPERNOVA } from '@/utils/constants/colors'; import { PAGES } from '@/utils/constants/links'; @@ -29,44 +23,23 @@ const LockedCollateralsCard = (): JSX.Element => { const prices = useGetPrices(); const { - isIdle: cumulativeRelayChainNativeTokenVolumesIdle, - isLoading: cumulativeRelayChainNativeTokenVolumesLoading, - data: cumulativeRelayChainNativeTokenVolumes, - error: cumulativeRelayChainNativeTokenVolumesError - } = useCumulativeCollateralVolumes(RELAY_CHAIN_NATIVE_TOKEN, cutoffTimestamps); - useErrorHandler(cumulativeRelayChainNativeTokenVolumesError); - - const { - isIdle: cumulativeGovernanceTokenVolumesIdle, - isLoading: cumulativeGovernanceTokenVolumesLoading, - data: cumulativeGovernanceTokenVolumes, - error: cumulativeGovernanceTokenVolumesError - } = useCumulativeCollateralVolumes(GOVERNANCE_TOKEN, cutoffTimestamps); - useErrorHandler(cumulativeGovernanceTokenVolumesError); - - const relayChainNativeTokenPriceInUSD = getTokenPrice(prices, RELAY_CHAIN_NATIVE_TOKEN_SYMBOL)?.usd; - const governanceTokenPriceInUSD = getTokenPrice(prices, GOVERNANCE_TOKEN_SYMBOL)?.usd; + data: allCumulativeVaultCollateralVolumes, + error: allCumulativeVaultCollateralVolumesError + } = useAllCumulativeVaultCollateralVolumes(cutoffTimestamps); + useErrorHandler(allCumulativeVaultCollateralVolumesError); const cumulativeUSDVolumes = React.useMemo(() => { - if (cumulativeRelayChainNativeTokenVolumes === undefined || cumulativeGovernanceTokenVolumes === undefined) return; + if (allCumulativeVaultCollateralVolumes === undefined) return; return Array(COUNT_OF_DATES_FOR_CHART) .fill(0) .map((_, index) => { - const collaterals = [ - { - cumulativeVolumes: cumulativeRelayChainNativeTokenVolumes, - tokenPriceInUSD: relayChainNativeTokenPriceInUSD - } - ]; - - // Includes governance token data only if the price is available. - if (governanceTokenPriceInUSD !== undefined) { - collaterals.push({ - cumulativeVolumes: cumulativeGovernanceTokenVolumes, - tokenPriceInUSD: governanceTokenPriceInUSD - }); - } + const collateralTickers = Object.keys(allCumulativeVaultCollateralVolumes); + + const collaterals = collateralTickers.map((ticker: string) => ({ + cumulativeVolumes: allCumulativeVaultCollateralVolumes[ticker], + tokenPriceInUSD: getTokenPrice(prices, ticker)?.usd + })); let sumValueInUSD = 0; for (const collateral of collaterals) { @@ -80,21 +53,11 @@ const LockedCollateralsCard = (): JSX.Element => { tillTimestamp: cutoffTimestamps[index] }; }); - }, [ - cumulativeRelayChainNativeTokenVolumes, - cumulativeGovernanceTokenVolumes, - relayChainNativeTokenPriceInUSD, - governanceTokenPriceInUSD - ]); + }, [allCumulativeVaultCollateralVolumes, prices]); const renderContent = () => { // TODO: should use skeleton loaders - if ( - cumulativeRelayChainNativeTokenVolumesIdle || - cumulativeRelayChainNativeTokenVolumesLoading || - cumulativeGovernanceTokenVolumesIdle || - cumulativeGovernanceTokenVolumesLoading - ) { + if (allCumulativeVaultCollateralVolumes === undefined) { return <>Loading...; } diff --git a/src/pages/Strategies/Strategy/Strategy.tsx b/src/pages/Strategies/Strategy/Strategy.tsx index d9e2fbad88..85d527d353 100644 --- a/src/pages/Strategies/Strategy/Strategy.tsx +++ b/src/pages/Strategies/Strategy/Strategy.tsx @@ -10,6 +10,7 @@ import { StrategyInfographics, StrategyInsights, StrategyTag } from '../componen import { getContent } from '../helpers/content'; import { useGetStrategies } from '../hooks/use-get-strategies'; import { useGetStrategyPosition } from '../hooks/use-get-strategy-position'; +import { useGetStrategyProxyAccount } from '../hooks/use-get-strategy-proxy-account'; import { StrategyRisk, StrategyType } from '../types'; import { StyledFlex, StyledInfoCards, StyledStrategyForm } from './Strategy.styles'; @@ -21,7 +22,9 @@ const Strategy = (): JSX.Element | null => { const strategy = getStrategy(strategyType); - const { data: position, isLoading: isPositionLoading } = useGetStrategyPosition(strategy); + const { account: proxyAccount } = useGetStrategyProxyAccount(strategyType); + + const { data: position, isLoading: isPositionLoading } = useGetStrategyPosition(strategy, proxyAccount); if (!strategies || isPositionLoading) { return ; diff --git a/src/pages/Strategies/components/StrategyForm/StrategyDepositForm.tsx b/src/pages/Strategies/components/StrategyForm/StrategyDepositForm.tsx index e08be71914..4783bebcec 100644 --- a/src/pages/Strategies/components/StrategyForm/StrategyDepositForm.tsx +++ b/src/pages/Strategies/components/StrategyForm/StrategyDepositForm.tsx @@ -5,8 +5,9 @@ import { useTranslation } from 'react-i18next'; import { convertMonetaryAmountToValueInUSD, newSafeMonetaryAmount } from '@/common/utils/utils'; import { Flex, TokenInput } from '@/component-library'; -import { AuthCTA, TransactionFeeDetails } from '@/components'; -import { WRAPPED_TOKEN, WRAPPED_TOKEN_SYMBOL } from '@/config/relay-chains'; +import { AuthCTA } from '@/components'; +import { GOVERNANCE_TOKEN, WRAPPED_TOKEN, WRAPPED_TOKEN_SYMBOL } from '@/config/relay-chains'; +import { useGetBalances } from '@/hooks/api/tokens/use-get-balances'; import { useGetPrices } from '@/hooks/api/use-get-prices'; import { Transaction, useTransaction } from '@/hooks/transaction'; import { @@ -21,7 +22,9 @@ import { import { StrategyData } from '../../hooks/use-get-strategies'; import { useGetStrategyAvailableAmounts } from '../../hooks/use-get-strategy-available-amounts'; import { StrategyPositionData } from '../../hooks/use-get-strategy-position'; +import { useGetStrategyProxyAccount } from '../../hooks/use-get-strategy-proxy-account'; import { StrategyFormType } from '../../types'; +import { StrategyFormTransactionFees } from './StrategyFormTransactionFees'; type StrategyDepositFormProps = { strategy: StrategyData; @@ -31,16 +34,29 @@ type StrategyDepositFormProps = { const StrategyDepositForm = ({ strategy, position }: StrategyDepositFormProps): JSX.Element => { const { t } = useTranslation(); const prices = useGetPrices(); - const transaction = useTransaction(Transaction.STRATEGIES_DEPOSIT, { + const transaction = useTransaction({ onSuccess: () => { - form.resetForm(); + if (proxyAccount) { + form.resetForm(); + } else { + refetchProxyAccount(); + } } }); + const { getAvailableBalance } = useGetBalances(); + + const { + isLoading: isLoadingProxyAccount, + account: proxyAccount, + isIdentitySet, + refetch: refetchProxyAccount + } = useGetStrategyProxyAccount(strategy.type); + const { data: { maxAmount, minAmount } - } = useGetStrategyAvailableAmounts(StrategyFormType.DEPOSIT, strategy, position); + } = useGetStrategyAvailableAmounts(StrategyFormType.DEPOSIT, strategy, proxyAccount, position); - const getTransactionArgs = useCallback( + const getDepositTransactionArgs = useCallback( (values: StrategyDepositFormData) => { const amount = values[STRATEGY_DEPOSIT_AMOUNT_FIELD] || 0; const monetaryAmount = newMonetaryAmount(amount, strategy.currency, true); @@ -51,13 +67,28 @@ const StrategyDepositForm = ({ strategy, position }: StrategyDepositFormProps): ); const handleSubmit = (values: StrategyDepositFormData) => { - const transactionData = getTransactionArgs(values); - - if (!transactionData) return; - - const { monetaryAmount } = transactionData; - - transaction.execute(WRAPPED_TOKEN, monetaryAmount); + if (proxyAccount) { + const depositTransactionData = getDepositTransactionArgs(values); + + if (!depositTransactionData) return; + + let { monetaryAmount } = depositTransactionData; + + if (transaction.fee.isEqualFeeCurrency(monetaryAmount.currency)) { + monetaryAmount = transaction.calculateAmountWithFeeDeducted(monetaryAmount); + } + + transaction.execute( + Transaction.STRATEGIES_DEPOSIT, + strategy.type, + proxyAccount, + !!isIdentitySet, + WRAPPED_TOKEN, + monetaryAmount + ); + } else { + transaction.execute(Transaction.STRATEGIES_INITIALIZE_PROXY, strategy.type); + } }; const form = useForm({ @@ -65,16 +96,36 @@ const StrategyDepositForm = ({ strategy, position }: StrategyDepositFormProps): [STRATEGY_DEPOSIT_AMOUNT_FIELD]: '', [STRATEGY_DEPOSIT_FEE_TOKEN_FIELD]: transaction.fee.defaultCurrency.ticker }, - validationSchema: strategyDepositSchema('deposit', { maxAmount, minAmount }), + validationSchema: strategyDepositSchema( + 'deposit', + { + maxAmount, + minAmount, + requireProxyDeposit: !isIdentitySet, + governanceBalance: getAvailableBalance(GOVERNANCE_TOKEN.ticker) || newMonetaryAmount(0, GOVERNANCE_TOKEN) + }, + t + ), onSubmit: handleSubmit, onComplete: (values: StrategyDepositFormData) => { - const transactionData = getTransactionArgs(values); - - if (!transactionData) return; - - const { monetaryAmount } = transactionData; - - transaction.fee.estimate(WRAPPED_TOKEN, monetaryAmount); + if (proxyAccount) { + const depositTransactionData = getDepositTransactionArgs(values); + + if (!depositTransactionData) return; + + const { monetaryAmount } = depositTransactionData; + + transaction.fee.estimate( + Transaction.STRATEGIES_DEPOSIT, + strategy.type, + proxyAccount, + !!isIdentitySet, + WRAPPED_TOKEN, + monetaryAmount + ); + } else { + transaction.fee.estimate(Transaction.STRATEGIES_INITIALIZE_PROXY, strategy.type); + } } }); @@ -84,7 +135,7 @@ const StrategyDepositForm = ({ strategy, position }: StrategyDepositFormProps): true ); const inputUSDValue = convertMonetaryAmountToValueInUSD(inputMonetaryAmount, prices?.[WRAPPED_TOKEN_SYMBOL].usd) || 0; - const isSubmitButtonDisabled = isFormDisabled(form); + const isSubmitButtonDisabled = isFormDisabled(form) || isLoadingProxyAccount; return (
@@ -99,12 +150,13 @@ const StrategyDepositForm = ({ strategy, position }: StrategyDepositFormProps): {...mergeProps(form.getFieldProps(STRATEGY_DEPOSIT_AMOUNT_FIELD))} /> - - {t('deposit')} + {proxyAccount ? t('deposit') : t('strategy.initialize')} diff --git a/src/pages/Strategies/components/StrategyForm/StrategyFormTransactionFees.tsx b/src/pages/Strategies/components/StrategyForm/StrategyFormTransactionFees.tsx new file mode 100644 index 0000000000..44f08a82b7 --- /dev/null +++ b/src/pages/Strategies/components/StrategyForm/StrategyFormTransactionFees.tsx @@ -0,0 +1,108 @@ +import { mergeProps, useId } from '@react-aria/utils'; +import { ReactNode } from 'react'; +import { useTranslation } from 'react-i18next'; + +import { displayMonetaryAmountInUSDFormat, formatUSD } from '@/common/utils/utils'; +import { Alert, Flex } from '@/component-library'; +import { + TransactionDetails, + TransactionDetailsDd, + TransactionDetailsDt, + TransactionDetailsGroup, + TransactionDetailsProps, + TransactionSelectToken, + TransactionSelectTokenProps +} from '@/components'; +import { GOVERNANCE_TOKEN } from '@/config/relay-chains'; +import { useGetPrices } from '@/hooks/api/use-get-prices'; +import { UseFeeEstimateResult } from '@/hooks/transaction/types/hook'; +import { SelectCurrencyFilter, useSelectCurrency } from '@/hooks/use-select-currency'; +import { PROXY_ACCOUNT_RESERVE_AMOUNT } from '@/utils/constants/account'; +import { getTokenPrice } from '@/utils/helpers/prices'; + +type Props = { + label?: ReactNode; + tooltipLabel?: ReactNode; + selectProps?: TransactionSelectTokenProps; + fee?: UseFeeEstimateResult; + includeProxyAccountFee?: boolean; +}; + +type InheritAttrs = Omit; + +type StrategyFormTransactionFeesProps = Props & InheritAttrs; + +const StrategyFormTransactionFees = ({ + selectProps, + label, + tooltipLabel, + className, + fee, + includeProxyAccountFee, + ...props +}: StrategyFormTransactionFeesProps): JSX.Element => { + const { t } = useTranslation(); + const id = useId(); + const prices = useGetPrices(); + const selectCurrency = useSelectCurrency(SelectCurrencyFilter.TRADEABLE_FOR_NATIVE_CURRENCY); + + const { selectProps: feeSelectProps, data } = fee || {}; + const { amount, isValid } = data || {}; + + const amountLabel = amount + ? `${amount.toHuman()} ${amount.currency.ticker} (${displayMonetaryAmountInUSDFormat( + amount, + getTokenPrice(prices, amount.currency.ticker)?.usd + )})` + : `${0.0} ${selectProps?.value} (${formatUSD(0)})`; + + const proxyDepositAmonut = includeProxyAccountFee + ? `${PROXY_ACCOUNT_RESERVE_AMOUNT.toHuman()} ${ + PROXY_ACCOUNT_RESERVE_AMOUNT.currency.ticker + } (${displayMonetaryAmountInUSDFormat( + PROXY_ACCOUNT_RESERVE_AMOUNT, + getTokenPrice(prices, PROXY_ACCOUNT_RESERVE_AMOUNT.currency.ticker)?.usd + )})` + : `${0.0} ${selectProps?.value} (${formatUSD(0)})`; + + const errorMessage = + isValid === false && t('forms.ensure_adequate_amount_left_to_cover_action', { action: t('fees').toLowerCase() }); + + return ( + + + {selectProps && ( + + )} + + {label || t('tx_fees')} + {amountLabel} + + {includeProxyAccountFee && ( + + + {label || t('strategies.proxy_deposit', { currency: GOVERNANCE_TOKEN.ticker })} + + {proxyDepositAmonut} + + )} + + {errorMessage && ( + + {errorMessage} + + )} + + ); +}; + +export { StrategyFormTransactionFees }; +export type { StrategyFormTransactionFeesProps }; diff --git a/src/pages/Strategies/components/StrategyForm/StrategyWithdrawalForm.tsx b/src/pages/Strategies/components/StrategyForm/StrategyWithdrawalForm.tsx index 75929e4f28..e617ac726e 100644 --- a/src/pages/Strategies/components/StrategyForm/StrategyWithdrawalForm.tsx +++ b/src/pages/Strategies/components/StrategyForm/StrategyWithdrawalForm.tsx @@ -20,6 +20,7 @@ import { import { StrategyData } from '../../hooks/use-get-strategies'; import { useGetStrategyAvailableAmounts } from '../../hooks/use-get-strategy-available-amounts'; import { StrategyPositionData } from '../../hooks/use-get-strategy-position'; +import { useGetStrategyProxyAccount } from '../../hooks/use-get-strategy-proxy-account'; import { StrategyFormType } from '../../types'; type StrategyWithdrawalFormProps = { @@ -32,15 +33,26 @@ const StrategyWithdrawalForm = ({ strategy, position }: StrategyWithdrawalFormPr const prices = useGetPrices(); const transaction = useTransaction({ onSuccess: () => { - form.resetForm(); + if (proxyAccount) { + form.resetForm(); + } else { + refetchProxyAccount(); + } } }); + + const { + isLoading: isLoadingProxyAccount, + account: proxyAccount, + refetch: refetchProxyAccount + } = useGetStrategyProxyAccount(strategy.type); + const { data: { maxAmount, minAmount }, isMaxAmount - } = useGetStrategyAvailableAmounts(StrategyFormType.WITHDRAW, strategy, position); + } = useGetStrategyAvailableAmounts(StrategyFormType.WITHDRAW, strategy, proxyAccount, position); - const getTransactionArgs = useCallback( + const getWithdrawalTransactionArgs = useCallback( (values: StrategyWithdrawFormData) => { const amount = values[STRATEGY_WITHDRAW_AMOUNT_FIELD] || 0; const monetaryAmount = newMonetaryAmount(amount, strategy.currency, true); @@ -51,18 +63,38 @@ const StrategyWithdrawalForm = ({ strategy, position }: StrategyWithdrawalFormPr ); const handleSubmit = (values: StrategyWithdrawFormData) => { - const transactionData = getTransactionArgs(values); + if (proxyAccount) { + const transactionData = getWithdrawalTransactionArgs(values); - if (!transactionData) return; + if (!transactionData) return; - const { monetaryAmount } = transactionData; + let { monetaryAmount } = transactionData; - const isWithdrawAll = isMaxAmount(monetaryAmount); + if (transaction.fee.isEqualFeeCurrency(monetaryAmount.currency)) { + monetaryAmount = transaction.calculateAmountWithFeeDeducted(monetaryAmount); + } - if (isWithdrawAll) { - return transaction.execute(Transaction.STRATEGIES_ALL_WITHDRAW, monetaryAmount.currency); + const isWithdrawAll = isMaxAmount(monetaryAmount); + + if (isWithdrawAll) { + return transaction.execute( + Transaction.STRATEGIES_ALL_WITHDRAW, + strategy.type, + proxyAccount, + monetaryAmount.currency, + monetaryAmount + ); + } else { + return transaction.execute( + Transaction.STRATEGIES_WITHDRAW, + strategy.type, + proxyAccount, + monetaryAmount.currency, + monetaryAmount + ); + } } else { - return transaction.execute(Transaction.STRATEGIES_WITHDRAW, monetaryAmount.currency, monetaryAmount); + transaction.execute(Transaction.STRATEGIES_INITIALIZE_PROXY, strategy.type); } }; @@ -77,18 +109,34 @@ const StrategyWithdrawalForm = ({ strategy, position }: StrategyWithdrawalFormPr }), onSubmit: handleSubmit, onComplete: (values: StrategyWithdrawFormData) => { - const transactionData = getTransactionArgs(values); - - if (!transactionData) return; - - const { monetaryAmount } = transactionData; - - const isWithdrawAll = isMaxAmount(monetaryAmount); - - if (isWithdrawAll) { - return transaction.fee.estimate(Transaction.STRATEGIES_ALL_WITHDRAW, monetaryAmount.currency); + if (proxyAccount) { + const transactionData = getWithdrawalTransactionArgs(values); + + if (!transactionData) return; + + const { monetaryAmount } = transactionData; + + const isWithdrawAll = isMaxAmount(monetaryAmount); + + if (isWithdrawAll) { + return transaction.fee.estimate( + Transaction.STRATEGIES_ALL_WITHDRAW, + strategy.type, + proxyAccount, + monetaryAmount.currency, + monetaryAmount + ); + } else { + return transaction.fee.estimate( + Transaction.STRATEGIES_WITHDRAW, + strategy.type, + proxyAccount, + monetaryAmount.currency, + monetaryAmount + ); + } } else { - return transaction.fee.estimate(Transaction.STRATEGIES_WITHDRAW, monetaryAmount.currency, monetaryAmount); + transaction.fee.estimate(Transaction.STRATEGIES_INITIALIZE_PROXY, strategy.type); } } }); @@ -99,7 +147,7 @@ const StrategyWithdrawalForm = ({ strategy, position }: StrategyWithdrawalFormPr true ); const inputUSDValue = convertMonetaryAmountToValueInUSD(inputMonetaryAmount, prices?.[WRAPPED_TOKEN_SYMBOL].usd) || 0; - const isSubmitButtonDisabled = isFormDisabled(form); + const isSubmitButtonDisabled = isFormDisabled(form) || isLoadingProxyAccount; return ( @@ -120,7 +168,7 @@ const StrategyWithdrawalForm = ({ strategy, position }: StrategyWithdrawalFormPr selectProps={{ ...form.getSelectFieldProps(STRATEGY_WITHDRAW_FEE_TOKEN_FIELD) }} /> - {t('withdraw')} + {proxyAccount ? t('withdraw') : t('strategy.initialize')} diff --git a/src/pages/Strategies/hooks/use-get-strategy-available-amounts.ts b/src/pages/Strategies/hooks/use-get-strategy-available-amounts.ts index 0df60edb21..792881ca42 100644 --- a/src/pages/Strategies/hooks/use-get-strategy-available-amounts.ts +++ b/src/pages/Strategies/hooks/use-get-strategy-available-amounts.ts @@ -1,3 +1,5 @@ +import { AccountId } from '@polkadot/types/interfaces'; + import { useGetLoanAvailableAmounts, UseGetLoanAvailableAmountsResult @@ -12,12 +14,14 @@ type useGetStrategyAvailableAmountsResult = UseGetLoanAvailableAmountsResult; const useGetStrategyAvailableAmounts = ( type: StrategyFormType, strategy: StrategyData, + proxyAccount: AccountId | undefined, position?: StrategyPositionData ): useGetStrategyAvailableAmountsResult => { const loanAvailableAmounts = useGetLoanAvailableAmounts( type === StrategyFormType.DEPOSIT ? 'lend' : 'withdraw', strategy.loanAsset, - position?.loanPosition + position?.loanPosition, + proxyAccount ); switch (strategy.type) { diff --git a/src/pages/Strategies/hooks/use-get-strategy-position.ts b/src/pages/Strategies/hooks/use-get-strategy-position.ts index 88dc11bbe2..734b4f0180 100644 --- a/src/pages/Strategies/hooks/use-get-strategy-position.ts +++ b/src/pages/Strategies/hooks/use-get-strategy-position.ts @@ -1,5 +1,6 @@ import { CurrencyExt } from '@interlay/interbtc-api'; import { MonetaryAmount } from '@interlay/monetary-js'; +import { AccountId } from '@polkadot/types/interfaces'; import { useGetAccountPositions } from '@/hooks/api/loans/use-get-account-positions'; import { CollateralPosition } from '@/types/loans'; @@ -18,8 +19,11 @@ type UseGetStrategyPositionResult = { data: StrategyPositionData | undefined; }; -const useGetStrategyPosition = (strategy: StrategyData | undefined): UseGetStrategyPositionResult => { - const { getLendPosition, isLoading: isAccountPositionsLoading } = useGetAccountPositions(); +const useGetStrategyPosition = ( + strategy: StrategyData | undefined, + proxyAccount: AccountId | undefined +): UseGetStrategyPositionResult => { + const { getLendPosition, isLoading: isAccountPositionsLoading } = useGetAccountPositions(proxyAccount); if (!strategy) { return { diff --git a/src/pages/Strategies/hooks/use-get-strategy-proxy-account.ts b/src/pages/Strategies/hooks/use-get-strategy-proxy-account.ts new file mode 100644 index 0000000000..3ffae84c6b --- /dev/null +++ b/src/pages/Strategies/hooks/use-get-strategy-proxy-account.ts @@ -0,0 +1,92 @@ +import { storageKeyToNthInner } from '@interlay/interbtc-api'; +import { AccountId } from '@polkadot/types/interfaces'; +import { useErrorHandler } from 'react-error-boundary'; +import { useQuery } from 'react-query'; + +import useAccountId from '@/hooks/use-account-id'; + +import { StrategyType } from '../types'; + +interface UseGetStrategyProxyAccountResult { + account: AccountId | undefined; + isIdentitySet: boolean | undefined; + isLoading: boolean; + refetch: () => void; +} + +const getProxyIdentities = (proxyAccounts: Array) => + new Promise>((resolve) => + window.bridge.api.query.identity.identityOf.multi(proxyAccounts, (identities) => { + const accountIdentities = identities.map((identity) => { + if (identity.isNone) { + return undefined; + } + return identity.unwrap().info.additional[0][1].asRaw.toHuman() as StrategyType; + }); + + const accountsWithStrategies = proxyAccounts.map( + (account, index) => [account, accountIdentities[index]] as [AccountId, StrategyType | undefined] + ); + + resolve(accountsWithStrategies); + }) + ); + +const getStrategyProxyAccount = async ( + strategyType: StrategyType, + primaryAccount: AccountId | undefined +): Promise<{ account: AccountId; isIdentitySet: boolean } | undefined> => { + if (!primaryAccount) { + return undefined; + } + + // MEMO: Not possible to query proxy accounts by delegate, + // therefore all are fetched and then filtered. + + const allProxies = await window.bridge.api.query.proxy.proxies.entries(); + const proxiesOfUserAccount = allProxies + .filter((proxy) => proxy[1][0][0].delegate.toString() === primaryAccount.toString()) + .map((proxy) => storageKeyToNthInner(proxy[0])); + + if (proxiesOfUserAccount.length === 0) { + return undefined; + } + + const accountToStrategy = await getProxyIdentities(proxiesOfUserAccount); + + const strategyAccount = accountToStrategy.find( + ([, accountStrategyType]) => accountStrategyType === strategyType + )?.[0]; + + if (strategyAccount) { + return { account: strategyAccount, isIdentitySet: true }; + } + // If strategy is not connected with any proxy account return first unused proxy account + // that will be assigned with first strategy deposit. + + const firstUnusedProxyAccount = accountToStrategy.find( + ([, accountStrategyType]) => accountStrategyType === undefined + )?.[0]; + + if (!firstUnusedProxyAccount) { + throw new Error('Proxy account limit was exceeded.'); + } + + return { account: firstUnusedProxyAccount, isIdentitySet: false }; +}; + +const useGetStrategyProxyAccount = (strategyType: StrategyType): UseGetStrategyProxyAccountResult => { + const primaryAccount = useAccountId(); + + const { data, error, refetch, isLoading } = useQuery({ + queryKey: ['strategy-proxy-account', strategyType, primaryAccount?.toString()], + queryFn: () => getStrategyProxyAccount(strategyType, primaryAccount), + enabled: !!primaryAccount + }); + + useErrorHandler(error); + + return { account: data?.account, isIdentitySet: data?.isIdentitySet, isLoading, refetch }; +}; + +export { useGetStrategyProxyAccount }; diff --git a/src/pages/Vaults/Vault/components/IssueRedeemForm/IssueRedeemForm.tsx b/src/pages/Vaults/Vault/components/IssueRedeemForm/IssueRedeemForm.tsx index f78fce7bf3..e2af9bab22 100644 --- a/src/pages/Vaults/Vault/components/IssueRedeemForm/IssueRedeemForm.tsx +++ b/src/pages/Vaults/Vault/components/IssueRedeemForm/IssueRedeemForm.tsx @@ -165,10 +165,7 @@ const IssueRedeemForm = ({ const label = isIssueModal ? 'Issue amount' : 'Reddem amount'; const highlightTerm = isIssueModal ? 'Maximum vault capacity:' : 'Locked:'; - const handleSubmit = (data: IssueRedeemFormData) => { - onSubmit?.(); - console.log(data); - }; + const handleSubmit = () => onSubmit?.(); const parsedBTCAmount = new BitcoinAmount(inputBTCAmount); const bridgeFee = parsedBTCAmount.mul(issueFeeRate); diff --git a/src/services/fetchers/cumulative-vault-collateral-volumes-fetcher.ts b/src/services/fetchers/cumulative-vault-collateral-volumes-fetcher.ts new file mode 100644 index 0000000000..23f2b31010 --- /dev/null +++ b/src/services/fetchers/cumulative-vault-collateral-volumes-fetcher.ts @@ -0,0 +1,80 @@ +import { CollateralCurrencyExt, CurrencyExt, newMonetaryAmount, TickerToData } from '@interlay/interbtc-api'; + +import { WRAPPED_TOKEN } from '@/config/relay-chains'; +import graphqlFetcher, { GRAPHQL_FETCHER } from '@/services/fetchers/graphql-fetcher'; +import { getCurrencyEqualityCondition } from '@/utils/helpers/currencies'; + +import { VolumeDataPoint } from './cumulative-volumes-fetcher'; + +const CUMULATIVE_VAULT_COLLATERALVOLUMES_FETCHER = 'cumulative-vault-collateral-volumes-fetcher'; + +const cumulativeVaultCollateralVolumesFetcher = async ( + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types + { queryKey }: any +): Promise>> => { + const [key, cutoffTimestamps, collateralCurrencies] = queryKey as CumulativeVaultCollateralVolumesFetcherParams; + + if (key !== CUMULATIVE_VAULT_COLLATERALVOLUMES_FETCHER) throw new Error('Invalid key!'); + + const queryFragment = (date: Date, collateralCurrency: CurrencyExt) => { + const where = `{ + tillTimestamp_lte: "${date.toISOString()}", + type_eq: Collateral, + ${`collateralCurrency: { + ${getCurrencyEqualityCondition(collateralCurrency)}}`}, + ${`wrappedCurrency: { + ${getCurrencyEqualityCondition(WRAPPED_TOKEN)}}`}, + }`; + + return ` + ts${date.getTime()}_${ + collateralCurrency?.ticker + }: cumulativeVolumePerCurrencyPairs (where: ${where}, orderBy: tillTimestamp_DESC, limit: 1) { + amount + tillTimestamp + } + `; + }; + + const query = ` + { + ${cutoffTimestamps.map((date) => collateralCurrencies.map((currency) => queryFragment(date, currency)))} + } + `; + + // TODO: should type properly (`Relay`) + const volumesData = await graphqlFetcher>()({ + queryKey: [GRAPHQL_FETCHER, query] + }); + + const volumes = volumesData?.data || {}; + + return Object.entries(volumes).reduce((result, [key, [volumeData]]) => { + const [rawTimestamp, ticker] = key.split('_'); + const timestamp = rawTimestamp.slice(2); + const currency = collateralCurrencies.find((collateralCurrency) => collateralCurrency.ticker === ticker); + if (currency === undefined) { + throw new Error('Ivalid query.'); + } + return { + ...result, + [ticker]: [ + ...(result[ticker] || []), + { + amount: newMonetaryAmount(volumeData.amount || 0, currency), + tillTimestamp: cutoffTimestamps.find((cutoffTimestamp) => cutoffTimestamp.getTime().toString() === timestamp) + } + ] + }; + }, {} as any); +}; + +type CumulativeVaultCollateralVolumesFetcherParams = [ + queryKey: string, + cutoffTimestamp: Array, + collateralCurrency: Array +]; + +export { CUMULATIVE_VAULT_COLLATERALVOLUMES_FETCHER }; + +export default cumulativeVaultCollateralVolumesFetcher; diff --git a/src/services/fetchers/cumulative-volumes-fetcher.ts b/src/services/fetchers/cumulative-volumes-fetcher.ts index 10609caa9b..5589771170 100644 --- a/src/services/fetchers/cumulative-volumes-fetcher.ts +++ b/src/services/fetchers/cumulative-volumes-fetcher.ts @@ -2,6 +2,7 @@ import { CollateralCurrencyExt, CurrencyExt, newMonetaryAmount, WrappedCurrency import { MonetaryAmount } from '@interlay/monetary-js'; import graphqlFetcher, { GRAPHQL_FETCHER } from '@/services/fetchers/graphql-fetcher'; +import { getCurrencyEqualityCondition } from '@/utils/helpers/currencies'; const CUMULATIVE_VOLUMES_FETCHER = 'cumulative-volumes-fetcher'; @@ -35,41 +36,26 @@ const cumulativeVolumesFetcher = async ( const queryFragment = ( type: VolumeType, date: Date, - collateralCurrencyIdLiteral?: string | number, - wrappedCurrencyIdLiteral?: string | number + collateralCurrency?: CurrencyExt, + wrappedCurrency?: CurrencyExt ) => { - let colCurrCond = ''; - if (collateralCurrencyIdLiteral !== undefined) { - colCurrCond = - (typeof collateralCurrencyIdLiteral === 'number' ? 'asset_eq: ' : 'token_eq: ') + - collateralCurrencyIdLiteral.toString(); - } - let wrapCurrCond = ''; - if (wrappedCurrencyIdLiteral !== undefined) { - wrapCurrCond = - (typeof wrappedCurrencyIdLiteral === 'number' ? 'asset_eq: ' : 'token_eq: ') + - wrappedCurrencyIdLiteral.toString(); - } const where = `{ tillTimestamp_lte: "${date.toISOString()}", type_eq: ${type}, ${ - collateralCurrencyIdLiteral + collateralCurrency ? `collateralCurrency: { - ${colCurrCond}}` + ${getCurrencyEqualityCondition(collateralCurrency)}}` : `` }, ${ - wrappedCurrencyIdLiteral + wrappedCurrency ? `wrappedCurrency: { - ${wrapCurrCond}}` + ${getCurrencyEqualityCondition(wrappedCurrency)}}` : `` }, }`; - const entityName = - collateralCurrencyIdLiteral || wrappedCurrencyIdLiteral - ? `cumulativeVolumePerCurrencyPairs` - : `cumulativeVolumes`; + const entityName = collateralCurrency || wrappedCurrency ? `cumulativeVolumePerCurrencyPairs` : `cumulativeVolumes`; return ` ts${date.getTime()}: ${entityName} (where: ${where}, orderBy: tillTimestamp_DESC, limit: 1) { amount @@ -80,14 +66,7 @@ const cumulativeVolumesFetcher = async ( const query = ` { - ${cutoffTimestamps.map((date) => { - let col; - // TODO: Need to refactor when we want to support lend tokens as collateral for vaults. - if (collateralCurrency) { - col = 'foreignAsset' in collateralCurrency ? collateralCurrency.foreignAsset.id : collateralCurrency.ticker; - } - return queryFragment(type, date, col, wrappedCurrency?.ticker); - })} + ${cutoffTimestamps.map((date) => queryFragment(type, date, collateralCurrency, wrappedCurrency))} } `; diff --git a/src/utils/constants/account.ts b/src/utils/constants/account.ts index 467df8b303..a9c88d129d 100644 --- a/src/utils/constants/account.ts +++ b/src/utils/constants/account.ts @@ -1,5 +1,11 @@ -import { APP_NAME } from '@/config/relay-chains'; +import { MonetaryAmount } from '@interlay/monetary-js'; + +import { APP_NAME, GOVERNANCE_TOKEN } from '@/config/relay-chains'; const SELECTED_ACCOUNT_LOCAL_STORAGE_KEY = `${APP_NAME}-selected-account`; -export { SELECTED_ACCOUNT_LOCAL_STORAGE_KEY }; +const DEFAULT_PROXY_ACCOUNT_AMOUNT = 10; + +const PROXY_ACCOUNT_RESERVE_AMOUNT = new MonetaryAmount(GOVERNANCE_TOKEN, 26); + +export { DEFAULT_PROXY_ACCOUNT_AMOUNT, PROXY_ACCOUNT_RESERVE_AMOUNT, SELECTED_ACCOUNT_LOCAL_STORAGE_KEY }; diff --git a/src/utils/helpers/extrinsic.ts b/src/utils/helpers/extrinsic.ts new file mode 100644 index 0000000000..acc58dfe86 --- /dev/null +++ b/src/utils/helpers/extrinsic.ts @@ -0,0 +1,9 @@ +import { SubmittableExtrinsic } from '@polkadot/api/types'; +import { AccountId } from '@polkadot/types/interfaces'; + +const proxifyExtrinsic = ( + proxyAccount: AccountId, + extrinsic: SubmittableExtrinsic<'promise'> +): SubmittableExtrinsic<'promise'> => window.bridge.api.tx.proxy.proxy(proxyAccount, 'Any', extrinsic); + +export { proxifyExtrinsic };