From fa39637f89061f6c860ce702323cd47ebd9d475c Mon Sep 17 00:00:00 2001 From: Rahul Sethuram Date: Tue, 17 Dec 2024 16:00:14 +0400 Subject: [PATCH] feat: deploy --- .../default/VelodromePriceOracleFraxtal.sol | 6 +- .../deploy/14-deploy-levered-positions.ts | 21 ++ packages/sdk/src/generated.ts | 271 +++++++++++------- packages/sdk/src/modules/Leverage.ts | 31 +- .../dashboards/CollateralSwapPopup.tsx | 8 +- packages/ui/app/layout.tsx | 5 + packages/ui/package.json | 2 +- yarn.lock | 94 +++++- 8 files changed, 320 insertions(+), 118 deletions(-) diff --git a/packages/contracts/contracts/oracles/default/VelodromePriceOracleFraxtal.sol b/packages/contracts/contracts/oracles/default/VelodromePriceOracleFraxtal.sol index c153ad6e5..019f71463 100644 --- a/packages/contracts/contracts/oracles/default/VelodromePriceOracleFraxtal.sol +++ b/packages/contracts/contracts/oracles/default/VelodromePriceOracleFraxtal.sol @@ -5,15 +5,15 @@ import "../BasePriceOracle.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; -interface Prices { +interface Prices_Fraxtal { function getRate(address srcToken, address dstToken, bool useSrcWrappers) external view returns (uint256 weightedRate); } contract VelodromePriceOracleFraxtal is BasePriceOracle { - Prices immutable prices; + Prices_Fraxtal immutable prices; constructor(address _prices) { - prices = Prices(_prices); + prices = Prices_Fraxtal(_prices); } /** * @notice Fetches the token/ETH price, with 18 decimals of precision. diff --git a/packages/contracts/deploy/14-deploy-levered-positions.ts b/packages/contracts/deploy/14-deploy-levered-positions.ts index 27501e5d1..a569e28c9 100644 --- a/packages/contracts/deploy/14-deploy-levered-positions.ts +++ b/packages/contracts/deploy/14-deploy-levered-positions.ts @@ -4,6 +4,8 @@ import { Address, Hash, zeroAddress } from "viem"; import { ChainDeployConfig, chainDeployConfig } from "../chainDeploy"; import { prepareAndLogTransaction } from "../chainDeploy/helpers/logging"; +const LIFI_SWAP_ROUTER = "0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE"; + const func: DeployFunction = async ({ viem, getNamedAccounts, deployments, getChainId }) => { const { deployer, multisig } = await getNamedAccounts(); const publicClient = await viem.getPublicClient(); @@ -231,6 +233,25 @@ const func: DeployFunction = async ({ viem, getNamedAccounts, deployments, getCh console.error("Could not deploy:", error); } + const factory = await viem.getContractAt("ILeveredPositionFactory", leveredPositionFactory.address); + const isWhitelisted = await factory.read.isSwapRoutersWhitelisted([LIFI_SWAP_ROUTER]); + console.log("isWhitelisted: ", isWhitelisted); + if (!isWhitelisted) { + const owner = await factory.read.owner(); + if (owner.toLowerCase() !== deployer.toLowerCase()) { + await prepareAndLogTransaction({ + contractInstance: factory, + functionName: "_setWhitelistedSwapRouters", + args: [[LIFI_SWAP_ROUTER]], + description: "Whitelist LIFI Swap Router", + inputs: [{ internalType: "address[]", name: "swapRouters", type: "address[]" }] + }); + } else { + tx = await factory.write._setWhitelistedSwapRouters([[LIFI_SWAP_ROUTER]]); + await publicClient.waitForTransactionReceipt({ hash: tx }); + console.log("whitelisted the LIFI Swap Router in the LeveredPositionFactory", tx); + } + } //// AUTHORITIES REGISTRY try { await deployments.deploy("AuthoritiesRegistry", { diff --git a/packages/sdk/src/generated.ts b/packages/sdk/src/generated.ts index 550e815c3..5180de98a 100644 --- a/packages/sdk/src/generated.ts +++ b/packages/sdk/src/generated.ts @@ -5004,6 +5004,7 @@ export const cErc20Abi = [ ], name: 'Transfer', }, + { type: 'error', inputs: [], name: 'CallerIsNotEOA' }, { type: 'error', inputs: [], name: 'InteractionNotAllowed' }, ] as const; @@ -5607,6 +5608,7 @@ export const cErc20DelegateAbi = [ ], name: 'Transfer', }, + { type: 'error', inputs: [], name: 'CallerIsNotEOA' }, { type: 'error', inputs: [], name: 'InteractionNotAllowed' }, ] as const; @@ -7249,6 +7251,7 @@ export const cErc20PluginDelegateAbi = [ ], name: 'Transfer', }, + { type: 'error', inputs: [], name: 'CallerIsNotEOA' }, { type: 'error', inputs: [], name: 'InteractionNotAllowed' }, ] as const; @@ -7739,6 +7742,7 @@ export const cErc20PluginRewardsDelegateAbi = [ ], name: 'Transfer', }, + { type: 'error', inputs: [], name: 'CallerIsNotEOA' }, { type: 'error', inputs: [], name: 'InteractionNotAllowed' }, ] as const; @@ -8552,6 +8556,7 @@ export const cErc20RewardsDelegateAbi = [ ], name: 'Transfer', }, + { type: 'error', inputs: [], name: 'CallerIsNotEOA' }, { type: 'error', inputs: [], name: 'InteractionNotAllowed' }, ] as const; @@ -9430,6 +9435,7 @@ export const cTokenFirstExtensionAbi = [ ], name: 'Transfer', }, + { type: 'error', inputs: [], name: 'CallerIsNotEOA' }, { type: 'error', inputs: [], name: 'InteractionNotAllowed' }, ] as const; @@ -9872,6 +9878,7 @@ export const cTokenOracleProtectedAbi = [ outputs: [{ name: '', internalType: 'address', type: 'address' }], stateMutability: 'view', }, + { type: 'error', inputs: [], name: 'CallerIsNotEOA' }, { type: 'error', inputs: [], name: 'InteractionNotAllowed' }, ] as const; @@ -26616,43 +26623,39 @@ export const iHistoricalRatesAbi = [ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// export const iHypernativeOracleAbi = [ - { - type: 'function', - inputs: [{ name: 'account', internalType: 'address', type: 'address' }], - name: 'isBlacklistedAccount', - outputs: [{ name: '', internalType: 'bool', type: 'bool' }], - stateMutability: 'view', - }, { type: 'function', inputs: [ - { name: 'sender', internalType: 'address', type: 'address' }, - { name: 'origin', internalType: 'address', type: 'address' }, + { name: 'account', internalType: 'address', type: 'address' }, + { name: 'isStrictMode', internalType: 'bool', type: 'bool' }, ], - name: 'isBlacklistedContext', - outputs: [{ name: '', internalType: 'bool', type: 'bool' }], - stateMutability: 'view', + name: 'register', + outputs: [], + stateMutability: 'nonpayable', }, { type: 'function', - inputs: [{ name: 'account', internalType: 'address', type: 'address' }], - name: 'isTimeExceeded', - outputs: [{ name: '', internalType: 'bool', type: 'bool' }], - stateMutability: 'view', + inputs: [{ name: 'sender', internalType: 'address', type: 'address' }], + name: 'validateBlacklistedAccountInteraction', + outputs: [], + stateMutability: 'nonpayable', }, { type: 'function', - inputs: [{ name: 'account', internalType: 'address', type: 'address' }], - name: 'register', + inputs: [{ name: 'sender', internalType: 'address', type: 'address' }], + name: 'validateForbiddenAccountInteraction', outputs: [], - stateMutability: 'nonpayable', + stateMutability: 'view', }, { type: 'function', - inputs: [{ name: 'account', internalType: 'address', type: 'address' }], - name: 'registerStrict', + inputs: [ + { name: 'origin', internalType: 'address', type: 'address' }, + { name: 'sender', internalType: 'address', type: 'address' }, + ], + name: 'validateForbiddenContextInteraction', outputs: [], - stateMutability: 'nonpayable', + stateMutability: 'view', }, ] as const; @@ -28529,6 +28532,24 @@ export const iLeveredPositionFactoryAbi = [ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }], stateMutability: 'view', }, + { + type: 'function', + inputs: [ + { name: 'ratioIncreases', internalType: 'bool', type: 'bool' }, + { name: 'targetRatio', internalType: 'uint256', type: 'uint256' }, + { name: 'collateralAssetPrice', internalType: 'uint256', type: 'uint256' }, + { name: 'borrowedAssetPrice', internalType: 'uint256', type: 'uint256' }, + { name: 'expectedSlippage', internalType: 'uint256', type: 'uint256' }, + { name: 'positionSupplyAmount', internalType: 'uint256', type: 'uint256' }, + { name: 'debtAmount', internalType: 'uint256', type: 'uint256' }, + ], + name: 'calculateAdjustmentAmountDeltas', + outputs: [ + { name: 'supplyDelta', internalType: 'uint256', type: 'uint256' }, + { name: 'borrowsDelta', internalType: 'uint256', type: 'uint256' }, + ], + stateMutability: 'pure', + }, { type: 'function', inputs: [ @@ -28557,7 +28578,6 @@ export const iLeveredPositionFactoryAbi = [ { name: '_fundingAmount', internalType: 'uint256', type: 'uint256' }, { name: 'aggregatorTarget', internalType: 'address', type: 'address' }, { name: 'aggregatorData', internalType: 'bytes', type: 'bytes' }, - { name: 'expectedSlippage', internalType: 'uint256', type: 'uint256' }, ], name: 'createAndFundPosition', outputs: [{ name: '', internalType: 'contract LeveredPosition', type: 'address' }], @@ -28581,19 +28601,6 @@ export const iLeveredPositionFactoryAbi = [ outputs: [{ name: '', internalType: 'contract LeveredPosition', type: 'address' }], stateMutability: 'nonpayable', }, - { - type: 'function', - inputs: [ - { name: '_collateralMarket', internalType: 'contract ICErc20', type: 'address' }, - { name: '_stableMarket', internalType: 'contract ICErc20', type: 'address' }, - { name: '_fundingAsset', internalType: 'contract IERC20Upgradeable', type: 'address' }, - { name: '_fundingAmount', internalType: 'uint256', type: 'uint256' }, - { name: '_leverageRatio', internalType: 'uint256', type: 'uint256' }, - ], - name: 'createAndFundPositionAtRatio', - outputs: [{ name: '', internalType: 'contract LeveredPosition', type: 'address' }], - stateMutability: 'nonpayable', - }, { type: 'function', inputs: [ @@ -28759,6 +28766,24 @@ export const iLeveredPositionFactoryExtensionAbi = [ outputs: [], stateMutability: 'nonpayable', }, + { + type: 'function', + inputs: [ + { name: 'ratioIncreases', internalType: 'bool', type: 'bool' }, + { name: 'targetRatio', internalType: 'uint256', type: 'uint256' }, + { name: 'collateralAssetPrice', internalType: 'uint256', type: 'uint256' }, + { name: 'borrowedAssetPrice', internalType: 'uint256', type: 'uint256' }, + { name: 'expectedSlippage', internalType: 'uint256', type: 'uint256' }, + { name: 'positionSupplyAmount', internalType: 'uint256', type: 'uint256' }, + { name: 'debtAmount', internalType: 'uint256', type: 'uint256' }, + ], + name: 'calculateAdjustmentAmountDeltas', + outputs: [ + { name: 'supplyDelta', internalType: 'uint256', type: 'uint256' }, + { name: 'borrowsDelta', internalType: 'uint256', type: 'uint256' }, + ], + stateMutability: 'pure', + }, { type: 'function', inputs: [ @@ -28787,7 +28812,6 @@ export const iLeveredPositionFactoryExtensionAbi = [ { name: '_fundingAmount', internalType: 'uint256', type: 'uint256' }, { name: 'aggregatorTarget', internalType: 'address', type: 'address' }, { name: 'aggregatorData', internalType: 'bytes', type: 'bytes' }, - { name: 'expectedSlippage', internalType: 'uint256', type: 'uint256' }, ], name: 'createAndFundPosition', outputs: [{ name: '', internalType: 'contract LeveredPosition', type: 'address' }], @@ -28811,19 +28835,6 @@ export const iLeveredPositionFactoryExtensionAbi = [ outputs: [{ name: '', internalType: 'contract LeveredPosition', type: 'address' }], stateMutability: 'nonpayable', }, - { - type: 'function', - inputs: [ - { name: '_collateralMarket', internalType: 'contract ICErc20', type: 'address' }, - { name: '_stableMarket', internalType: 'contract ICErc20', type: 'address' }, - { name: '_fundingAsset', internalType: 'contract IERC20Upgradeable', type: 'address' }, - { name: '_fundingAmount', internalType: 'uint256', type: 'uint256' }, - { name: '_leverageRatio', internalType: 'uint256', type: 'uint256' }, - ], - name: 'createAndFundPositionAtRatio', - outputs: [{ name: '', internalType: 'contract LeveredPosition', type: 'address' }], - stateMutability: 'nonpayable', - }, { type: 'function', inputs: [ @@ -28937,6 +28948,24 @@ export const iLeveredPositionFactoryFirstExtensionAbi = [ outputs: [], stateMutability: 'nonpayable', }, + { + type: 'function', + inputs: [ + { name: 'ratioIncreases', internalType: 'bool', type: 'bool' }, + { name: 'targetRatio', internalType: 'uint256', type: 'uint256' }, + { name: 'collateralAssetPrice', internalType: 'uint256', type: 'uint256' }, + { name: 'borrowedAssetPrice', internalType: 'uint256', type: 'uint256' }, + { name: 'expectedSlippage', internalType: 'uint256', type: 'uint256' }, + { name: 'positionSupplyAmount', internalType: 'uint256', type: 'uint256' }, + { name: 'debtAmount', internalType: 'uint256', type: 'uint256' }, + ], + name: 'calculateAdjustmentAmountDeltas', + outputs: [ + { name: 'supplyDelta', internalType: 'uint256', type: 'uint256' }, + { name: 'borrowsDelta', internalType: 'uint256', type: 'uint256' }, + ], + stateMutability: 'pure', + }, { type: 'function', inputs: [ @@ -29051,7 +29080,6 @@ export const iLeveredPositionFactorySecondExtensionAbi = [ { name: '_fundingAmount', internalType: 'uint256', type: 'uint256' }, { name: 'aggregatorTarget', internalType: 'address', type: 'address' }, { name: 'aggregatorData', internalType: 'bytes', type: 'bytes' }, - { name: 'expectedSlippage', internalType: 'uint256', type: 'uint256' }, ], name: 'createAndFundPosition', outputs: [{ name: '', internalType: 'contract LeveredPosition', type: 'address' }], @@ -29075,19 +29103,6 @@ export const iLeveredPositionFactorySecondExtensionAbi = [ outputs: [{ name: '', internalType: 'contract LeveredPosition', type: 'address' }], stateMutability: 'nonpayable', }, - { - type: 'function', - inputs: [ - { name: '_collateralMarket', internalType: 'contract ICErc20', type: 'address' }, - { name: '_stableMarket', internalType: 'contract ICErc20', type: 'address' }, - { name: '_fundingAsset', internalType: 'contract IERC20Upgradeable', type: 'address' }, - { name: '_fundingAmount', internalType: 'uint256', type: 'uint256' }, - { name: '_leverageRatio', internalType: 'uint256', type: 'uint256' }, - ], - name: 'createAndFundPositionAtRatio', - outputs: [{ name: '', internalType: 'contract LeveredPosition', type: 'address' }], - stateMutability: 'nonpayable', - }, { type: 'function', inputs: [ @@ -41960,6 +41975,29 @@ export const leveredPositionAbi = [ ], stateMutability: 'nonpayable', }, + { + type: 'function', + inputs: [ + { name: 'targetRatio', internalType: 'uint256', type: 'uint256' }, + { name: 'assumedSlippage', internalType: 'uint256', type: 'uint256' }, + ], + name: 'getAdjustmentAmountDeltas', + outputs: [ + { name: '', internalType: 'uint256', type: 'uint256' }, + { name: '', internalType: 'uint256', type: 'uint256' }, + ], + stateMutability: 'view', + }, + { + type: 'function', + inputs: [{ name: 'targetRatio', internalType: 'uint256', type: 'uint256' }], + name: 'getAdjustmentAmountDeltas', + outputs: [ + { name: '', internalType: 'uint256', type: 'uint256' }, + { name: '', internalType: 'uint256', type: 'uint256' }, + ], + stateMutability: 'view', + }, { type: 'function', inputs: [], @@ -42002,29 +42040,6 @@ export const leveredPositionAbi = [ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }], stateMutability: 'view', }, - { - type: 'function', - inputs: [{ name: 'targetRatio', internalType: 'uint256', type: 'uint256' }], - name: 'getSupplyAmountDelta', - outputs: [ - { name: '', internalType: 'uint256', type: 'uint256' }, - { name: '', internalType: 'uint256', type: 'uint256' }, - ], - stateMutability: 'view', - }, - { - type: 'function', - inputs: [ - { name: 'targetRatio', internalType: 'uint256', type: 'uint256' }, - { name: 'assumedSlippage', internalType: 'uint256', type: 'uint256' }, - ], - name: 'getSupplyAmountDelta', - outputs: [ - { name: '', internalType: 'uint256', type: 'uint256' }, - { name: '', internalType: 'uint256', type: 'uint256' }, - ], - stateMutability: 'view', - }, { type: 'function', inputs: [], @@ -42085,6 +42100,7 @@ export const leveredPositionAbi = [ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }], stateMutability: 'nonpayable', }, + { type: 'error', inputs: [], name: 'AggregatorCallFailed' }, { type: 'error', inputs: [], name: 'AssetNotRescuable' }, { type: 'error', @@ -42092,6 +42108,7 @@ export const leveredPositionAbi = [ name: 'BorrowStableFailed', }, { type: 'error', inputs: [], name: 'ConvertFundsFailed' }, + { type: 'error', inputs: [], name: 'DelegateCallToNonContract' }, { type: 'error', inputs: [{ name: 'errorCode', internalType: 'uint256', type: 'uint256' }], @@ -42102,6 +42119,9 @@ export const leveredPositionAbi = [ inputs: [{ name: '_functionSelector', internalType: 'bytes4', type: 'bytes4' }], name: 'ExtNotFound', }, + { type: 'error', inputs: [], name: 'FlashLoanSourceError' }, + { type: 'error', inputs: [], name: 'LowLevelDelegateCallFailed' }, + { type: 'error', inputs: [], name: 'MarketsPoolsDiffer' }, { type: 'error', inputs: [], name: 'NotPositionOwner' }, { type: 'error', inputs: [], name: 'OnlyFactoryOwner' }, { type: 'error', inputs: [], name: 'OnlyWhenClosed' }, @@ -42325,6 +42345,24 @@ export const leveredPositionFactoryFirstExtensionAbi = [ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }], stateMutability: 'view', }, + { + type: 'function', + inputs: [ + { name: 'ratioIncreases', internalType: 'bool', type: 'bool' }, + { name: 'targetRatio', internalType: 'uint256', type: 'uint256' }, + { name: 'collateralAssetPrice', internalType: 'uint256', type: 'uint256' }, + { name: 'borrowedAssetPrice', internalType: 'uint256', type: 'uint256' }, + { name: 'expectedSlippage', internalType: 'uint256', type: 'uint256' }, + { name: 'positionSupplyAmount', internalType: 'uint256', type: 'uint256' }, + { name: 'debtAmount', internalType: 'uint256', type: 'uint256' }, + ], + name: 'calculateAdjustmentAmountDeltas', + outputs: [ + { name: 'supplyDelta', internalType: 'uint256', type: 'uint256' }, + { name: 'borrowsDelta', internalType: 'uint256', type: 'uint256' }, + ], + stateMutability: 'pure', + }, { type: 'function', inputs: [ @@ -42523,7 +42561,6 @@ export const leveredPositionFactorySecondExtensionAbi = [ { name: '_fundingAmount', internalType: 'uint256', type: 'uint256' }, { name: '_aggregatorTarget', internalType: 'address', type: 'address' }, { name: '_aggregatorData', internalType: 'bytes', type: 'bytes' }, - { name: 'expectedSlippage', internalType: 'uint256', type: 'uint256' }, ], name: 'createAndFundPosition', outputs: [{ name: '', internalType: 'contract LeveredPosition', type: 'address' }], @@ -42547,19 +42584,6 @@ export const leveredPositionFactorySecondExtensionAbi = [ outputs: [{ name: '', internalType: 'contract LeveredPosition', type: 'address' }], stateMutability: 'nonpayable', }, - { - type: 'function', - inputs: [ - { name: '_collateralMarket', internalType: 'contract ICErc20', type: 'address' }, - { name: '_stableMarket', internalType: 'contract ICErc20', type: 'address' }, - { name: '_fundingAsset', internalType: 'contract IERC20Upgradeable', type: 'address' }, - { name: '_fundingAmount', internalType: 'uint256', type: 'uint256' }, - { name: '_leverageRatio', internalType: 'uint256', type: 'uint256' }, - ], - name: 'createAndFundPositionAtRatio', - outputs: [{ name: '', internalType: 'contract LeveredPosition', type: 'address' }], - stateMutability: 'nonpayable', - }, { type: 'function', inputs: [ @@ -42631,6 +42655,7 @@ export const leveredPositionFactorySecondExtensionAbi = [ name: 'OwnershipTransferred', }, { type: 'error', inputs: [], name: 'PairNotWhitelisted' }, + { type: 'error', inputs: [], name: 'WrongFnsArrayLength' }, ] as const; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -48405,6 +48430,24 @@ export const pricesAbi = [ }, ] as const; +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Prices_Fraxtal +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +export const pricesFraxtalAbi = [ + { + type: 'function', + inputs: [ + { name: 'srcToken', internalType: 'address', type: 'address' }, + { name: 'dstToken', internalType: 'address', type: 'address' }, + { name: 'useSrcWrappers', internalType: 'bool', type: 'bool' }, + ], + name: 'getRate', + outputs: [{ name: 'weightedRate', internalType: 'uint256', type: 'uint256' }], + stateMutability: 'view', + }, +] as const; + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Proxy ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -54378,6 +54421,32 @@ export const velodromePriceOracleAbi = [ }, ] as const; +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// VelodromePriceOracleFraxtal +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +export const velodromePriceOracleFraxtalAbi = [ + { + type: 'constructor', + inputs: [{ name: '_prices', internalType: 'address', type: 'address' }], + stateMutability: 'nonpayable', + }, + { + type: 'function', + inputs: [{ name: 'cToken', internalType: 'contract ICErc20', type: 'address' }], + name: 'getUnderlyingPrice', + outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }], + stateMutability: 'view', + }, + { + type: 'function', + inputs: [{ name: 'underlying', internalType: 'address', type: 'address' }], + name: 'price', + outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }], + stateMutability: 'view', + }, +] as const; + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // VelodromeV2Liquidator ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/packages/sdk/src/modules/Leverage.ts b/packages/sdk/src/modules/Leverage.ts index 947c5a88a..88303131c 100644 --- a/packages/sdk/src/modules/Leverage.ts +++ b/packages/sdk/src/modules/Leverage.ts @@ -5,7 +5,7 @@ import { OpenPosition, PositionInfo } from "@ionicprotocol/types"; -import { Address, erc20Abi, getContract, Hex, maxUint256, parseEther } from "viem"; +import { Address, erc20Abi, getContract, Hex, maxUint256, parseEther, zeroAddress } from "viem"; import { CreateContractsModule } from "./CreateContracts"; import { ChainSupportedAssets } from "./Pools"; @@ -37,7 +37,12 @@ export interface ILeverage { borrowMarket: Address, fundingAsset: Address, fundingAmount: bigint, - leverageRatio: bigint + leverageRatio: bigint, + fundingTarget: Address, + fundingData: Hex, + aggregatorTarget: Address, + aggregatorData: Hex, + expectedSlippage: bigint ): Promise; getRangeOfLeverageRatio(address: Address): Promise<[bigint, bigint]>; isPositionClosed(address: Address): Promise; @@ -278,7 +283,7 @@ export function withLeverage