From a6a8736ed4c44274d99e02498446871f69a6c052 Mon Sep 17 00:00:00 2001 From: Peiman <25097709+Rickk137@users.noreply.github.com> Date: Wed, 13 Nov 2024 06:34:55 +0330 Subject: [PATCH] feat: Mainnet close position (#60) * feat: mainnet close position * Remove optionality --------- Co-authored-by: peiman666 Co-authored-by: Noisekit --- liquidity/lib/contracts/importers/importClosePosition.js | 8 ++++++++ .../src/components/ClosePosition/ClosePositionOneStep.tsx | 2 +- .../ClosePosition/ClosePositionTransactions.tsx | 2 +- .../src/components/ClosePosition/fetchPriceUpdateTxn.ts | 8 ++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/liquidity/lib/contracts/importers/importClosePosition.js b/liquidity/lib/contracts/importers/importClosePosition.js index aea5ecd8..d3a0fae7 100644 --- a/liquidity/lib/contracts/importers/importClosePosition.js +++ b/liquidity/lib/contracts/importers/importClosePosition.js @@ -13,6 +13,14 @@ const abi = [ export async function importClosePosition(chainId, preset) { const deployment = `${Number(chainId).toFixed(0)}-${preset}`; switch (deployment) { + case '1-main': { + // https://etherscan.io/address/0x800b12d24ebb639bce7280861b05149f0d60f99e#code + return { address: '0x800b12d24ebb639bce7280861b05149f0d60f99e', abi }; + } + case '11155111-main': { + // https://sepolia.etherscan.io/address/0xcc998ef6d1923f206be1fed700eb1afebd69fbce#code + return { address: '0xcc998ef6d1923f206be1fed700eb1afebd69fbce', abi }; + } case '42161-main': { // https://arbiscan.io/address/0x28551921507790D91260d8eD08E3D688d525A752#code return { address: '0x28551921507790D91260d8eD08E3D688d525A752', abi }; diff --git a/liquidity/ui/src/components/ClosePosition/ClosePositionOneStep.tsx b/liquidity/ui/src/components/ClosePosition/ClosePositionOneStep.tsx index 412a8aac..598c072a 100644 --- a/liquidity/ui/src/components/ClosePosition/ClosePositionOneStep.tsx +++ b/liquidity/ui/src/components/ClosePosition/ClosePositionOneStep.tsx @@ -288,7 +288,7 @@ export function ClosePositionOneStep({ return ( - + Close Position diff --git a/liquidity/ui/src/components/ClosePosition/ClosePositionTransactions.tsx b/liquidity/ui/src/components/ClosePosition/ClosePositionTransactions.tsx index 1ac82d34..da2050bd 100644 --- a/liquidity/ui/src/components/ClosePosition/ClosePositionTransactions.tsx +++ b/liquidity/ui/src/components/ClosePosition/ClosePositionTransactions.tsx @@ -346,7 +346,7 @@ export const ClosePositionTransactions: FC<{ return ( - + Close Position diff --git a/liquidity/ui/src/components/ClosePosition/fetchPriceUpdateTxn.ts b/liquidity/ui/src/components/ClosePosition/fetchPriceUpdateTxn.ts index 8ee3b6ff..ad3ed397 100644 --- a/liquidity/ui/src/components/ClosePosition/fetchPriceUpdateTxn.ts +++ b/liquidity/ui/src/components/ClosePosition/fetchPriceUpdateTxn.ts @@ -9,6 +9,14 @@ export async function fetchPriceUpdateTxn({ PythVerfier: { address: string; abi: string[] }; pythFeeds: string[]; }) { + if (!pythFeeds.length) { + return { + target: PythVerfier.address, + callData: ethers.constants.HashZero, + value: ethers.BigNumber.from(0), + requireSuccess: false, + }; + } const PythVerifierInterface = new ethers.utils.Interface(PythVerfier.abi); const priceService = new EvmPriceServiceConnection(offchainMainnetEndpoint); const signedOffchainData = await priceService.getPriceFeedsUpdateData(pythFeeds);