mirror of
https://github.com/tornadocash/tornado-relayer
synced 2024-02-02 15:04:06 +01:00
checkMiningFee for rewards
This commit is contained in:
parent
fd8b5dcbb4
commit
22a170f809
@ -69,7 +69,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
@ -82,7 +83,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
@ -95,7 +97,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
@ -108,7 +111,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
@ -121,7 +125,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
@ -134,7 +139,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
@ -147,7 +153,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
@ -160,7 +167,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
@ -210,7 +218,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
@ -223,7 +232,8 @@
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
"type": "function",
|
||||
"constant": true
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
|
@ -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,
|
||||
|
10
yarn.lock
10
yarn.lock
@ -1011,6 +1011,11 @@ decamelize@^1.2.0:
|
||||
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
|
||||
integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=
|
||||
|
||||
decimal.js@^10.2.0:
|
||||
version "10.2.1"
|
||||
resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.2.1.tgz#238ae7b0f0c793d3e3cea410108b35a2c01426a3"
|
||||
integrity sha512-KaL7+6Fw6i5A2XSnsbhm/6B+NuEA7TZ4vqxnd5tXz9sbKtrN9Srj8ab4vKVdK8YAqZO9P1kg45Y6YLoduPf+kw==
|
||||
|
||||
decode-uri-component@^0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
|
||||
@ -3898,11 +3903,12 @@ toidentifier@1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553"
|
||||
integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==
|
||||
|
||||
"tornado-cash-anonymity-mining@git+https://github.com/tornadocash/tornado-anonymity-mining.git#e3ae8b98b14eb7fee7cb8c93221920a20b1e0cd8":
|
||||
"tornado-cash-anonymity-mining@git+https://github.com/tornadocash/tornado-anonymity-mining.git#dd4b996b89580fad986604e507a7e56ad64a3f71":
|
||||
version "1.0.0"
|
||||
resolved "git+https://github.com/tornadocash/tornado-anonymity-mining.git#e3ae8b98b14eb7fee7cb8c93221920a20b1e0cd8"
|
||||
resolved "git+https://github.com/tornadocash/tornado-anonymity-mining.git#dd4b996b89580fad986604e507a7e56ad64a3f71"
|
||||
dependencies:
|
||||
circomlib "git+https://github.com/tornadocash/circomlib.git#5beb6aee94923052faeecea40135d45b6ce6172c"
|
||||
decimal.js "^10.2.0"
|
||||
eth-sig-util "^2.5.3"
|
||||
fixed-merkle-tree "^0.3.4"
|
||||
snarkjs "git+https://github.com/tornadocash/snarkjs.git#869181cfaf7526fe8972073d31655493a04326d5"
|
||||
|
Loading…
Reference in New Issue
Block a user