feat: add Arbitrum

This commit is contained in:
Danil Kovtonyuk 2021-11-23 00:50:29 +10:00 committed by 0xZick
parent 07b091ff46
commit 3d952f1906
4 changed files with 34 additions and 4 deletions

@ -1,6 +1,6 @@
{
"name": "relay",
"version": "5.0.0-beta.6",
"version": "5.0.0-beta.7",
"description": "Relayer for Tornado.cash privacy solution. https://tornado.cash",
"scripts": {
"server": "node src/server.js",

@ -19,6 +19,7 @@ module.exports = {
gasPrices,
gasLimits: {
[jobType.TORNADO_WITHDRAW]: 390000,
[jobType.ARB_TORNADO_WITHDRAW]: 1900000,
},
proxyLight,
nativeCurrency,

@ -1,5 +1,6 @@
const jobType = Object.freeze({
TORNADO_WITHDRAW: 'TORNADO_WITHDRAW',
ARB_TORNADO_WITHDRAW: 'ARB_TORNADO_WITHDRAW',
})
const status = Object.freeze({
@ -79,6 +80,28 @@ const networkConfig = {
},
proxyLight: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17',
},
netId42161: {
gasPrices: {
instant: 4,
fast: 3,
standard: 2.52,
low: 2.29,
},
nativeCurrency: 'eth',
instances: {
eth: {
instanceAddress: {
0.1: '0x84443CFd09A48AF6eF360C6976C5392aC5023a1F',
1: '0xd47438C816c9E7f2E2888E060936a499Af9582b3',
10: '0x330bdFADE01eE9bF63C209Ee33102DD334618e0a',
100: '0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD',
},
symbol: 'ETH',
decimals: 18,
},
},
proxyLight: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17',
},
netId43114: {
gasPrices: {
instant: 225,

@ -50,7 +50,7 @@ function start() {
}
async function getGasPrices() {
const networksWithOracle = [56, 100, 137, 43114]
const networksWithOracle = [56, 100, 137, 43114, 42161]
if (networksWithOracle.includes(netId)) {
return await gasPriceOracle.gasPrices()
}
@ -58,6 +58,12 @@ async function getGasPrices() {
return gasPrices
}
function getGasLimit() {
const action = Number(netId) === 42161 ? jobType.ARB_TORNADO_WITHDRAW : jobType.TORNADO_WITHDRAW
return gasLimits[action]
}
async function checkTornadoFee({ args, contract }) {
const { currency, amount } = getInstance(contract)
const { decimals } = instances[currency]
@ -65,7 +71,7 @@ async function checkTornadoFee({ args, contract }) {
const { fast } = await getGasPrices()
const expense = toBN(toWei(fast.toString(), 'gwei')).mul(toBN(gasLimits[jobType.TORNADO_WITHDRAW]))
const expense = toBN(toWei(fast.toString(), 'gwei')).mul(toBN(getGasLimit()))
const feePercent = toBN(fromDecimals(amount, decimals))
.mul(toBN(parseInt(tornadoServiceFee * 1e10)))
.div(toBN(1e10 * 100))
@ -93,7 +99,7 @@ async function getTxObject({ data }) {
value: data.args[5],
to: contract._address,
data: calldata,
gasLimit: gasLimits[jobType.TORNADO_WITHDRAW],
gasLimit: getGasLimit(),
gasPrice: toHex(toWei(fast.toString(), 'gwei')),
}
}