Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[release] Kintsugi 2.34.0 #1311

Merged
merged 45 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
182fba6
feat: redirect when access from forbidden country is detected (#1209)
peterslany May 19, 2023
ab6a554
Feature/updated transfer UI (#876)
tomjeatt May 22, 2023
65b0748
chore: release v2.32.0
tomjeatt May 22, 2023
8ff52df
Update API healthchecks (#778)
ns212 May 22, 2023
e9157c7
[earn strategies] placeholder page, nav and feature flag (#1216)
tomjeatt May 22, 2023
b04beda
feat: add useTransaction (#1189)
danielsimao May 23, 2023
e158798
chore: update monetary to latest 0.7.3 (#1214)
peterslany May 23, 2023
eee628c
chore: bump lib and bridge (#1219)
tomjeatt May 23, 2023
63b059a
chore: release v2.32.1
tomjeatt May 24, 2023
65d0a00
fix: add missing icons and remove erroring RPC (#1222)
tomjeatt May 24, 2023
250f722
chore: release v2.32.2
tomjeatt May 24, 2023
c000243
fix: compare input configs with method not operator (#1225)
tomjeatt May 24, 2023
17251a3
refactor: reset selected account on account change (#1226)
tomjeatt May 24, 2023
0d81dc5
chore: release v2.32.3
tomjeatt May 24, 2023
63487d0
feature: add geoblock feature flag (#1230)
tomjeatt May 25, 2023
d6db39b
chore: release v2.32.4
tomjeatt May 25, 2023
5f0dcb8
chore: bump bridge (#1233)
tomjeatt May 26, 2023
891de67
chore: release v2.32.5
tomjeatt May 26, 2023
918e944
Peter/earn strategies feat deposit withdraw form (#1229)
peterslany May 30, 2023
aca4e7d
feat: add Popover, Underlay and ProgressBar. Changes to Dialog, Modal…
danielsimao May 30, 2023
252285f
fix: Dialog, Modal and Popover (#1245)
danielsimao May 31, 2023
c845c54
chore: rename strategies feature (#1247)
tomjeatt May 31, 2023
64716ee
chore: release v2.32.6
tomjeatt May 31, 2023
a38f2af
Fix: back button behaviour from bridge page (#1246)
Chanakya888 May 31, 2023
ce9f284
feat: add transaction notifications (#1177)
danielsimao Jun 1, 2023
74eb7ee
chore: remove console.log (#1262)
danielsimao Jun 1, 2023
869efa9
fix(TokenInput): adorment ticker (#1257)
danielsimao Jun 2, 2023
f178d58
fix: get vesting data (#1264)
danielsimao Jun 2, 2023
7283d1e
Peter/chore update lib 2.3.0 (#1267)
peterslany Jun 5, 2023
f9afbb7
fix: sort notifications (#1270)
danielsimao Jun 6, 2023
f6be34f
fix: transaction none (#1271)
danielsimao Jun 7, 2023
36c41c6
fix(Loans): apy label (#1275)
danielsimao Jun 8, 2023
4bf3e13
Peter/loans fix subsidy rewards (#1276)
peterslany Jun 9, 2023
6f2972d
Peter/fix loans incentive apr computation (#1256)
peterslany Jun 9, 2023
0fb9217
chore: release v2.33.0
tomjeatt Jun 12, 2023
d5818f3
Peter/chore update lib 2.3.3 (#1282)
peterslany Jun 12, 2023
c4f05dc
fix: enable faucet on Interlay testnet (#1289)
tomjeatt Jun 14, 2023
bf01bb3
chore: bump bridge (#1285)
tomjeatt Jun 14, 2023
1b48685
fix(Swap): update trade object on each block (#1297)
danielsimao Jun 15, 2023
7669181
api: use diadata as main datasource (#1277)
ns212 Jun 19, 2023
4a19226
Peter/fix interlay issues (#1300)
peterslany Jun 19, 2023
4e1c721
api: select price source via query param and ticker renaming (#1307)
ns212 Jun 19, 2023
a6885d8
api: fix tether label for dia (#1309)
ns212 Jun 19, 2023
bf818bd
chore: release v2.34.0
tomjeatt Jun 20, 2023
52bf520
Merge branch 'master' into release/kintsugi/2.34.0
tomjeatt Jun 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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