UNPKG

@knine-sdk/contracts

Version:

Contracts for Knine projects. Part of Knine JS SDK

55 lines (52 loc) 3.8 kB
import { AggregatorAbi__factory } from './generated/factories/AggregatorAbi__factory.js'; import { WithdrawalQueueAbi__factory } from './generated/factories/WithdrawalQueueAbi__factory.js'; import { Erc20Abi__factory } from './generated/factories/Erc20Abi__factory.js'; import { NodeOperatorRegistryAbi__factory } from './generated/factories/NodeOperatorRegistryAbi__factory.js'; import { UnstBoneAbi__factory } from './generated/factories/UnstBoneAbi__factory.js'; import { InstantPoolAbi__factory } from './generated/factories/InstantPoolAbi__factory.js'; import { KnboneAbi__factory } from './generated/factories/KnboneAbi__factory.js'; import { ShibariumKnBoneAbi__factory } from './generated/factories/ShibariumKnBoneAbi__factory.js'; import { StakeManagerAbi__factory } from './generated/factories/StakeManagerAbi__factory.js'; import { RealYieldStakingAbi__factory } from './generated/factories/RealYieldStakingAbi__factory.js'; import { VestingAbi__factory } from './generated/factories/VestingAbi__factory.js'; import { FarmingPoolAbi__factory } from './generated/factories/FarmingPoolAbi__factory.js'; import { LpTokenAbi__factory } from './generated/factories/LpTokenAbi__factory.js'; import { FarmingFactoryAbi__factory } from './generated/factories/FarmingFactoryAbi__factory.js'; import { KnineMintableAbi__factory } from './generated/factories/KnineMintableAbi__factory.js'; const createContractGetter = (factory) => { const providerCache = new WeakMap(); return (address, signerOrProvider, cacheSeed = 0) => { const cacheByAddressKey = `${address}-${cacheSeed}`; let cacheByAddress = providerCache.get(signerOrProvider); let contract = cacheByAddress === null || cacheByAddress === void 0 ? void 0 : cacheByAddress[cacheByAddressKey]; if (!cacheByAddress) { cacheByAddress = {}; providerCache.set(signerOrProvider, cacheByAddress); } if (!contract) { contract = factory.connect(address, signerOrProvider); cacheByAddress[cacheByAddressKey] = contract; } return contract; }; }; // TODO: remove unused contracts // lido const getAggregatorContract = createContractGetter(AggregatorAbi__factory); const getWithdrawalQueueContract = createContractGetter(WithdrawalQueueAbi__factory); // BASE const getERC20Contract = createContractGetter(Erc20Abi__factory); // KNINE contracts const getNodeOperatorRegistryContract = createContractGetter(NodeOperatorRegistryAbi__factory); const getUstBoneContract = createContractGetter(UnstBoneAbi__factory); const getInstantPoolContract = createContractGetter(InstantPoolAbi__factory); const getKnBoneContract = createContractGetter(KnboneAbi__factory); const getShibariumKnBoneContract = createContractGetter(ShibariumKnBoneAbi__factory); const getStakeManagerContract = createContractGetter(StakeManagerAbi__factory); const getRealYieldStakingContract = createContractGetter(RealYieldStakingAbi__factory); const getVestingContract = createContractGetter(VestingAbi__factory); const getFarmingPoolContract = createContractGetter(FarmingPoolAbi__factory); const getLpTokenContract = createContractGetter(LpTokenAbi__factory); const getFarmingFactoryContract = createContractGetter(FarmingFactoryAbi__factory); const getKnineMintableContract = createContractGetter(KnineMintableAbi__factory); export { createContractGetter, getAggregatorContract, getERC20Contract, getFarmingFactoryContract, getFarmingPoolContract, getInstantPoolContract, getKnBoneContract, getKnineMintableContract, getLpTokenContract, getNodeOperatorRegistryContract, getRealYieldStakingContract, getShibariumKnBoneContract, getStakeManagerContract, getUstBoneContract, getVestingContract, getWithdrawalQueueContract };