import type { AnchorDefined, AnchorTypes } from "@saberhq/anchor-contrib"; import type { PublicKey } from "@solana/web3.js"; import type Decimal from "decimal.js"; import type { CremaPositionWrapperIDL } from "../idls/crema_position_wrapper"; import { CremaPositionWrapperJSON } from "../idls/crema_position_wrapper"; export * from "../idls/crema_position_wrapper"; export type PositionWrapperTypes = AnchorTypes< CremaPositionWrapperIDL, { positionWrapper: PositionWrapperData; position: PositionData; } >; type Accounts = PositionWrapperTypes["Accounts"]; export type PositionWrapperData = Accounts["PositionWrapper"]; export type PositionData = Accounts["Position"]; export type PositionWrapperError = PositionWrapperTypes["Error"]; export type PositionWrapperProgram = PositionWrapperTypes["Program"]; export type PositionWrapperDefs = AnchorDefined; export interface PositionWrapperInfo extends PositionWrapperData { address: PublicKey; } export interface PositionWrapperDetail extends PositionWrapperInfo { totalTVL: Decimal; totalAmountA: Decimal; totalAmountB: Decimal; effectiveLiquity: Decimal; } export const POSITION_ACCOUNT_SIZE = 306; export const WRAPPER_ACCOUNT_SIZE = 313; export const PositionWrapperErrors = (function (): Map { const m: Map = new Map(); CremaPositionWrapperJSON.errors.forEach((v) => { m.set(v.code, v.msg); }); return m; })();