import { ContractRunner, ethers } from 'ethers' import { lockupAbi } from './abi' import { createGetValueCaller } from './getValue' import { createGetPropertyValueCaller } from './getPropertyValue' import { createWithdrawCaller } from './withdraw' import { createCalculateWithdrawableInterestAmountCaller } from './calculateWithdrawableInterestAmount' import { createGetAllValueCaller } from './getAllValue' import { createGetStorageWithdrawalStatusCaller } from './getStorageWithdrawalStatus' import { createCalculateCumulativeHoldersRewardAmountCaller } from './calculateCumulativeHoldersRewardAmount' import { createCalculateCumulativeRewardPricesCaller } from './calculateCumulativeRewardPrices' import { createCalculateRewardAmountCaller } from './calculateRewardAmount' import { createCapCaller } from './cap' import { createWithdrawByPositionCaller } from './withdrawByPosition' import { createcalculateWithdrawableInterestAmountByPositionCaller } from './calculateWithdrawableInterestAmountByPosition' import { createDepositToPropertyCaller } from './depositToProperty' import { createDepositToPositionCaller } from './depositToPosition' import { createMigrateToSTokensCaller } from './migrateToSTokens' import { FallbackableOverrides } from '../../common/utils/execute' import type { TransactionResponse } from 'ethers' export type LockupContract = { readonly getValue: ( propertyAddress: string, accountAddress: string, ) => Promise readonly getAllValue: () => Promise readonly getPropertyValue: (address: string) => Promise readonly withdrawByPosition: ( positionTokenId: string, amount: string, overrides?: FallbackableOverrides, ) => Promise readonly withdraw: ( propertyAddress: string, amount: string, overrides?: FallbackableOverrides, ) => Promise readonly calculateWithdrawableInterestAmountByPosition: ( positionTokenId: string, ) => Promise readonly calculateWithdrawableInterestAmount: ( propertyAddress: string, accountAddress: string, ) => Promise readonly calculateCumulativeHoldersRewardAmount: ( propertyAddress: string, ) => Promise readonly getStorageWithdrawalStatus: ( propertyAddress: string, accountAddress: string, ) => Promise readonly calculateCumulativeRewardPrices: () => Promise< readonly [string, string, string, string] > readonly calculateRewardAmount: ( propertyAddress: string, ) => Promise readonly cap: () => Promise readonly depositToProperty: ( propertyAddress: string, amount: string, payload?: string | Uint8Array, overrides?: FallbackableOverrides, ) => Promise readonly depositToPosition: ( positionTokenId: string, amount: string, overrides?: FallbackableOverrides, ) => Promise readonly migrateToSTokens: ( positionTokenId: string, overrides?: FallbackableOverrides, ) => Promise readonly contract: () => ethers.Contract } export const createLockupContract = (provider: ContractRunner) => (address: string): LockupContract => { const contract = new ethers.Contract(address, [...lockupAbi], provider) return { getValue: createGetValueCaller(contract), getAllValue: createGetAllValueCaller(contract), getPropertyValue: createGetPropertyValueCaller(contract), withdrawByPosition: createWithdrawByPositionCaller(contract), withdraw: createWithdrawCaller(contract), calculateWithdrawableInterestAmountByPosition: createcalculateWithdrawableInterestAmountByPositionCaller(contract), calculateWithdrawableInterestAmount: createCalculateWithdrawableInterestAmountCaller(contract), calculateCumulativeHoldersRewardAmount: createCalculateCumulativeHoldersRewardAmountCaller(contract), getStorageWithdrawalStatus: createGetStorageWithdrawalStatusCaller(contract), calculateCumulativeRewardPrices: createCalculateCumulativeRewardPricesCaller(contract), calculateRewardAmount: createCalculateRewardAmountCaller(contract), cap: createCapCaller(contract), depositToProperty: createDepositToPropertyCaller(contract), depositToPosition: createDepositToPositionCaller(contract), migrateToSTokens: createMigrateToSTokensCaller(contract), contract: () => contract, } }