Skip to content

Commit

Permalink
fix approval target
Browse files Browse the repository at this point in the history
  • Loading branch information
benisgold committed Dec 9, 2024
1 parent 149c19b commit 9afef38
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
7 changes: 1 addition & 6 deletions src/raps/claimClaimable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,11 @@ export async function createClaimClaimableRap(parameters: RapSwapActionParameter
}

if (swapAssetNeedsUnlocking) {
if (!quote.to) {
logger.error(new RainbowError('[raps/claimClaimable]: quote.to is undefined'));
return { actions: [] };
}

const unlock = createNewAction('unlock', {
fromAddress: accountAddress,
assetToUnlock: assetToSell,
chainId,
contractAddress: quote.to as Address,
contractAddress: allowanceTarget,
});
actions = actions.concat(unlock);
}
Expand Down
12 changes: 5 additions & 7 deletions src/screens/claimables/transaction/estimateGas.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CrosschainQuote, Quote, getRainbowRouterContractAddress } from '@rainbow-me/swaps';
import { CrosschainQuote, Quote } from '@rainbow-me/swaps';
import { getProvider } from '@/handlers/web3';
import { Address } from 'viem';
import { metadataPOSTClient } from '@/graphql';
Expand Down Expand Up @@ -34,10 +34,8 @@ export const estimateClaimUnlockSwapGasLimit = async ({

let swapAssetNeedsUnlocking = false;

const spender = getRainbowRouterContractAddress(chainId as number);

if (quote) {
const { from: accountAddress, sellTokenAddress, allowanceNeeded, sellTokenAsset, sellAmount } = quote;
const { from: accountAddress, sellTokenAddress, allowanceNeeded, allowanceTarget, sellTokenAsset, sellAmount } = quote;

if (!sellTokenAsset) {
logger.error(new RainbowError('[estimateClaimUnlockSwapGasLimit]: Quote is missing sellTokenAsset'));
Expand All @@ -48,7 +46,7 @@ export const estimateClaimUnlockSwapGasLimit = async ({
const allowance = await getAssetRawAllowance({
owner: accountAddress as Address,
assetAddress: sellTokenAddress as Address,
spender,
spender: allowanceTarget as Address,
chainId,
});

Expand All @@ -62,7 +60,7 @@ export const estimateClaimUnlockSwapGasLimit = async ({
const approveTransaction = await populateApprove({
owner: accountAddress as Address,
tokenAddress: sellTokenAddress as Address,
spender,
spender: allowanceTarget as Address,
chainId,
});

Expand Down Expand Up @@ -125,7 +123,7 @@ export const estimateClaimUnlockSwapGasLimit = async ({
gasEstimate = await estimateApprove({
owner: quote.from as Address,
tokenAddress: quote.sellTokenAddress as Address,
spender,
spender: quote.allowanceTarget as Address,
chainId,
});
} else if (step === 'swap') {
Expand Down

0 comments on commit 9afef38

Please sign in to comment.