Skip to content
This repository was archived by the owner on Feb 25, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/routes/balancer.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ router.post('/sell-price', async (req, res) => {
maxSwaps,
)

const gasLimit = estimateGasLimit(swaps.length)

if (swaps != null && expectedOut != null) {
const gasLimit = estimateGasLimit(swaps.length)
res.status(200).json({
network: balancer.network,
timestamp: initTime,
Expand Down Expand Up @@ -145,9 +144,8 @@ router.post('/buy-price', async (req, res) => {
maxSwaps,
)

const gasLimit = estimateGasLimit(swaps.length)

if (swaps != null && expectedIn != null) {
const gasLimit = estimateGasLimit(swaps.length)
res.status(200).json({
network: balancer.network,
timestamp: initTime,
Expand Down
6 changes: 4 additions & 2 deletions src/services/eth.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,17 @@ export default class Ethereum {
}

// approve a spender to transfer tokens from a wallet address
async approveERC20 (wallet, spender, tokenAddress, amount, gasPrice = this.gasPrice, gasLimit = 50000) {
async approveERC20 (wallet, spender, tokenAddress, amount, gasPrice = this.gasPrice, gasLimit) {
try {
// fixate gas limit to prevent overwriting
const approvalGasLimit = 50000
// instantiate a contract and pass in wallet, which act on behalf of that signer
const contract = new ethers.Contract(tokenAddress, abi.ERC20Abi, wallet)
return await contract.approve(
spender,
amount, {
gasPrice: gasPrice * 1e9,
gasLimit: gasLimit
gasLimit: approvalGasLimit
}
)
} catch (err) {
Expand Down