{"version":3,"file":"lazer_price.mjs","names":[],"sources":["../../../src/contracts/deepbook_predict_math/lazer_price.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/**\n * A Pyth Lazer price decoded from a verified update, for Predict's order-flow\n * commit.\n *\n * A `LazerPrice` is built only from a `pyth_lazer::update::Update`, which only\n * Pyth's verifier produces, so holding one proves a Pyth signature over its feed,\n * channel, timestamps, and price. It has `copy` and `drop` but not `store`, so it\n * lives within one transaction. The decode is Predict v4's queue commit decode: it\n * aborts on an update that does not carry the requested feed or lacks its price,\n * exponent, or feed-update-time property, because the caller then passed the wrong\n * update, and it returns `none` only when the feed has no usable price at that\n * tick: an empty price or update time, or a price that does not normalize to\n * Predict's pricing-safe 1e9 spot.\n */\n\nimport { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nimport { U64 } from '../../bcs/integers.js';\nimport { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';\nconst $moduleName = '@local-pkg/deepbook_predict_math::lazer_price';\nexport const LazerPrice = new MoveStruct({\n\tname: `${$moduleName}::LazerPrice`,\n\tfields: {\n\t\tfeed_id: bcs.u32(),\n\t\t/**\n\t\t * A Lazer channel id: `channel_fixed_rate_50ms!()`, `channel_fixed_rate_200ms!()`,\n\t\t * or `1` for real-time.\n\t\t */\n\t\tchannel: bcs.u8(),\n\t\t/** The update's timestamp, in µs. */\n\t\tenvelope_us: U64,\n\t\t/** The feed's own update time, in µs. Never after the envelope. */\n\t\tgeneration_us: U64,\n\t\t/**\n\t\t * The price normalized to 1e9, rounded down when the source is finer; positive and\n\t\t * at most `u64::MAX / 100`.\n\t\t */\n\t\tspot: U64,\n\t},\n});\nexport interface FromUpdateArguments {\n\tupdate: TransactionArgument;\n\tfeedId: RawTransactionArgument<number>;\n}\nexport interface FromUpdateOptions {\n\tpackage?: string;\n\targuments:\n\t\tFromUpdateArguments | [update: TransactionArgument, feedId: RawTransactionArgument<number>];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\n/**\n * Decode `feed_id` from a verified Lazer update. `none` when the feed's price or\n * update time is empty at this tick, or its price does not normalize to a\n * pricing-safe spot. Aborts `EFeedMissing` when the update does not carry the feed\n * and `EPropertyNotRequested` when the feed lacks the price, exponent, or\n * update-time property, because the caller then passed the wrong update, and\n * `EGenerationAfterEnvelope` when the feed claims an update time after the\n * envelope that carries it.\n *\n * Uses Lazer's v1 `Update`, which Pyth marked deprecated on Mainnet but still\n * serves; a later library upgrade adds a constructor for v2.\n */\nexport function fromUpdate(options: FromUpdateOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = [null, 'u32'] satisfies (string | null)[];\n\tconst parameterNames = ['update', 'feedId'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'lazer_price',\n\t\t\tfunction: 'from_update',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface FeedIdArguments {\n\tprice: TransactionArgument;\n}\nexport interface FeedIdOptions {\n\tpackage?: string;\n\targuments: FeedIdArguments | [price: TransactionArgument];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\nexport function feedId(options: FeedIdOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['price'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'lazer_price',\n\t\t\tfunction: 'feed_id',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface ChannelArguments {\n\tprice: TransactionArgument;\n}\nexport interface ChannelOptions {\n\tpackage?: string;\n\targuments: ChannelArguments | [price: TransactionArgument];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\nexport function channel(options: ChannelOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['price'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'lazer_price',\n\t\t\tfunction: 'channel',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface EnvelopeUsArguments {\n\tprice: TransactionArgument;\n}\nexport interface EnvelopeUsOptions {\n\tpackage?: string;\n\targuments: EnvelopeUsArguments | [price: TransactionArgument];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\nexport function envelopeUs(options: EnvelopeUsOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['price'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'lazer_price',\n\t\t\tfunction: 'envelope_us',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface GenerationUsArguments {\n\tprice: TransactionArgument;\n}\nexport interface GenerationUsOptions {\n\tpackage?: string;\n\targuments: GenerationUsArguments | [price: TransactionArgument];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\nexport function generationUs(options: GenerationUsOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['price'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'lazer_price',\n\t\t\tfunction: 'generation_us',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface SpotArguments {\n\tprice: TransactionArgument;\n}\nexport interface SpotOptions {\n\tpackage?: string;\n\targuments: SpotArguments | [price: TransactionArgument];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\nexport function spot(options: SpotOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['price'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'lazer_price',\n\t\t\tfunction: 'spot',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,cAAc;AACpB,MAAa,aAAa,IAAI,WAAW;CACxC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,SAAS,IAAI,KAAK;EAKlB,SAAS,IAAI,IAAI;EAEjB,aAAa;EAEb,eAAe;EAKf,MAAM;EACN;CACD,CAAC;;;;;;;;;;;;;AAyBF,SAAgB,WAAW,SAA4B;CACtD,MAAM,iBACL,QAAQ,WAAW,QAAQ,QAAQ,wBAAwB;CAC5D,MAAM,iBAAiB,CAAC,MAAM,MAAM;CACpC,MAAM,iBAAiB,CAAC,UAAU,SAAS;AAC3C,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,CAAC;;AAYJ,SAAgB,OAAO,SAAwB;CAC9C,MAAM,iBACL,QAAQ,WAAW,QAAQ,QAAQ,wBAAwB;CAC5D,MA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