import { ContractRunner, ethers } from 'ethers' import { lockupAbi } from './abi' import { createTotalLockedCaller } from './totalLocked' import { createTotalLockedForPropertyCaller } from './totalLockedForProperty' import { createWithdrawByPositionCaller } from '../../ethereum/lockup/withdrawByPosition' import { createcalculateWithdrawableInterestAmountByPositionCaller } from '../../ethereum/lockup/calculateWithdrawableInterestAmountByPosition' import { createCalculateCumulativeHoldersRewardAmountCaller } from '../../ethereum/lockup/calculateCumulativeHoldersRewardAmount' import { createCalculateCumulativeRewardPricesCaller } from '../../ethereum/lockup/calculateCumulativeRewardPrices' import { createCalculateRewardAmountCaller } from '../../ethereum/lockup/calculateRewardAmount' import { createCapCaller } from '../../ethereum/lockup/cap' import { createDepositToPropertyCaller } from '../../ethereum/lockup/depositToProperty' import { createDepositToPositionCaller } from '../../ethereum/lockup/depositToPosition' import { createGetLockedupPropertiesCaller, LockedupProperty, } from './getLockedupProperties' import type { TransactionResponse } from 'ethers' import { FallbackableOverrides } from '../../common/utils/execute' export type LockupContract = { readonly withdrawByPosition: ( positionTokenId: string, amount: string, overrides?: FallbackableOverrides, ) => Promise readonly calculateWithdrawableInterestAmountByPosition: ( positionTokenId: string, ) => Promise readonly calculateCumulativeHoldersRewardAmount: ( propertyAddress: 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 totalLocked: () => Promise readonly totalLockedForProperty: (address: string) => Promise readonly getLockedupProperties: () => Promise readonly contract: () => ethers.Contract } export const createLockupContract = (provider: ContractRunner) => (address: string): LockupContract => { const contract = new ethers.Contract(address, [...lockupAbi], provider) return { withdrawByPosition: createWithdrawByPositionCaller(contract), calculateWithdrawableInterestAmountByPosition: createcalculateWithdrawableInterestAmountByPositionCaller(contract), calculateCumulativeHoldersRewardAmount: createCalculateCumulativeHoldersRewardAmountCaller(contract), calculateCumulativeRewardPrices: createCalculateCumulativeRewardPricesCaller(contract), calculateRewardAmount: createCalculateRewardAmountCaller(contract), cap: createCapCaller(contract), depositToProperty: createDepositToPropertyCaller(contract), depositToPosition: createDepositToPositionCaller(contract), totalLocked: createTotalLockedCaller(contract), totalLockedForProperty: createTotalLockedForPropertyCaller(contract), getLockedupProperties: createGetLockedupPropertiesCaller(contract), contract: () => contract, } }