From f4f611fb86235a0df6fb814294899fa33a29f944 Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Mon, 26 Jul 2021 14:45:32 +0100 Subject: [PATCH 01/30] 1.11.0 (#606) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 050a6d92c2..10347a184f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@balancer-labs/frontend-v2", - "version": "1.10.4", + "version": "1.11.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@balancer-labs/frontend-v2", - "version": "1.10.4", + "version": "1.11.0", "license": "MIT", "dependencies": { "@balancer-labs/assets": "github:balancer-labs/assets#master", diff --git a/package.json b/package.json index 89d7685c00..838cdac392 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@balancer-labs/frontend-v2", - "version": "1.10.4", + "version": "1.11.0", "engines": { "node": "14.x", "npm": ">=7" From 0ba8464cff23f21542bd383dcf16b6a4ed0b321f Mon Sep 17 00:00:00 2001 From: John Grant Date: Mon, 26 Jul 2021 15:23:49 +0100 Subject: [PATCH 02/30] WIP - Updated to new SDK SOR. (#584) Co-authored-by: Gareth Fuller --- package-lock.json | 168 +++++++++++++++--- package.json | 2 +- .../pool/calculator/calculator.sevice.ts | 10 +- src/services/pool/calculator/stable.ts | 90 +++++----- src/services/pool/calculator/weighted.ts | 68 +++---- 5 files changed, 227 insertions(+), 111 deletions(-) diff --git a/package-lock.json b/package-lock.json index 10347a184f..216def3e35 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@balancer-labs/assets": "github:balancer-labs/assets#master", "@balancer-labs/sor": "github:balancer-labs/balancer-sor#john/v1-consideringFees-package", - "@balancer-labs/sor2": "github:balancer-labs/balancer-sor#develop-V2", + "@balancer-labs/sor2": "github:balancer-labs/balancer-sor#john/ui-629-sor-integrate-sdk-maths", "@ensdomains/content-hash": "^2.5.3", "@ethersproject/abi": "^5.0.1", "@ethersproject/abstract-signer": "^5.3.0", @@ -1483,7 +1483,7 @@ }, "node_modules/@balancer-labs/sor2": { "version": "2.0.1", - "resolved": "git+ssh://git@github.com/balancer-labs/balancer-sor.git#a03a7225ea6106c7435affb013907e298401a59f", + "resolved": "git+ssh://git@github.com/balancer-labs/balancer-sor.git#82784ee91ae9221ae68fbef5373fbfc44a40ff28", "license": "GPL-3.0-only", "dependencies": { "@ethersproject/address": "^5.0.5", @@ -1491,9 +1491,8 @@ "@ethersproject/contracts": "^5.0.5", "@ethersproject/providers": "5.0.12", "@ethersproject/solidity": "^5.0.5", - "@ethersproject/units": "^5.0.6", - "bignumber.js": "^9.0.0", - "decimal.js": "^10.2.1", + "@georgeroman/balancer-v2-pools": "^0.0.5", + "bignumber.js": "^9.0.1", "isomorphic-fetch": "^2.2.1" } }, @@ -1523,6 +1522,11 @@ "ws": "7.2.3" } }, + "node_modules/@balancer-labs/v2-deployments": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@balancer-labs/v2-deployments/-/v2-deployments-1.1.1.tgz", + "integrity": "sha512-emB/xHCM/njxpReZQx2BqzHXwrWF+iIwn/hSwnSOxp+P6GH0rOaboio6/+Aapj7f9tCCjqRspetX//9TumX82Q==" + }, "node_modules/@base2/pretty-print-object": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@base2/pretty-print-object/-/pretty-print-object-1.0.0.tgz", @@ -2387,6 +2391,18 @@ "purgecss": "^3.1.3" } }, + "node_modules/@georgeroman/balancer-v2-pools": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/@georgeroman/balancer-v2-pools/-/balancer-v2-pools-0.0.5.tgz", + "integrity": "sha512-fx+QmDJ80+E4RoaBfmnKFaOlRLM/FSbzksaTrqXM+0EeWX5Zu99SO03pjTIBDsBifq2WfHBcCU5CW5ulGF/kkg==", + "dependencies": { + "@balancer-labs/v2-deployments": "^1.0.0", + "bignumber.js": "^9.0.1", + "ethers": "^5.2.0", + "graphql": "^15.5.0", + "graphql-request": "^3.4.0" + } + }, "node_modules/@gnosis.pm/gp-v2-contracts": { "version": "0.0.1-alpha.19", "resolved": "https://registry.npmjs.org/@gnosis.pm/gp-v2-contracts/-/gp-v2-contracts-0.0.1-alpha.19.tgz", @@ -13525,11 +13541,6 @@ "node": ">=0.10.0" } }, - "node_modules/decimal.js": { - "version": "10.3.1", - "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.3.1.tgz", - "integrity": "sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ==" - }, "node_modules/decode-uri-component": { "version": "0.2.0", "license": "MIT", @@ -15784,6 +15795,17 @@ "node": ">=0.10.0" } }, + "node_modules/extract-files": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/extract-files/-/extract-files-9.0.0.tgz", + "integrity": "sha512-CvdFfHkC95B4bBBk36hcEmvdR2awOdhhVUYH6S/zrVj3477zven/fJMYg7121h4T1xHZC+tetUpubpAhxwI7hQ==", + "engines": { + "node": "^10.17.0 || ^12.0.0 || >= 13.7.0" + }, + "funding": { + "url": "https://github.com/sponsors/jaydenseric" + } + }, "node_modules/extract-from-css": { "version": "0.4.4", "dev": true, @@ -16959,6 +16981,56 @@ "version": "4.2.6", "license": "ISC" }, + "node_modules/graphql": { + "version": "15.5.1", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-15.5.1.tgz", + "integrity": "sha512-FeTRX67T3LoE3LWAxxOlW2K3Bz+rMYAC18rRguK4wgXaTZMiJwSUwDmPFo3UadAKbzirKIg5Qy+sNJXbpPRnQw==", + "engines": { + "node": ">= 10.x" + } + }, + "node_modules/graphql-request": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/graphql-request/-/graphql-request-3.4.0.tgz", + "integrity": "sha512-acrTzidSlwAj8wBNO7Q/UQHS8T+z5qRGquCQRv9J1InwR01BBWV9ObnoE+JS5nCCEj8wSGS0yrDXVDoRiKZuOg==", + "dependencies": { + "cross-fetch": "^3.0.6", + "extract-files": "^9.0.0", + "form-data": "^3.0.0" + }, + "peerDependencies": { + "graphql": "14.x || 15.x" + } + }, + "node_modules/graphql-request/node_modules/cross-fetch": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz", + "integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==", + "dependencies": { + "node-fetch": "2.6.1" + } + }, + "node_modules/graphql-request/node_modules/form-data": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/graphql-request/node_modules/node-fetch": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==", + "engines": { + "node": "4.x || >=6.0.0" + } + }, "node_modules/growly": { "version": "1.3.0", "dev": true, @@ -32734,17 +32806,16 @@ } }, "@balancer-labs/sor2": { - "version": "git+ssh://git@github.com/balancer-labs/balancer-sor.git#a03a7225ea6106c7435affb013907e298401a59f", - "from": "@balancer-labs/sor2@github:balancer-labs/balancer-sor#develop-V2", + "version": "git+ssh://git@github.com/balancer-labs/balancer-sor.git#82784ee91ae9221ae68fbef5373fbfc44a40ff28", + "from": "@balancer-labs/sor2@github:balancer-labs/balancer-sor#john/ui-629-sor-integrate-sdk-maths", "requires": { "@ethersproject/address": "^5.0.5", "@ethersproject/constants": "^5.0.5", "@ethersproject/contracts": "^5.0.5", "@ethersproject/providers": "5.0.12", "@ethersproject/solidity": "^5.0.5", - "@ethersproject/units": "^5.0.6", - "bignumber.js": "^9.0.0", - "decimal.js": "^10.2.1", + "@georgeroman/balancer-v2-pools": "^0.0.5", + "bignumber.js": "^9.0.1", "isomorphic-fetch": "^2.2.1" }, "dependencies": { @@ -32776,6 +32847,11 @@ } } }, + "@balancer-labs/v2-deployments": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@balancer-labs/v2-deployments/-/v2-deployments-1.1.1.tgz", + "integrity": "sha512-emB/xHCM/njxpReZQx2BqzHXwrWF+iIwn/hSwnSOxp+P6GH0rOaboio6/+Aapj7f9tCCjqRspetX//9TumX82Q==" + }, "@base2/pretty-print-object": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@base2/pretty-print-object/-/pretty-print-object-1.0.0.tgz", @@ -33307,6 +33383,18 @@ "purgecss": "^3.1.3" } }, + "@georgeroman/balancer-v2-pools": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/@georgeroman/balancer-v2-pools/-/balancer-v2-pools-0.0.5.tgz", + "integrity": "sha512-fx+QmDJ80+E4RoaBfmnKFaOlRLM/FSbzksaTrqXM+0EeWX5Zu99SO03pjTIBDsBifq2WfHBcCU5CW5ulGF/kkg==", + "requires": { + "@balancer-labs/v2-deployments": "^1.0.0", + "bignumber.js": "^9.0.1", + "ethers": "^5.2.0", + "graphql": "^15.5.0", + "graphql-request": "^3.4.0" + } + }, "@gnosis.pm/gp-v2-contracts": { "version": "0.0.1-alpha.19", "resolved": "https://registry.npmjs.org/@gnosis.pm/gp-v2-contracts/-/gp-v2-contracts-0.0.1-alpha.19.tgz", @@ -41434,11 +41522,6 @@ "decamelize": { "version": "1.2.0" }, - "decimal.js": { - "version": "10.3.1", - "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.3.1.tgz", - "integrity": "sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ==" - }, "decode-uri-component": { "version": "0.2.0" }, @@ -43125,6 +43208,11 @@ } } }, + "extract-files": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/extract-files/-/extract-files-9.0.0.tgz", + "integrity": "sha512-CvdFfHkC95B4bBBk36hcEmvdR2awOdhhVUYH6S/zrVj3477zven/fJMYg7121h4T1xHZC+tetUpubpAhxwI7hQ==" + }, "extract-from-css": { "version": "0.4.4", "dev": true, @@ -43954,6 +44042,46 @@ "graceful-fs": { "version": "4.2.6" }, + "graphql": { + "version": "15.5.1", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-15.5.1.tgz", + "integrity": "sha512-FeTRX67T3LoE3LWAxxOlW2K3Bz+rMYAC18rRguK4wgXaTZMiJwSUwDmPFo3UadAKbzirKIg5Qy+sNJXbpPRnQw==" + }, + "graphql-request": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/graphql-request/-/graphql-request-3.4.0.tgz", + "integrity": "sha512-acrTzidSlwAj8wBNO7Q/UQHS8T+z5qRGquCQRv9J1InwR01BBWV9ObnoE+JS5nCCEj8wSGS0yrDXVDoRiKZuOg==", + "requires": { + "cross-fetch": "^3.0.6", + "extract-files": "^9.0.0", + "form-data": "^3.0.0" + }, + "dependencies": { + "cross-fetch": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz", + "integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==", + "requires": { + "node-fetch": "2.6.1" + } + }, + "form-data": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, + "node-fetch": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" + } + } + }, "growly": { "version": "1.3.0", "dev": true diff --git a/package.json b/package.json index 838cdac392..0b3583946b 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "dependencies": { "@balancer-labs/assets": "github:balancer-labs/assets#master", "@balancer-labs/sor": "github:balancer-labs/balancer-sor#john/v1-consideringFees-package", - "@balancer-labs/sor2": "github:balancer-labs/balancer-sor#develop-V2", + "@balancer-labs/sor2": "github:balancer-labs/balancer-sor#john/ui-629-sor-integrate-sdk-maths", "@ensdomains/content-hash": "^2.5.3", "@ethersproject/abi": "^5.0.1", "@ethersproject/abstract-signer": "^5.3.0", diff --git a/src/services/pool/calculator/calculator.sevice.ts b/src/services/pool/calculator/calculator.sevice.ts index bc7277ae6f..c1f4d9c2cc 100644 --- a/src/services/pool/calculator/calculator.sevice.ts +++ b/src/services/pool/calculator/calculator.sevice.ts @@ -1,7 +1,6 @@ import BigNumber from 'bignumber.js'; import { parseUnits, formatUnits } from '@ethersproject/units'; import { BigNumberish } from '@ethersproject/bignumber'; -import { FixedPointNumber } from '@balancer-labs/sor2/dist/math/FixedPointNumber'; import { FullPool } from '@/services/balancer/subgraph/types'; @@ -63,7 +62,7 @@ export default class CalculatorService { return this.weighted.priceImpact(tokenAmounts, opts); } - public exactTokensInForBPTOut(tokenAmounts: string[]): FixedPointNumber { + public exactTokensInForBPTOut(tokenAmounts: string[]): BigNumber { if (this.isStablePool) { return this.stable.exactTokensInForBPTOut(tokenAmounts); } @@ -73,17 +72,14 @@ export default class CalculatorService { public exactBPTInForTokenOut( bptAmount: string, tokenIndex: number - ): FixedPointNumber { + ): BigNumber { if (this.isStablePool) { return this.stable.exactBPTInForTokenOut(bptAmount, tokenIndex); } return this.weighted.exactBPTInForTokenOut(bptAmount, tokenIndex); } - public bptInForExactTokenOut( - amount: string, - tokenIndex: number - ): FixedPointNumber { + public bptInForExactTokenOut(amount: string, tokenIndex: number): BigNumber { if (this.isStablePool) { return this.stable.bptInForExactTokenOut(amount, tokenIndex); } diff --git a/src/services/pool/calculator/stable.ts b/src/services/pool/calculator/stable.ts index 120c3a68a0..944bc10ec1 100644 --- a/src/services/pool/calculator/stable.ts +++ b/src/services/pool/calculator/stable.ts @@ -4,15 +4,9 @@ import { parseUnits, formatUnits } from '@ethersproject/units'; import { bnum } from '@/lib/utils'; import BigNumber from 'bignumber.js'; -import { - _exactTokensInForBPTOut, - _exactBPTInForTokenOut, - _bptInForExactTokensOut -} from '@balancer-labs/sor2/dist/pools/stablePool/stableMathEvm'; import { BPTForTokensZeroPriceImpact as _bptForTokensZeroPriceImpact } from '@balancer-labs/sor2/dist/frontendHelpers/stableHelpers'; -import { fnum } from '@balancer-labs/sor2/dist/math/lib/fixedPoint'; -import { FixedPointNumber } from '@balancer-labs/sor2/dist/math/FixedPointNumber'; import { BigNumberish } from '@ethersproject/bignumber'; +import * as SDK from '@georgeroman/balancer-v2-pools'; /** * The stableMathEvm works with all values scaled to 18 decimals, @@ -20,25 +14,27 @@ import { BigNumberish } from '@ethersproject/bignumber'; */ export default class Stable { calc: Calculator; + AMP_PRECISION = bnum(1000); constructor(calculator) { this.calc = calculator; } - public exactTokensInForBPTOut(tokenAmounts: string[]): FixedPointNumber { - const amp = fnum(this.calc.pool.onchain.amp?.toString() || '0'); + public exactTokensInForBPTOut(tokenAmounts: string[]): BigNumber { + const amp = bnum(this.calc.pool.onchain.amp?.toString() || '0'); + const ampAdjusted = this.adjustAmp(amp); const denormAmounts = this.calc.denormAmounts( tokenAmounts, this.calc.poolTokenDecimals.map(() => 18) ); - const amounts = denormAmounts.map(a => fnum(a.toString())); + const amounts = denormAmounts.map(a => bnum(a.toString())); - const bptOut = _exactTokensInForBPTOut( + const bptOut = SDK.StableMath._calcBptOutGivenExactTokensIn( + ampAdjusted, this.scaledBalances, - amp, amounts, this.scaledPoolTotalSupply, - fnum(this.calc.poolSwapFee.toString()) + bnum(this.calc.poolSwapFee.toString()) ); return this.scaleOutput( @@ -48,20 +44,22 @@ export default class Stable { ); } - public bptInForExactTokensOut(tokenAmounts: string[]): FixedPointNumber { - const amp = fnum(this.calc.pool.onchain.amp?.toString() || '0'); + public bptInForExactTokensOut(tokenAmounts: string[]): BigNumber { + const amp = bnum(this.calc.pool.onchain.amp?.toString() || '0'); + const ampAdjusted = this.adjustAmp(amp); + const denormAmounts = this.calc.denormAmounts( tokenAmounts, this.calc.poolTokenDecimals.map(() => 18) ); - const amounts = denormAmounts.map(a => fnum(a.toString())); + const amounts = denormAmounts.map(a => bnum(a.toString())); - const bptIn = _bptInForExactTokensOut( + const bptIn = SDK.StableMath._calcBptInGivenExactTokensOut( + ampAdjusted, this.scaledBalances, - amp, amounts, this.scaledPoolTotalSupply, - fnum(this.calc.poolSwapFee.toString()) + bnum(this.calc.poolSwapFee.toString()) ); return this.scaleOutput( @@ -71,22 +69,20 @@ export default class Stable { ); } - public bptInForExactTokenOut( - amount: string, - tokenIndex: number - ): FixedPointNumber { - const amp = fnum(this.calc.pool.onchain.amp?.toString() || '0'); + public bptInForExactTokenOut(amount: string, tokenIndex: number): BigNumber { + const amp = bnum(this.calc.pool.onchain.amp?.toString() || '0'); + const ampAdjusted = this.adjustAmp(amp); const amounts = this.calc.pool.tokenAddresses.map((address, i) => { - if (i === tokenIndex) return fnum(parseUnits(amount, 18).toString()); - return fnum('0'); + if (i === tokenIndex) return bnum(parseUnits(amount, 18).toString()); + return bnum('0'); }); - const bptIn = _bptInForExactTokensOut( + const bptIn = SDK.StableMath._calcBptInGivenExactTokensOut( + ampAdjusted, this.scaledBalances, - amp, amounts, this.scaledPoolTotalSupply, - fnum(this.calc.poolSwapFee.toString()) + bnum(this.calc.poolSwapFee.toString()) ); return this.scaleOutput( @@ -99,17 +95,18 @@ export default class Stable { public exactBPTInForTokenOut( bptAmount: string, tokenIndex: number - ): FixedPointNumber { - const amp = fnum(this.calc.pool.onchain.amp?.toString() || '0'); - const bptAmountIn = fnum(parseUnits(bptAmount, 18).toString()); + ): BigNumber { + const amp = bnum(this.calc.pool.onchain.amp?.toString() || '0'); + const ampAdjusted = this.adjustAmp(amp); + const bptAmountIn = bnum(parseUnits(bptAmount, 18).toString()); - const tokenAmountOut = _exactBPTInForTokenOut( - tokenIndex, + const tokenAmountOut = SDK.StableMath._calcTokenOutGivenExactBptIn( + ampAdjusted, this.scaledBalances, - amp, + tokenIndex, bptAmountIn, this.scaledPoolTotalSupply, - fnum(this.calc.poolSwapFee.toString()) + bnum(this.calc.poolSwapFee.toString()) ); return this.scaleOutput( @@ -120,7 +117,7 @@ export default class Stable { } public priceImpact(tokenAmounts: string[], opts: PiOptions): BigNumber { - let bptAmount: FixedPointNumber | BigNumberish; + let bptAmount: BigNumber | BigNumberish; let bptZeroPriceImpact: BigNumber; if (this.calc.action === 'join') { @@ -162,7 +159,7 @@ export default class Stable { // PRIVATE FUNCTIONS private bptForTokensZeroPriceImpact(tokenAmounts: string[]): BigNumber { - const amp = fnum(this.calc.pool.onchain.amp?.toString() || '0'); + const amp = bnum(this.calc.pool.onchain.amp?.toString() || '0'); const denormAmounts = this.calc.denormAmounts( tokenAmounts, this.calc.poolTokenDecimals @@ -182,37 +179,42 @@ export default class Stable { return bptZeroImpact; } - private get scaledBalances(): FixedPointNumber[] { + private get scaledBalances(): BigNumber[] { return this.calc.poolTokenBalances.map((balance, i) => { const normalizedBalance = formatUnits( balance, this.calc.poolTokenDecimals[i] ); const scaledBalance = parseUnits(normalizedBalance, 18); - return fnum(scaledBalance.toString()); + return bnum(scaledBalance.toString()); }); } - private get scaledPoolTotalSupply(): FixedPointNumber { + private get scaledPoolTotalSupply(): BigNumber { const normalizedSupply = formatUnits( this.calc.poolTotalSupply, this.calc.poolDecimals ); const scaledSupply = parseUnits(normalizedSupply, 18); - return fnum(scaledSupply.toString()); + return bnum(scaledSupply.toString()); } private scaleOutput( amount: string, decimals: number, rounding: BigNumber.RoundingMode - ): FixedPointNumber { + ): BigNumber { const normalizedAmount = bnum(formatUnits(amount, 18)).toFixed( decimals, rounding ); const scaledAmount = parseUnits(normalizedAmount, decimals); - return fnum(scaledAmount.toString()); + return bnum(scaledAmount.toString()); + } + + // Solidity maths uses precison method for amp that must be replicated + private adjustAmp(amp: BigNumber): BigNumber { + return amp.times(this.AMP_PRECISION); } } diff --git a/src/services/pool/calculator/weighted.ts b/src/services/pool/calculator/weighted.ts index bd39f04ddf..f94775fe3d 100644 --- a/src/services/pool/calculator/weighted.ts +++ b/src/services/pool/calculator/weighted.ts @@ -4,15 +4,8 @@ import { parseUnits, formatUnits } from '@ethersproject/units'; import { bnum } from '@/lib/utils'; import BigNumber from 'bignumber.js'; -import { - _exactTokensInForBPTOut, - _exactBPTInForTokenOut, - _bptInForExactTokenOut, - _bptInForExactTokensOut -} from '@balancer-labs/sor2/dist/pools/weightedPool/weightedMathEvm'; +import * as SDK from '@georgeroman/balancer-v2-pools'; import { BPTForTokensZeroPriceImpact as _bptForTokensZeroPriceImpact } from '@balancer-labs/sor2/dist/frontendHelpers/weightedHelpers'; -import { fnum } from '@balancer-labs/sor2/dist/math/lib/fixedPoint'; -import { FixedPointNumber } from '@balancer-labs/sor2/dist/math/FixedPointNumber'; export default class Weighted { calc: Calculator; @@ -21,59 +14,56 @@ export default class Weighted { this.calc = calculator; } - public exactTokensInForBPTOut(tokenAmounts: string[]): FixedPointNumber { - const balances = this.calc.poolTokenBalances.map(b => fnum(b.toString())); - const weights = this.calc.poolTokenWeights.map(w => fnum(w.toString())); + public exactTokensInForBPTOut(tokenAmounts: string[]): BigNumber { + const balances = this.calc.poolTokenBalances.map(b => bnum(b.toString())); + const weights = this.calc.poolTokenWeights.map(w => bnum(w.toString())); const denormAmounts = this.calc.denormAmounts( tokenAmounts, this.calc.poolTokenDecimals ); - const amounts = denormAmounts.map(a => fnum(a.toString())); + const amounts = denormAmounts.map(a => bnum(a.toString())); - return _exactTokensInForBPTOut( + return SDK.WeightedMath._calcBptOutGivenExactTokensIn( balances, weights, amounts, - fnum(this.calc.poolTotalSupply.toString()), - fnum(this.calc.poolSwapFee.toString()) + bnum(this.calc.poolTotalSupply.toString()), + bnum(this.calc.poolSwapFee.toString()) ); } - public bptInForExactTokensOut(tokenAmounts: string[]): FixedPointNumber { - const balances = this.calc.poolTokenBalances.map(b => fnum(b.toString())); - const weights = this.calc.poolTokenWeights.map(w => fnum(w.toString())); + public bptInForExactTokensOut(tokenAmounts: string[]): BigNumber { + const balances = this.calc.poolTokenBalances.map(b => bnum(b.toString())); + const weights = this.calc.poolTokenWeights.map(w => bnum(w.toString())); const denormAmounts = this.calc.denormAmounts( tokenAmounts, this.calc.poolTokenDecimals ); - const amounts = denormAmounts.map(a => fnum(a.toString())); + const amounts = denormAmounts.map(a => bnum(a.toString())); - return _bptInForExactTokensOut( + return SDK.WeightedMath._calcBptInGivenExactTokensOut( balances, weights, amounts, - fnum(this.calc.poolTotalSupply.toString()), - fnum(this.calc.poolSwapFee.toString()) + bnum(this.calc.poolTotalSupply.toString()), + bnum(this.calc.poolSwapFee.toString()) ); } - public bptInForExactTokenOut( - amount: string, - tokenIndex: number - ): FixedPointNumber { - const tokenBalance = fnum( + public bptInForExactTokenOut(amount: string, tokenIndex: number): BigNumber { + const tokenBalance = bnum( this.calc.poolTokenBalances[tokenIndex].toString() ); - const tokenNormalizedWeight = fnum( + const tokenNormalizedWeight = bnum( this.calc.poolTokenWeights[tokenIndex].toString() ); - const bptAmountIn = fnum( + const bptAmountIn = bnum( parseUnits(amount, this.calc.poolTokenDecimals[tokenIndex]).toString() ); - const bptTotalSupply = fnum(this.calc.poolTotalSupply.toString()); - const swapFee = fnum(this.calc.poolSwapFee.toString()); + const bptTotalSupply = bnum(this.calc.poolTotalSupply.toString()); + const swapFee = bnum(this.calc.poolSwapFee.toString()); - return _bptInForExactTokenOut( + return SDK.WeightedMath._calcBptInGivenExactTokenOut( tokenBalance, tokenNormalizedWeight, bptAmountIn, @@ -85,23 +75,23 @@ export default class Weighted { public exactBPTInForTokenOut( bptAmount: string, tokenIndex: number - ): FixedPointNumber { - const tokenBalance = fnum( + ): BigNumber { + const tokenBalance = bnum( this.calc.poolTokenBalances[tokenIndex].toString() ); - const tokenNormalizedWeight = fnum( + const tokenNormalizedWeight = bnum( this.calc.poolTokenWeights[tokenIndex].toString() ); - const bptAmountIn = fnum( + const bptAmountIn = bnum( parseUnits(bptAmount, this.calc.poolDecimals).toString() ); - return _exactBPTInForTokenOut( + return SDK.WeightedMath._calcTokenOutGivenExactBptIn( tokenBalance, tokenNormalizedWeight, bptAmountIn, - fnum(this.calc.poolTotalSupply.toString()), - fnum(this.calc.poolSwapFee.toString()) + bnum(this.calc.poolTotalSupply.toString()), + bnum(this.calc.poolSwapFee.toString()) ); } From 5f2ef2fa00322313f6e08c561b03a083210132f2 Mon Sep 17 00:00:00 2001 From: Ansaf Ahmed <40786269+1saf@users.noreply.github.com> Date: Tue, 27 Jul 2021 17:31:31 +1000 Subject: [PATCH 03/30] Providers patch (#602) * update: usages of the composables which now rely on a provider * update: move composable content to a top level global provider pattern * fix: linting errors * update: uptick version * update: shuffle providers to its own folder in src * fix: imports * update: provider structure change * update: provider is kill * update: uptick version * fix: type and lint errors * fix: patch overidden registry change * fix: linting errors --- src/Root.ts | 31 +++++ .../SelectTokenModal/SelectTokenModal.vue | 13 +- src/composables/trade/useTokenApproval.ts | 4 +- src/composables/trade/useValidation.ts | 4 +- src/composables/useAccountBalances.ts | 87 ++---------- src/composables/useAllowances.ts | 93 +++---------- src/composables/useTokens.ts | 81 ++--------- src/composables/useTokensStore.ts | 118 +++------------- src/main.ts | 8 +- src/pages/Trade.vue | 4 +- src/providers/allowances.provider.ts | 119 ++++++++++++++++ src/providers/balances.provider.ts | 116 ++++++++++++++++ src/providers/index.ts | 4 + src/providers/tokens.provider.ts | 93 +++++++++++++ src/providers/tokenstore.provider.ts | 129 ++++++++++++++++++ src/store/modules/registry.ts | 22 --- 16 files changed, 570 insertions(+), 356 deletions(-) create mode 100644 src/Root.ts create mode 100644 src/providers/allowances.provider.ts create mode 100644 src/providers/balances.provider.ts create mode 100644 src/providers/index.ts create mode 100644 src/providers/tokens.provider.ts create mode 100644 src/providers/tokenstore.provider.ts diff --git a/src/Root.ts b/src/Root.ts new file mode 100644 index 0000000000..0edfecd7cd --- /dev/null +++ b/src/Root.ts @@ -0,0 +1,31 @@ +import { defineComponent, h } from 'vue'; +import App from './App.vue'; +import * as providerMap from './providers'; + +const providers = Object.values(providerMap); + +export default defineComponent({ + components: { + App, + ...providerMap + }, + + render() { + function renderProviders(providers) { + if (!providers.length) return h(App); + + const [provider, ...remainingProviders] = providers; + return h( + provider, + {}, + { + default() { + return [renderProviders(remainingProviders)]; + } + } + ); + } + + return renderProviders(providers); + } +}); diff --git a/src/components/modals/SelectTokenModal/SelectTokenModal.vue b/src/components/modals/SelectTokenModal/SelectTokenModal.vue index d945250330..7bc0f129bf 100644 --- a/src/components/modals/SelectTokenModal/SelectTokenModal.vue +++ b/src/components/modals/SelectTokenModal/SelectTokenModal.vue @@ -108,7 +108,7 @@ import { defineComponent, reactive, toRefs, computed } from 'vue'; import { useStore } from 'vuex'; import { useI18n } from 'vue-i18n'; import { isAddress, getAddress } from '@ethersproject/address'; -import useTokenLists from '@/composables/useTokensStore'; +import useTokenStore from '@/composables/useTokensStore'; // import useTokenLists2 from '@/composables/useTokenLists2'; import TokenListItem from '@/components/lists/TokenListItem.vue'; import TokenListsListItem from '@/components/lists/TokenListsListItem.vue'; @@ -147,15 +147,18 @@ export default defineComponent({ isActiveList, listMap, activeTokenLists - } = useTokenLists(); - const { tokens: tokenMap } = useTokens(data); - const tokens = computed(() => Object.values(tokenMap.value)); + } = useTokenStore(); + + const { tokens: tokenMap } = useTokens(toRefs(data)); + const tokens = computed(() => { + return Object.values(tokenMap.value); + }); // const { // approvedTokenLists, // toggleList, // toggled: toggledTokenLists, // isToggled: isToggledList - // } = useTokenLists2(); + // } = useTokenStore2(); // COMPOSABLES const store = useStore(); diff --git a/src/composables/trade/useTokenApproval.ts b/src/composables/trade/useTokenApproval.ts index 111a8c4681..154e197176 100644 --- a/src/composables/trade/useTokenApproval.ts +++ b/src/composables/trade/useTokenApproval.ts @@ -1,4 +1,4 @@ -import { computed, ComputedRef, Ref, ref, watch } from 'vue'; +import { computed, Ref, ref, watch } from 'vue'; import { useI18n } from 'vue-i18n'; import { parseUnits } from '@ethersproject/units'; import { TransactionResponse } from '@ethersproject/providers'; @@ -18,7 +18,7 @@ import { TokenMap } from '@/types'; export default function useTokenApproval( tokenInAddress: Ref, amount: Ref, - tokens: ComputedRef + tokens: Ref ) { const approving = ref(false); const approved = ref(false); diff --git a/src/composables/trade/useValidation.ts b/src/composables/trade/useValidation.ts index 138d555503..6d8d6cb700 100644 --- a/src/composables/trade/useValidation.ts +++ b/src/composables/trade/useValidation.ts @@ -1,4 +1,4 @@ -import { computed, ComputedRef, Ref } from 'vue'; +import { computed, Ref } from 'vue'; import useWeb3 from '@/services/web3/useWeb3'; import { configService } from '@/services/config/config.service'; @@ -21,7 +21,7 @@ export default function useValidation( tokenInAmount: Ref, tokenOutAddress: Ref, tokenOutAmount: Ref, - tokens: ComputedRef + tokens: Ref ) { const { isWalletReady } = useWeb3(); diff --git a/src/composables/useAccountBalances.ts b/src/composables/useAccountBalances.ts index 25c1cf1a99..bad1242e78 100644 --- a/src/composables/useAccountBalances.ts +++ b/src/composables/useAccountBalances.ts @@ -1,90 +1,21 @@ -import getProvider from '@/lib/utils/provider'; -import { useQuery } from 'vue-query'; -import { computed, reactive } from 'vue'; -import { getBalances } from '@/lib/utils/balancer/tokens'; -import { formatEther, formatUnits } from '@ethersproject/units'; -import { getAddress } from '@ethersproject/address'; -import QUERY_KEYS from '@/constants/queryKeys'; -import { ETHER } from '@/constants/tokenlists'; -import useWeb3 from '@/services/web3/useWeb3'; -import useTokenStore from './useTokensStore'; +import { + BalancesProviderPayload, + BalancesProviderSymbol +} from '@/providers/balances.provider'; +import { inject } from 'vue'; // THE CONTENTS OF THIS WILL BE REPLACED/ALTERED WITH THE REGISTRY REFACTOR export default function useAccountBalances() { - const { account, userNetworkConfig, isWalletReady } = useWeb3(); - const { allTokens: tokens, isLoading: isLoadingTokens } = useTokenStore(); - - const isQueryEnabled = computed( - () => - account.value !== null && - Object.keys(tokens).length !== 0 && - isWalletReady.value && - !isLoadingTokens.value - ); - const { - data, + balances, + hasBalance, error, isLoading, isIdle, isError, isFetching, - refetch: refetchBalances - } = useQuery( - reactive(QUERY_KEYS.Balances.All(account, userNetworkConfig, tokens)), - () => { - return Promise.all([ - getBalances( - String(userNetworkConfig.value?.chainId), - getProvider(userNetworkConfig.value?.key), - account.value, - Object.values(tokens.value) - .map(token => token.address) - .filter(token => token !== ETHER.address) - ), - getProvider(userNetworkConfig.value?.key).getBalance( - account.value.toLowerCase() - ) - ]); - }, - reactive({ - enabled: isQueryEnabled, - keepPreviousData: isWalletReady - }) - ); - - const balances = computed(() => { - if (data.value) { - const balances = {}; - Object.keys(data.value[0]).forEach((tokenAddress: string) => { - const balance = formatUnits( - data.value[0][tokenAddress], - tokens.value[getAddress(tokenAddress)]?.decimals || 18 - ); - // not concerned with tokens which have a 0 balance - if (balance === '0.0') return; - balances[tokenAddress] = { - balance, - symbol: tokens.value[getAddress(tokenAddress)].symbol, - address: getAddress(tokenAddress) - }; - }); - - // separate case for native ether - balances[ETHER.address.toLowerCase()] = { - balance: formatEther(data.value[1] || 0), - symbol: ETHER.symbol, - address: ETHER.address - }; - return balances; - } - return null; - }); - - function hasBalance(address: string): boolean { - return !!(balances.value || {})[address]; - } - + refetchBalances + } = inject(BalancesProviderSymbol) as BalancesProviderPayload; return { balances, hasBalance, diff --git a/src/composables/useAllowances.ts b/src/composables/useAllowances.ts index d9711b0962..d62781bd1e 100644 --- a/src/composables/useAllowances.ts +++ b/src/composables/useAllowances.ts @@ -1,88 +1,29 @@ -import useWeb3 from '@/services/web3/useWeb3'; -import { useQuery } from 'vue-query'; -import { getAllowances } from '@/lib/utils/balancer/tokens'; -import getProvider from '@/lib/utils/provider'; -import { computed, reactive, Ref, ref } from 'vue'; -import { ETHER } from '@/constants/tokenlists'; -import { isAddress } from 'web3-utils'; -import QUERY_KEYS from '@/constants/queryKeys'; -import useTokens from './useTokens'; +import { inject, onBeforeMount, Ref } from 'vue'; +import { + AllowancesProviderSymbol, + AllowancesProviderPayload +} from '@/providers/allowances.provider'; type UseAccountPayload = { tokens?: Ref; dstList?: Ref; }; -const dstAllowanceMap = ref({}); - // THE CONTENTS OF THIS WILL BE REPLACED/ALTERED WITH THE REGISTRY REFACTOR export default function useAllowances(payload?: UseAccountPayload) { - const { userNetworkConfig, account } = useWeb3(); - const { tokens: allTokens } = useTokens(); - const provider = getProvider(String(userNetworkConfig.value?.chainId)); - // filter out ether and any bad addresses - const tokens = computed(() => - (payload?.tokens?.value || Object.keys(allTokens.value)).filter( - t => t !== ETHER.address && isAddress(t) - ) - ); - const dstList = computed(() => [ - ...(payload?.dstList?.value || []), - userNetworkConfig.value?.addresses.vault - ]); - - const isQueryEnabled = computed( - () => account.value != '' && tokens.value.length > 0 - ); const { - data: allowances, - isLoading, - isFetching, - refetch: refetchAllowances - } = useQuery( - QUERY_KEYS.Account.Allowances(userNetworkConfig, account, dstList, tokens), - () => - Promise.all( - dstList.value.map(async dst => - getAllowances( - String(userNetworkConfig.value?.chainId), - provider, - account.value, - dst, - tokens.value - ) - ) - ), - reactive({ - enabled: isQueryEnabled, - onSuccess: allowances => { - allowances.forEach((allowance, i) => { - dstAllowanceMap.value[dstList.value[i]] = allowance; - }); - } - }) - ); - - const isLoadingOrFetching = computed( - () => isLoading.value || isFetching.value - ); - - const getRequiredAllowances = query => { - const tokens = query.tokens; - const amounts = query.amounts; - const dst = query.dst || userNetworkConfig.value?.addresses.vault; - - const requiredAllowances = tokens.filter((token, index) => { - const amount = amounts[index]; - if (parseFloat(amount) == 0) return false; - if (!dstAllowanceMap.value) return false; - if (!dstAllowanceMap.value[dst]) return true; - if (!dstAllowanceMap.value[dst][token.toLowerCase()]) return true; - return dstAllowanceMap.value[dst][token.toLowerCase()].lt(amount); - }); - - return requiredAllowances; - }; + allowances, + getRequiredAllowances, + isLoading: isLoadingOrFetching, + refetchAllowances, + updateAllowanceRequest + } = inject(AllowancesProviderSymbol) as AllowancesProviderPayload; + + onBeforeMount(() => { + if (payload) { + updateAllowanceRequest(payload); + } + }); return { allowances, diff --git a/src/composables/useTokens.ts b/src/composables/useTokens.ts index d8fcf8a073..a3fb414afd 100644 --- a/src/composables/useTokens.ts +++ b/src/composables/useTokens.ts @@ -1,73 +1,22 @@ -import { Token, TokenMap } from '@/types'; -import { getAddress } from '@ethersproject/address'; -import { keyBy, orderBy, uniqBy } from 'lodash'; -import { computed } from 'vue'; -import { useStore } from 'vuex'; -import useAccountBalances from './useAccountBalances'; -import useTokenStore from './useTokensStore'; - -type TokenRequest = { - query?: string; - queryAddress?: string; -}; +import { + TokenRequest, + TokensProviderPayload, + TokensProviderSymbol +} from '@/providers/tokens.provider'; +import { inject, onBeforeMount } from 'vue'; export default function useTokens(request?: TokenRequest) { - const store = useStore(); - const prices = computed(() => store.state.market.prices); - const { allTokens: _allTokens } = useTokenStore(); - const { balances } = useAccountBalances(); - - const tokensList = computed(() => { - const _tokens = uniqBy( - orderBy( - // populate token data into list of tokens - Object.values(_allTokens.value).map(token => { - const balance = - (balances.value || {})[token.address.toLowerCase()]?.balance || '0'; - const price = prices.value[token.address.toLowerCase()]?.price || 0; - const value = balance * price; - const price24HChange = - prices.value[token.address.toLowerCase()]?.price24HChange || 0; - const value24HChange = (value / 100) * price24HChange; - return { - ...token, - address: getAddress(token.address), // Enforce that we use checksummed addresses - value, - price, - price24HChange, - balance, - value24HChange - }; - }), - ['value', 'balance'], - ['desc', 'desc'] - ), - 'address' - ); - - if (request?.queryAddress) { - const queryAddressLC = request?.queryAddress?.toLowerCase(); - - return _tokens.filter( - token => token.address?.toLowerCase() === queryAddressLC - ); - } - - // search functionality, this can be better - if (request?.query) { - const queryLC = request?.query?.toLowerCase(); + const { tokens, updateTokenRequest } = inject( + TokensProviderSymbol + ) as TokensProviderPayload; - return _tokens.filter( - token => - token.name.toLowerCase().includes(queryLC) || - token.symbol.toLowerCase().includes(queryLC) - ); + onBeforeMount(() => { + if (request) { + updateTokenRequest(request); } - - return _tokens; }); - const tokens = computed(() => keyBy(tokensList.value, 'address') as TokenMap); - - return { tokens }; + return { + tokens + }; } diff --git a/src/composables/useTokensStore.ts b/src/composables/useTokensStore.ts index 52a31690cb..c3140b52fa 100644 --- a/src/composables/useTokensStore.ts +++ b/src/composables/useTokensStore.ts @@ -1,15 +1,8 @@ -import { computed, ref } from 'vue'; -import { useStore } from 'vuex'; -import { useQuery } from 'vue-query'; -import { flatten, keyBy } from 'lodash'; - -import QUERY_KEYS from '@/constants/queryKeys'; -import TOKEN_LISTS, { ETHER } from '@/constants/tokenlists'; - -import { getTokensListURL, loadTokenlist } from '@/lib/utils/tokenlists'; -import { lsSet } from '@/lib/utils'; - -import { Token } from '@/types'; +import { inject } from 'vue'; +import { + TokenStoreProviderPayload, + TokenStoreProviderSymbol +} from '@/providers/tokenstore.provider'; export type TokenListItem = { address: string; @@ -35,104 +28,31 @@ type TokenList = { tokenListsURL: string; }; -const loadAllTokenLists = async () => { - // since a request to retrieve the list can fail - // it is best to use allSettled as we still want to - // retrieve what we can - return ( - await Promise.allSettled( - TOKEN_LISTS.Approved.map(async listURI => { - const tokenList = (await loadTokenlist(listURI)) as Omit< - TokenList, - 'tokenListsURL' - >; - - return { - ...tokenList, - tokenListsURL: getTokensListURL(listURI) - }; - }) - ) - ) - .filter(result => result.status === 'fulfilled') - .map(result => (result as PromiseFulfilledResult).value); -}; - // THE CONTENTS OF THIS WILL BE REPLACED/ALTERED WITH THE REGISTRY REFACTOR // This composable retrieves all the tokens from active token lists, // all the injected tokens from the store and the ETHER token // for other composables to build upon export default function useTokenStore() { - const store = useStore(); - const activeTokenLists = ref(['Balancer']); - const queryKey = QUERY_KEYS.TokenLists; - const queryFn = loadAllTokenLists; - - const getEther = () => { - const ether: any = ETHER; - ether.balance = 0; - ether.balanceDenorm = '0'; - ether.price = - store.state.market.prices[ether.address.toLowerCase()]?.price || 0; - ether.price24HChange = - store.state.market.prices[ether.address.toLowerCase()]?.price24HChange || - 0; - ether.chainId = Number(process.env.VUE_APP_NETWORK || 1); - return ether; - }; - - const { data: lists, isLoading, refetch: refreshTokenLists } = useQuery< - TokenList[] - >(queryKey, queryFn, { - refetchOnMount: false, - refetchOnWindowFocus: false - }); - - const listMap = computed(() => keyBy(lists.value, 'name')); - const injectedTokens = computed(() => store.state.registry.injected); - - const allTokens = computed(() => { - // get all the tokens from all the active lists - // get all tokens that are injected - // get the ETHER token ALWAYS - return keyBy( - flatten([ - ...Object.values(injectedTokens.value).map((t: any) => ({ ...t })), - ...activeTokenLists.value.map(name => listMap.value[name]?.tokens), - getEther() - ]) - // invalid network tokens get filtered out - .filter( - token => token?.chainId === Number(process.env.VUE_APP_NETWORK || 1) - ) as Token[], - 'address' - ); - }); - - const toggleActiveTokenList = (name: string) => { - if (activeTokenLists.value.includes(name)) { - activeTokenLists.value = activeTokenLists.value.filter( - listName => listName !== name - ); - } else { - activeTokenLists.value.push(name); - } - lsSet('activeTokenLists', activeTokenLists.value); - }; - - const isActiveList = (name: string) => { - return activeTokenLists.value.includes(name); - }; + const { + isLoading, + lists, + allTokens, + listMap, + activeTokenLists, + refreshTokenLists, + toggleActiveTokenList, + isActiveList + } = inject(TokenStoreProviderSymbol) as TokenStoreProviderPayload; return { isLoading, lists, - toggleActiveTokenList, - isActiveList, - refreshTokenLists, allTokens, listMap, - activeTokenLists + activeTokenLists, + refreshTokenLists, + toggleActiveTokenList, + isActiveList }; } diff --git a/src/main.ts b/src/main.ts index a6cb87c64a..f08580bfd0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,4 @@ import { createApp } from 'vue'; -import App from '@/App.vue'; import store from '@/store'; import router from '@/plugins/router'; import mixins from '@/plugins/mixins'; @@ -28,6 +27,7 @@ import '@/assets/css/tailwind.css'; import '@/assets/css/index.css'; import 'vue3-virtual-scroller/dist/vue3-virtual-scroller.css'; import { Web3Provider } from '@ethersproject/providers'; +import Root from './Root'; use([ TitleComponent, @@ -41,16 +41,16 @@ use([ MarkLineComponent ]); -const app = createApp(App) +const app = createApp(Root) .use(i18n) .use(router) .use(store) .use(blocknative) .use(VueApexCharts) .use(vueQuery) - .use(VueVirtualScroller) .use(Web3Plugin, Web3Provider) - .mixin(mixins); + .mixin(mixins) + .use(VueVirtualScroller); registerDirectives(app); registerGlobalComponents(app); diff --git a/src/pages/Trade.vue b/src/pages/Trade.vue index 22bf3b4929..5f557f8a19 100644 --- a/src/pages/Trade.vue +++ b/src/pages/Trade.vue @@ -16,7 +16,7 @@ import { useStore } from 'vuex'; import TradeCard from '@/components/cards/TradeCard/TradeCard.vue'; import TradeCardGP from '@/components/cards/TradeCardGP/TradeCardGP.vue'; -import useTokenLists from '@/composables/useTokensStore'; +import useTokenStore from '@/composables/useTokensStore'; import { TradeInterface } from '@/store/modules/app'; import usePoolFilters from '@/composables/pools/usePoolFilters'; @@ -29,7 +29,7 @@ export default defineComponent({ setup() { // COMPOSABLES const store = useStore(); - const { isLoading: isLoadingTokens } = useTokenLists(); + const { isLoading: isLoadingTokens } = useTokenStore(); const { setSelectedTokens } = usePoolFilters(); // COMPUTED diff --git a/src/providers/allowances.provider.ts b/src/providers/allowances.provider.ts new file mode 100644 index 0000000000..607b94b019 --- /dev/null +++ b/src/providers/allowances.provider.ts @@ -0,0 +1,119 @@ +import useWeb3 from '@/services/web3/useWeb3'; +import { useQuery } from 'vue-query'; +import { getAllowances } from '@/lib/utils/balancer/tokens'; +import getProvider from '@/lib/utils/provider'; +import { computed, provide, reactive, Ref, ref } from 'vue'; +import { ETHER } from '@/constants/tokenlists'; +import { isAddress } from 'web3-utils'; +import QUERY_KEYS from '@/constants/queryKeys'; +import useTokens from '@/composables/useTokens'; + +type UseAccountPayload = { + tokens?: Ref; + dstList?: Ref; +}; + +export type AllowancesProviderPayload = { + allowances: Ref; + getRequiredAllowances: (query: any) => any; + isLoading: Ref; + refetchAllowances: Ref; + updateAllowanceRequest: (payload: UseAccountPayload) => void; +}; + +export const AllowancesProviderSymbol = Symbol('ALLOWANCES_PROVIDER'); + +const dstAllowanceMap = ref({}); + +// THE CONTENTS OF THIS WILL BE REPLACED/ALTERED WITH THE REGISTRY REFACTOR +export default { + name: 'AllowancesProvider', + setup(props, { slots }) { + const requestPayload = ref(); + const { userNetworkConfig, account } = useWeb3(); + const { tokens: allTokens } = useTokens(); + const provider = getProvider(String(userNetworkConfig.value?.chainId)); + // filter out ether and any bad addresses + const tokens = computed(() => + ( + requestPayload?.value?.tokens?.value || Object.keys(allTokens.value) + ).filter(t => t !== ETHER.address && isAddress(t)) + ); + const dstList = computed(() => [ + ...(requestPayload?.value?.dstList?.value || []), + userNetworkConfig.value?.addresses.vault + ]); + + const isQueryEnabled = computed( + () => account.value != '' && tokens.value.length > 0 + ); + const { + data: allowances, + isLoading, + isFetching, + refetch: refetchAllowances + } = useQuery( + QUERY_KEYS.Account.Allowances( + userNetworkConfig, + account, + dstList, + tokens + ), + () => + Promise.all( + dstList.value.map(async dst => + getAllowances( + String(userNetworkConfig.value?.chainId), + provider, + account.value, + dst, + tokens.value + ) + ) + ), + reactive({ + enabled: isQueryEnabled, + onSuccess: allowances => { + allowances.forEach((allowance, i) => { + dstAllowanceMap.value[dstList.value[i]] = allowance; + }); + } + }) + ); + + const isLoadingOrFetching = computed( + () => isLoading.value || isFetching.value + ); + + const getRequiredAllowances = query => { + const tokens = query.tokens; + const amounts = query.amounts; + const dst = query.dst || userNetworkConfig.value?.addresses.vault; + + const requiredAllowances = tokens.filter((token, index) => { + const amount = amounts[index]; + if (parseFloat(amount) == 0) return false; + if (!dstAllowanceMap.value) return false; + if (!dstAllowanceMap.value[dst]) return true; + if (!dstAllowanceMap.value[dst][token.toLowerCase()]) return true; + return dstAllowanceMap.value[dst][token.toLowerCase()].lt(amount); + }); + + return requiredAllowances; + }; + + const updateAllowanceRequest = (payload: UseAccountPayload) => { + requestPayload.value = payload; + }; + + provide(AllowancesProviderSymbol, { + allowances, + getRequiredAllowances, + isLoading: isLoadingOrFetching, + refetchAllowances, + updateAllowanceRequest + }); + + return () => slots.default(); + } +}; diff --git a/src/providers/balances.provider.ts b/src/providers/balances.provider.ts new file mode 100644 index 0000000000..97bca9458f --- /dev/null +++ b/src/providers/balances.provider.ts @@ -0,0 +1,116 @@ +import getProvider from '@/lib/utils/provider'; +import { useQuery } from 'vue-query'; +import { computed, provide, reactive, Ref } from 'vue'; +import { getBalances } from '@/lib/utils/balancer/tokens'; +import { formatEther, formatUnits } from '@ethersproject/units'; +import { getAddress } from '@ethersproject/address'; +import QUERY_KEYS from '@/constants/queryKeys'; +import { ETHER } from '@/constants/tokenlists'; +import useWeb3 from '@/services/web3/useWeb3'; +import useTokenStore from '@/composables/useTokensStore'; + +export const BalancesProviderSymbol = Symbol('BALANCES_PROVIDER'); + +export type BalancesProviderPayload = { + balances: Ref>; + hasBalance: (address: string) => boolean; + error: Ref | Ref; + isLoading: Ref; + isIdle: Ref; + isError: Ref; + isFetching: Ref; + refetchBalances: Ref; +}; + +// THE CONTENTS OF THIS WILL BE REPLACED/ALTERED WITH THE REGISTRY REFACTOR +export default { + name: 'BalancesProvider', + setup(props, { slots }) { + const { account, userNetworkConfig, isWalletReady } = useWeb3(); + const { allTokens: tokens, isLoading: isLoadingTokens } = useTokenStore(); + + const isQueryEnabled = computed( + () => + account.value !== null && + Object.keys(tokens).length !== 0 && + isWalletReady.value && + !isLoadingTokens.value + ); + + const { + data, + error, + isLoading, + isIdle, + isError, + isFetching, + refetch: refetchBalances + } = useQuery( + reactive(QUERY_KEYS.Balances.All(account, userNetworkConfig, tokens)), + () => { + return Promise.all([ + getBalances( + String(userNetworkConfig.value?.chainId), + getProvider(userNetworkConfig.value?.key), + account.value, + Object.values(tokens.value) + .map(token => token.address) + .filter(token => token !== ETHER.address) + ), + getProvider(userNetworkConfig.value?.key).getBalance( + account.value.toLowerCase() + ) + ]); + }, + reactive({ + enabled: isQueryEnabled, + keepPreviousData: isWalletReady + }) + ); + + const balances = computed(() => { + if (data.value) { + const balances = {}; + Object.keys(data.value[0]).forEach((tokenAddress: string) => { + const balance = formatUnits( + data.value[0][tokenAddress], + tokens.value[getAddress(tokenAddress)]?.decimals || 18 + ); + // not concerned with tokens which have a 0 balance + if (balance === '0.0') return; + balances[tokenAddress] = { + balance, + symbol: tokens.value[getAddress(tokenAddress)].symbol, + address: getAddress(tokenAddress) + }; + }); + + // separate case for native ether + balances[ETHER.address.toLowerCase()] = { + balance: formatEther(data.value[1] || 0), + symbol: ETHER.symbol, + address: ETHER.address + }; + return balances; + } + return null; + }); + + function hasBalance(address: string): boolean { + return (balances.value || {})[address]; + } + + provide(BalancesProviderSymbol, { + balances, + hasBalance, + error, + isLoading, + isIdle, + isError, + isFetching, + refetchBalances + }); + + return () => slots.default(); + } +}; diff --git a/src/providers/index.ts b/src/providers/index.ts new file mode 100644 index 0000000000..e54392fdf5 --- /dev/null +++ b/src/providers/index.ts @@ -0,0 +1,4 @@ +export { default as TokenStoreProvider } from './tokenstore.provider'; +export { default as BalancesProvider } from './balances.provider'; +export { default as TokensProvider } from './tokens.provider'; +export { default as AllowancesProvider } from './allowances.provider'; diff --git a/src/providers/tokens.provider.ts b/src/providers/tokens.provider.ts new file mode 100644 index 0000000000..9420a4edea --- /dev/null +++ b/src/providers/tokens.provider.ts @@ -0,0 +1,93 @@ +import { Token, TokenMap } from '@/types'; +import { getAddress } from '@ethersproject/address'; +import { keyBy, orderBy, uniqBy } from 'lodash'; +import { computed, provide, Ref, ref } from 'vue'; +import { useStore } from 'vuex'; +import useAccountBalances from '@/composables/useAccountBalances'; +import useTokenStore from '@/composables/useTokensStore'; + +export type TokenRequest = { + query?: Ref; + queryAddress?: Ref; +}; + +export const TokensProviderSymbol = Symbol('TOKENS_PROVIDER'); + +export type TokensProviderPayload = { + tokens: Ref; + updateTokenRequest: (request: TokenRequest) => void; +}; + +export default { + name: 'TokenListsProvider', + setup(props, { slots }) { + const request = ref(); + const store = useStore(); + const prices = computed(() => store.state.market.prices); + const { allTokens: _allTokens } = useTokenStore(); + const { balances } = useAccountBalances(); + + const updateTokenRequest = (_request: TokenRequest) => { + request.value = _request; + }; + + const tokensList = computed(() => { + const _tokens = uniqBy( + orderBy( + // populate token data into list of tokens + Object.values(_allTokens.value).map(token => { + const balance = + (balances.value || {})[token.address.toLowerCase()]?.balance || + '0'; + const price = prices.value[token.address.toLowerCase()]?.price || 0; + const value = Number(balance) * price; + const price24HChange = + prices.value[token.address.toLowerCase()]?.price24HChange || 0; + const value24HChange = (value / 100) * price24HChange; + return { + ...token, + address: getAddress(token.address), // Enforce that we use checksummed addresses + value, + price, + price24HChange, + balance, + value24HChange + }; + }), + ['value', 'balance'], + ['desc', 'desc'] + ), + 'address' + ); + + if (request.value?.queryAddress) { + const queryAddressLC = request?.value.queryAddress?.value.toLowerCase(); + + return _tokens.filter( + token => token.address?.toLowerCase() === queryAddressLC + ); + } + + // search functionality, this can be better + if (request?.value?.query) { + const queryLC = request?.value.query?.value.toLowerCase(); + + return _tokens.filter( + token => + token.name.toLowerCase().includes(queryLC) || + token.symbol.toLowerCase().includes(queryLC) + ); + } + + return _tokens; + }); + const tokens = computed( + () => keyBy(tokensList.value, 'address') as TokenMap + ); + + const payload = { tokens, updateTokenRequest }; + provide(TokensProviderSymbol, payload); + + return () => slots.default(); + } +}; diff --git a/src/providers/tokenstore.provider.ts b/src/providers/tokenstore.provider.ts new file mode 100644 index 0000000000..6f96b9d158 --- /dev/null +++ b/src/providers/tokenstore.provider.ts @@ -0,0 +1,129 @@ +import QUERY_KEYS from '@/constants/queryKeys'; +import TOKEN_LISTS, { ETHER } from '@/constants/tokenlists'; +import { lsGet, lsSet } from '@/lib/utils'; +import { getTokensListURL, loadTokenlist } from '@/lib/utils/tokenlists'; +import { Token, TokenMap } from '@/types'; +import { TokenList } from '@/types/TokenList'; +import { flatten, keyBy } from 'lodash'; +import { computed, provide, Ref, ref } from 'vue'; +import { useQuery } from 'vue-query'; +import { useStore } from 'vuex'; + +export const TokenStoreProviderSymbol = Symbol('TOKENSTORE_PROVIDER'); + +export type TokenStoreProviderPayload = { + isLoading: Ref; + lists: Ref | Ref; + listMap: Ref>; + activeTokenLists: Ref; + allTokens: Ref; + toggleActiveTokenList: (name: string) => void; + isActiveList: (name: string) => boolean; + refreshTokenLists: Ref; +}; + +const loadAllTokenLists = async () => { + // since a request to retrieve the list can fail + // it is best to use allSettled as we still want to + // retrieve what we can + return ( + await Promise.allSettled( + TOKEN_LISTS.Approved.map(async listURI => { + const tokenList = (await loadTokenlist(listURI)) as Omit< + TokenList, + 'tokenListsURL' + >; + + return { + ...tokenList, + tokenListsURL: getTokensListURL(listURI) + }; + }) + ) + ) + .filter(result => result.status === 'fulfilled') + .map(result => (result as PromiseFulfilledResult).value); +}; + +export default { + name: 'TokenStoreProvider', + setup(props, { slots }) { + const store = useStore(); + const activeTokenLists = ref( + lsGet('activeTokenLists', ['Balancer']) + ); + const queryKey = QUERY_KEYS.TokenLists; + const queryFn = loadAllTokenLists; + + const { data: lists, isLoading, refetch: refreshTokenLists } = useQuery< + TokenList[] + >(queryKey, queryFn, { + refetchOnMount: false, + refetchOnWindowFocus: false + }); + + const getEther = () => { + const ether: any = ETHER; + ether.balance = 0; + ether.balanceDenorm = '0'; + ether.price = + store.state.market.prices[ether.address.toLowerCase()]?.price || 0; + ether.price24HChange = + store.state.market.prices[ether.address.toLowerCase()] + ?.price24HChange || 0; + ether.chainId = Number(process.env.VUE_APP_NETWORK || 1); + return ether; + }; + + const listMap = computed(() => keyBy(lists.value, 'name')); + const injectedTokens = computed(() => store.state.registry.injected); + + const allTokens = computed(() => { + // get all the tokens from all the active lists + // get all tokens that are injected + // get the ETHER token ALWAYS + // activeTokenLists; + return keyBy( + flatten([ + ...Object.values(injectedTokens.value).map((t: any) => ({ ...t })), + ...activeTokenLists.value.map(name => listMap.value[name]?.tokens), + getEther() + ]) + // invalid network tokens get filtered out + .filter( + token => token?.chainId === Number(process.env.VUE_APP_NETWORK || 1) + ) as Token[], + 'address' + ); + }); + + const toggleActiveTokenList = (name: string) => { + if (activeTokenLists.value.includes(name)) { + activeTokenLists.value = activeTokenLists.value.filter( + listName => listName !== name + ); + } else { + activeTokenLists.value = [...activeTokenLists.value, name]; + } + lsSet('activeTokenLists', activeTokenLists.value); + }; + + const isActiveList = (name: string) => { + return activeTokenLists.value.includes(name); + }; + + const payload: TokenStoreProviderPayload = { + isLoading, + lists, + allTokens, + listMap, + activeTokenLists, + refreshTokenLists, + toggleActiveTokenList, + isActiveList + }; + + provide(TokenStoreProviderSymbol, payload); + return () => slots.default(); + } +}; diff --git a/src/store/modules/registry.ts b/src/store/modules/registry.ts index 7717b2abe5..3aeb938fe9 100644 --- a/src/store/modules/registry.ts +++ b/src/store/modules/registry.ts @@ -1,6 +1,4 @@ -import { formatUnits } from '@ethersproject/units'; import { getAddress, isAddress } from '@ethersproject/address'; -import orderBy from 'lodash/orderBy'; import { loadTokenlist } from '@/lib/utils/tokenlists'; import TOKEN_LISTS, { ETHER } from '@/constants/tokenlists'; import { clone, lsGet, lsSet } from '@/lib/utils'; @@ -39,13 +37,6 @@ const getters = { ether.price24HChange = rootState.market.prices[ether.address.toLowerCase()]?.price24HChange || 0; ether.chainId = Number(process.env.VUE_APP_NETWORK || 1); - if (rootState.web3.account) { - ether.balanceDenorm = rootState.account.balances.ether || '0'; - ether.balance = formatUnits(ether.balanceDenorm, ether.decimals); - ether.value = ether.balance * ether.price; - ether.value24HChange = - (parseFloat(ether.value) / 100) * ether.price24HChange; - } return ether; }, @@ -85,19 +76,6 @@ const getters = { return token; }); - if (rootState?.web3?.account) { - tokens = tokens.map(token => { - const address = token.address.toLowerCase(); - token.balanceDenorm = rootState.account.balances[address] || '0'; - token.balance = formatUnits(token.balanceDenorm, token.decimals); - token.value = token.balance * token.price; - token.value24HChange = - (parseFloat(token.value) / 100) * token.price24HChange; - return token; - }); - tokens = orderBy(tokens, ['value', 'balance'], ['desc', 'desc']); - } - // Query filters if (includeEther) { From a3b9a415cd64ddcbaac1d5ede03e7f58e770f430 Mon Sep 17 00:00:00 2001 From: Tom French Date: Thu, 29 Jul 2021 12:58:27 +0100 Subject: [PATCH 04/30] fix: hide Element pools from the homepage --- package-lock.json | 7 +++++-- package.json | 2 +- src/services/balancer/subgraph/entities/pools/query.ts | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 10347a184f..45975147ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@balancer-labs/frontend-v2", - "version": "1.11.0", + "version": "1.11.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@balancer-labs/frontend-v2", - "version": "1.11.0", + "version": "1.11.1", "license": "MIT", "dependencies": { "@balancer-labs/assets": "github:balancer-labs/assets#master", @@ -34192,6 +34192,7 @@ "integrity": "sha512-IWnb10ImrzRMT2qw9785p3wYEI6U9gjsg6H2zKcRJQP5dEboqeX3OFjUKfXkaIWii4nz8MtJjBg5t4BdEYqLdw==", "dev": true, "requires": { + "@babel/core": "^7.12.10", "@babel/generator": "^7.12.11", "@babel/parser": "^7.12.11", "@babel/plugin-transform-react-jsx": "^7.12.12", @@ -37709,6 +37710,7 @@ "@vue/babel-preset-app": { "version": "4.5.12", "requires": { + "@babel/core": "^7.11.0", "@babel/helper-compilation-targets": "^7.9.6", "@babel/helper-module-imports": "^7.8.3", "@babel/plugin-proposal-class-properties": "^7.8.3", @@ -37721,6 +37723,7 @@ "@vue/babel-plugin-jsx": "^1.0.3", "@vue/babel-preset-jsx": "^1.2.4", "babel-plugin-dynamic-import-node": "^2.3.3", + "core-js": "^3.6.5", "core-js-compat": "^3.6.5", "semver": "^6.1.0" } diff --git a/package.json b/package.json index 838cdac392..221d78c3a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@balancer-labs/frontend-v2", - "version": "1.11.0", + "version": "1.11.1", "engines": { "node": "14.x", "npm": ">=7" diff --git a/src/services/balancer/subgraph/entities/pools/query.ts b/src/services/balancer/subgraph/entities/pools/query.ts index ed39669352..4c0b9a034b 100644 --- a/src/services/balancer/subgraph/entities/pools/query.ts +++ b/src/services/balancer/subgraph/entities/pools/query.ts @@ -7,7 +7,8 @@ const defaultArgs = { orderDirection: 'desc', where: { totalShares_gt: 0.01, - id_not_in: POOLS.BlockList + id_not_in: POOLS.BlockList, + poolType_not: 'Element' } }; From 8d0b2a6d9278562e27c10efe8f72c253dfb985e6 Mon Sep 17 00:00:00 2001 From: Ansaf Ahmed <40786269+1saf@users.noreply.github.com> Date: Fri, 30 Jul 2021 11:20:04 +1000 Subject: [PATCH 05/30] fix: allowances query (#607) * fix: allowances query * fix: lint Co-authored-by: Evgeny Boxer --- src/composables/trade/useTokenApproval.ts | 4 ++-- src/composables/trade/useTokenApprovalGP.ts | 4 ++-- src/composables/useAllowances.ts | 6 +++--- src/providers/allowances.provider.ts | 13 ++++++------- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/composables/trade/useTokenApproval.ts b/src/composables/trade/useTokenApproval.ts index 154e197176..b55845c382 100644 --- a/src/composables/trade/useTokenApproval.ts +++ b/src/composables/trade/useTokenApproval.ts @@ -38,8 +38,8 @@ export default function useTokenApproval( getRequiredAllowances, isLoading: isLoadingAllowances } = useAllowances({ - dstList, - tokens: allowanceTokens + dstList: dstList.value, + tokens: allowanceTokens.value }); const allowanceState = computed(() => { diff --git a/src/composables/trade/useTokenApprovalGP.ts b/src/composables/trade/useTokenApprovalGP.ts index 44f7ed119a..22f9413609 100644 --- a/src/composables/trade/useTokenApprovalGP.ts +++ b/src/composables/trade/useTokenApprovalGP.ts @@ -35,8 +35,8 @@ export default function useTokenApprovalGP( getRequiredAllowances, isLoading: isLoadingAllowances } = useAllowances({ - dstList, - tokens: allowanceTokens + dstList: dstList.value, + tokens: allowanceTokens.value }); const allowanceState = computed(() => { diff --git a/src/composables/useAllowances.ts b/src/composables/useAllowances.ts index d62781bd1e..2475971be0 100644 --- a/src/composables/useAllowances.ts +++ b/src/composables/useAllowances.ts @@ -1,12 +1,12 @@ -import { inject, onBeforeMount, Ref } from 'vue'; +import { inject, onBeforeMount } from 'vue'; import { AllowancesProviderSymbol, AllowancesProviderPayload } from '@/providers/allowances.provider'; type UseAccountPayload = { - tokens?: Ref; - dstList?: Ref; + tokens?: string[]; + dstList?: string[]; }; // THE CONTENTS OF THIS WILL BE REPLACED/ALTERED WITH THE REGISTRY REFACTOR diff --git a/src/providers/allowances.provider.ts b/src/providers/allowances.provider.ts index 607b94b019..307b04da3a 100644 --- a/src/providers/allowances.provider.ts +++ b/src/providers/allowances.provider.ts @@ -9,8 +9,8 @@ import QUERY_KEYS from '@/constants/queryKeys'; import useTokens from '@/composables/useTokens'; type UseAccountPayload = { - tokens?: Ref; - dstList?: Ref; + tokens?: string[]; + dstList?: string[]; }; export type AllowancesProviderPayload = { @@ -35,12 +35,12 @@ export default { const provider = getProvider(String(userNetworkConfig.value?.chainId)); // filter out ether and any bad addresses const tokens = computed(() => - ( - requestPayload?.value?.tokens?.value || Object.keys(allTokens.value) - ).filter(t => t !== ETHER.address && isAddress(t)) + (requestPayload?.value?.tokens || Object.keys(allTokens.value)).filter( + t => t !== ETHER.address && isAddress(t) + ) ); const dstList = computed(() => [ - ...(requestPayload?.value?.dstList?.value || []), + ...(requestPayload?.value?.dstList || []), userNetworkConfig.value?.addresses.vault ]); @@ -98,7 +98,6 @@ export default { if (!dstAllowanceMap.value[dst][token.toLowerCase()]) return true; return dstAllowanceMap.value[dst][token.toLowerCase()].lt(amount); }); - return requiredAllowances; }; From 735b657880ba11f15871fcdb2845f62f3b2f36f3 Mon Sep 17 00:00:00 2001 From: Markus Buhatem Koch Date: Thu, 29 Jul 2021 23:29:29 -0300 Subject: [PATCH 06/30] Update MultiTokenLiquidityMining.json (#610) # ETHEREUM CHANGES # None. # POLYGON CHANGES # WMATIC/USDC/QI/BAL/MAI pool moved from T3 to T4. This now receives 1,000 BAL per week. WMATIC/USDC/WETH/BAL pool given an extra T3 slot, had a T4 slot removed. This now receives 7,500 BAL per week. Co-authored-by: bakamoto20 <85693860+bakamoto20@users.noreply.github.com> --- .../MultiTokenLiquidityMining.json | 229 ++++++++++++++++++ 1 file changed, 229 insertions(+) diff --git a/src/lib/utils/liquidityMining/MultiTokenLiquidityMining.json b/src/lib/utils/liquidityMining/MultiTokenLiquidityMining.json index 5efe3910e7..ed8c13f74c 100644 --- a/src/lib/utils/liquidityMining/MultiTokenLiquidityMining.json +++ b/src/lib/utils/liquidityMining/MultiTokenLiquidityMining.json @@ -1282,5 +1282,234 @@ ] } } + ], + "week_62": [ + { + "chainId": 1, + "pools": { + "0xa6f548df93de924d73be7d25dc02554c6bd66db500020000000000000000000e": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 15000 + } + ], + "0x0b09dea16768f0799065c475be02919503cb2a3500020000000000000000001a": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 15000 + } + ], + "0x5c6ee304399dbdb9c8ef030ab642b10820db8f56000200000000000000000014": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 30000 + } + ], + "0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000063": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 15000 + } + ], + "0x96646936b91d6b9d7d0c47c496afbf3d6ec7b6f8000200000000000000000019": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 5000 + } + ], + "0xa1116930326d21fb917d5a27f1e9943a9595fb47": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 12500 + } + ], + "0x3e5fa9518ea95c3e533eb377c001702a9aacaa32000200000000000000000052": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 5000 + } + ], + "0xaac98ee71d4f8a156b6abaa6844cdb7789d086ce00020000000000000000001b": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 2500 + } + ], + "0x186084ff790c65088ba694df11758fae4943ee9e000200000000000000000013": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 2500 + } + ], + "0x072f14b85add63488ddad88f855fda4a99d6ac9b000200000000000000000027": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 2500 + } + ], + "0xe99481dc77691d8e2456e5f3f61c1810adfc1503000200000000000000000018": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 2500 + } + ], + "0xefaa1604e82e1b3af8430b90192c1b9e8197e377000200000000000000000021": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 2500 + } + ], + "0xfeadd389a5c427952d8fdb8057d6c8ba1156cc56000000000000000000000066": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 2500 + } + ], + "0x148ce9b50be946a96e94a4f5479b771bab9b1c59000100000000000000000054": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 2500 + } + ], + "0xec60a5fef79a92c741cb74fdd6bfc340c0279b01000200000000000000000015": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 1000 + } + ], + "0xa02e4b3d18d4e6b8d18ac421fbc3dfff8933c40a00020000000000000000004b": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 1000 + } + ], + "0x61d5dc44849c9c87b0856a2a311536205c96c7fd000100000000000000000001": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 1000 + } + ], + "0xf5aaf7ee8c39b651cebf5f1f50c10631e78e0ef9000200000000000000000069": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 1000 + } + ], + "0x14462305d211c12a736986f4e8216e28c5ea7ab4000200000000000000000068": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 1000 + } + ] + + } + }, + { + "chainId": 137, + "pools": { + "0x0297e37f1873d2dab4487aa67cd56b58e2f27875000100000000000000000002": [ + { + "tokenAddress": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3", + "amount": 7500 + }, + { + "tokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", + "amount": 112500 + } + ], + "0x36128d5436d2d70cab39c9af9cce146c38554ff0000100000000000000000008": [ + { + "tokenAddress": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3", + "amount": 6000 + }, + { + "tokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", + "amount": 90000 + } + ], + "0x03cd191f589d12b0582a99808cf19851e468e6b500010000000000000000000a": [ + { + "tokenAddress": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3", + "amount": 2500 + }, + { + "tokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", + "amount": 37500 + } + ], + "0xce66904b68f1f070332cbc631de7ee98b650b499000100000000000000000009": [ + { + "tokenAddress": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3", + "amount": 2500 + }, + { + "tokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", + "amount": 37500 + } + ], + "0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000012": [ + { + "tokenAddress": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3", + "amount": 2500 + }, + { + "tokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", + "amount": 37500 + }, + { + "tokenAddress": "0x580a84c73811e1839f75d86d75d88cca0c241ff4", + "amount": 15000 + } + ], + "0xf461f2240b66d55dcf9059e26c022160c06863bf000100000000000000000006": [ + { + "tokenAddress": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3", + "amount": 1000 + }, + { + "tokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", + "amount": 15000 + }, + { + "tokenAddress": "0x580a84c73811e1839f75d86d75d88cca0c241ff4", + "amount": 15000 + } + ], + "0x614b5038611729ed49e0ded154d8a5d3af9d1d9e00010000000000000000001d": [ + { + "tokenAddress": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3", + "amount": 1000 + }, + { + "tokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", + "amount": 15000 + }, + { + "tokenAddress": "0xF501dd45a1198C2E1b5aEF5314A68B9006D842E0", + "amount": 15000 + } + ], + "0x4e7f40cd37cee710f5e87ad72959d30ef8a01a5d00010000000000000000000b": [ + { + "tokenAddress": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3", + "amount": 1000 + }, + { + "tokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", + "amount": 15000 + } + ], + "0xfeadd389a5c427952d8fdb8057d6c8ba1156cc5600020000000000000000001e": [ + { + "tokenAddress": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3", + "amount": 1000 + }, + { + "tokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", + "amount": 15000 + } + ] + } + } ] } From 9d1286ed5fce4876af2c6c328a65fdeff2a88ea4 Mon Sep 17 00:00:00 2001 From: Markus Buhatem Koch Date: Thu, 29 Jul 2021 23:31:30 -0300 Subject: [PATCH 07/30] version bump --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 45975147ab..dd3037f70e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@balancer-labs/frontend-v2", - "version": "1.11.1", + "version": "1.11.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@balancer-labs/frontend-v2", - "version": "1.11.1", + "version": "1.11.2", "license": "MIT", "dependencies": { "@balancer-labs/assets": "github:balancer-labs/assets#master", diff --git a/package.json b/package.json index 221d78c3a9..09056b9160 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@balancer-labs/frontend-v2", - "version": "1.11.1", + "version": "1.11.2", "engines": { "node": "14.x", "npm": ">=7" From 84c6f6b80e822aa638b67a3e4c94948a3c34f76e Mon Sep 17 00:00:00 2001 From: Evgeny Boxer Date: Fri, 30 Jul 2021 21:46:33 +1000 Subject: [PATCH 08/30] Gnosis interface tweaks (#604) * limit to quote to 6 decimals * remove unused code * fix: show gnosis error when when doing a gnosis trade * copy update * add a warning for high trading fees * update copy * remove approval card when there is only 1 required * tweak copy/design * copy updates * update copy * reset state after trade * fix: spread initial state * add error handling for low balance * remove console.log * add price impact error * update copy * refactor: make approval/confirm horizontal * impl. wrap/unwrap view * move trade route to be located after the confirm trade + minor fixes * copy update * fix: less agressive resetState for gnosis * fix: use reactive instead of plain objects for state in composables --- src/components/cards/TradeCard/TradeCard.vue | 7 +- .../cards/TradeCardGP/TradeCardGP.vue | 114 +++++- src/components/modals/TradePreviewModalGP.vue | 329 +++++++++++------- src/composables/trade/useGnosis.ts | 104 ++++-- src/composables/trade/useSor.ts | 32 +- src/composables/trade/useTokenApprovalGP.ts | 5 +- src/composables/trade/useTrading.ts | 29 +- src/locales/default.json | 59 +++- src/plugins/blocknative.ts | 2 +- 9 files changed, 472 insertions(+), 209 deletions(-) diff --git a/src/components/cards/TradeCard/TradeCard.vue b/src/components/cards/TradeCard/TradeCard.vue index 3c4b844653..3e85787d4f 100644 --- a/src/components/cards/TradeCard/TradeCard.vue +++ b/src/components/cards/TradeCard/TradeCard.vue @@ -149,6 +149,10 @@ export default defineComponent({ const txHash = ref(''); const modalTradePreviewIsOpen = ref(false); + const slippageBufferRate = computed(() => + parseFloat(store.state.app.slippage) + ); + const tokenIn = computed(() => tokens.value[tokenInAddress.value]); const tokenOut = computed(() => tokens.value[tokenOutAddress.value]); @@ -219,7 +223,8 @@ export default defineComponent({ isWrap, isUnwrap, tokenIn, - tokenOut + tokenOut, + slippageBufferRate }); const { errorMessage } = useValidation( tokenInAddress, diff --git a/src/components/cards/TradeCardGP/TradeCardGP.vue b/src/components/cards/TradeCardGP/TradeCardGP.vue index 610feb74bb..1e3e946406 100644 --- a/src/components/cards/TradeCardGP/TradeCardGP.vue +++ b/src/components/cards/TradeCardGP/TradeCardGP.vue @@ -32,6 +32,15 @@ block @actionClick="handleErrorButtonClick" /> + { switch (bp.value) { @@ -156,12 +171,22 @@ export default defineComponent({ trading.tokens ); - const tradeDisabled = computed( + const isHighPriceImpact = computed( () => - errorMessage.value !== TradeValidation.VALID || - (trading.isGnosisTrade.value && trading.gnosis.hasErrors.value) + trading.sor.errors.value.highPriceImpact && + !dismissedErrors.value.highPriceImpact ); + const tradeDisabled = computed(() => { + const hasValidationErrors = errorMessage.value !== TradeValidation.VALID; + const hasGnosisErrors = + trading.isGnosisTrade.value && trading.gnosis.hasErrors.value; + const hasBalancerErrors = + trading.isBalancerTrade.value && isHighPriceImpact.value; + + return hasValidationErrors || hasGnosisErrors || hasBalancerErrors; + }); + useTokenApprovalGP(tokenInAddress, tokenInAmount); const title = computed(() => { @@ -175,14 +200,8 @@ export default defineComponent({ }); const error = computed(() => { - if (trading.gnosis.errors.value.feeExceedsPrice) { - return { - header: 'Low amount', - body: 'Fees exceeds from amount' - }; - } switch (errorMessage.value) { - case TradeValidation.NO_NATIVE_ASSET: + case TradeValidation.NO_NATIVE_ASSET: { return { header: t('noNativeAsset', [nativeAsset.symbol]), body: t('noNativeAssetDetailed', [ @@ -190,32 +209,88 @@ export default defineComponent({ configService.network.chainName ]) }; - case TradeValidation.NO_BALANCE: + } + case TradeValidation.NO_BALANCE: { return { header: t('insufficientBalance'), body: t('insufficientBalanceDetailed') }; - case TradeValidation.NO_LIQUIDITY: + } + case TradeValidation.NO_LIQUIDITY: { return { header: t('insufficientLiquidity'), body: t('insufficientLiquidityDetailed') }; + } default: - return undefined; } + + if (trading.isGnosisTrade.value) { + if (trading.gnosis.errors.value.feeExceedsPrice) { + return { + header: t('gnosisErrors.lowAmount.header'), + body: t('gnosisErrors.lowAmount.body') + }; + } + if (trading.gnosis.errors.value.priceExceedsBalance) { + return { + header: t('gnosisErrors.lowBalance.header', [ + trading.tokenIn.value.symbol + ]), + body: t('gnosisErrors.lowBalance.body', [ + trading.tokenIn.value.symbol, + fNum( + formatUnits( + trading.getQuote().maximumInAmount, + trading.tokenIn.value.decimals + ), + 'token' + ), + fNum(trading.slippageBufferRate.value, 'percent') + ]) + }; + } + } else if (trading.isBalancerTrade.value) { + if (isHighPriceImpact.value) { + return { + header: t('highPriceImpact'), + body: t('highPriceImpactDetailed'), + label: t('accept') + }; + } + } + + return undefined; }); - // METHODS - function handleErrorButtonClick() { - console.log('TOOD: implement if needed'); - } + const warning = computed(() => { + if (trading.isGnosisTrade.value) { + if (trading.gnosis.warnings.value.highFees) { + return { + header: t('gnosisWarnings.highFees.header'), + body: t('gnosisWarnings.highFees.body') + }; + } + } + + return undefined; + }); + // METHODS function trade() { trading.trade(() => { + tokenInAmount.value = ''; + tokenOutAmount.value = ''; modalTradePreviewIsOpen.value = false; }); } + function handleErrorButtonClick() { + if (trading.sor.errors.value.highPriceImpact) { + dismissedErrors.value.highPriceImpact = true; + } + } + async function populateInitialTokens(): Promise { let assetIn = router.currentRoute.value.params.assetIn as string; @@ -262,15 +337,16 @@ export default defineComponent({ // computed title, error, + warning, errorMessage, isRequired, tradeDisabled, tradeCardShadow, // methods - handleErrorButtonClick, trade, - switchToWETH + switchToWETH, + handleErrorButtonClick }; } }); diff --git a/src/components/modals/TradePreviewModalGP.vue b/src/components/modals/TradePreviewModalGP.vue index d74e41a69f..f12d9b0e7c 100644 --- a/src/components/modals/TradePreviewModalGP.vue +++ b/src/components/modals/TradePreviewModalGP.vue @@ -1,5 +1,5 @@ + + + + Total + + + + + + + @@ -194,7 +235,7 @@ import { watch, computed } from 'vue'; -import { sortBy, sumBy } from 'lodash'; +import { sortBy, sumBy, tail } from 'lodash'; type Sticky = 'horizontal' | 'vertical' | 'both'; type Data = any; @@ -229,6 +270,8 @@ export type ColumnDefinition = { sortKey?: string | ((row: T) => unknown); width?: number; + + totalsCell?: string; }; export default defineComponent({ @@ -380,6 +423,10 @@ export default defineComponent({ props.columns.filter(column => !column.hidden) ); + const shouldRenderTotals = computed(() => + props.columns.some(column => column.totalsCell !== undefined) + ); + watch( () => props.data, newData => { @@ -402,6 +449,7 @@ export default defineComponent({ getHorizontalStickyClass, handleSort, handleRowClick, + tail, //data isColumnStuck, @@ -411,7 +459,8 @@ export default defineComponent({ placeholderBlockWidth, // computed - filteredColumns + filteredColumns, + shouldRenderTotals }; } }); diff --git a/src/components/tables/LMTable/LMTable.vue b/src/components/tables/LMTable/LMTable.vue new file mode 100644 index 0000000000..84db4c89d8 --- /dev/null +++ b/src/components/tables/LMTable/LMTable.vue @@ -0,0 +1,242 @@ + + + diff --git a/src/composables/queries/usePoolsQuery.ts b/src/composables/queries/usePoolsQuery.ts index 05dc714418..c5cb455da0 100644 --- a/src/composables/queries/usePoolsQuery.ts +++ b/src/composables/queries/usePoolsQuery.ts @@ -17,9 +17,15 @@ type PoolsQueryResponse = { skip?: number; }; +type FilterOptions = { + poolIds?: Ref; + pageSize?: number; +}; + export default function usePoolsQuery( tokenList: Ref = ref([]), - options: UseInfiniteQueryOptions = {} + options: UseInfiniteQueryOptions = {}, + filterOptions?: FilterOptions ) { // SERVICES const balancerSubgraph = new BalancerSubgraph(); @@ -29,7 +35,7 @@ export default function usePoolsQuery( const { tokens: allTokens } = useTokens(); // DATA - const queryKey = QUERY_KEYS.Pools.All(tokenList); + const queryKey = QUERY_KEYS.Pools.All(tokenList, filterOptions?.poolIds); // COMPUTED const appLoading = computed(() => store.state.app.loading); @@ -43,16 +49,20 @@ export default function usePoolsQuery( // METHODS const queryFn = async ({ pageParam = 0 }) => { + const queryArgs: any = { + first: filterOptions?.pageSize || POOLS.Pagination.PerPage, + skip: pageParam, + where: { + tokensList_contains: tokenList.value + } + }; + + if (filterOptions?.poolIds?.value.length) + queryArgs.where.id_in = filterOptions.poolIds.value; const pools = await balancerSubgraph.pools.getDecorated( '24h', prices.value, - { - first: POOLS.Pagination.PerPage, - skip: pageParam, - where: { - tokensList_contains: tokenList.value - } - } + queryArgs ); const tokens = flatten(pools.map(pool => pool.tokenAddresses)); diff --git a/src/constants/queryKeys.ts b/src/constants/queryKeys.ts index 9aa8958b1c..91d75ee65c 100644 --- a/src/constants/queryKeys.ts +++ b/src/constants/queryKeys.ts @@ -8,7 +8,11 @@ export const CLAIMS_ROOT_KEY = 'claims'; const QUERY_KEYS = { Pools: { - All: (tokens: Ref) => [POOLS_ROOT_KEY, 'all', { tokens }], + All: (tokens: Ref, poolIds: Ref | undefined) => [ + POOLS_ROOT_KEY, + 'all', + { tokens, poolIds } + ], User: (account: Ref) => [POOLS_ROOT_KEY, 'user', { account }], Current: (id: string) => [POOLS_ROOT_KEY, 'current', { id }], Snapshot: (id: string) => [POOLS_ROOT_KEY, 'snapshot', { id }], diff --git a/src/pages/LiquidityMining.vue b/src/pages/LiquidityMining.vue new file mode 100644 index 0000000000..099537c4f1 --- /dev/null +++ b/src/pages/LiquidityMining.vue @@ -0,0 +1,138 @@ + + + diff --git a/src/plugins/router.ts b/src/plugins/router.ts index 0607f00b3e..5f0a60e1e4 100644 --- a/src/plugins/router.ts +++ b/src/plugins/router.ts @@ -1,6 +1,7 @@ import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'; import Home from '@/pages/Home.vue'; import Pool from '@/pages/Pool.vue'; +import LiquidityMining from '@/pages/LiquidityMining.vue'; import Trade from '@/pages/Trade.vue'; const routes: RouteRecordRaw[] = [ @@ -13,6 +14,11 @@ const routes: RouteRecordRaw[] = [ } }, { path: '/pool/:id', name: 'pool', component: Pool }, + { + path: '/liquidity-mining', + name: 'liquidity-mining', + component: LiquidityMining + }, { path: '/:pathMatch(.*)*', name: 'not-found', redirect: '/' } ]; From ac39342d8d4500ed59994bf8e537300d57f5dbbf Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Mon, 2 Aug 2021 21:18:53 +0100 Subject: [PATCH 12/30] Update walletconnect version --- package-lock.json | 637 ++++++++++++++++++++++++++++------------------ package.json | 2 +- 2 files changed, 389 insertions(+), 250 deletions(-) diff --git a/package-lock.json b/package-lock.json index dd3037f70e..cc6bbccdd2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,7 +39,7 @@ "@vue/cli-plugin-typescript": "^4.4.0", "@vue/cli-service": "^4.4.0", "@vueuse/core": "^4.3.4", - "@walletconnect/web3-provider": "^1.3.1", + "@walletconnect/web3-provider": "^1.5.2", "animejs": "^3.2.1", "apexcharts": "^3.23.1", "autoprefixer": "^9.8.6", @@ -2811,20 +2811,6 @@ "node": ">= 6" } }, - "node_modules/@json-rpc-tools/types": { - "version": "1.6.4", - "license": "MIT", - "dependencies": { - "keyvaluestorage-interface": "^1.0.0" - } - }, - "node_modules/@json-rpc-tools/utils": { - "version": "1.6.1", - "license": "MIT", - "dependencies": { - "@json-rpc-tools/types": "^1.6.1" - } - }, "node_modules/@koa/router": { "version": "9.4.0", "dev": true, @@ -3084,28 +3070,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@pedrouid/iso-crypto": { - "version": "1.1.0", - "license": "MIT", - "dependencies": { - "@pedrouid/iso-random": "^1.1.0", - "aes-js": "^3.1.2", - "enc-utils": "^3.0.0", - "hash.js": "^1.1.7" - } - }, - "node_modules/@pedrouid/iso-crypto/node_modules/aes-js": { - "version": "3.1.2", - "license": "MIT" - }, - "node_modules/@pedrouid/iso-random": { - "version": "1.1.0", - "license": "MIT", - "dependencies": { - "enc-utils": "^3.0.0", - "randombytes": "^2.1.0" - } - }, "node_modules/@popperjs/core": { "version": "2.9.2", "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.9.2.tgz", @@ -9127,81 +9091,155 @@ } }, "node_modules/@walletconnect/browser-utils": { - "version": "1.4.1", - "license": "LGPL-3.0", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/browser-utils/-/browser-utils-1.5.2.tgz", + "integrity": "sha512-nP7ktHwYmvHfXIbq7lGPoig8nO7HYi2dWE8UDxBlgNMs4mvzm2jyN6cm0JZ4xh5gO90/gQwbyuU33zLcZGUPhw==", "dependencies": { - "@walletconnect/types": "^1.4.1", - "detect-browser": "5.2.0", - "safe-json-utils": "1.0.0", - "window-getters": "1.0.0", - "window-metadata": "1.0.0" + "@walletconnect/safe-json": "1.0.0", + "@walletconnect/types": "^1.5.2", + "@walletconnect/window-getters": "1.0.0", + "@walletconnect/window-metadata": "1.0.0", + "detect-browser": "5.2.0" } }, "node_modules/@walletconnect/client": { - "version": "1.4.1", - "license": "LGPL-3.0", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/client/-/client-1.5.2.tgz", + "integrity": "sha512-dAMK4zqNBZ88YpUQxTMt3RCS2ThTwecPmlq3MK76liLwrsGYRfnQ104GHZGI93rZEdcDWX04p5e3NsCXWMXcNw==", "dependencies": { - "@walletconnect/core": "^1.4.1", - "@walletconnect/iso-crypto": "^1.4.1", - "@walletconnect/types": "^1.4.1", - "@walletconnect/utils": "^1.4.1" + "@walletconnect/core": "^1.5.2", + "@walletconnect/iso-crypto": "^1.5.2", + "@walletconnect/types": "^1.5.2", + "@walletconnect/utils": "^1.5.2" } }, "node_modules/@walletconnect/core": { - "version": "1.4.1", - "license": "LGPL-3.0", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-1.5.2.tgz", + "integrity": "sha512-uzrIbjzSHdPPeFSqwPYhp/VhyJKUODDc0STt+5R1A2orE1nh9Rb6XqSkBfLkOlf8pdKUObI95Lr0LH9TbSzF/A==", "dependencies": { - "@walletconnect/socket-transport": "^1.4.1", - "@walletconnect/types": "^1.4.1", - "@walletconnect/utils": "^1.4.1" + "@walletconnect/socket-transport": "^1.5.2", + "@walletconnect/types": "^1.5.2", + "@walletconnect/utils": "^1.5.2" } }, + "node_modules/@walletconnect/crypto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@walletconnect/crypto/-/crypto-1.0.1.tgz", + "integrity": "sha512-IgUReNrycIFxkGgq8YT9HsosCkhutakWD9Q411PR0aJfxpEa/VKJeaLRtoz6DvJpztWStwhIHnAbBoOVR72a6g==", + "dependencies": { + "@walletconnect/encoding": "^1.0.0", + "@walletconnect/environment": "^1.0.0", + "@walletconnect/randombytes": "^1.0.1", + "aes-js": "^3.1.2", + "hash.js": "^1.1.7" + } + }, + "node_modules/@walletconnect/crypto/node_modules/aes-js": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", + "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==" + }, + "node_modules/@walletconnect/encoding": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@walletconnect/encoding/-/encoding-1.0.0.tgz", + "integrity": "sha512-4nkJFnS0QF5JdieG/3VPD1/iEWkLSZ14EBInLZ00RWxmC6EMZrzAeHNAWIgm+xP3NK0lqz+7lEsmWGtcl5gYnQ==", + "dependencies": { + "is-typedarray": "1.0.0", + "typedarray-to-buffer": "3.1.5" + } + }, + "node_modules/@walletconnect/environment": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@walletconnect/environment/-/environment-1.0.0.tgz", + "integrity": "sha512-4BwqyWy6KpSvkocSaV7WR3BlZfrxLbJSLkg+j7Gl6pTDE+U55lLhJvQaMuDVazXYxcjBsG09k7UlH7cGiUI5vQ==" + }, "node_modules/@walletconnect/http-connection": { - "version": "1.4.1", - "license": "LGPL-3.0", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/http-connection/-/http-connection-1.5.2.tgz", + "integrity": "sha512-drBwFzCHb+A/YAvMYGHs9DglL4NHQn079/dJzJPOC4kG9DA9WPw24CSeOUrqbP+370NwnaHbYtg4cbDgJQRy6g==", "dependencies": { - "@walletconnect/types": "^1.4.1", - "@walletconnect/utils": "^1.4.1", + "@walletconnect/types": "^1.5.2", + "@walletconnect/utils": "^1.5.2", "eventemitter3": "4.0.7", "xhr2-cookies": "1.1.0" } }, "node_modules/@walletconnect/iso-crypto": { - "version": "1.4.1", - "license": "LGPL-3.0", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/iso-crypto/-/iso-crypto-1.5.2.tgz", + "integrity": "sha512-tRd0+AfmOy0nwCqLx7oR3DyrsahgoyOAm/KqKzKu2eawnfG4dSaluUa/PxMjoC5r93K+ka7qmCq4k4m53qYiog==", "dependencies": { - "@pedrouid/iso-crypto": "^1.0.0", - "@walletconnect/types": "^1.4.1", - "@walletconnect/utils": "^1.4.1" + "@walletconnect/crypto": "^1.0.1", + "@walletconnect/types": "^1.5.2", + "@walletconnect/utils": "^1.5.2" + } + }, + "node_modules/@walletconnect/jsonrpc-types": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-types/-/jsonrpc-types-1.0.0.tgz", + "integrity": "sha512-11QXNq5H1PKZk7bP8SxgmCw3HRaDuPOVE+wObqEvmhc7OWYUZqfuaaMb+OXGRSOHL3sbC+XHfdeCxFTMXSFyng==", + "dependencies": { + "keyvaluestorage-interface": "^1.0.0" + } + }, + "node_modules/@walletconnect/jsonrpc-utils": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-utils/-/jsonrpc-utils-1.0.0.tgz", + "integrity": "sha512-qUHbKUK6sHeHn67qtHZoLoYk5hS6x1arTPjKDRkY93/6Fx+ZmNIpdm1owX3l6aYueyegJ7mz43FpvYHUqJ8xcw==", + "dependencies": { + "@walletconnect/environment": "^1.0.0", + "@walletconnect/jsonrpc-types": "^1.0.0" } }, "node_modules/@walletconnect/mobile-registry": { "version": "1.4.0", - "license": "MIT" + "resolved": "https://registry.npmjs.org/@walletconnect/mobile-registry/-/mobile-registry-1.4.0.tgz", + "integrity": "sha512-ZtKRio4uCZ1JUF7LIdecmZt7FOLnX72RPSY7aUVu7mj7CSfxDwUn6gBuK6WGtH+NZCldBqDl5DenI5fFSvkKYw==", + "deprecated": "Deprecated in favor of dynamic registry available from: https://github.com/walletconnect/walletconnect-registry" }, "node_modules/@walletconnect/qrcode-modal": { - "version": "1.4.1", - "license": "LGPL-3.0", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/qrcode-modal/-/qrcode-modal-1.5.2.tgz", + "integrity": "sha512-ciWh7kfZQ4qX+YYfF6+qVqw1Z0kyITGnzH7K2jEIxgCI5jsKeKoMcIfucSGIODGrM7OWshB/oA19UFTRdj4GFg==", "dependencies": { - "@walletconnect/browser-utils": "^1.4.1", + "@walletconnect/browser-utils": "^1.5.2", "@walletconnect/mobile-registry": "^1.4.0", - "@walletconnect/types": "^1.4.1", + "@walletconnect/types": "^1.5.2", + "copy-to-clipboard": "^3.3.1", "preact": "10.4.1", "qrcode": "1.4.4" } }, + "node_modules/@walletconnect/randombytes": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@walletconnect/randombytes/-/randombytes-1.0.1.tgz", + "integrity": "sha512-YJTyq69i0PtxVg7osEpKfvjTaWuAsR49QEcqGKZRKVQWMbGXBZ65fovemK/SRgtiFRv0V8PwsrlKSheqzfPNcg==", + "dependencies": { + "@walletconnect/encoding": "^1.0.0", + "@walletconnect/environment": "^1.0.0", + "randombytes": "^2.1.0" + } + }, + "node_modules/@walletconnect/safe-json": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@walletconnect/safe-json/-/safe-json-1.0.0.tgz", + "integrity": "sha512-QJzp/S/86sUAgWY6eh5MKYmSfZaRpIlmCJdi5uG4DJlKkZrHEF7ye7gA+VtbVzvTtpM/gRwO2plQuiooIeXjfg==" + }, "node_modules/@walletconnect/socket-transport": { - "version": "1.4.1", - "license": "LGPL-3.0", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/socket-transport/-/socket-transport-1.5.2.tgz", + "integrity": "sha512-eXafL2STkPocpYo0lDTpsQFIQ5ggCw78dXri9kqNhiSwRdLpjswGxt745V37enOXuFumz18MRXp3Og8yc+HIFQ==", "dependencies": { - "@walletconnect/types": "^1.4.1", - "@walletconnect/utils": "^1.4.1", + "@walletconnect/types": "^1.5.2", + "@walletconnect/utils": "^1.5.2", "ws": "7.3.0" } }, "node_modules/@walletconnect/socket-transport/node_modules/ws": { "version": "7.3.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz", + "integrity": "sha512-iFtXzngZVXPGgpTlP1rBqsUK82p9tKqsWRPg5L56egiljujJT3vGAYnHANvFxBieXrTFavhzhxW52jnaWV+w2w==", "engines": { "node": ">=8.3.0" }, @@ -9219,42 +9257,61 @@ } }, "node_modules/@walletconnect/types": { - "version": "1.4.1", - "license": "LGPL-3.0" + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-1.5.2.tgz", + "integrity": "sha512-ygUIqrn+IyANuA3OKLX2GzVB18zUvoRTWX0llKeM0unSlrF7oEs8m5+H5NHLB9sDs00Jae7Eb+JvUaGa/VKIPw==" }, "node_modules/@walletconnect/utils": { - "version": "1.4.1", - "license": "LGPL-3.0", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-1.5.2.tgz", + "integrity": "sha512-3m7Ty7oe/jb2NbYj7IAli+cyqlpg4XZG1xGrzCcQEEG6bkijCyc4qd51amimyh38wPsXp+kq7C4I+WAPBd9TkA==", "dependencies": { - "@json-rpc-tools/utils": "1.6.1", - "@walletconnect/browser-utils": "^1.4.1", - "@walletconnect/types": "^1.4.1", + "@walletconnect/browser-utils": "^1.5.2", + "@walletconnect/encoding": "^1.0.0", + "@walletconnect/jsonrpc-utils": "^1.0.0", + "@walletconnect/types": "^1.5.2", "bn.js": "4.11.8", - "enc-utils": "3.0.0", "js-sha3": "0.8.0", "query-string": "6.13.5" } }, "node_modules/@walletconnect/utils/node_modules/bn.js": { "version": "4.11.8", - "license": "MIT" + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", + "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" }, "node_modules/@walletconnect/utils/node_modules/js-sha3": { "version": "0.8.0", - "license": "MIT" + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", + "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" }, "node_modules/@walletconnect/web3-provider": { - "version": "1.4.1", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/web3-provider/-/web3-provider-1.5.2.tgz", + "integrity": "sha512-y60fAgobe4SwlVZYU0JQFHD8K3kXLCanGV+j998necBFppY3Ki+0szyROc08ok+PWpC1RbvFbRPibMrfHjnF6g==", "license": "LGPL-3.0", "dependencies": { - "@walletconnect/client": "^1.4.1", - "@walletconnect/http-connection": "^1.4.1", - "@walletconnect/qrcode-modal": "^1.4.1", - "@walletconnect/types": "^1.4.1", - "@walletconnect/utils": "^1.4.1", + "@walletconnect/client": "^1.5.2", + "@walletconnect/http-connection": "^1.5.2", + "@walletconnect/qrcode-modal": "^1.5.2", + "@walletconnect/types": "^1.5.2", + "@walletconnect/utils": "^1.5.2", "web3-provider-engine": "16.0.1" } }, + "node_modules/@walletconnect/window-getters": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@walletconnect/window-getters/-/window-getters-1.0.0.tgz", + "integrity": "sha512-xB0SQsLaleIYIkSsl43vm8EwETpBzJ2gnzk7e0wMF3ktqiTGS6TFHxcprMl5R44KKh4tCcHCJwolMCaDSwtAaA==" + }, + "node_modules/@walletconnect/window-metadata": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@walletconnect/window-metadata/-/window-metadata-1.0.0.tgz", + "integrity": "sha512-9eFvmJxIKCC3YWOL97SgRkKhlyGXkrHwamfechmqszbypFspaSk+t2jQXAEU7YClHF6Qjw5eYOmy1//zFi9/GA==", + "dependencies": { + "@walletconnect/window-getters": "^1.0.0" + } + }, "node_modules/@webassemblyjs/ast": { "version": "1.9.0", "license": "MIT", @@ -11321,7 +11378,8 @@ }, "node_modules/buffer-alloc": { "version": "1.2.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", + "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", "dependencies": { "buffer-alloc-unsafe": "^1.1.0", "buffer-fill": "^1.0.0" @@ -11329,7 +11387,8 @@ }, "node_modules/buffer-alloc-unsafe": { "version": "1.1.0", - "license": "MIT" + "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", + "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==" }, "node_modules/buffer-crc32": { "version": "0.2.13", @@ -11342,7 +11401,8 @@ }, "node_modules/buffer-fill": { "version": "1.0.0", - "license": "MIT" + "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", + "integrity": "sha1-+PeLdniYiO858gXNY39o5wISKyw=" }, "node_modules/buffer-from": { "version": "1.1.1", @@ -12583,7 +12643,6 @@ "version": "3.3.1", "resolved": "https://registry.npmjs.org/copy-to-clipboard/-/copy-to-clipboard-3.3.1.tgz", "integrity": "sha512-i13qo6kIHTTpCm8/Wup+0b1mVWETvu2kIMzKoK8FpkLkFxlt0znUAHcMzox+T8sPlqtZXq3CulEjQHsYiGFJUw==", - "dev": true, "dependencies": { "toggle-selection": "^1.0.6" } @@ -13824,7 +13883,8 @@ }, "node_modules/detect-browser": { "version": "5.2.0", - "license": "MIT" + "resolved": "https://registry.npmjs.org/detect-browser/-/detect-browser-5.2.0.tgz", + "integrity": "sha512-tr7XntDAu50BVENgQfajMLzacmSe34D+qZc4zjnniz0ZVuw/TZcLcyxHQjYpJTM36sGEkZZlYLnIM1hH7alTMA==" }, "node_modules/detect-newline": { "version": "2.1.0", @@ -13947,8 +14007,9 @@ } }, "node_modules/dijkstrajs": { - "version": "1.0.1", - "license": "MIT" + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.2.tgz", + "integrity": "sha512-QV6PMaHTCNmKSeP6QoXhVTw9snc9VD8MulTT0Bd99Pacp4SS1cjcrYPgBPmibqKVtMJJfqC6XvOXgPMEEPH/fg==" }, "node_modules/dir-glob": { "version": "2.2.2", @@ -14323,14 +14384,6 @@ "react": ">=16.3.0" } }, - "node_modules/enc-utils": { - "version": "3.0.0", - "license": "MIT", - "dependencies": { - "is-typedarray": "1.0.0", - "typedarray-to-buffer": "3.1.5" - } - }, "node_modules/encodeurl": { "version": "1.0.2", "license": "MIT", @@ -20132,7 +20185,8 @@ }, "node_modules/keyvaluestorage-interface": { "version": "1.0.0", - "license": "MIT" + "resolved": "https://registry.npmjs.org/keyvaluestorage-interface/-/keyvaluestorage-interface-1.0.0.tgz", + "integrity": "sha512-8t6Q3TclQ4uZynJY9IGr2+SsIGwK9JHcO6ootkHCGA0CrQCRy+VkouYNO2xicET6b9al7QKzpebNow+gkpCL8g==" }, "node_modules/killable": { "version": "1.0.1", @@ -22790,7 +22844,8 @@ }, "node_modules/pngjs": { "version": "3.4.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-3.4.0.tgz", + "integrity": "sha512-NCrCHhWmnQklfH4MtJMRjZ2a8c80qXeMlQMv2uVp9ISJMTt562SbGd6n2oq0PaPgKm7Z6pL9E2UlLIhC+SHL3w==", "engines": { "node": ">=4.0.0" } @@ -23517,7 +23572,8 @@ }, "node_modules/preact": { "version": "10.4.1", - "license": "MIT", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.4.1.tgz", + "integrity": "sha512-WKrRpCSwL2t3tpOOGhf2WfTpcmbpxaWtDbdJdKdjd0aEiTkvOmS4NBkG6kzlaAHI9AkQ3iVqbFWM3Ei7mZ4o1Q==", "funding": { "type": "opencollective", "url": "https://opencollective.com/preact" @@ -24067,7 +24123,8 @@ }, "node_modules/qrcode": { "version": "1.4.4", - "license": "MIT", + "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.4.4.tgz", + "integrity": "sha512-oLzEC5+NKFou9P0bMj5+v6Z40evexeE29Z9cummZXZ9QXyMr3lphkURzxjXgPJC5azpxcshoDWV1xE46z+/c3Q==", "dependencies": { "buffer": "^5.4.3", "buffer-alloc": "^1.2.0", @@ -24086,14 +24143,16 @@ }, "node_modules/qrcode/node_modules/camelcase": { "version": "5.3.1", - "license": "MIT", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", "engines": { "node": ">=6" } }, "node_modules/qrcode/node_modules/cliui": { "version": "5.0.0", - "license": "ISC", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", "dependencies": { "string-width": "^3.1.0", "strip-ansi": "^5.2.0", @@ -24102,11 +24161,13 @@ }, "node_modules/qrcode/node_modules/emoji-regex": { "version": "7.0.3", - "license": "MIT" + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==" }, "node_modules/qrcode/node_modules/string-width": { "version": "3.1.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", "dependencies": { "emoji-regex": "^7.0.1", "is-fullwidth-code-point": "^2.0.0", @@ -24118,7 +24179,8 @@ }, "node_modules/qrcode/node_modules/wrap-ansi": { "version": "5.1.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", "dependencies": { "ansi-styles": "^3.2.0", "string-width": "^3.0.0", @@ -24130,7 +24192,8 @@ }, "node_modules/qrcode/node_modules/yargs": { "version": "13.3.2", - "license": "MIT", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz", + "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==", "dependencies": { "cliui": "^5.0.0", "find-up": "^3.0.0", @@ -24146,7 +24209,8 @@ }, "node_modules/qrcode/node_modules/yargs-parser": { "version": "13.1.2", - "license": "ISC", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", + "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", "dependencies": { "camelcase": "^5.0.0", "decamelize": "^1.2.0" @@ -24161,7 +24225,8 @@ }, "node_modules/query-string": { "version": "6.13.5", - "license": "MIT", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-6.13.5.tgz", + "integrity": "sha512-svk3xg9qHR39P3JlHuD7g3nRnyay5mHbrPctEBDUxUkHRifPHXJDhBUycdCC0NBjXoDf44Gb+IsOZL1Uwn8M/Q==", "dependencies": { "decode-uri-component": "^0.2.0", "split-on-first": "^1.0.0", @@ -25913,10 +25978,6 @@ "events": "^3.0.0" } }, - "node_modules/safe-json-utils": { - "version": "1.0.0", - "license": "MIT" - }, "node_modules/safe-regex": { "version": "1.1.0", "license": "MIT", @@ -26766,7 +26827,8 @@ }, "node_modules/split-on-first": { "version": "1.1.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz", + "integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==", "engines": { "node": ">=6" } @@ -26989,7 +27051,8 @@ }, "node_modules/strict-uri-encode": { "version": "2.0.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", + "integrity": "sha1-ucczDHBChi9rFC3CdLvMWGbONUY=", "engines": { "node": ">=4" } @@ -28016,8 +28079,7 @@ "node_modules/toggle-selection": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz", - "integrity": "sha1-bkWxJj8gF/oKzH2J14sVuL932jI=", - "dev": true + "integrity": "sha1-bkWxJj8gF/oKzH2J14sVuL932jI=" }, "node_modules/toidentifier": { "version": "1.0.0", @@ -31190,17 +31252,6 @@ "node": ">=8" } }, - "node_modules/window-getters": { - "version": "1.0.0", - "license": "MIT" - }, - "node_modules/window-metadata": { - "version": "1.0.0", - "license": "MIT", - "dependencies": { - "window-getters": "^1.0.0" - } - }, "node_modules/with": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/with/-/with-7.0.2.tgz", @@ -33624,18 +33675,6 @@ "@types/yargs": "^13.0.0" } }, - "@json-rpc-tools/types": { - "version": "1.6.4", - "requires": { - "keyvaluestorage-interface": "^1.0.0" - } - }, - "@json-rpc-tools/utils": { - "version": "1.6.1", - "requires": { - "@json-rpc-tools/types": "^1.6.1" - } - }, "@koa/router": { "version": "9.4.0", "dev": true, @@ -33828,27 +33867,6 @@ } } }, - "@pedrouid/iso-crypto": { - "version": "1.1.0", - "requires": { - "@pedrouid/iso-random": "^1.1.0", - "aes-js": "^3.1.2", - "enc-utils": "^3.0.0", - "hash.js": "^1.1.7" - }, - "dependencies": { - "aes-js": { - "version": "3.1.2" - } - } - }, - "@pedrouid/iso-random": { - "version": "1.1.0", - "requires": { - "enc-utils": "^3.0.0", - "randombytes": "^2.1.0" - } - }, "@popperjs/core": { "version": "2.9.2", "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.9.2.tgz", @@ -34192,7 +34210,6 @@ "integrity": "sha512-IWnb10ImrzRMT2qw9785p3wYEI6U9gjsg6H2zKcRJQP5dEboqeX3OFjUKfXkaIWii4nz8MtJjBg5t4BdEYqLdw==", "dev": true, "requires": { - "@babel/core": "^7.12.10", "@babel/generator": "^7.12.11", "@babel/parser": "^7.12.11", "@babel/plugin-transform-react-jsx": "^7.12.12", @@ -37710,7 +37727,6 @@ "@vue/babel-preset-app": { "version": "4.5.12", "requires": { - "@babel/core": "^7.11.0", "@babel/helper-compilation-targets": "^7.9.6", "@babel/helper-module-imports": "^7.8.3", "@babel/plugin-proposal-class-properties": "^7.8.3", @@ -37723,7 +37739,6 @@ "@vue/babel-plugin-jsx": "^1.0.3", "@vue/babel-preset-jsx": "^1.2.4", "babel-plugin-dynamic-import-node": "^2.3.3", - "core-js": "^3.6.5", "core-js-compat": "^3.6.5", "semver": "^6.1.0" } @@ -38262,110 +38277,217 @@ } }, "@walletconnect/browser-utils": { - "version": "1.4.1", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/browser-utils/-/browser-utils-1.5.2.tgz", + "integrity": "sha512-nP7ktHwYmvHfXIbq7lGPoig8nO7HYi2dWE8UDxBlgNMs4mvzm2jyN6cm0JZ4xh5gO90/gQwbyuU33zLcZGUPhw==", "requires": { - "@walletconnect/types": "^1.4.1", - "detect-browser": "5.2.0", - "safe-json-utils": "1.0.0", - "window-getters": "1.0.0", - "window-metadata": "1.0.0" + "@walletconnect/safe-json": "1.0.0", + "@walletconnect/types": "^1.5.2", + "@walletconnect/window-getters": "1.0.0", + "@walletconnect/window-metadata": "1.0.0", + "detect-browser": "5.2.0" } }, "@walletconnect/client": { - "version": "1.4.1", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/client/-/client-1.5.2.tgz", + "integrity": "sha512-dAMK4zqNBZ88YpUQxTMt3RCS2ThTwecPmlq3MK76liLwrsGYRfnQ104GHZGI93rZEdcDWX04p5e3NsCXWMXcNw==", "requires": { - "@walletconnect/core": "^1.4.1", - "@walletconnect/iso-crypto": "^1.4.1", - "@walletconnect/types": "^1.4.1", - "@walletconnect/utils": "^1.4.1" + "@walletconnect/core": "^1.5.2", + "@walletconnect/iso-crypto": "^1.5.2", + "@walletconnect/types": "^1.5.2", + "@walletconnect/utils": "^1.5.2" } }, "@walletconnect/core": { - "version": "1.4.1", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-1.5.2.tgz", + "integrity": "sha512-uzrIbjzSHdPPeFSqwPYhp/VhyJKUODDc0STt+5R1A2orE1nh9Rb6XqSkBfLkOlf8pdKUObI95Lr0LH9TbSzF/A==", "requires": { - "@walletconnect/socket-transport": "^1.4.1", - "@walletconnect/types": "^1.4.1", - "@walletconnect/utils": "^1.4.1" + "@walletconnect/socket-transport": "^1.5.2", + "@walletconnect/types": "^1.5.2", + "@walletconnect/utils": "^1.5.2" + } + }, + "@walletconnect/crypto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@walletconnect/crypto/-/crypto-1.0.1.tgz", + "integrity": "sha512-IgUReNrycIFxkGgq8YT9HsosCkhutakWD9Q411PR0aJfxpEa/VKJeaLRtoz6DvJpztWStwhIHnAbBoOVR72a6g==", + "requires": { + "@walletconnect/encoding": "^1.0.0", + "@walletconnect/environment": "^1.0.0", + "@walletconnect/randombytes": "^1.0.1", + "aes-js": "^3.1.2", + "hash.js": "^1.1.7" + }, + "dependencies": { + "aes-js": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", + "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==" + } } }, + "@walletconnect/encoding": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@walletconnect/encoding/-/encoding-1.0.0.tgz", + "integrity": "sha512-4nkJFnS0QF5JdieG/3VPD1/iEWkLSZ14EBInLZ00RWxmC6EMZrzAeHNAWIgm+xP3NK0lqz+7lEsmWGtcl5gYnQ==", + "requires": { + "is-typedarray": "1.0.0", + "typedarray-to-buffer": "3.1.5" + } + }, + "@walletconnect/environment": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@walletconnect/environment/-/environment-1.0.0.tgz", + "integrity": "sha512-4BwqyWy6KpSvkocSaV7WR3BlZfrxLbJSLkg+j7Gl6pTDE+U55lLhJvQaMuDVazXYxcjBsG09k7UlH7cGiUI5vQ==" + }, "@walletconnect/http-connection": { - "version": "1.4.1", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/http-connection/-/http-connection-1.5.2.tgz", + "integrity": "sha512-drBwFzCHb+A/YAvMYGHs9DglL4NHQn079/dJzJPOC4kG9DA9WPw24CSeOUrqbP+370NwnaHbYtg4cbDgJQRy6g==", "requires": { - "@walletconnect/types": "^1.4.1", - "@walletconnect/utils": "^1.4.1", + "@walletconnect/types": "^1.5.2", + "@walletconnect/utils": "^1.5.2", "eventemitter3": "4.0.7", "xhr2-cookies": "1.1.0" } }, "@walletconnect/iso-crypto": { - "version": "1.4.1", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/iso-crypto/-/iso-crypto-1.5.2.tgz", + "integrity": "sha512-tRd0+AfmOy0nwCqLx7oR3DyrsahgoyOAm/KqKzKu2eawnfG4dSaluUa/PxMjoC5r93K+ka7qmCq4k4m53qYiog==", "requires": { - "@pedrouid/iso-crypto": "^1.0.0", - "@walletconnect/types": "^1.4.1", - "@walletconnect/utils": "^1.4.1" + "@walletconnect/crypto": "^1.0.1", + "@walletconnect/types": "^1.5.2", + "@walletconnect/utils": "^1.5.2" + } + }, + "@walletconnect/jsonrpc-types": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-types/-/jsonrpc-types-1.0.0.tgz", + "integrity": "sha512-11QXNq5H1PKZk7bP8SxgmCw3HRaDuPOVE+wObqEvmhc7OWYUZqfuaaMb+OXGRSOHL3sbC+XHfdeCxFTMXSFyng==", + "requires": { + "keyvaluestorage-interface": "^1.0.0" + } + }, + "@walletconnect/jsonrpc-utils": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-utils/-/jsonrpc-utils-1.0.0.tgz", + "integrity": "sha512-qUHbKUK6sHeHn67qtHZoLoYk5hS6x1arTPjKDRkY93/6Fx+ZmNIpdm1owX3l6aYueyegJ7mz43FpvYHUqJ8xcw==", + "requires": { + "@walletconnect/environment": "^1.0.0", + "@walletconnect/jsonrpc-types": "^1.0.0" } }, "@walletconnect/mobile-registry": { - "version": "1.4.0" + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@walletconnect/mobile-registry/-/mobile-registry-1.4.0.tgz", + "integrity": "sha512-ZtKRio4uCZ1JUF7LIdecmZt7FOLnX72RPSY7aUVu7mj7CSfxDwUn6gBuK6WGtH+NZCldBqDl5DenI5fFSvkKYw==" }, "@walletconnect/qrcode-modal": { - "version": "1.4.1", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/qrcode-modal/-/qrcode-modal-1.5.2.tgz", + "integrity": "sha512-ciWh7kfZQ4qX+YYfF6+qVqw1Z0kyITGnzH7K2jEIxgCI5jsKeKoMcIfucSGIODGrM7OWshB/oA19UFTRdj4GFg==", "requires": { - "@walletconnect/browser-utils": "^1.4.1", + "@walletconnect/browser-utils": "^1.5.2", "@walletconnect/mobile-registry": "^1.4.0", - "@walletconnect/types": "^1.4.1", + "@walletconnect/types": "^1.5.2", + "copy-to-clipboard": "^3.3.1", "preact": "10.4.1", "qrcode": "1.4.4" } }, + "@walletconnect/randombytes": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@walletconnect/randombytes/-/randombytes-1.0.1.tgz", + "integrity": "sha512-YJTyq69i0PtxVg7osEpKfvjTaWuAsR49QEcqGKZRKVQWMbGXBZ65fovemK/SRgtiFRv0V8PwsrlKSheqzfPNcg==", + "requires": { + "@walletconnect/encoding": "^1.0.0", + "@walletconnect/environment": "^1.0.0", + "randombytes": "^2.1.0" + } + }, + "@walletconnect/safe-json": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@walletconnect/safe-json/-/safe-json-1.0.0.tgz", + "integrity": "sha512-QJzp/S/86sUAgWY6eh5MKYmSfZaRpIlmCJdi5uG4DJlKkZrHEF7ye7gA+VtbVzvTtpM/gRwO2plQuiooIeXjfg==" + }, "@walletconnect/socket-transport": { - "version": "1.4.1", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/socket-transport/-/socket-transport-1.5.2.tgz", + "integrity": "sha512-eXafL2STkPocpYo0lDTpsQFIQ5ggCw78dXri9kqNhiSwRdLpjswGxt745V37enOXuFumz18MRXp3Og8yc+HIFQ==", "requires": { - "@walletconnect/types": "^1.4.1", - "@walletconnect/utils": "^1.4.1", + "@walletconnect/types": "^1.5.2", + "@walletconnect/utils": "^1.5.2", "ws": "7.3.0" }, "dependencies": { "ws": { "version": "7.3.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz", + "integrity": "sha512-iFtXzngZVXPGgpTlP1rBqsUK82p9tKqsWRPg5L56egiljujJT3vGAYnHANvFxBieXrTFavhzhxW52jnaWV+w2w==", "requires": {} } } }, "@walletconnect/types": { - "version": "1.4.1" + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-1.5.2.tgz", + "integrity": "sha512-ygUIqrn+IyANuA3OKLX2GzVB18zUvoRTWX0llKeM0unSlrF7oEs8m5+H5NHLB9sDs00Jae7Eb+JvUaGa/VKIPw==" }, "@walletconnect/utils": { - "version": "1.4.1", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-1.5.2.tgz", + "integrity": "sha512-3m7Ty7oe/jb2NbYj7IAli+cyqlpg4XZG1xGrzCcQEEG6bkijCyc4qd51amimyh38wPsXp+kq7C4I+WAPBd9TkA==", "requires": { - "@json-rpc-tools/utils": "1.6.1", - "@walletconnect/browser-utils": "^1.4.1", - "@walletconnect/types": "^1.4.1", + "@walletconnect/browser-utils": "^1.5.2", + "@walletconnect/encoding": "^1.0.0", + "@walletconnect/jsonrpc-utils": "^1.0.0", + "@walletconnect/types": "^1.5.2", "bn.js": "4.11.8", - "enc-utils": "3.0.0", "js-sha3": "0.8.0", "query-string": "6.13.5" }, "dependencies": { "bn.js": { - "version": "4.11.8" + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", + "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" }, "js-sha3": { - "version": "0.8.0" + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", + "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" } } }, "@walletconnect/web3-provider": { - "version": "1.4.1", - "requires": { - "@walletconnect/client": "^1.4.1", - "@walletconnect/http-connection": "^1.4.1", - "@walletconnect/qrcode-modal": "^1.4.1", - "@walletconnect/types": "^1.4.1", - "@walletconnect/utils": "^1.4.1", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@walletconnect/web3-provider/-/web3-provider-1.5.2.tgz", + "integrity": "sha512-y60fAgobe4SwlVZYU0JQFHD8K3kXLCanGV+j998necBFppY3Ki+0szyROc08ok+PWpC1RbvFbRPibMrfHjnF6g==", + "requires": { + "@walletconnect/client": "^1.5.2", + "@walletconnect/http-connection": "^1.5.2", + "@walletconnect/qrcode-modal": "^1.5.2", + "@walletconnect/types": "^1.5.2", + "@walletconnect/utils": "^1.5.2", "web3-provider-engine": "16.0.1" } }, + "@walletconnect/window-getters": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@walletconnect/window-getters/-/window-getters-1.0.0.tgz", + "integrity": "sha512-xB0SQsLaleIYIkSsl43vm8EwETpBzJ2gnzk7e0wMF3ktqiTGS6TFHxcprMl5R44KKh4tCcHCJwolMCaDSwtAaA==" + }, + "@walletconnect/window-metadata": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@walletconnect/window-metadata/-/window-metadata-1.0.0.tgz", + "integrity": "sha512-9eFvmJxIKCC3YWOL97SgRkKhlyGXkrHwamfechmqszbypFspaSk+t2jQXAEU7YClHF6Qjw5eYOmy1//zFi9/GA==", + "requires": { + "@walletconnect/window-getters": "^1.0.0" + } + }, "@webassemblyjs/ast": { "version": "1.9.0", "requires": { @@ -39867,13 +39989,17 @@ }, "buffer-alloc": { "version": "1.2.0", + "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", + "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", "requires": { "buffer-alloc-unsafe": "^1.1.0", "buffer-fill": "^1.0.0" } }, "buffer-alloc-unsafe": { - "version": "1.1.0" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", + "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==" }, "buffer-crc32": { "version": "0.2.13", @@ -39882,7 +40008,9 @@ "dev": true }, "buffer-fill": { - "version": "1.0.0" + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", + "integrity": "sha1-+PeLdniYiO858gXNY39o5wISKyw=" }, "buffer-from": { "version": "1.1.1" @@ -40751,7 +40879,6 @@ "version": "3.3.1", "resolved": "https://registry.npmjs.org/copy-to-clipboard/-/copy-to-clipboard-3.3.1.tgz", "integrity": "sha512-i13qo6kIHTTpCm8/Wup+0b1mVWETvu2kIMzKoK8FpkLkFxlt0znUAHcMzox+T8sPlqtZXq3CulEjQHsYiGFJUw==", - "dev": true, "requires": { "toggle-selection": "^1.0.6" } @@ -41639,7 +41766,9 @@ } }, "detect-browser": { - "version": "5.2.0" + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/detect-browser/-/detect-browser-5.2.0.tgz", + "integrity": "sha512-tr7XntDAu50BVENgQfajMLzacmSe34D+qZc4zjnniz0ZVuw/TZcLcyxHQjYpJTM36sGEkZZlYLnIM1hH7alTMA==" }, "detect-newline": { "version": "2.1.0", @@ -41731,7 +41860,9 @@ } }, "dijkstrajs": { - "version": "1.0.1" + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.2.tgz", + "integrity": "sha512-QV6PMaHTCNmKSeP6QoXhVTw9snc9VD8MulTT0Bd99Pacp4SS1cjcrYPgBPmibqKVtMJJfqC6XvOXgPMEEPH/fg==" }, "dir-glob": { "version": "2.2.2", @@ -42036,13 +42167,6 @@ "hoist-non-react-statics": "^3.3.0" } }, - "enc-utils": { - "version": "3.0.0", - "requires": { - "is-typedarray": "1.0.0", - "typedarray-to-buffer": "3.1.5" - } - }, "encodeurl": { "version": "1.0.2" }, @@ -46155,7 +46279,9 @@ } }, "keyvaluestorage-interface": { - "version": "1.0.0" + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/keyvaluestorage-interface/-/keyvaluestorage-interface-1.0.0.tgz", + "integrity": "sha512-8t6Q3TclQ4uZynJY9IGr2+SsIGwK9JHcO6ootkHCGA0CrQCRy+VkouYNO2xicET6b9al7QKzpebNow+gkpCL8g==" }, "killable": { "version": "1.0.1" @@ -48050,7 +48176,9 @@ "dev": true }, "pngjs": { - "version": "3.4.0" + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-3.4.0.tgz", + "integrity": "sha512-NCrCHhWmnQklfH4MtJMRjZ2a8c80qXeMlQMv2uVp9ISJMTt562SbGd6n2oq0PaPgKm7Z6pL9E2UlLIhC+SHL3w==" }, "pnp-webpack-plugin": { "version": "1.6.4", @@ -48599,7 +48727,9 @@ "version": "4.1.0" }, "preact": { - "version": "10.4.1" + "version": "10.4.1", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.4.1.tgz", + "integrity": "sha512-WKrRpCSwL2t3tpOOGhf2WfTpcmbpxaWtDbdJdKdjd0aEiTkvOmS4NBkG6kzlaAHI9AkQ3iVqbFWM3Ei7mZ4o1Q==" }, "precond": { "version": "0.2.3" @@ -49020,6 +49150,8 @@ }, "qrcode": { "version": "1.4.4", + "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.4.4.tgz", + "integrity": "sha512-oLzEC5+NKFou9P0bMj5+v6Z40evexeE29Z9cummZXZ9QXyMr3lphkURzxjXgPJC5azpxcshoDWV1xE46z+/c3Q==", "requires": { "buffer": "^5.4.3", "buffer-alloc": "^1.2.0", @@ -49031,10 +49163,14 @@ }, "dependencies": { "camelcase": { - "version": "5.3.1" + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" }, "cliui": { "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", "requires": { "string-width": "^3.1.0", "strip-ansi": "^5.2.0", @@ -49042,10 +49178,14 @@ } }, "emoji-regex": { - "version": "7.0.3" + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==" }, "string-width": { "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", "requires": { "emoji-regex": "^7.0.1", "is-fullwidth-code-point": "^2.0.0", @@ -49054,6 +49194,8 @@ }, "wrap-ansi": { "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", "requires": { "ansi-styles": "^3.2.0", "string-width": "^3.0.0", @@ -49062,6 +49204,8 @@ }, "yargs": { "version": "13.3.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz", + "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==", "requires": { "cliui": "^5.0.0", "find-up": "^3.0.0", @@ -49077,6 +49221,8 @@ }, "yargs-parser": { "version": "13.1.2", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", + "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", "requires": { "camelcase": "^5.0.0", "decamelize": "^1.2.0" @@ -49089,6 +49235,8 @@ }, "query-string": { "version": "6.13.5", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-6.13.5.tgz", + "integrity": "sha512-svk3xg9qHR39P3JlHuD7g3nRnyay5mHbrPctEBDUxUkHRifPHXJDhBUycdCC0NBjXoDf44Gb+IsOZL1Uwn8M/Q==", "requires": { "decode-uri-component": "^0.2.0", "split-on-first": "^1.0.0", @@ -50326,9 +50474,6 @@ "events": "^3.0.0" } }, - "safe-json-utils": { - "version": "1.0.0" - }, "safe-regex": { "version": "1.1.0", "requires": { @@ -50953,7 +51098,9 @@ } }, "split-on-first": { - "version": "1.1.0" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz", + "integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==" }, "split-string": { "version": "3.1.0", @@ -51108,7 +51255,9 @@ "version": "1.0.1" }, "strict-uri-encode": { - "version": "2.0.0" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", + "integrity": "sha1-ucczDHBChi9rFC3CdLvMWGbONUY=" }, "string_decoder": { "version": "1.1.1", @@ -51803,8 +51952,7 @@ "toggle-selection": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz", - "integrity": "sha1-bkWxJj8gF/oKzH2J14sVuL932jI=", - "dev": true + "integrity": "sha1-bkWxJj8gF/oKzH2J14sVuL932jI=" }, "toidentifier": { "version": "1.0.0" @@ -54108,15 +54256,6 @@ } } }, - "window-getters": { - "version": "1.0.0" - }, - "window-metadata": { - "version": "1.0.0", - "requires": { - "window-getters": "^1.0.0" - } - }, "with": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/with/-/with-7.0.2.tgz", diff --git a/package.json b/package.json index 09056b9160..674efc6fa7 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@vue/cli-plugin-typescript": "^4.4.0", "@vue/cli-service": "^4.4.0", "@vueuse/core": "^4.3.4", - "@walletconnect/web3-provider": "^1.3.1", + "@walletconnect/web3-provider": "^1.5.2", "animejs": "^3.2.1", "apexcharts": "^3.23.1", "autoprefixer": "^9.8.6", From 06422becd2ca952e7c1514327f4dbead2e461ea2 Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Mon, 2 Aug 2021 21:19:39 +0100 Subject: [PATCH 13/30] 1.11.3 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index cc6bbccdd2..3902806bee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@balancer-labs/frontend-v2", - "version": "1.11.2", + "version": "1.11.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@balancer-labs/frontend-v2", - "version": "1.11.2", + "version": "1.11.3", "license": "MIT", "dependencies": { "@balancer-labs/assets": "github:balancer-labs/assets#master", diff --git a/package.json b/package.json index 674efc6fa7..a654ed9e0f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@balancer-labs/frontend-v2", - "version": "1.11.2", + "version": "1.11.3", "engines": { "node": "14.x", "npm": ">=7" From ad59aef5c15e3cfbe9fa5c80f0938b4450ab4cf4 Mon Sep 17 00:00:00 2001 From: Evgeny Boxer Date: Tue, 3 Aug 2021 19:53:28 +1000 Subject: [PATCH 14/30] [Gnosis]: More UI Tweaks (#616) * resetState only on amountChange * add a non-blocking user confirmation state * implement price update alert --- src/components/modals/TradePreviewModalGP.vue | 92 +++++++++++++++++-- src/composables/trade/useGnosis.ts | 12 +-- src/composables/trade/useSor.ts | 18 ++-- src/composables/trade/useTrading.ts | 27 +++--- src/locales/default.json | 5 + 5 files changed, 120 insertions(+), 34 deletions(-) diff --git a/src/components/modals/TradePreviewModalGP.vue b/src/components/modals/TradePreviewModalGP.vue index f12d9b0e7c..d9d5b98999 100644 --- a/src/components/modals/TradePreviewModalGP.vue +++ b/src/components/modals/TradePreviewModalGP.vue @@ -146,6 +146,21 @@ +
{{ labels.confirmTrade }} @@ -211,21 +227,25 @@ diff --git a/src/components/cards/TradeCard/GasReimbursement.vue b/src/components/cards/TradeCard/GasReimbursement.vue index 36c4ef6eb7..7a79fefe04 100644 --- a/src/components/cards/TradeCard/GasReimbursement.vue +++ b/src/components/cards/TradeCard/GasReimbursement.vue @@ -18,7 +18,6 @@ + + From c07cd20780eb4977cd730ac1e0aaad5546b7a536 Mon Sep 17 00:00:00 2001 From: Evgeny Boxer Date: Thu, 5 Aug 2021 21:33:55 +1000 Subject: [PATCH 23/30] Add support for transaction speed ups / cancellations (#631) * feat: support speed ups and cancellations * add comment --- src/composables/useTransactions.ts | 90 ++++++++++++++++++++---------- src/composables/useWeb3Watchers.ts | 34 ++++++++++- src/locales/default.json | 2 +- 3 files changed, 92 insertions(+), 34 deletions(-) diff --git a/src/composables/useTransactions.ts b/src/composables/useTransactions.ts index 51eff5347d..e94dd7be7e 100644 --- a/src/composables/useTransactions.ts +++ b/src/composables/useTransactions.ts @@ -21,7 +21,8 @@ import useNumbers from './useNumbers'; import { GnosisTransactionDetails } from './trade/useGnosis'; const WEEK_MS = 86_400_000 * 7; -const TRANSACTIONS_SCHEMA_VERSION = '1.0'; +// Please update the schema version when making changes to the transaction structure. +const TRANSACTIONS_SCHEMA_VERSION = '1.1'; export type TransactionStatus = | 'pending' @@ -53,8 +54,12 @@ export type TxReceipt = Pick< export type OrderReceipt = OrderMetaData; +export type ReplacementReason = 'txSpeedUp' | 'txCancel'; + export type Transaction = { id: string; + originalId?: string; + replacementReason?: ReplacementReason; action: TransactionAction; type: TransactionType; receipt?: OrderReceipt | TxReceipt; @@ -150,7 +155,7 @@ function getTransaction(id: string, type: TransactionType) { const transactionsMap = getTransactions(); const txId = getId(id, type); - return transactionsMap[txId]; + return transactionsMap[txId] ?? null; } function updateTransaction( @@ -163,7 +168,17 @@ function updateTransaction( const transaction = transactionsMap[txId]; if (transaction != null) { - transactionsMap[txId] = merge(transaction, updates); + // id change requires a replacement of the transaction + if (updates.id != null) { + const newTxId = getId(updates.id, type); + + transactionsMap[newTxId] = merge({}, transaction, updates, { + originalId: id + }); + delete transactionsMap[txId]; + } else { + transactionsMap[txId] = merge({}, transaction, updates); + } setTransactions(transactionsMap); @@ -174,7 +189,10 @@ function updateTransaction( } function isSuccessfulTransaction(transaction: Transaction) { - if (transaction.status === 'confirmed') { + if ( + transaction.status === 'confirmed' && + transaction.replacementReason !== 'txCancel' + ) { if (transaction.type === 'order') { return (transaction.receipt as OrderReceipt)?.status === 'fulfilled'; } else { @@ -287,21 +305,23 @@ export default function useTransactions() { if (receipt != null) { const transaction = getTransaction(id, type); - const updateSuccessful = updateTransaction(id, type, { - receipt: - type === 'tx' - ? normalizeTxReceipt(receipt as TransactionReceipt) - : receipt, - summary: - type === 'order' - ? getSettledOrderSummary(transaction, receipt as OrderReceipt) - : transaction.summary, - status: 'confirmed', - confirmedTime: Date.now() - }); - if (updateSuccessful) { - addNotificationForTransaction(id, type); - return true; + if (transaction != null) { + const updateSuccessful = updateTransaction(id, type, { + receipt: + type === 'tx' + ? normalizeTxReceipt(receipt as TransactionReceipt) + : receipt, + summary: + type === 'order' + ? getSettledOrderSummary(transaction, receipt as OrderReceipt) + : transaction.summary, + status: 'confirmed', + confirmedTime: Date.now() + }); + if (updateSuccessful) { + addNotificationForTransaction(id, type); + return true; + } } } @@ -311,18 +331,25 @@ export default function useTransactions() { function addNotificationForTransaction(id: string, type: TransactionType) { const transaction = getTransaction(id, type); - addNotification({ - title: `${t(`transactionAction.${transaction.action}`)} ${t( - `transactionStatus.${transaction.status}` - )}`, - message: transaction.summary, - transactionMetadata: { - id: transaction.id, - status: transaction.status, - isSuccess: isSuccessfulTransaction(transaction), - explorerLink: getExplorerLink(transaction.id, transaction.type) - } - }); + if (transaction != null) { + const transactionStatus: TransactionStatus = + transaction.replacementReason === 'txCancel' + ? 'cancelled' + : transaction.status; + + addNotification({ + title: `${t(`transactionAction.${transaction.action}`)} ${t( + `transactionStatus.${transactionStatus}` + )}`, + message: transaction.summary, + transactionMetadata: { + id: transaction.id, + status: transaction.status, + isSuccess: isSuccessfulTransaction(transaction), + explorerLink: getExplorerLink(transaction.id, transaction.type) + } + }); + } } function checkOrderActivity(transaction: Transaction) { @@ -397,6 +424,7 @@ export default function useTransactions() { finalizeTransaction, getExplorerLink, isSuccessfulTransaction, + updateTransaction, // computed pendingTransactions, diff --git a/src/composables/useWeb3Watchers.ts b/src/composables/useWeb3Watchers.ts index 385022a1a7..0258144294 100644 --- a/src/composables/useWeb3Watchers.ts +++ b/src/composables/useWeb3Watchers.ts @@ -1,11 +1,12 @@ import useWeb3 from '@/services/web3/useWeb3'; +import { EthereumTransactionData } from 'bnc-sdk/dist/types/src/interfaces'; import { watch } from 'vue'; import { useI18n } from 'vue-i18n'; import { useStore } from 'vuex'; import useBlocknative from './useBlocknative'; import useTokens from './useTokens'; -import useTransactions from './useTransactions'; +import useTransactions, { ReplacementReason } from './useTransactions'; export default function useWeb3Watchers() { // COMPOSABLES @@ -21,7 +22,22 @@ export default function useWeb3Watchers() { blockNumber } = useWeb3(); const { refetchBalances, refetchAllowances } = useTokens(); - const { handlePendingTransactions } = useTransactions(); + const { handlePendingTransactions, updateTransaction } = useTransactions(); + + function handleTransactionReplacement( + tx: EthereumTransactionData, + replacementReason: ReplacementReason + ) { + const originalHash = tx.replaceHash; + + if (originalHash != null) { + updateTransaction(originalHash, 'tx', { + // new id + id: tx.hash, + replacementReason + }); + } + } // Watch for user account change: // -> Unsubscribe Blocknative from old account if exits @@ -38,6 +54,20 @@ export default function useWeb3Watchers() { refetchBalances.value(); refetchAllowances.value(); }); + + emitter.on('txSpeedUp', tx => + handleTransactionReplacement( + tx as EthereumTransactionData, + 'txSpeedUp' + ) + ); + + emitter.on('txCancel', tx => + handleTransactionReplacement( + tx as EthereumTransactionData, + 'txCancel' + ) + ); } } ); diff --git a/src/locales/default.json b/src/locales/default.json index 0139050820..dd7d0bfe56 100644 --- a/src/locales/default.json +++ b/src/locales/default.json @@ -213,7 +213,7 @@ "confirmed": "Confirmed", "expired": "Expired", "cancelling": "Cancelling", - "Cancelled": "Cancelled" + "cancelled": "Cancelled" }, "transactionSummary": { "investInPool": "{0} in {1}", From c1b0ff436e5125f61778ddef1a017720de5f239b Mon Sep 17 00:00:00 2001 From: Markus Buhatem Koch Date: Thu, 5 Aug 2021 19:08:17 -0300 Subject: [PATCH 24/30] LM week 63, no changes --- .../MultiTokenLiquidityMining.json | 229 ++++++++++++++++++ 1 file changed, 229 insertions(+) diff --git a/src/lib/utils/liquidityMining/MultiTokenLiquidityMining.json b/src/lib/utils/liquidityMining/MultiTokenLiquidityMining.json index ed8c13f74c..753547737a 100644 --- a/src/lib/utils/liquidityMining/MultiTokenLiquidityMining.json +++ b/src/lib/utils/liquidityMining/MultiTokenLiquidityMining.json @@ -1511,5 +1511,234 @@ ] } } + ], + "week_63": [ + { + "chainId": 1, + "pools": { + "0xa6f548df93de924d73be7d25dc02554c6bd66db500020000000000000000000e": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 15000 + } + ], + "0x0b09dea16768f0799065c475be02919503cb2a3500020000000000000000001a": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 15000 + } + ], + "0x5c6ee304399dbdb9c8ef030ab642b10820db8f56000200000000000000000014": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 30000 + } + ], + "0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000063": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 15000 + } + ], + "0x96646936b91d6b9d7d0c47c496afbf3d6ec7b6f8000200000000000000000019": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 5000 + } + ], + "0xa1116930326d21fb917d5a27f1e9943a9595fb47": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 12500 + } + ], + "0x3e5fa9518ea95c3e533eb377c001702a9aacaa32000200000000000000000052": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 5000 + } + ], + "0xaac98ee71d4f8a156b6abaa6844cdb7789d086ce00020000000000000000001b": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 2500 + } + ], + "0x186084ff790c65088ba694df11758fae4943ee9e000200000000000000000013": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 2500 + } + ], + "0x072f14b85add63488ddad88f855fda4a99d6ac9b000200000000000000000027": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 2500 + } + ], + "0xe99481dc77691d8e2456e5f3f61c1810adfc1503000200000000000000000018": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 2500 + } + ], + "0xefaa1604e82e1b3af8430b90192c1b9e8197e377000200000000000000000021": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 2500 + } + ], + "0xfeadd389a5c427952d8fdb8057d6c8ba1156cc56000000000000000000000066": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 2500 + } + ], + "0x148ce9b50be946a96e94a4f5479b771bab9b1c59000100000000000000000054": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 2500 + } + ], + "0xec60a5fef79a92c741cb74fdd6bfc340c0279b01000200000000000000000015": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 1000 + } + ], + "0xa02e4b3d18d4e6b8d18ac421fbc3dfff8933c40a00020000000000000000004b": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 1000 + } + ], + "0x61d5dc44849c9c87b0856a2a311536205c96c7fd000100000000000000000001": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 1000 + } + ], + "0xf5aaf7ee8c39b651cebf5f1f50c10631e78e0ef9000200000000000000000069": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 1000 + } + ], + "0x14462305d211c12a736986f4e8216e28c5ea7ab4000200000000000000000068": [ + { + "tokenAddress": "0xba100000625a3754423978a60c9317c58a424e3d", + "amount": 1000 + } + ] + + } + }, + { + "chainId": 137, + "pools": { + "0x0297e37f1873d2dab4487aa67cd56b58e2f27875000100000000000000000002": [ + { + "tokenAddress": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3", + "amount": 7500 + }, + { + "tokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", + "amount": 112500 + } + ], + "0x36128d5436d2d70cab39c9af9cce146c38554ff0000100000000000000000008": [ + { + "tokenAddress": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3", + "amount": 6000 + }, + { + "tokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", + "amount": 90000 + } + ], + "0x03cd191f589d12b0582a99808cf19851e468e6b500010000000000000000000a": [ + { + "tokenAddress": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3", + "amount": 2500 + }, + { + "tokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", + "amount": 37500 + } + ], + "0xce66904b68f1f070332cbc631de7ee98b650b499000100000000000000000009": [ + { + "tokenAddress": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3", + "amount": 2500 + }, + { + "tokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", + "amount": 37500 + } + ], + "0x06df3b2bbb68adc8b0e302443692037ed9f91b42000000000000000000000012": [ + { + "tokenAddress": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3", + "amount": 2500 + }, + { + "tokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", + "amount": 37500 + }, + { + "tokenAddress": "0x580a84c73811e1839f75d86d75d88cca0c241ff4", + "amount": 15000 + } + ], + "0xf461f2240b66d55dcf9059e26c022160c06863bf000100000000000000000006": [ + { + "tokenAddress": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3", + "amount": 1000 + }, + { + "tokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", + "amount": 15000 + }, + { + "tokenAddress": "0x580a84c73811e1839f75d86d75d88cca0c241ff4", + "amount": 15000 + } + ], + "0x614b5038611729ed49e0ded154d8a5d3af9d1d9e00010000000000000000001d": [ + { + "tokenAddress": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3", + "amount": 1000 + }, + { + "tokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", + "amount": 15000 + }, + { + "tokenAddress": "0xF501dd45a1198C2E1b5aEF5314A68B9006D842E0", + "amount": 15000 + } + ], + "0x4e7f40cd37cee710f5e87ad72959d30ef8a01a5d00010000000000000000000b": [ + { + "tokenAddress": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3", + "amount": 1000 + }, + { + "tokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", + "amount": 15000 + } + ], + "0xfeadd389a5c427952d8fdb8057d6c8ba1156cc5600020000000000000000001e": [ + { + "tokenAddress": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3", + "amount": 1000 + }, + { + "tokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", + "amount": 15000 + } + ] + } + } ] } From 67c0cb3c14b492ba975a10563e76a4502073206f Mon Sep 17 00:00:00 2001 From: Markus Buhatem Koch Date: Thu, 5 Aug 2021 19:09:13 -0300 Subject: [PATCH 25/30] version bump --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index dfc5c23210..a09e320c17 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@balancer-labs/frontend-v2", - "version": "1.11.4", + "version": "1.11.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@balancer-labs/frontend-v2", - "version": "1.11.4", + "version": "1.11.5", "license": "MIT", "dependencies": { "@balancer-labs/assets": "github:balancer-labs/assets#master", diff --git a/package.json b/package.json index ffcdf938f5..31677eb727 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@balancer-labs/frontend-v2", - "version": "1.11.4", + "version": "1.11.5", "engines": { "node": "14.x", "npm": ">=7" From 77df109863bac8204f5b27972a00ccccb7346971 Mon Sep 17 00:00:00 2001 From: Evgeny Boxer Date: Fri, 6 Aug 2021 15:46:16 +1000 Subject: [PATCH 26/30] fix: use more accurate buy/sell amounts for transactions (#635) --- src/composables/trade/useGnosis.ts | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/composables/trade/useGnosis.ts b/src/composables/trade/useGnosis.ts index c8c83e39be..8566359511 100644 --- a/src/composables/trade/useGnosis.ts +++ b/src/composables/trade/useGnosis.ts @@ -173,16 +173,25 @@ export default function useGnosis({ owner: account.value }); + const sellAmount = exactIn.value + ? tokenInAmountInput.value + : formatUnits(quote.maximumInAmount, tokenIn.value.decimals).toString(); + + const buyAmount = exactIn.value + ? formatUnits( + quote.minimumOutAmount, + tokenOut.value.decimals + ).toString() + : tokenOutAmountInput.value; + const tokenInAmountEst = exactIn.value ? '' : '~'; const tokenOutAmountEst = exactIn.value ? '~' : ''; - const summary = `${tokenInAmountEst}${fNum( - tokenInAmountInput.value, - 'token' - )} ${tokenIn.value.symbol} -> ${tokenOutAmountEst}${fNum( - tokenOutAmountInput.value, - 'token' - )} ${tokenOut.value.symbol}`; + const summary = `${tokenInAmountEst}${fNum(sellAmount, 'token')} ${ + tokenIn.value.symbol + } -> ${tokenOutAmountEst}${fNum(buyAmount, 'token')} ${ + tokenOut.value.symbol + }`; const { validTo, partiallyFillable } = unsignedOrder; From 3919956dafb9b94bdfcbfe378383e78976bb57cd Mon Sep 17 00:00:00 2001 From: Evgeny Boxer Date: Fri, 6 Aug 2021 19:54:56 +1000 Subject: [PATCH 27/30] [Gnosis]: Add wrap/unwrap transaction action (#636) * add a new wrap/unwrap action * bump version and turn to semver --- src/composables/trade/useSor.ts | 9 +++------ src/composables/useTransactions.ts | 4 +++- src/locales/default.json | 8 +++++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/composables/trade/useSor.ts b/src/composables/trade/useSor.ts index 1e602e03f5..9b4d1b80bf 100644 --- a/src/composables/trade/useSor.ts +++ b/src/composables/trade/useSor.ts @@ -31,7 +31,7 @@ import useWeb3 from '@/services/web3/useWeb3'; import { TransactionResponse } from '@ethersproject/providers'; import useEthers from '../useEthers'; import { TradeQuote } from './types'; -import useTransactions from '../useTransactions'; +import useTransactions, { TransactionAction } from '../useTransactions'; import useNumbers from '../useNumbers'; import { TokenInfo, TokenInfoMap } from '@/types/TokenList'; import useTokens from '../useTokens'; @@ -347,10 +347,7 @@ export default function useSor({ priceImpact.value >= HIGH_PRICE_IMPACT_THRESHOLD; } - function txHandler( - tx: TransactionResponse, - action?: 'wrap' | 'unwrap' | 'trade' - ): void { + function txHandler(tx: TransactionResponse, action: TransactionAction): void { confirming.value = false; let summary = ''; @@ -368,7 +365,7 @@ export default function useSor({ addTransaction({ id: tx.hash, type: 'tx', - action: 'trade', + action, summary, details: { tokenIn: tokenIn?.value, diff --git a/src/composables/useTransactions.ts b/src/composables/useTransactions.ts index e94dd7be7e..94af0476a7 100644 --- a/src/composables/useTransactions.ts +++ b/src/composables/useTransactions.ts @@ -22,7 +22,7 @@ import { GnosisTransactionDetails } from './trade/useGnosis'; const WEEK_MS = 86_400_000 * 7; // Please update the schema version when making changes to the transaction structure. -const TRANSACTIONS_SCHEMA_VERSION = '1.1'; +const TRANSACTIONS_SCHEMA_VERSION = '1.1.1'; export type TransactionStatus = | 'pending' @@ -35,6 +35,8 @@ export type TransactionAction = | 'claim' | 'approve' | 'trade' + | 'wrap' + | 'unwrap' | 'invest' | 'withdraw'; diff --git a/src/locales/default.json b/src/locales/default.json index dd7d0bfe56..1258ae1ad4 100644 --- a/src/locales/default.json +++ b/src/locales/default.json @@ -206,7 +206,9 @@ "approve": "Approve", "claim": "Claim", "invest": "Invest", - "withdraw": "Withdraw" + "withdraw": "Withdraw", + "wrap": "Wrap", + "unwrap": "Unwrap" }, "transactionStatus": { "pending": "Pending", @@ -221,8 +223,8 @@ "claimBAL": "{0} BAL", "approveForInvesting": "Approve {0} for investing", "approveForTrading": "Approve {0} for trading", - "wrapETH": "Wrap {0} ETH to WETH", - "unwrapETH": "Unwrap {0} WETH to ETH" + "wrapETH": "{0} ETH to WETH", + "unwrapETH": "{0} WETH to ETH" }, "tradeSummary": { "exactIn": { From 4db6a5ff05037eb338aea362e1cb6631615c88bf Mon Sep 17 00:00:00 2001 From: John Grant Date: Mon, 9 Aug 2021 14:47:09 +0100 Subject: [PATCH 28/30] Fix SOR version. (#639) --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 78750e3f7c..a27139a202 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1463,7 +1463,7 @@ }, "node_modules/@balancer-labs/sor2": { "version": "2.0.1", - "resolved": "git+ssh://git@github.com/balancer-labs/balancer-sor.git#740030e9a79de2c412c7336ae0253de1ced67f71", + "resolved": "git+ssh://git@github.com/balancer-labs/balancer-sor.git#f41d4548556007dc2fe9471bcd052715c92b68bb", "license": "GPL-3.0-only", "dependencies": { "@ethersproject/address": "^5.0.5", @@ -31950,8 +31950,8 @@ } }, "@balancer-labs/sor2": { - "version": "git+ssh://git@github.com/balancer-labs/balancer-sor.git#740030e9a79de2c412c7336ae0253de1ced67f71", - "from": "@balancer-labs/sor2@github:balancer-labs/balancer-sor#develop-V2", + "version": "git+ssh://git@github.com/balancer-labs/balancer-sor.git#f41d4548556007dc2fe9471bcd052715c92b68bb", + "from": "@balancer-labs/sor2@github:balancer-labs/balancer-sor#john/ui-629-sor-integrate-sdk-maths", "requires": { "@ethersproject/address": "^5.0.5", "@ethersproject/constants": "^5.0.5", From 1cdb39bf51c81ef4e80b4fa20606cd3f179e428c Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Mon, 9 Aug 2021 15:08:38 +0100 Subject: [PATCH 29/30] Release fixes (#638) * Reset form after investment success * Fix investment approvals --- src/components/forms/pool_actions/InvestForm.vue | 2 ++ src/composables/pools/useTokenApprovals.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/forms/pool_actions/InvestForm.vue b/src/components/forms/pool_actions/InvestForm.vue index 4eb0018a8c..457647c967 100644 --- a/src/components/forms/pool_actions/InvestForm.vue +++ b/src/components/forms/pool_actions/InvestForm.vue @@ -592,6 +592,8 @@ export default defineComponent({ emit('success', tx); data.amounts = []; data.loading = false; + setPropMax(); + resetSlider(); }, onTxFailed: () => { data.loading = false; diff --git a/src/composables/pools/useTokenApprovals.ts b/src/composables/pools/useTokenApprovals.ts index 53461b2320..929fddb876 100644 --- a/src/composables/pools/useTokenApprovals.ts +++ b/src/composables/pools/useTokenApprovals.ts @@ -48,7 +48,7 @@ export default function useTokenApprovals( async function approveAllowances(): Promise { try { approving.value = true; - const tokenAddress = tokenAddresses[0]; + const tokenAddress = requiredAllowances.value[0]; const txs = await approveTokens( getProvider(), From c74aba6c44555dff214997d531eb6025e16584f0 Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Mon, 9 Aug 2021 15:19:43 +0100 Subject: [PATCH 30/30] 1.12.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index a27139a202..2dee25ad58 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@balancer-labs/frontend-v2", - "version": "1.11.5", + "version": "1.12.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@balancer-labs/frontend-v2", - "version": "1.11.5", + "version": "1.12.0", "license": "MIT", "dependencies": { "@balancer-labs/assets": "github:balancer-labs/assets#master", diff --git a/package.json b/package.json index 0054263b43..1d297afc0b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@balancer-labs/frontend-v2", - "version": "1.11.5", + "version": "1.12.0", "engines": { "node": "14.x", "npm": ">=7"