Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #258 from onyb/fix-swap-bugs
Browse files Browse the repository at this point in the history
Fix swap bugs for Milestone 1.0.32
  • Loading branch information
onyb authored Jul 15, 2021
2 parents a0163fe + 9746b34 commit 77e3bf3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 14 deletions.
4 changes: 2 additions & 2 deletions ui/app/components/ui/unit-input/unit-input.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export default class UnitInput extends PureComponent {
getInputWidth (value) {
const valueString = String(value)
const valueLength = valueString.length || 1
const decimalPointDeficit = valueString.match(/\./) ? -0.5 : 0
return (valueLength + decimalPointDeficit + 0.5) + 'ch'
const decimalPointDeficit = valueString.match(/\./) ? -0.56 : 0
return (valueLength + decimalPointDeficit + 0.56) + 'ch'
}

render () {
Expand Down
5 changes: 5 additions & 0 deletions ui/app/css/itcss/components/swap.scss
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,11 @@
height: 0;
}

.btn-secondary[disabled] {
opacity: 0.75;
color: #b0d7f2 !important;
}

&__gas-fee-display {
width: 100%;
position: relative;
Expand Down
18 changes: 10 additions & 8 deletions ui/app/pages/swap/swap-footer/swap-footer.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,16 @@ export default class SwapFooter extends Component {
const { t } = this.context

return (
<PageContainerFooter
onSubmit={(e) => this.onSubmit(e)}
submitText={t('reviewSwap')}
disabled={this.reviewSwapButtonShouldBeDisabled()}
hideCancel
>
{this.renderFooterExtra()}
</PageContainerFooter>
<div className="swap-v2">
<PageContainerFooter
onSubmit={(e) => this.onSubmit(e)}
submitText={t('reviewSwap')}
disabled={this.reviewSwapButtonShouldBeDisabled()}
hideCancel
>
{this.renderFooterExtra()}
</PageContainerFooter>
</div>
)
}
}
4 changes: 2 additions & 2 deletions ui/app/pages/swap/swap.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ export default function getConfig (network) {
case ROPSTEN:
return {
swapAPIURL: 'https://ropsten.api.0x.org/swap/v1',
buyTokenPercentageFee: 0.00875,
buyTokenPercentageFee: '0.00875',
feeRecipient: '0x7B4933b164092b480A7c1b9bbCdBc8Ecd5201B96',
}

case MAINNET:
default:
return {
swapAPIURL: 'https://api.0x.org/swap/v1',
buyTokenPercentageFee: 0.00875,
buyTokenPercentageFee: '0.00875',
feeRecipient: '0xbd9420A98a7Bd6B89765e5715e169481602D9c3d',
}
}
Expand Down
11 changes: 9 additions & 2 deletions ui/app/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,20 @@ export function fetchSwapQuote (fromAsset, toAsset, amount, gasPrice, slippage,
const network = getNetworkIdentifier(state)
const selectedAddress = getSelectedAddress(state)

const gasPriceDecimal = gasPrice && parseInt(gasPrice, 16).toString()
const gasPriceDecimal = gasPrice && ethers.BigNumber.from(
ethUtil.addHexPrefix(gasPrice),
).toString()

const amountDecimal = ethers.BigNumber.from(
ethUtil.addHexPrefix(amount),
).toString()

const conn = exports.getBackgroundConnection()

const quote = await conn.quote(
fromAsset,
toAsset,
parseInt(amount, 16),
amountDecimal,
gasPriceDecimal,
slippage,
selectedAddress,
Expand Down

0 comments on commit 77e3bf3

Please sign in to comment.