Merge pull request #187 from QuickMythril/dynamic-fee

Add dynamic fee to Trades
This commit is contained in:
AlphaX-Projects 2023-08-13 10:29:16 +02:00 committed by GitHub
commit 8f09ae49eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 1 deletions

View File

@ -2104,6 +2104,7 @@ class TradeBotPortal extends LitElement {
this.changeTheme()
this.changeLanguage()
this.tradeFee()
this.autoHelperMessage = this.renderAutoHelperPass()
@ -3736,6 +3737,20 @@ class TradeBotPortal extends LitElement {
}
}
async tradeFee() {
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
const url = `${nodeUrl}/transactions/unitfee?txType=DEPLOY_AT`
await fetch(url).then((response) => {
if (response.ok) {
return response.json()
}
return Promise.reject(response)
}).then((json) => {
this.listedCoins.get("QORTAL").tradeFee = (Number(json) + 100000) / 1e8
})
}
getApiKey() {
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node];
let apiKey = myNode.apiKey;

View File

@ -1421,6 +1421,7 @@ class TradePortal extends LitElement {
this.changeTheme()
this.changeLanguage()
this.tradeFee()
this.tradeHelperMessage = this.renderTradeHelperPass()
@ -2758,7 +2759,7 @@ class TradePortal extends LitElement {
}
}
if (this.round(parseFloat(fundingQortAmount) + parseFloat(0.002)) > parseFloat(this.listedCoins.get("QORTAL").balance)) {
if (this.round(parseFloat(fundingQortAmount) + parseFloat(this.listedCoins.get("QORTAL").tradeFee)) > parseFloat(this.listedCoins.get("QORTAL").balance)) {
this.isSellLoading = false
this.sellBtnDisable = false
let snack4string = get("tradepage.tchange22")
@ -3021,6 +3022,20 @@ class TradePortal extends LitElement {
}
}
async tradeFee() {
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
const url = `${nodeUrl}/transactions/unitfee?txType=DEPLOY_AT`
await fetch(url).then((response) => {
if (response.ok) {
return response.json()
}
return Promise.reject(response)
}).then((json) => {
this.listedCoins.get("QORTAL").tradeFee = (Number(json) + 100000) / 1e8
})
}
getApiKey() {
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node];
let apiKey = myNode.apiKey;