Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Hotfix 1.17.4 #779

Merged
merged 3 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@balancer-labs/frontend-v2",
"version": "1.17.2",
"version": "1.17.4",
"engines": {
"node": "14.x",
"npm": ">=7"
Expand Down Expand Up @@ -29,7 +29,7 @@
"@gnosis.pm/safe-apps-sdk": "^4.0.0",
"@metamask/detect-provider": "^1.2.0",
"@popperjs/core": "^2.9.2",
"@portis/web3": "^3.0.3",
"@portis/web3": "^3.0.10",
"@sentry/browser": "^6.3.2",
"@sentry/tracing": "^6.3.2",
"@tailwindcss/postcss7-compat": "^2.0.4",
Expand Down
2 changes: 1 addition & 1 deletion src/services/balancer/subgraph/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface PoolToken {
address: string;
balance: string;
weight: string;
priceRate?: string;
priceRate: string | null;
}

export interface Pool {
Expand Down
15 changes: 11 additions & 4 deletions src/services/pool/calculator/stable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class Stable {
return this.scaleOutput(
'0',
this.calc.poolTokenDecimals[tokenIndex],
this.calc.pool.tokens[tokenIndex]?.priceRate ?? '1',
this.calc.pool.tokens[tokenIndex].priceRate,
BigNumber.ROUND_DOWN // If OUT given IN, round down
);

Expand All @@ -119,7 +119,7 @@ export default class Stable {
return this.scaleOutput(
tokenAmountOut.toString(),
this.calc.poolTokenDecimals[tokenIndex],
this.calc.pool.tokens[tokenIndex]?.priceRate ?? '1',
this.calc.pool.tokens[tokenIndex].priceRate,
BigNumber.ROUND_DOWN // If OUT given IN, round down
);
}
Expand Down Expand Up @@ -220,7 +220,12 @@ export default class Stable {
return bnum(scaledSupply.toString());
}

private scaleInput(normalizedAmount: string, priceRate = '1'): BigNumber {
private scaleInput(
normalizedAmount: string,
priceRate: string | null = null
): BigNumber {
if (priceRate === null) priceRate = '1';

const denormAmount = bnum(parseUnits(normalizedAmount, 18).toString())
.times(priceRate)
.toFixed(0, BigNumber.ROUND_UP);
Expand All @@ -231,9 +236,11 @@ export default class Stable {
private scaleOutput(
amount: string,
decimals: number,
priceRate: string,
priceRate: string | null,
rounding: BigNumber.RoundingMode
): BigNumber {
if (priceRate === null) priceRate = '1';

const amountAfterPriceRate = bnum(amount)
.div(priceRate)
.toString();
Expand Down
10 changes: 4 additions & 6 deletions src/services/web3/connectors/portis/portis.connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,17 @@ export class PortisConnector extends Connector {
configService.env.PORTIS_DAPP_ID,
configService.network.network
) as any;

const provider = portis.provider;

if (provider) {
this.provider = provider;
this.active.value = true;

try {
if (provider.request) {
const accounts = await provider.request({
method: 'eth_requestAccounts'
});

const chainId = await provider.request({ method: 'eth_chainId' });
if (provider.send) {
const accounts = await provider.send('eth_accounts');
const chainId = await provider.send('eth_chainId');
this.handleChainChanged(chainId);
this.handleAccountsChanged(accounts);
}
Expand Down