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

Update wallet 1.15.0 #945

Merged
merged 1 commit into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polkaswap-exchange-web",
"version": "1.14.0",
"version": "1.15.0",
"repository": {
"type": "git",
"url": "https://github.com/sora-xor/polkaswap-exchange-web.git"
Expand All @@ -25,7 +25,7 @@
},
"dependencies": {
"@metamask/detect-provider": "^2.0.0",
"@soramitsu/soraneo-wallet-web": "1.14.1",
"@soramitsu/soraneo-wallet-web": "1.15.0",
"@walletconnect/web3-provider": "^1.8.0",
"base-64": "^1.0.0",
"core-js": "^3.26.0",
Expand Down
30 changes: 15 additions & 15 deletions src/components/Swap/Chart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ enum CHART_TYPES {
type ChartFilter = {
name: TIMEFRAME_TYPES;
label: string;
type: SUBQUERY_TYPES.AssetSnapshotTypes;
type: SUBQUERY_TYPES.SnapshotTypes;
count: number;
group?: number;
};
Expand All @@ -174,40 +174,40 @@ const CHART_TYPE_ICONS = {
};

const SECONDS_IN_TYPE = {
[SUBQUERY_TYPES.AssetSnapshotTypes.DEFAULT]: 5 * 60 * 1000,
[SUBQUERY_TYPES.AssetSnapshotTypes.HOUR]: 60 * 60 * 1000,
[SUBQUERY_TYPES.AssetSnapshotTypes.DAY]: 24 * 60 * 60 * 1000,
[SUBQUERY_TYPES.SnapshotTypes.DEFAULT]: 5 * 60 * 1000,
[SUBQUERY_TYPES.SnapshotTypes.HOUR]: 60 * 60 * 1000,
[SUBQUERY_TYPES.SnapshotTypes.DAY]: 24 * 60 * 60 * 1000,
};

const LINE_CHART_FILTERS: ChartFilter[] = [
{
name: TIMEFRAME_TYPES.DAY,
label: '1D',
type: SUBQUERY_TYPES.AssetSnapshotTypes.DEFAULT,
type: SUBQUERY_TYPES.SnapshotTypes.DEFAULT,
count: 288, // 5 mins in day
},
{
name: TIMEFRAME_TYPES.WEEK,
label: '1W',
type: SUBQUERY_TYPES.AssetSnapshotTypes.HOUR,
type: SUBQUERY_TYPES.SnapshotTypes.HOUR,
count: 24 * 7, // hours in week
},
{
name: TIMEFRAME_TYPES.MONTH,
label: '1M',
type: SUBQUERY_TYPES.AssetSnapshotTypes.DAY,
type: SUBQUERY_TYPES.SnapshotTypes.DAY,
count: 30, // days in month
},
{
name: TIMEFRAME_TYPES.YEAR,
label: '1Y',
type: SUBQUERY_TYPES.AssetSnapshotTypes.DAY,
type: SUBQUERY_TYPES.SnapshotTypes.DAY,
count: 365, // days in year
},
{
name: TIMEFRAME_TYPES.ALL,
label: 'ALL',
type: SUBQUERY_TYPES.AssetSnapshotTypes.DAY,
type: SUBQUERY_TYPES.SnapshotTypes.DAY,
count: Infinity,
},
];
Expand All @@ -216,40 +216,40 @@ const CANDLE_CHART_FILTERS = [
{
name: TIMEFRAME_TYPES.FIVE_MINUTES,
label: '5m',
type: SUBQUERY_TYPES.AssetSnapshotTypes.DEFAULT,
type: SUBQUERY_TYPES.SnapshotTypes.DEFAULT,
count: 48, // 5 mins in 4 hours
},
{
name: TIMEFRAME_TYPES.FIFTEEN_MINUTES,
label: '15m',
type: SUBQUERY_TYPES.AssetSnapshotTypes.DEFAULT,
type: SUBQUERY_TYPES.SnapshotTypes.DEFAULT,
count: 48 * 3, // 5 mins in 12 hours,
group: 3, // 5 min in 15 min
},
{
name: TIMEFRAME_TYPES.THIRTY_MINUTES,
label: '30m',
type: SUBQUERY_TYPES.AssetSnapshotTypes.DEFAULT,
type: SUBQUERY_TYPES.SnapshotTypes.DEFAULT,
count: 48 * 3 * 2, // 5 mins in 24 hours,
group: 6, // 5 min in 30 min
},
{
name: TIMEFRAME_TYPES.HOUR,
label: '1h',
type: SUBQUERY_TYPES.AssetSnapshotTypes.HOUR,
type: SUBQUERY_TYPES.SnapshotTypes.HOUR,
count: 24, // hours in day
},
{
name: TIMEFRAME_TYPES.FOUR_HOURS,
label: '4h',
type: SUBQUERY_TYPES.AssetSnapshotTypes.HOUR,
type: SUBQUERY_TYPES.SnapshotTypes.HOUR,
count: 24 * 4, // hours in 4 days,
group: 4, // 1 hour in 4 hours
},
{
name: TIMEFRAME_TYPES.DAY,
label: '1D',
type: SUBQUERY_TYPES.AssetSnapshotTypes.DAY,
type: SUBQUERY_TYPES.SnapshotTypes.DAY,
count: 90, // days in 3 months
},
];
Expand Down
77 changes: 37 additions & 40 deletions src/views/Explore/Tokens.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ import { Component, Mixins } from 'vue-property-decorator';
import { components, SubqueryExplorerService } from '@soramitsu/soraneo-wallet-web';
import { SortDirection } from '@soramitsu/soramitsu-js-ui/lib/components/Table/consts';
import type { Asset } from '@sora-substrate/util/build/assets/types';
import type {
AssetEntity,
AssetSnapshotEntity,
EntitiesQueryResponse,
} from '@soramitsu/soraneo-wallet-web/lib/services/subquery/types';
import type { AmountWithSuffix } from '@/types/formats';

import { Components } from '@/consts';
Expand All @@ -162,9 +167,17 @@ import { calcPriceChange, formatAmountWithSuffix } from '@/utils';
import { getter } from '@/store/decorators';

import ExplorePageMixin from '@/components/mixins/ExplorePageMixin';

import TranslationMixin from '@/components/mixins/TranslationMixin';

type AssetData = AssetEntity & {
daySnapshots: {
nodes: AssetSnapshotEntity[];
};
weekSnapshot: {
nodes: AssetSnapshotEntity[];
};
};

type TokenData = {
reserves: FPNumber;
startPriceDay: FPNumber;
Expand All @@ -185,9 +198,9 @@ type TableItem = {
tvlFormatted: AmountWithSuffix;
} & Asset;

const AssetsQuery = gql`
const AssetsQuery = gql<EntitiesQueryResponse<AssetData>>`
query AssetsQuery($after: Cursor, $ids: [String!], $dayTimestamp: Int, $weekTimestamp: Int) {
assets(after: $after, filter: { id: { in: $ids } }) {
entities: assets(after: $after, filter: { id: { in: $ids } }) {
pageInfo {
hasNextPage
endCursor
Expand Down Expand Up @@ -221,6 +234,23 @@ const AssetsQuery = gql`
}
`;

const parse = (item: AssetData): Record<string, TokenData> => {
const volume = item.daySnapshots.nodes.reduce((buffer, snapshot) => {
const hourVolume = new FPNumber(snapshot.volume.amountUSD);

return buffer.add(hourVolume);
}, FPNumber.ZERO);

return {
[item.id]: {
reserves: FPNumber.fromCodecValue(item.liquidity ?? 0),
startPriceDay: new FPNumber(item.daySnapshots.nodes?.[0]?.priceUSD?.open ?? 0),
startPriceWeek: new FPNumber(item.weekSnapshot.nodes?.[0]?.priceUSD?.open ?? 0),
volume,
},
};
};

@Component({
components: {
PriceChange: lazyComponent(Components.PriceChange),
Expand Down Expand Up @@ -286,45 +316,12 @@ export default class Tokens extends Mixins(ExplorePageMixin, TranslationMixin) {
const weekTimestamp = now - 60 * 60 * 24 * 7; // latest week snapshot (unix)
const ids = this.items.map((item) => item.address);

const tokensData = {};
let hasNextPage = true;
let after = '';
const variables = { ids, dayTimestamp, weekTimestamp };
const items = await SubqueryExplorerService.fetchAndParseEntities(parse, AssetsQuery, variables);

try {
do {
const response = await SubqueryExplorerService.request(AssetsQuery, {
after,
ids,
dayTimestamp,
weekTimestamp,
});
if (!items) return {};

if (!response || !response.assets) return tokensData;

hasNextPage = response.assets.pageInfo.hasNextPage;
after = response.assets.pageInfo.endCursor;

response.assets.nodes.forEach((item) => {
const volume = item.daySnapshots.nodes.reduce((buffer, snapshot) => {
const hourVolume = new FPNumber(snapshot.volume.amountUSD);

return buffer.add(hourVolume);
}, FPNumber.ZERO);

tokensData[item.id] = {
reserves: FPNumber.fromCodecValue(item.liquidity ?? 0),
startPriceDay: new FPNumber(item.daySnapshots.nodes?.[0]?.priceUSD?.open ?? 0),
startPriceWeek: new FPNumber(item.weekSnapshot.nodes?.[0]?.priceUSD?.open ?? 0),
volume,
};
});
} while (hasNextPage);

return tokensData;
} catch (error) {
console.error(error);
return tokensData;
}
return items.reduce((acc, item) => ({ ...acc, ...item }), {});
}
}
</script>
Expand Down
72 changes: 36 additions & 36 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2521,60 +2521,60 @@
resolved "https://registry.yarnpkg.com/@soda/get-current-script/-/get-current-script-1.0.2.tgz#a53515db25d8038374381b73af20bb4f2e508d87"
integrity sha512-T7VNNlYVM1SgQ+VsMYhnDkcGmWhQdL0bDyGm5TlQ3GBXnJscEClUUOKduWTmm2zCnvNLC1hc3JpuXjs/nFOc5w==

"@sora-substrate/api@1.14.5":
version "1.14.5"
resolved "https://registry.yarnpkg.com/@sora-substrate/api/-/api-1.14.5.tgz#9c5e57fbcee8e682ac3b6aa88834a71cb6d320cb"
integrity sha512-tigssGuUepgvoAgSZx86s34/+vjmB3VMvAKKQGWierRDdXtpHQGjwJL4K+Zhvqn1W6GsZbIYRMQ47SlqikYX3g==
"@sora-substrate/api@1.14.8":
version "1.14.8"
resolved "https://registry.yarnpkg.com/@sora-substrate/api/-/api-1.14.8.tgz#edae514f8db44eeccaabab2508e58ee022c5c35f"
integrity sha512-lJAPLUhTWb9GULoZcOmzJNskS4QbUCsoFHnrWXEKslxs+9sfpcsncv7VhPXLL91koRXF8BYPU3iQQRSY1RzsDw==
dependencies:
"@open-web3/orml-api-derive" "0.9.4-26"
"@polkadot/api" "9.6.2"
"@sora-substrate/types" "1.14.5"
"@sora-substrate/types" "1.14.8"

"@sora-substrate/liquidity-proxy@1.14.5":
version "1.14.5"
resolved "https://registry.yarnpkg.com/@sora-substrate/liquidity-proxy/-/liquidity-proxy-1.14.5.tgz#6521bc1a7b7922053837369d001f91e93c04a75d"
integrity sha512-UxmiXu+yyrZ5RwUJlwXVbfDE6JsGxM+bNMyXSGF5euX3mD2dsruJerndaN8yH9h1aecYfBJnBm0EMI8vmLkzCQ==
"@sora-substrate/liquidity-proxy@1.14.8":
version "1.14.8"
resolved "https://registry.yarnpkg.com/@sora-substrate/liquidity-proxy/-/liquidity-proxy-1.14.8.tgz#d1879fc05cd8a5fdfeeb62359c718e10d60c1cf8"
integrity sha512-1Jfmna6tld7pyxwgyB8hH/cEGZoqV7REozxbIxxB4fYLcFvl+6wFouSFWaJXjHBbZhXWaSXEAfQq+i0Fy94G1g==
dependencies:
"@sora-substrate/math" "1.14.5"
"@sora-substrate/math" "1.14.8"

"@sora-substrate/math@1.14.5":
version "1.14.5"
resolved "https://registry.yarnpkg.com/@sora-substrate/math/-/math-1.14.5.tgz#949d56e9df06b58386c63518622a6409bab99f98"
integrity sha512-Z23DMvKmQ0egMBXgiHtRPxQW1XkPwt4xqhGq56iiGyRrpyaB2ANUxYXs4Hxn2/3EG7jWANRXwaO9mws1RJ/fKQ==
"@sora-substrate/math@1.14.8":
version "1.14.8"
resolved "https://registry.yarnpkg.com/@sora-substrate/math/-/math-1.14.8.tgz#b5a64d103208ec8d8fdbc2882bd1e1eabc704b33"
integrity sha512-5iE9273Oq9XDfjFPIHRsr9Bk9VKpCJhfMzy9F/1QbMEX5HmUBhrr8jrxIDzSuxylcD35Sq0b0YA2McLf2YMqkg==
dependencies:
"@polkadot/types" "9.6.2"
bignumber.js "^9.0.1"
lodash "^4.17.15"

"@sora-substrate/type-definitions@1.14.5":
version "1.14.5"
resolved "https://registry.yarnpkg.com/@sora-substrate/type-definitions/-/type-definitions-1.14.5.tgz#d1fddad83674d4ca5a3024b5830d501a889f700b"
integrity sha512-YPoO0U7uZ2Hq88MLMrqQPCxulE/OnqonMEEzwTWIg4JaS4mce1+6mPrRjC/hYGRQRKFY1qxLyjubYTGYlVnGag==
"@sora-substrate/type-definitions@1.14.8":
version "1.14.8"
resolved "https://registry.yarnpkg.com/@sora-substrate/type-definitions/-/type-definitions-1.14.8.tgz#662cd18da9edbe9ff9d4f8e042aeb9063b7c7db5"
integrity sha512-fZkRCaknwxvE75RaTWUBz4S3/GFaQyweQU5mMsuHur+OjSKma0JJb8MtJKgN2xgP1txxuKA+2D8bkXT6QyfmRg==
dependencies:
"@open-web3/orml-type-definitions" "0.9.4-26"

"@sora-substrate/types@1.14.5":
version "1.14.5"
resolved "https://registry.yarnpkg.com/@sora-substrate/types/-/types-1.14.5.tgz#7f172fdef70efde5b162f93c37169b05fb3a572c"
integrity sha512-oSjSYvYUN9edy6ujKa5NQkR/i2OqrUxx4n/WH5HAGSxVjH2KWfz+n9s5GyFUTlROSlonn5mXudSxRcYUZGR6iA==
"@sora-substrate/types@1.14.8":
version "1.14.8"
resolved "https://registry.yarnpkg.com/@sora-substrate/types/-/types-1.14.8.tgz#9b4f62b39f21850397e3dc082f1bfb400d0cc66a"
integrity sha512-c8m304qgKK+r8YncEwezUozzbb5RLHZWp9VdwlwVXOg++JIhDx1zNJc+xqotOXDdYtI8u8KJDfAsEMZOL0YL+g==
dependencies:
"@open-web3/api-mobx" "0.9.4-26"
"@open-web3/orml-types" "0.9.4-26"
"@polkadot/api" "9.6.2"
"@polkadot/typegen" "9.6.2"
"@polkadot/types" "9.6.2"
"@sora-substrate/type-definitions" "1.14.5"
"@sora-substrate/type-definitions" "1.14.8"

"@sora-substrate/util@1.14.5":
version "1.14.5"
resolved "https://registry.yarnpkg.com/@sora-substrate/util/-/util-1.14.5.tgz#4ae598f708135e3f8e34be90854e872e437e8206"
integrity sha512-ikAL4m5+UI1OvZBjjfFkdLxdPjzLGxJZKuAJQ+0jqCmaRTZjnDUATQ+AJu5giM3V76jykN8iYtZq0+Ml1qwMvQ==
"@sora-substrate/util@1.14.8":
version "1.14.8"
resolved "https://registry.yarnpkg.com/@sora-substrate/util/-/util-1.14.8.tgz#106cf9fae00b25873f4107dcf23f14ed326f6072"
integrity sha512-7EYpsQ90EHhMyATaNttX2ch2PAupMszZr4a5F8Zhi1cb9PV2OkKmQOnSTIxyiiP/TZk85oU++e726YciYx6Caw==
dependencies:
"@polkadot/ui-keyring" "2.9.14"
"@sora-substrate/api" "1.14.5"
"@sora-substrate/liquidity-proxy" "1.14.5"
"@sora-substrate/math" "1.14.5"
"@sora-substrate/types" "1.14.5"
"@sora-substrate/api" "1.14.8"
"@sora-substrate/liquidity-proxy" "1.14.8"
"@sora-substrate/math" "1.14.8"
"@sora-substrate/types" "1.14.8"
axios "^0.21.1"
bignumber.js "^9.0.1"
crypto-js "^4.0.0"
Expand All @@ -2597,13 +2597,13 @@
vue-property-decorator "^9.1.2"
vuex "^3.6.2"

"@soramitsu/soraneo-wallet-web@1.14.1":
version "1.14.1"
resolved "https://nexus.iroha.tech/repository/npm-group/@soramitsu/soraneo-wallet-web/-/soraneo-wallet-web-1.14.1.tgz#211fd1370097e8204f5afc3f10bae07ebe4fec8c"
integrity sha512-A8btNSAPVGrXcTXKU+Af8JcoFhXLsYSwx6KNDG/dsbICTSkoUEnJya91w1vRgH5PkXhQ7JqU4/efPgNwuDiwsQ==
"@soramitsu/soraneo-wallet-web@1.15.0":
version "1.15.0"
resolved "https://nexus.iroha.tech/repository/npm-group/@soramitsu/soraneo-wallet-web/-/soraneo-wallet-web-1.15.0.tgz#270f18f975c511ddaabe937f67dba241435162ed"
integrity sha512-yh4Kz14grcBL0Kyzrkj4+6YJcfuq1bHszCP7P2HLDeiQAZyYAZpK7ORSwC7pBjP0c8y5RO034Rl4gQhQyR9Pgw==
dependencies:
"@polkadot/vue-identicon" "2.9.14"
"@sora-substrate/util" "1.14.5"
"@sora-substrate/util" "1.14.8"
"@soramitsu/soramitsu-js-ui" "^1.0.42"
"@subwallet/wallet-connect" "^0.2.3"
"@urql/core" "^3.0.5"
Expand Down