Skip to content

Commit

Permalink
[release] Kintsugi 2.34.0 (#1311)
Browse files Browse the repository at this point in the history
* 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 3ade26d.

* 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 bd29f8c.

* Revert "refactor: remove duplicated monetary conversion"

This reverts commit 5fd3d64.

* 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 8f31ee8.

* 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 d05e012.

* 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 c0cb306.

* 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 <rui.daniel.simao@gmail.com>

* 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

---------

Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com>
Co-authored-by: Rui Simão <rui.daniel.simao@gmail.com>
Co-authored-by: ns212 <73105077+ns212@users.noreply.github.com>
Co-authored-by: Chanakya Kilaru <samuraichanakya1@gmail.com>
  • Loading branch information
5 people authored Jun 20, 2023
1 parent 30a6aff commit d1924e1
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 33 deletions.
66 changes: 61 additions & 5 deletions api/market_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,81 @@

api_key = os.environ.get("CG_API_KEY")

tickers = {
"Tether USD": "tether",
}

@app.after_request
def add_header(response):
response.cache_control.max_age = 0
response.cache_control.s_maxage = 300
return response


@app.route("/marketdata/price", methods=["GET"])
def get_price():
args = request.args

def coingecko(args):
headers_dict = {
"content-type": "application/json",
"accept": "application/json",
}
url = "https://api.coingecko.com/api/v3/simple/price"
resp = requests.get(url, params=args, headers=headers_dict)
data = resp.json()
return data

def dia(asset):
headers_dict = {
"content-type": "application/json",
"accept": "application/json",
"x-cg-pro-api-key": api_key,
}
url = "https://api.diadata.org/v1/assetQuotation"
if asset == "bitcoin":
url += "/Bitcoin/0x0000000000000000000000000000000000000000"
elif asset == "interlay":
url += "/Interlay/0x0000000000000000000000000000000000000000"
elif asset == "liquid-staking-dot":
return { "liquid-staking-dot": None }
elif asset == "polkadot":
url += "/Polkadot/0x0000000000000000000000000000000000000000/"
elif asset == "tether":
url += "/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7"

resp = requests.get(url, headers=headers_dict)
data = resp.json()

# optionally rename the ticker
ticker = tickers.get(data["Name"], data["Name"]).lower()

return {
ticker: {
"usd": data["Price"],
}
}


@app.route("/marketdata/price", methods=["GET"])
def get_price():
args = request.args

price_source = args.get('price-source')

data = {}

def _dia():
ticker_ids = args["ids"].split(",")
for ticker_id in ticker_ids:
data.update(dia(ticker_id))

if price_source == "dia":
_dia()
elif price_source == "coingecko":
data = coingecko(args)
else:
try:
_dia()
except Exception as e:
print("Error", e)
data = coingecko(args)

return jsonify(data)


Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "interbtc-ui",
"version": "2.33.0",
"version": "2.34.0",
"private": true,
"dependencies": {
"@craco/craco": "^6.1.1",
"@headlessui/react": "^1.1.1",
"@heroicons/react": "^2.0.18",
"@interlay/bridge": "^0.3.11",
"@interlay/interbtc-api": "2.3.1",
"@interlay/bridge": "^0.3.13",
"@interlay/interbtc-api": "2.3.3",
"@interlay/monetary-js": "0.7.3",
"@polkadot/api": "9.14.2",
"@polkadot/extension-dapp": "0.44.1",
Expand Down
2 changes: 1 addition & 1 deletion src/components/LoanPositionsTable/ApyCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const ApyCell = ({
}: ApyCellProps): JSX.Element => {
const rewardsApy = getSubsidyRewardApy(currency, rewardsPerYear, prices);

const totalApy = isBorrow ? apy.sub(rewardsApy || 0) : apy.add(rewardsApy || 0);
const totalApy = isBorrow ? (rewardsApy || Big(0)).sub(apy) : apy.add(rewardsApy || 0);

const totalApyLabel = getApyLabel(totalApy);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const DepositOutputAssets = ({ pool, values, prices }: DepositOutputAssetsProps)
return (
<Flex direction='column' gap='spacing4'>
<P align='center' size='xs'>
{t('amm.pools.receivable_assets')}
{t('receivable_assets')}
</P>
<Dl direction='column' gap='spacing2'>
<StyledDlGroup justifyContent='space-between'>
Expand Down
28 changes: 15 additions & 13 deletions src/pages/AMM/Swap/components/SwapForm/SwapForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Big from 'big.js';
import { ChangeEventHandler, Key, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
import { useDebounce } from 'react-use';
import { useDebounce, useInterval } from 'react-use';

import { StoreType } from '@/common/types/util.types';
import { convertMonetaryAmountToValueInUSD, formatUSD, newSafeMonetaryAmount } from '@/common/utils/utils';
Expand All @@ -20,6 +20,7 @@ import {
} from '@/lib/form';
import { SlippageManager } from '@/pages/AMM/shared/components';
import { SwapPair } from '@/types/swap';
import { REFETCH_INTERVAL } from '@/utils/constants/api';
import { SWAP_PRICE_IMPACT_LIMIT } from '@/utils/constants/swap';
import { getTokenPrice } from '@/utils/helpers/prices';
import { useGetBalances } from '@/utils/hooks/api/tokens/use-get-balances';
Expand Down Expand Up @@ -120,20 +121,21 @@ const SwapForm = ({
onSuccess: onSwap
});

useDebounce(
() => {
if (!pair.input || !pair.output || !inputAmount) {
return setTrade(undefined);
}
const handleChangeTrade = () => {
if (!pair.input || !pair.output || !inputAmount) {
return setTrade(undefined);
}

const inputMonetaryAmount = newMonetaryAmount(inputAmount, pair.input, true);
const trade = window.bridge.amm.getOptimalTrade(inputMonetaryAmount, pair.output, liquidityPools);
const inputMonetaryAmount = newMonetaryAmount(inputAmount, pair.input, true);
const trade = window.bridge.amm.getOptimalTrade(inputMonetaryAmount, pair.output, liquidityPools);

setTrade(trade);
},
500,
[inputAmount, pair]
);
setTrade(trade);
};

// attemp to update trade object on each new block
useInterval(handleChangeTrade, REFETCH_INTERVAL.BLOCK);

useDebounce(handleChangeTrade, 500, [inputAmount, pair]);

const inputBalance = pair.input && getAvailableBalance(pair.input.ticker);
const outputBalance = pair.output && getAvailableBalance(pair.output.ticker);
Expand Down
4 changes: 2 additions & 2 deletions src/parts/Topbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const Topbar = (): JSX.Element => {
const { selectProps } = useSignMessage();
const { list } = useNotifications();

const kintBalanceIsZero = getAvailableBalance('KINT')?.isZero();
const governanceTokenBalanceIsZero = getAvailableBalance(GOVERNANCE_TOKEN.ticker)?.isZero();

const handleRequestFromFaucet = async (): Promise<void> => {
if (!selectedAccount) return;
Expand Down Expand Up @@ -106,7 +106,7 @@ const Topbar = (): JSX.Element => {
{isBanxaEnabled ? <FundWallet /> : <GetGovernanceTokenUI className={SMALL_SIZE_BUTTON_CLASSES} />}
{selectedAccount !== undefined && (
<>
{process.env.REACT_APP_FAUCET_URL && kintBalanceIsZero && (
{process.env.REACT_APP_FAUCET_URL && governanceTokenBalanceIsZero && (
<>
<InterlayDenimOrKintsugiMidnightOutlinedButton
className={SMALL_SIZE_BUTTON_CLASSES}
Expand Down
3 changes: 3 additions & 0 deletions src/utils/helpers/loans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const MIN_DECIMAL_NUMBER = 0.01;

// MEMO: returns formatted apy or better representation of a very small apy
const getApyLabel = (apy: Big): string => {
if (apy.eq(0)) {
return formatPercentage(0);
}
const isPositive = apy.gt(0);
const isTinyApy = isPositive ? apy.lt(MIN_DECIMAL_NUMBER) : apy.gt(-MIN_DECIMAL_NUMBER);

Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2099,10 +2099,10 @@
resolved "https://registry.yarnpkg.com/@iarna/toml/-/toml-2.2.5.tgz#b32366c89b43c6f8cefbdefac778b9c828e3ba8c"
integrity sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==

"@interlay/bridge@^0.3.11":
version "0.3.11"
resolved "https://registry.yarnpkg.com/@interlay/bridge/-/bridge-0.3.11.tgz#45b2f3bb44d5e7eb1777ba82cfdf1a2f5dbf2b1d"
integrity sha512-HMgUlSFw5wOR7Qi+JxrDeY8TqoybRd7MWdXUqswDpiCgc0WZGTSDK+2NmuKRgDjRYoly0xIpzpkb8oek6v/JQw==
"@interlay/bridge@^0.3.13":
version "0.3.13"
resolved "https://registry.yarnpkg.com/@interlay/bridge/-/bridge-0.3.13.tgz#8add2a9d8a811ea3bbe73498bf3ebc19cd279ec6"
integrity sha512-LXXomxfI2n1h2MHeN8woRaQgh+gLKKlHfH1oTBAMyKPpSI7tTvtrE2XwIKt+Qg1TvmukRngtmwWtEXh760Dtkw==
dependencies:
"@acala-network/api" "4.1.8-13"
"@acala-network/sdk" "4.1.8-13"
Expand All @@ -2120,10 +2120,10 @@
dependencies:
axios "^0.21.1"

"@interlay/interbtc-api@2.3.1":
version "2.3.1"
resolved "https://registry.yarnpkg.com/@interlay/interbtc-api/-/interbtc-api-2.3.1.tgz#99bd9058453f6125d0fe1aa7bae208acda3191ed"
integrity sha512-XTbFNz0W/ev9cLfO0hKOfoPa79ARUrhKItrNolA98n055DMWHS7Lu9P1HUBG9KfKvgoiB5hQBo1Gc4hG+oPKQg==
"@interlay/interbtc-api@2.3.3":
version "2.3.3"
resolved "https://registry.yarnpkg.com/@interlay/interbtc-api/-/interbtc-api-2.3.3.tgz#e75f0aa64ae6db604d4314cadf307fe09d128741"
integrity sha512-q5uDFejEJoy4ZC5sc2YSmksILDA14qR/A+oQonMJGIh2F8k58YHdC8Zpp+6ayYUjp13rwkeQQwoBS1kwBFFdqg==
dependencies:
"@interlay/esplora-btc-api" "0.4.0"
"@interlay/interbtc-types" "1.12.0"
Expand Down

1 comment on commit d1924e1

@vercel
Copy link

@vercel vercel bot commented on d1924e1 Jun 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.