mirror of
https://github.com/tornadocash/tornado-relayer
synced 2024-02-02 15:04:06 +01:00
fix fee handling
This commit is contained in:
parent
ca1eb0d6cf
commit
09367f76a8
@ -26,7 +26,7 @@
|
|||||||
"gas-price-oracle": "^0.1.5",
|
"gas-price-oracle": "^0.1.5",
|
||||||
"ioredis": "^4.14.1",
|
"ioredis": "^4.14.1",
|
||||||
"node-fetch": "^2.6.0",
|
"node-fetch": "^2.6.0",
|
||||||
"tornado-cash-anonymity-mining": "git+ssh://github.com/tornadocash/tornado-anonymity-mining.git#dd4b996b89580fad986604e507a7e56ad64a3f71",
|
"tornado-cash-anonymity-mining": "git+ssh://github.com/tornadocash/tornado-anonymity-mining.git#02ff4c9061eef94617b3c1b91a02c0d25bb1c410",
|
||||||
"tx-manager": "git+ssh://github.com/tornadocash/tx-manager.git#df118be318b007e597e157504d105dfa3e6322a1",
|
"tx-manager": "git+ssh://github.com/tornadocash/tx-manager.git#df118be318b007e597e157504d105dfa3e6322a1",
|
||||||
"torn-token": "git+ssh://github.com/tornadocash/torn-token.git#b90fc5adccbf9a87c3bdac6175a0e038a9ed3dd8",
|
"torn-token": "git+ssh://github.com/tornadocash/torn-token.git#b90fc5adccbf9a87c3bdac6175a0e038a9ed3dd8",
|
||||||
"uuid": "^8.3.0",
|
"uuid": "^8.3.0",
|
||||||
|
@ -9,8 +9,8 @@ module.exports = {
|
|||||||
wsRpcUrl: process.env.WS_RPC_URL,
|
wsRpcUrl: process.env.WS_RPC_URL,
|
||||||
oracleRpcUrl: process.env.ORACLE_RPC_URL || 'https://mainnet.infura.io/',
|
oracleRpcUrl: process.env.ORACLE_RPC_URL || 'https://mainnet.infura.io/',
|
||||||
oracleAddress: '0xA2b8E7ee7c8a18ea561A5CF7C9C365592026E374',
|
oracleAddress: '0xA2b8E7ee7c8a18ea561A5CF7C9C365592026E374',
|
||||||
minerAddress: '0xB28038Cd60777aF2264F46C0009dC57975239B11', // each network has its own instance
|
minerAddress: '0x3E0a9C6Cf76136862De28ce25a56cDBF38EF9D37', // each network has its own instance
|
||||||
swapAddress: '0xec236719BEbfC1D303739FbE11Bf3a42aF1A41f4',
|
swapAddress: '0x1E73e0a484a595B692f3d212642AE4B3BF30E7e3',
|
||||||
minerMerkleTreeHeight: 20,
|
minerMerkleTreeHeight: 20,
|
||||||
privateKey: process.env.PRIVATE_KEY,
|
privateKey: process.env.PRIVATE_KEY,
|
||||||
instances: require('torn-token').instances,
|
instances: require('torn-token').instances,
|
||||||
|
@ -129,17 +129,17 @@ const miningWithdrawSchema = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
amount: bytes32Type,
|
amount: bytes32Type,
|
||||||
fee: bytes32Type,
|
|
||||||
extDataHash: bytes32Type,
|
extDataHash: bytes32Type,
|
||||||
extData: {
|
extData: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
|
fee: bytes32Type,
|
||||||
recipient: addressType,
|
recipient: addressType,
|
||||||
relayer: relayerType,
|
relayer: relayerType,
|
||||||
encryptedAccount: encryptedAccountType,
|
encryptedAccount: encryptedAccountType,
|
||||||
},
|
},
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
required: ['relayer', 'encryptedAccount', 'recipient'],
|
required: ['fee', 'relayer', 'encryptedAccount', 'recipient'],
|
||||||
},
|
},
|
||||||
account: {
|
account: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@ -161,7 +161,7 @@ const miningWithdrawSchema = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
required: ['amount', 'fee', 'extDataHash', 'extData', 'account'],
|
required: ['amount', 'extDataHash', 'extData', 'account'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
|
@ -154,14 +154,14 @@ async function checkMiningFee({ args }) {
|
|||||||
.div(toBN(1e10 * 100))
|
.div(toBN(1e10 * 100))
|
||||||
/* eslint-enable */
|
/* eslint-enable */
|
||||||
const desiredFee = expenseInPoints.add(serviceFeePercent) // in points
|
const desiredFee = expenseInPoints.add(serviceFeePercent) // in points
|
||||||
|
const providedFee = currentJob.data.type === jobType.MINING_REWARD ? args.fee : args.extData.fee
|
||||||
console.log(
|
console.log(
|
||||||
'sent fee, desired fee, serviceFeePercent',
|
'sent fee, desired fee, serviceFeePercent',
|
||||||
toBN(args.fee).toString(),
|
toBN(providedFee).toString(),
|
||||||
desiredFee.toString(),
|
desiredFee.toString(),
|
||||||
serviceFeePercent.toString(),
|
serviceFeePercent.toString(),
|
||||||
)
|
)
|
||||||
if (toBN(args.fee).lt(desiredFee)) {
|
if (toBN(providedFee).lt(desiredFee)) {
|
||||||
throw new Error('Provided fee is not enough. Probably it is a Gas Price spike, try to resubmit.')
|
throw new Error('Provided fee is not enough. Probably it is a Gas Price spike, try to resubmit.')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user