From 6bbf5e548738bfbfcbde431bb2d3d30b320f4140 Mon Sep 17 00:00:00 2001 From: Jan Date: Thu, 19 Oct 2023 19:43:06 +0200 Subject: [PATCH] use maxIssueance on base --- package-lock.json | 8 +++--- package.json | 2 +- .../issuance/components/zap/state/atoms.ts | 26 +++++++++++++------ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5a69046ae..d664bcb0f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "@popperjs/core": "^2.11.5", "@rainbow-me/rainbowkit": "1.0.11", "@react-spring/web": "^9.7.1", - "@reserve-protocol/token-zapper": "2.6.9", + "@reserve-protocol/token-zapper": "2.6.10", "@uiw/react-md-editor": "^3.20.5", "@uniswap/permit2-sdk": "^1.2.0", "@viem/anvil": "^0.0.6", @@ -4974,9 +4974,9 @@ } }, "node_modules/@reserve-protocol/token-zapper": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/@reserve-protocol/token-zapper/-/token-zapper-2.6.9.tgz", - "integrity": "sha512-o9Dq8HxLLyj0g/fY10CxIvVsjsK2ciJI2LEN8mmA1qWrpvvB5Lqty0/rsydcv0D0rCeCqJLlU62IEpg1MwMuGw==", + "version": "2.6.10", + "resolved": "https://registry.npmjs.org/@reserve-protocol/token-zapper/-/token-zapper-2.6.10.tgz", + "integrity": "sha512-+s+gn8Ze2TYrgcEQgcYSg7IfT6mCH0kyuUjjiwL0VrniiPtnXBRDjvnELOeFqkMMzxI2MGp2xQRsJN/6F3CH7w==", "dependencies": { "@ethersproject/abi": "^5.7.0", "@ethersproject/providers": "^5.7.2", diff --git a/package.json b/package.json index 96e6b9733..cb9352160 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "@popperjs/core": "^2.11.5", "@rainbow-me/rainbowkit": "1.0.11", "@react-spring/web": "^9.7.1", - "@reserve-protocol/token-zapper": "2.6.9", + "@reserve-protocol/token-zapper": "2.6.10", "@uiw/react-md-editor": "^3.20.5", "@uniswap/permit2-sdk": "^1.2.0", "@viem/anvil": "^0.0.6", diff --git a/src/views/issuance/components/zap/state/atoms.ts b/src/views/issuance/components/zap/state/atoms.ts index 9e195d341..8315aa533 100644 --- a/src/views/issuance/components/zap/state/atoms.ts +++ b/src/views/issuance/components/zap/state/atoms.ts @@ -10,6 +10,7 @@ import { loadable } from 'jotai/utils' import { balancesAtom, blockAtom, + chainIdAtom, isSmartWalletAtom, rTokenAtom, walletAtom, @@ -186,7 +187,6 @@ export const zapQuotePromise = loadable( export const zapQuote = simplifyLoadable(zapQuotePromise) - const approximateGasUsage: Record = { '0xa0d69e286b938e21cbf7e51d71f6a4c8918f482f': 3_000_000n, '0xe72b141df173b999ae7c1adcbf60cc9833ce56a8': 3_000_000n, @@ -195,7 +195,7 @@ const approximateGasUsage: Record = { '0x9b451beb49a03586e6995e5a93b9c745d068581e': 3_000_000n, '0xfc0b1eef20e4c68b3dcf36c4537cfa7ce46ca70b': 3_000_000n, '0x50249c768a6d3cb4b6565c0a2bfbdb62be94915c': 3_000_000n, - '0xcc7ff230365bd730ee4b352cc2492cedac49383e': 6_000_000n + '0xcc7ff230365bd730ee4b352cc2492cedac49383e': 6_000_000n, } export const selectedZapTokenBalance = atom((get) => { const token = get(selectedZapTokenAtom) @@ -207,7 +207,7 @@ export const selectedZapTokenBalance = atom((get) => { return null } const quantities = get(balancesAtom) ?? {} - const fr = quantities[token.address.address as any]?.balance ?? "0" + const fr = quantities[token.address.address as any]?.balance ?? '0' let bal = token.from(fr) return bal }) @@ -224,10 +224,14 @@ export const maxSelectedZapTokenBalance = atom((get) => { const rtoken = get(rTokenAtom) const zapTransaction = get(resolvedZapTransaction) const quantities = get(balancesAtom) ?? {} - const fr = quantities[token.address.address as any]?.balance ?? "0" + const fr = quantities[token.address.address as any]?.balance ?? '0' let bal = token.from(fr) if (token.address.address === '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE') { - const a = zapState.gasPrice * (zapTransaction?.transaction.gasEstimate ?? approximateGasUsage[rtoken?.address.toLowerCase() ?? ""] ?? 2_500_000n); + const a = + zapState.gasPrice * + (zapTransaction?.transaction.gasEstimate ?? + approximateGasUsage[rtoken?.address.toLowerCase() ?? ''] ?? + 2_500_000n) bal = bal.sub(token.from(a)) bal = bal.amount < 0n ? token.zero : bal } @@ -333,8 +337,13 @@ export const approvalTxFee = loadable( export const resolvedApprovalTxFee = simplifyLoadable(approvalTxFee) +const useMaxIssueance: Record = { + 1: false, + 8453: true, +} const zapTxAtom = atom(async (get) => { const result = get(zapQuote) + const chainId = get(chainIdAtom) const approvalNeeded = get(resolvedApprovalNeeded) if (!(approvalNeeded && result)) { return null @@ -347,13 +356,14 @@ const zapTxAtom = atom(async (get) => { permit2 = signature != null && permit != null ? { - permit: permit.permit, - signature, - } + permit: permit.permit, + signature, + } : undefined } const tx = await result.toTransaction({ permit2, + maxIssueance: useMaxIssueance[chainId] ?? false, returnDust: get(collectDust), }) // console.log("=== abstract zap transaction ===")