mirror of
https://github.com/tornadocash/tornado-relayer.git
synced 2025-11-09 07:35:19 -05:00
checkMiningFee for rewards
This commit is contained in:
parent
fd8b5dcbb4
commit
22a170f809
4 changed files with 39 additions and 23 deletions
|
|
@ -8,8 +8,8 @@ module.exports = {
|
|||
rpcUrl: process.env.RPC_URL || 'https://kovan.infura.io/',
|
||||
oracleRpcUrl: process.env.ORACLE_RPC_URL || 'https://mainnet.infura.io/',
|
||||
oracleAddress: '0xA2b8E7ee7c8a18ea561A5CF7C9C365592026E374',
|
||||
minerAddress: '0x0834DeaFD83130AE1867173919f693070DaE6eeD',
|
||||
swapAddress: '0x0834DeaFD83130AE1867173919f693070DaE6eeD',
|
||||
minerAddress: '0x96c7B5c39542bae92b3cD39392a81De514c6E698', // each network has its own instance
|
||||
swapAddress: '0xFc82977BfAEBE93486Ac42ac7c8Ea1043f9a3500',
|
||||
minerMerkleTreeHeight: 10,
|
||||
privateKey: process.env.PRIVATE_KEY,
|
||||
instances: {
|
||||
|
|
|
|||
|
|
@ -136,16 +136,16 @@ async function checkMiningFee({ args }) {
|
|||
const { fast } = await gasPriceOracle.gasPrices()
|
||||
const ethPrice = await redis.hget('prices', 'torn')
|
||||
|
||||
const expense = toBN(toWei(fast.toString(), 'gwei')).mul(toBN(gasLimits[args.type]))
|
||||
const expense = toBN(toWei(fast.toString(), 'gwei')).mul(toBN(gasLimits[currentJob.data.type]))
|
||||
const expenseInTorn = expense.mul(toBN(1e18)).div(toBN(ethPrice))
|
||||
// todo make aggregator for ethPrices and rewardSwap data
|
||||
const balance = await swap.virtualTornBalance()
|
||||
const poolWeight = await swap.poolWeight()
|
||||
const balance = await swap.methods.tornVirtualBalance().call()
|
||||
const poolWeight = await swap.methods.poolWeight().call()
|
||||
const expenseInPoints = Utils.reverseTornadoFormula({ balance, tokens: expenseInTorn, poolWeight })
|
||||
/* eslint-disable */
|
||||
const serviceFeePercent =
|
||||
args.type === jobType.MINING_REWARD
|
||||
? 0
|
||||
currentJob.data.type === jobType.MINING_REWARD
|
||||
? toBN(0)
|
||||
: toBN(args.amount)
|
||||
.mul(toBN(miningServiceFee * 1e10))
|
||||
.div(toBN(1e10 * 100))
|
||||
|
|
@ -154,9 +154,9 @@ async function checkMiningFee({ args }) {
|
|||
|
||||
console.log(
|
||||
'sent fee, desired fee, serviceFeePercent',
|
||||
fromWei(args.fee.toString()),
|
||||
fromWei(desiredFee.toString()),
|
||||
fromWei(serviceFeePercent.toString()),
|
||||
toBN(args.fee).toString(),
|
||||
desiredFee.toString(),
|
||||
serviceFeePercent.toString(),
|
||||
)
|
||||
if (toBN(args.fee).lt(desiredFee)) {
|
||||
throw new Error('Provided fee is not enough. Probably it is a Gas Price spike, try to resubmit.')
|
||||
|
|
@ -171,7 +171,7 @@ function getTxObject({ data }) {
|
|||
const method = data.type !== jobType.MINING_REWARD ? 'withdraw' : 'reward'
|
||||
|
||||
const contract = new web3.eth.Contract(ABI, contractAddress)
|
||||
const calldata = contract.methods[method](data.proof, ...data.args).encodeABI()
|
||||
const calldata = contract.methods[method](data.proof, data.args).encodeABI()
|
||||
|
||||
return {
|
||||
value,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue