{"version":3,"file":"Protocol.cjs","sources":["../../../../../src/plugins/protocolModule/models/Protocol.ts"],"sourcesContent":["import { PublicKey } from '@solana/web3.js';\nimport {\n  FeeParameters,\n  Instrument,\n  PrintTradeProvider,\n} from '@convergence-rfq/rfq';\n\nimport { ProtocolAccount } from '../accounts';\nimport { assert } from '../../../utils/assert';\nimport { removeDecimals } from '@/utils/conversions';\n\n/**\n * This model captures all the relevant information about an RFQ\n * on the Solana blockchain. That includes the Rfq's leg accounts.\n *\n * @group Models\n */\nexport type Protocol = {\n  /** A model identifier to distinguish models in the SDK. */\n  readonly model: 'protocol';\n\n  /** The address of the protocol. */\n  readonly address: PublicKey;\n\n  /** The authority of the protocol. */\n  readonly authority: PublicKey;\n\n  /** If the protocol is active. */\n  readonly active: boolean;\n\n  /** The settlement fees for the protocol. */\n  readonly settleFees: FeeParameters;\n\n  /** The default fees for the protocol */\n  readonly defaultFees: FeeParameters;\n\n  /** Sol fee to add a user asset */\n  readonly assetAddFee: number;\n\n  /** The address of the risk engine */\n  readonly riskEngine: PublicKey;\n\n  /** The address of the collateral mint. */\n  readonly collateralMint: PublicKey;\n\n  /** The procotol instruments. */\n  readonly instruments: Instrument[];\n\n  /** The procotol instruments. */\n  readonly printTradeProviders: PrintTradeProvider[];\n};\n\n/** @group Model Helpers */\nexport const isProtocol = (value: any): value is Protocol =>\n  typeof value === 'object' && value.model === 'protocol';\n\n/** @group Model Helpers */\nexport function assertProtocol(value: any): asserts value is Protocol {\n  assert(isProtocol(value), 'Expected Protocol model');\n}\n\n/** @group Model Helpers */\nexport const toProtocol = (account: ProtocolAccount): Protocol => ({\n  model: 'protocol',\n  address: account.publicKey,\n  authority: account.data.authority,\n  active: account.data.active,\n  settleFees: account.data.settleFees,\n  defaultFees: account.data.defaultFees,\n  assetAddFee: removeDecimals(account.data.assetAddFee, 9),\n  riskEngine: account.data.riskEngine,\n  collateralMint: account.data.collateralMint,\n  instruments: account.data.instruments,\n  printTradeProviders: account.data.printTradeProviders,\n});\n"],"names":["isProtocol","value","_typeof","model","assertProtocol","assert","toProtocol","account","address","publicKey","authority","data","active","settleFees","defaultFees","assetAddFee","removeDecimals","riskEngine","collateralMint","instruments","printTradeProviders"],"mappings":";;;;;;;;AAWA;AACA;AACA;AACA;AACA;AACA;;AAoCA;IACaA,UAAU,GAAG,SAAbA,UAAUA,CAAIC,KAAU,EAAA;EAAA,OACnCC,mCAAA,CAAOD,KAAK,CAAK,KAAA,QAAQ,IAAIA,KAAK,CAACE,KAAK,KAAK,UAAU,CAAA;AAAA,EAAA;;AAEzD;AACO,SAASC,cAAcA,CAACH,KAAU,EAA6B;AACpEI,EAAAA,aAAM,CAACL,UAAU,CAACC,KAAK,CAAC,EAAE,yBAAyB,CAAC,CAAA;AACtD,CAAA;;AAEA;IACaK,UAAU,GAAG,SAAbA,UAAUA,CAAIC,OAAwB,EAAA;EAAA,OAAgB;AACjEJ,IAAAA,KAAK,EAAE,UAAU;IACjBK,OAAO,EAAED,OAAO,CAACE,SAAS;AAC1BC,IAAAA,SAAS,EAAEH,OAAO,CAACI,IAAI,CAACD,SAAS;AACjCE,IAAAA,MAAM,EAAEL,OAAO,CAACI,IAAI,CAACC,MAAM;AAC3BC,IAAAA,UAAU,EAAEN,OAAO,CAACI,IAAI,CAACE,UAAU;AACnCC,IAAAA,WAAW,EAAEP,OAAO,CAACI,IAAI,CAACG,WAAW;IACrCC,WAAW,EAAEC,0BAAc,CAACT,OAAO,CAACI,IAAI,CAACI,WAAW,EAAE,CAAC,CAAC;AACxDE,IAAAA,UAAU,EAAEV,OAAO,CAACI,IAAI,CAACM,UAAU;AACnCC,IAAAA,cAAc,EAAEX,OAAO,CAACI,IAAI,CAACO,cAAc;AAC3CC,IAAAA,WAAW,EAAEZ,OAAO,CAACI,IAAI,CAACQ,WAAW;AACrCC,IAAAA,mBAAmB,EAAEb,OAAO,CAACI,IAAI,CAACS,mBAAAA;GACnC,CAAA;AAAA;;;;;;"}