Skip to content

Commit

Permalink
Merge pull request #4103 from NotEternal/feeRates
Browse files Browse the repository at this point in the history
Exchange: fee calculating in incognito, table row UI improvement. Cleanup
  • Loading branch information
noxonsu authored Mar 12, 2021
2 parents 3e81bd0 + e6a23ba commit b391b85
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 402 deletions.
6 changes: 4 additions & 2 deletions src/front/client/scss/config/vars/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ $l-background-elements: #fff;
$l-box-shadow: 0px 4px 16px rgba(0,0,0,0.08), 0px 1px 4px rgba(0,0,0,0.08);

$l-read-only: rgb(233, 233, 233);

// -----------------------------------------
// Dark theme

Expand All @@ -26,15 +27,16 @@ $d-background-elements: #242425;
$d-box-shadow: 0px 4px 16px rgba(0, 0, 0, 0.49),0px 1px 4px rgba(13, 13, 13, 0.06);

$d-read-only: rgb(44, 44, 44);

// -----------------------------------------
// Unchanging colors

$pale-color: #8882;
$indicating-color: #808080;
$notice-color: #8e9aa3;
$color-brand: #6144e5;
$color-f-brightest : #fff;
$color-f-error : #e32950;
$color-f-brightest: #fff;
$color-f-error: #e32950;
$color-good: #4dd3ab;
$color-bad: #f56e85;
$color-link: #007bff;
2 changes: 1 addition & 1 deletion src/front/config/bsc-mainnet/swapConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
BTC: {
withdrawTransactionHash: `btcSwapWithdrawTransactionHash`,
scriptCreatingTransactionHash: `utxoScriptCreatingTransactionHash`, // @to-do - remove this - use directly
explorerLink: api.blockcypher,
explorerLink: api.bitpay,
verifyScriptFunc: `verifyScript`, // @to-do - remove this - use directly
scriptValues: `utxoScriptValues`, // @to-do - remove this - use directly utxoScriptValues
},
Expand Down
2 changes: 1 addition & 1 deletion src/front/config/bsc-testnet/swapConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
BTC: {
withdrawTransactionHash: `btcSwapWithdrawTransactionHash`,
scriptCreatingTransactionHash: `utxoScriptCreatingTransactionHash`,
explorerLink: api.blockcypher,
explorerLink: api.bitpay,
verifyScriptFunc: `verifyScript`,
scriptValues: `utxoScriptValues`, // @to-do - remove this - use in code utxoScriptValues
},
Expand Down
2 changes: 1 addition & 1 deletion src/front/config/mainnet/swapConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
BTC: {
withdrawTransactionHash: `btcSwapWithdrawTransactionHash`,
scriptCreatingTransactionHash: `utxoScriptCreatingTransactionHash`, // @to-do - remove this - use directly
explorerLink: api.blockcypher,
explorerLink: api.bitpay,
verifyScriptFunc: `verifyScript`, // @to-do - remove this - use directly
scriptValues: `utxoScriptValues`, // @to-do - remove this - use directly utxoScriptValues
},
Expand Down
2 changes: 1 addition & 1 deletion src/front/config/testnet/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default {
defipulse: 'https://data-api.defipulse.com/api/v1/egs/api/ethgasAPI.json?api-key=53be2a60f8bc0bb818ad161f034286d709a9c4ccb1362054b0543df78e27',
bitpay: [
'https://api.bitcore.io/api/BTC/testnet',
// 'https://test-insight.bitpay.com/api'
// 'http://localhost:32250/btc/testnet',
//'https://test-insight.swaponline.io/insight-api',
//'https://invoices.swaponline.site/proxybitpay-testnet',
Expand All @@ -13,7 +14,6 @@ export default {
nextExplorer: 'https://explore.next.exchange/api',
nextExplorerCustom: 'https://next.swaponline.io/mainnet',
blockcypher: 'https://api.blockcypher.com/v1/btc/test3',
// bitpay: 'https://test-insight.bitpay.com/api',
etherscan: [
'https://api-ropsten.etherscan.io/api',
'https://invoices.swaponline.site/proxyetherscan-testnet',
Expand Down
2 changes: 1 addition & 1 deletion src/front/config/testnet/swapConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
BTC: {
withdrawTransactionHash: `btcSwapWithdrawTransactionHash`,
scriptCreatingTransactionHash: `utxoScriptCreatingTransactionHash`,
explorerLink: api.blockcypher,
explorerLink: api.bitpay,
verifyScriptFunc: `verifyScript`,
scriptValues: `utxoScriptValues`, // @to-do - remove this - use in code utxoScriptValues
},
Expand Down
30 changes: 1 addition & 29 deletions src/front/shared/helpers/btc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,33 +246,7 @@ const estimateFeeValue = async (options: EstimateFeeValueOptions): Promise<any>
return finalFeeValue
}

const estimateFeeRateBitcoinfees = async ({ speed = 'fast' } = {}) => {
const defaultRate = constants.defaultFeeRates.btc.rate

let apiResult

try {
apiResult = await api.asyncFetchApi(`https://bitcoinfees.earn.com/api/v1/fees/recommended`)
} catch (err) {
console.error(`EstimateFeeRate: ${err.message}`)
return defaultRate[speed]
}

const apiSpeeds = {
slow: `hourFee`,
normal: `halfHourFee`,
fast: `fastestFee`,
}

const apiSpeed = apiSpeeds[speed] || apiSpeeds.normal
const apiRate = new BigNumber(apiResult[apiSpeed]).multipliedBy(1024)

return apiRate.isGreaterThanOrEqualTo(DUST)
? apiRate.toString()
: defaultRate[speed]
}

const estimateFeeRateBlockcypher = async ({ speed = 'fast' } = {}) => {
const estimateFeeRate = async ({ speed = 'fast' } = {}) => {
const link = config.feeRates.btc
const defaultRate = constants.defaultFeeRates.btc.rate

Expand Down Expand Up @@ -304,8 +278,6 @@ const estimateFeeRateBlockcypher = async ({ speed = 'fast' } = {}) => {
: defaultRate[speed]
}

const estimateFeeRate = estimateFeeRateBlockcypher

export default {
calculateTxSize,
estimateFeeValue,
Expand Down
Loading

0 comments on commit b391b85

Please sign in to comment.