diff --git a/ui/src/stores/ForeignStore.js b/ui/src/stores/ForeignStore.js index 58e9b407..f97ed7ca 100644 --- a/ui/src/stores/ForeignStore.js +++ b/ui/src/stores/ForeignStore.js @@ -325,7 +325,7 @@ class ForeignStore { @action async getCurrentLimit() { try { - const result = await getCurrentLimit(this.foreignBridge, this.tokenDecimals) + const result = await getCurrentLimit(this.foreignBridge, this.homeStore.homeBridge, this.tokenDecimals) this.maxCurrentDeposit = result.maxCurrentDeposit this.dailyLimit = result.dailyLimit this.totalSpentPerDay = result.totalSpentPerDay diff --git a/ui/src/stores/HomeStore.js b/ui/src/stores/HomeStore.js index 99265046..1dbc9d01 100644 --- a/ui/src/stores/HomeStore.js +++ b/ui/src/stores/HomeStore.js @@ -429,7 +429,11 @@ class HomeStore { @action async getCurrentLimit() { try { - const result = await getCurrentLimit(this.homeBridge, this.tokenDecimals) + const result = await getCurrentLimit( + this.homeBridge, + this.rootStore.foreignStore.foreignBridge, + this.tokenDecimals + ) this.maxCurrentDeposit = result.maxCurrentDeposit this.dailyLimit = result.dailyLimit this.totalSpentPerDay = result.totalSpentPerDay diff --git a/ui/src/stores/utils/contract.js b/ui/src/stores/utils/contract.js index 8756b764..1bccc7d2 100644 --- a/ui/src/stores/utils/contract.js +++ b/ui/src/stores/utils/contract.js @@ -21,10 +21,10 @@ export const getMinPerTxLimit = async (contract, decimals) => { return fromDecimals(minPerTx, decimals) } -export const getCurrentLimit = async (contract, decimals) => { +export const getCurrentLimit = async (contract, otherContract, decimals) => { const currentDay = await contract.methods.getCurrentDay().call() const dailyLimit = await contract.methods.dailyLimit().call() - const totalSpentPerDay = await contract.methods.totalSpentPerDay(currentDay).call() + const totalSpentPerDay = await otherContract.methods.totalExecutedPerDay(currentDay).call() const maxCurrentDeposit = new BN(dailyLimit).minus(new BN(totalSpentPerDay)).toString(10) return { maxCurrentDeposit: fromDecimals(maxCurrentDeposit, decimals),