{"version":3,"file":"oracle.mjs","names":["type_name.TypeName","vec_map.VecMap"],"sources":["../../../src/contracts/deepbook_margin/oracle.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/** Oracle module for margin trading. */\n\nimport { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nimport { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';\nimport * as type_name from './deps/std/type_name.js';\nimport * as vec_map from './deps/sui/vec_map.js';\nconst $moduleName = '@deepbook/margin::oracle';\nexport const CoinTypeData = new MoveStruct({\n\tname: `${$moduleName}::CoinTypeData`,\n\tfields: {\n\t\tdecimals: bcs.u8(),\n\t\tprice_feed_id: bcs.vector(bcs.u8()),\n\t\ttype_name: type_name.TypeName,\n\t\tmax_conf_bps: bcs.u64(),\n\t\tmax_ewma_difference_bps: bcs.u64(),\n\t},\n});\nexport const PythConfig = new MoveStruct({\n\tname: `${$moduleName}::PythConfig`,\n\tfields: {\n\t\tcurrencies: vec_map.VecMap(type_name.TypeName, CoinTypeData),\n\t\tmax_age_secs: bcs.u64(),\n\t},\n});\nexport const ConversionConfig = new MoveStruct({\n\tname: `${$moduleName}::ConversionConfig`,\n\tfields: {\n\t\ttarget_decimals: bcs.u8(),\n\t\tbase_decimals: bcs.u8(),\n\t\tpyth_price: bcs.u64(),\n\t\tpyth_decimals: bcs.u8(),\n\t},\n});\nexport const PythReading = new MoveStruct({\n\tname: `${$moduleName}::PythReading`,\n\tfields: {\n\t\tprice: bcs.u64(),\n\t\tdecimals: bcs.u8(),\n\t\t/**\n\t\t * `some` only for validated reads. The confidence bound is a _pricing_ guard, not\n\t\t * a read guard: it is asserted in `price_config`, so a reading taken purely for\n\t\t * telemetry (the deposit event) is never rejected for a wide interval. Unvalidated\n\t\t * reads carry `none` and skip the check, as they always have.\n\t\t */\n\t\tconf: bcs.option(bcs.u64()),\n\t\t/**\n\t\t * The asset this price is _for_, stamped by the reader from the same config row\n\t\t * the feed id was checked against. `price_config` asserts it matches the type it\n\t\t * is being consumed as, so a reading routed to the wrong leg aborts instead of\n\t\t * silently mis-pricing. Without it, transposing the base and quote readings at a\n\t\t * call site is invisible: both are well-formed, both pass every other guard.\n\t\t */\n\t\tcoin_type: type_name.TypeName,\n\t},\n});\nexport interface NewCoinTypeDataArguments {\n\tCoinMetadata: RawTransactionArgument<string>;\n\tPriceFeedId: RawTransactionArgument<Array<number>>;\n\tMaxConfBps: RawTransactionArgument<number | bigint>;\n\tMaxEwmaDifferenceBps: RawTransactionArgument<number | bigint>;\n}\nexport interface NewCoinTypeDataOptions {\n\tpackage?: string;\n\targuments:\n\t\t| NewCoinTypeDataArguments\n\t\t| [\n\t\t\t\tCoinMetadata: RawTransactionArgument<string>,\n\t\t\t\tPriceFeedId: RawTransactionArgument<Array<number>>,\n\t\t\t\tMaxConfBps: RawTransactionArgument<number | bigint>,\n\t\t\t\tMaxEwmaDifferenceBps: RawTransactionArgument<number | bigint>,\n\t\t  ];\n\ttypeArguments: [string];\n}\n/**\n * Superseded by `new_coin_type_data_from_currency`, which reads decimals from\n * `Currency` instead of trusting the caller-supplied `CoinMetadata`. Retained as\n * an aborting stub because it is public in the deployed package: a `compatible`\n * upgrade cannot drop a public function.\n */\nexport function newCoinTypeData(options: NewCoinTypeDataOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null, 'vector<u8>', 'u64', 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['CoinMetadata', 'PriceFeedId', 'MaxConfBps', 'MaxEwmaDifferenceBps'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'oracle',\n\t\t\tfunction: 'new_coin_type_data',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface NewCoinTypeDataFromCurrencyArguments {\n\tcurrency: RawTransactionArgument<string>;\n\tpriceFeedId: RawTransactionArgument<Array<number>>;\n\tmaxConfBps: RawTransactionArgument<number | bigint>;\n\tmaxEwmaDifferenceBps: RawTransactionArgument<number | bigint>;\n}\nexport interface NewCoinTypeDataFromCurrencyOptions {\n\tpackage?: string;\n\targuments:\n\t\t| NewCoinTypeDataFromCurrencyArguments\n\t\t| [\n\t\t\t\tcurrency: RawTransactionArgument<string>,\n\t\t\t\tpriceFeedId: RawTransactionArgument<Array<number>>,\n\t\t\t\tmaxConfBps: RawTransactionArgument<number | bigint>,\n\t\t\t\tmaxEwmaDifferenceBps: RawTransactionArgument<number | bigint>,\n\t\t  ];\n\ttypeArguments: [string];\n}\n/**\n * Creates a new CoinTypeData struct of type T. Uses Currency to avoid any errors\n * in decimals.\n */\nexport function newCoinTypeDataFromCurrency(options: NewCoinTypeDataFromCurrencyOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null, 'vector<u8>', 'u64', 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['currency', 'priceFeedId', 'maxConfBps', 'maxEwmaDifferenceBps'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'oracle',\n\t\t\tfunction: 'new_coin_type_data_from_currency',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface NewPythConfigArguments {\n\tsetups: TransactionArgument;\n\tmaxAgeSecs: RawTransactionArgument<number | bigint>;\n}\nexport interface NewPythConfigOptions {\n\tpackage?: string;\n\targuments:\n\t\t| NewPythConfigArguments\n\t\t| [setups: TransactionArgument, maxAgeSecs: RawTransactionArgument<number | bigint>];\n}\n/**\n * Creates a new PythConfig struct. Can be attached by the Admin to MarginRegistry\n * to allow oracle to work.\n */\nexport function newPythConfig(options: NewPythConfigOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = ['vector<null>', 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['setups', 'maxAgeSecs'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'oracle',\n\t\t\tfunction: 'new_pyth_config',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\n"],"mappings":";;;;;;;;;;AAWA,MAAM,cAAc;AACpB,MAAa,eAAe,IAAI,WAAW;CAC1C,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,UAAU,IAAI,IAAI;EAClB,eAAe,IAAI,OAAO,IAAI,IAAI,CAAC;EACnC,WAAWA;EACX,cAAc,IAAI,KAAK;EACvB,yBAAyB,IAAI,KAAK;EAClC;CACD,CAAC;AACF,MAAa,aAAa,IAAI,WAAW;CACxC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,YAAYC,OAAeD,UAAoB,aAAa;EAC5D,cAAc,IAAI,KAAK;EACvB;CACD,CAAC;AACF,MAAa,mBAAmB,IAAI,WAAW;CAC9C,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,iBAAiB,IAAI,IAAI;EACzB,eAAe,IAAI,IAAI;EACvB,YAAY,IAAI,KAAK;EACrB,eAAe,IAAI,IAAI;EACvB;CACD,CAAC;AACF,MAAa,cAAc,IAAI,WAAW;CACzC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,OAAO,IAAI,KAAK;EAChB,UAAU,IAAI,IAAI;EAOlB,MAAM,IAAI,OAAO,IAAI,KAAK,CAAC;EAQ3B,WAAWA;EACX;CACD,CAAC;;;;;AA4DF,SAAgB,4BAA4B,SAA6C;CACxF,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB;EAAC;EAAM;EAAc;EAAO;EAAM;CACzD,MAAM,iBAAiB;EAAC;EAAY;EAAe;EAAc;EAAuB;AACxF,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,eAAe,QAAQ;EACvB,CAAC;;;;;;AAgBJ,SAAgB,cAAc,SAA+B;CAC5D,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB,CAAC,gBAAgB,MAAM;CAC9C,MAAM,iBAAiB,CAAC,UAAU,aAAa;AAC/C,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,CAAC"}