Skip to content

Commit

Permalink
fix: approved amount (#1997)
Browse files Browse the repository at this point in the history
  • Loading branch information
grothem authored Mar 22, 2024
1 parent e1cc882 commit 6dd0141
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/transactions/Switch/SwitchActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export const SwitchActions = ({
success: true,
});
} else {
const tx = generateApproval(approvalData, { chainId });
const tx = generateApproval(approvalData, { chainId, amount: amountToApprove });
const txWithGasEstimation = await estimateGasLimit(tx);
setApprovalTxState({ ...approvalTxState, loading: true });
const response = await sendTx(txWithGasEstimation);
Expand Down
8 changes: 5 additions & 3 deletions src/store/poolSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type RepayArgs = {

type GenerateApprovalOpts = {
chainId?: number;
amount?: string;
};

type GenerateSignatureRequestOpts = {
Expand Down Expand Up @@ -186,10 +187,11 @@ export const createPoolSlice: StateCreator<
});
}
},
generateApproval: (args: ApproveType, ops = {}) => {
const provider = get().jsonRpcProvider(ops.chainId);
generateApproval: (args: ApproveType, opts = {}) => {
const provider = get().jsonRpcProvider(opts.chainId);
const tokenERC20Service = new ERC20Service(provider);
return tokenERC20Service.approveTxData({ ...args, amount: MAX_UINT_AMOUNT });
const amount = opts.amount ?? MAX_UINT_AMOUNT;
return tokenERC20Service.approveTxData({ ...args, amount });
},
supply: (args: Omit<LPSupplyParamsType, 'user'>) => {
const poolBundle = get().getCorrectPoolBundle();
Expand Down

11 comments on commit 6dd0141

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

Please sign in to comment.