Skip to content

Commit

Permalink
feat: increase gas limit for 0x zap
Browse files Browse the repository at this point in the history
  • Loading branch information
quagliero committed Jan 9, 2023
1 parent e6d778b commit aa62903
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions packages/trade/src/trade/buy/buy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,34 +137,35 @@ const buy0xErc721 = async ({
slippagePercentage: 0,
});

const args = [vaultId, amount, specificIds, data, userAddress];
const slippageMultiplier = parseEther(`${slippage || 0}`).add(WeiPerEther);
const value = parseEther(guaranteedPrice)
.mul(buyAmount)
.div(WeiPerEther)
.mul(slippageMultiplier)
.div(WeiPerEther);

console.debug(
'buyAndRedeem',
vaultId,
`${amount}`,
specificIds,
data,
userAddress,
{
value: `${value}`,
}
);
const { gasEstimate, maxFeePerGas, maxPriorityFeePerGas } =
await estimateGasAndFees({
contract,
method: 'buyAndRedeem',
args: args,
overrides: omitNil({ value }),
});

const gasLimit = increaseGasLimit({ estimate: gasEstimate, amount: 3 });

const overrides = omitNil({
value,
gasLimit,
maxFeePerGas,
maxPriorityFeePerGas,
});

console.debug('buyAndRedeem', ...args, overrides);

// try {
const result = await contract.buyAndRedeem(
vaultId,
amount,
specificIds,
data,
userAddress,
{ value }
);
const result = await contract.buyAndRedeem(...args, overrides);
return result;
// } catch (e) {
// if (e?.code === 4001) {
Expand Down

0 comments on commit aa62903

Please sign in to comment.