@reyaxyz/common 0.168.5 → 0.168.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,5 +6,5 @@
6
6
 
7
7
  | Statements | Branches | Functions | Lines |
8
8
  | --------------------------- | ----------------------- | ------------------------- | ----------------- |
9
- | ![Statements](https://img.shields.io/badge/statements-15.43%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-14.85%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-9.45%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-16.05%25-red.svg?style=flat) |
9
+ | ![Statements](https://img.shields.io/badge/statements-15.04%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-14.85%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-9.21%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-15.62%25-red.svg?style=flat) |
10
10
 
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encodeOptionalMulticall = exports.encodeStrictMulticall = void 0;
4
+ var ethers_1 = require("ethers");
5
+ var MulticallV2_json_1 = require("./abis/MulticallV2.json");
6
+ var encodeMulticall = function (requireSuccess, calls) {
7
+ var functionSignature = 'tryAggregate';
8
+ var parameters = [requireSuccess, calls];
9
+ var INTERFACE = new ethers_1.ethers.Interface(MulticallV2_json_1.abi);
10
+ var calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);
11
+ return calldata;
12
+ };
13
+ var encodeStrictMulticall = function (calls) {
14
+ return encodeMulticall(true, calls);
15
+ };
16
+ exports.encodeStrictMulticall = encodeStrictMulticall;
17
+ var encodeOptionalMulticall = function (calls) {
18
+ return encodeMulticall(false, calls);
19
+ };
20
+ exports.encodeOptionalMulticall = encodeOptionalMulticall;
21
+ //# sourceMappingURL=buildMulticallTx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildMulticallTx.js","sourceRoot":"/","sources":["transactions/buildMulticallTx.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,4DAA8D;AAO9D,IAAM,eAAe,GAAG,UAAC,cAAuB,EAAE,KAAa;IAC7D,IAAM,iBAAiB,GAAG,cAAc,CAAC;IACzC,IAAM,UAAU,GAAsB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IAC9D,IAAM,SAAS,GAAG,IAAI,eAAM,CAAC,SAAS,CAAC,sBAAY,CAAC,CAAC;IACrD,IAAM,QAAQ,GAAG,SAAS,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;IAC7E,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEK,IAAM,qBAAqB,GAAG,UAAC,KAAa;IACjD,OAAA,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC;AAA5B,CAA4B,CAAC;AADlB,QAAA,qBAAqB,yBACH;AAExB,IAAM,uBAAuB,GAAG,UAAC,KAAa;IACnD,OAAA,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC;AAA7B,CAA6B,CAAC;AADnB,QAAA,uBAAuB,2BACJ","sourcesContent":["import { ethers } from 'ethers';\nimport { abi as MulticallAbi } from './abis/MulticallV2.json';\n\nexport type Call = {\n target: string;\n callData: string;\n};\n\nconst encodeMulticall = (requireSuccess: boolean, calls: Call[]): string => {\n const functionSignature = 'tryAggregate';\n const parameters: [boolean, Call[]] = [requireSuccess, calls];\n const INTERFACE = new ethers.Interface(MulticallAbi);\n const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);\n return calldata;\n};\n\nexport const encodeStrictMulticall = (calls: Call[]) =>\n encodeMulticall(true, calls);\n\nexport const encodeOptionalMulticall = (calls: Call[]) =>\n encodeMulticall(false, calls);\n"]}
@@ -10,6 +10,8 @@ var ContractType;
10
10
  ContractType["PERIPHERY_PROXY"] = "periphery_proxy";
11
11
  ContractType["CONDITIONAL_ORDERS_PROXY"] = "conditional_orders_proxy";
12
12
  ContractType["PASSIVE_PERP_PROXY"] = "passive_perp_proxy";
13
+ ContractType["ORACLE_ADAPTERS_PROXY"] = "oracle_adapters_proxy";
14
+ ContractType["MULTICALL"] = "multicall";
13
15
  })(ContractType || (exports.ContractType = ContractType = {}));
14
16
  var addresses = (_a = {},
15
17
  _a[types_1.ReyaChainId.reyaCronos] = (_b = {},
@@ -18,6 +20,8 @@ var addresses = (_a = {},
18
20
  _b[ContractType.PERIPHERY_PROXY] = '0x94ccae812f1647696754412082dd6684c2366a7f',
19
21
  _b[ContractType.CONDITIONAL_ORDERS_PROXY] = '0x5a0ac2f89e0bdeafc5c549e354842210a3e87ca5',
20
22
  _b[ContractType.PASSIVE_PERP_PROXY] = '0x9ec177fed042ef2307928be2f5cdbf663b20244b',
23
+ _b[ContractType.ORACLE_ADAPTERS_PROXY] = '0xc501a2356703cd351703d68963c6f4136120f7cf',
24
+ _b[ContractType.MULTICALL] = '0xd9f0f399f5264faac91476dbd950574726d18633',
21
25
  _b),
22
26
  _a[types_1.ReyaChainId.reyaNetwork] = (_c = {},
23
27
  _c[ContractType.CORE_PROXY] = '0xa763b6a5e09378434406c003dae6487fbbdc1a80',
@@ -25,6 +29,8 @@ var addresses = (_a = {},
25
29
  _c[ContractType.PERIPHERY_PROXY] = '0xcd2869d1eb1bc8991bc55de9e9b779e912faf736',
26
30
  _c[ContractType.CONDITIONAL_ORDERS_PROXY] = '0xfc8c96be87da63cecddbf54abfa7b13ee8044739',
27
31
  _c[ContractType.PASSIVE_PERP_PROXY] = '0x27e5cb712334e101b3c232eb0be198baaa595f5f',
32
+ _c[ContractType.ORACLE_ADAPTERS_PROXY] = '0x32edabc058c1207fe0ec5f8557643c28e4ff379e',
33
+ _c[ContractType.MULTICALL] = '0x82a55eb2346277d85d5d0a60101ebd0f02680b0d',
28
34
  _c),
29
35
  _a);
30
36
  var getAddress = function (chainId, contractName) {
@@ -1 +1 @@
1
- {"version":3,"file":"contractAddresses.js","sourceRoot":"/","sources":["transactions/contractAddresses.ts"],"names":[],"mappings":";;;;AAAA,kCAAgD;AAEhD,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,yCAAyB,CAAA;IACzB,yDAAyC,CAAA;IACzC,mDAAmC,CAAA;IACnC,qEAAqD,CAAA;IACrD,yDAAyC,CAAA;AAC3C,CAAC,EANW,YAAY,4BAAZ,YAAY,QAMvB;AAED,IAAM,SAAS;IACb,GAAC,mBAAW,CAAC,UAAU;QACrB,GAAC,YAAY,CAAC,UAAU,IAAG,4CAA4C;QACvE,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,eAAe,IAC3B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,wBAAwB,IACpC,4CAA4C;QAC9C,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;WAC/C;IACD,GAAC,mBAAW,CAAC,WAAW;QACtB,GAAC,YAAY,CAAC,UAAU,IAAG,4CAA4C;QACvE,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,eAAe,IAC3B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,wBAAwB,IACpC,4CAA4C;QAC9C,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;WAC/C;OACF,CAAC;AACK,IAAM,UAAU,GAAG,UACxB,OAAe,EACf,YAA0B;IAE1B,IAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAEtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CAAC,6CAAsC,UAAU,CAAE,CAAC,CAAC;IACtE,CAAC;IAED,IAAM,gBAAgB,GAAG,SAAS,CAAC,OAAsB,CAAC,CAAC;IAC3D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,kCAA2B,YAAY,cAAW,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACxC,CAAC,CAAC;AAhBW,QAAA,UAAU,cAgBrB","sourcesContent":["import { Address, ReyaChainId } from '../types';\n\nexport enum ContractType {\n CORE_PROXY = 'core_proxy',\n PASSIVE_POOL_PROXY = 'passive_pool_proxy',\n PERIPHERY_PROXY = 'periphery_proxy',\n CONDITIONAL_ORDERS_PROXY = 'conditional_orders_proxy',\n PASSIVE_PERP_PROXY = 'passive_perp_proxy',\n}\n\nconst addresses: Record<ReyaChainId, Record<ContractType, Address>> = {\n [ReyaChainId.reyaCronos]: {\n [ContractType.CORE_PROXY]: '0xc6fb022962e1426f4e0ec9d2f8861c57926e9f72',\n [ContractType.PASSIVE_POOL_PROXY]:\n '0x9a3a664987b88790a6fdc1632e3b607813fd94ff',\n [ContractType.PERIPHERY_PROXY]:\n '0x94ccae812f1647696754412082dd6684c2366a7f',\n [ContractType.CONDITIONAL_ORDERS_PROXY]:\n '0x5a0ac2f89e0bdeafc5c549e354842210a3e87ca5',\n [ContractType.PASSIVE_PERP_PROXY]:\n '0x9ec177fed042ef2307928be2f5cdbf663b20244b',\n },\n [ReyaChainId.reyaNetwork]: {\n [ContractType.CORE_PROXY]: '0xa763b6a5e09378434406c003dae6487fbbdc1a80',\n [ContractType.PASSIVE_POOL_PROXY]:\n '0xb4b77d6180cc14472a9a7bdff01cc2459368d413',\n [ContractType.PERIPHERY_PROXY]:\n '0xcd2869d1eb1bc8991bc55de9e9b779e912faf736',\n [ContractType.CONDITIONAL_ORDERS_PROXY]:\n '0xfc8c96be87da63cecddbf54abfa7b13ee8044739',\n [ContractType.PASSIVE_PERP_PROXY]:\n '0x27e5cb712334e101b3c232eb0be198baaa595f5f',\n },\n};\nexport const getAddress = (\n chainId: number,\n contractName: ContractType,\n): Address => {\n const keyChainId = chainId.toString();\n\n if (!Object.keys(addresses).includes(keyChainId)) {\n throw new Error(`Unspecified addresses for chain id ${keyChainId}`);\n }\n\n const networkAddresses = addresses[chainId as ReyaChainId];\n if (!Object.keys(networkAddresses).includes(contractName)) {\n throw new Error(`Unspecified address for ${contractName} contract`);\n }\n\n return networkAddresses[contractName];\n};\n"]}
1
+ {"version":3,"file":"contractAddresses.js","sourceRoot":"/","sources":["transactions/contractAddresses.ts"],"names":[],"mappings":";;;;AAAA,kCAAgD;AAEhD,IAAY,YAQX;AARD,WAAY,YAAY;IACtB,yCAAyB,CAAA;IACzB,yDAAyC,CAAA;IACzC,mDAAmC,CAAA;IACnC,qEAAqD,CAAA;IACrD,yDAAyC,CAAA;IACzC,+DAA+C,CAAA;IAC/C,uCAAuB,CAAA;AACzB,CAAC,EARW,YAAY,4BAAZ,YAAY,QAQvB;AAED,IAAM,SAAS;IACb,GAAC,mBAAW,CAAC,UAAU;QACrB,GAAC,YAAY,CAAC,UAAU,IAAG,4CAA4C;QACvE,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,eAAe,IAC3B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,wBAAwB,IACpC,4CAA4C;QAC9C,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,qBAAqB,IACjC,4CAA4C;QAC9C,GAAC,YAAY,CAAC,SAAS,IAAG,4CAA4C;WACvE;IACD,GAAC,mBAAW,CAAC,WAAW;QACtB,GAAC,YAAY,CAAC,UAAU,IAAG,4CAA4C;QACvE,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,eAAe,IAC3B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,wBAAwB,IACpC,4CAA4C;QAC9C,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,qBAAqB,IACjC,4CAA4C;QAC9C,GAAC,YAAY,CAAC,SAAS,IAAG,4CAA4C;WACvE;OACF,CAAC;AACK,IAAM,UAAU,GAAG,UACxB,OAAe,EACf,YAA0B;IAE1B,IAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAEtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CAAC,6CAAsC,UAAU,CAAE,CAAC,CAAC;IACtE,CAAC;IAED,IAAM,gBAAgB,GAAG,SAAS,CAAC,OAAsB,CAAC,CAAC;IAC3D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,kCAA2B,YAAY,cAAW,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACxC,CAAC,CAAC;AAhBW,QAAA,UAAU,cAgBrB","sourcesContent":["import { Address, ReyaChainId } from '../types';\n\nexport enum ContractType {\n CORE_PROXY = 'core_proxy',\n PASSIVE_POOL_PROXY = 'passive_pool_proxy',\n PERIPHERY_PROXY = 'periphery_proxy',\n CONDITIONAL_ORDERS_PROXY = 'conditional_orders_proxy',\n PASSIVE_PERP_PROXY = 'passive_perp_proxy',\n ORACLE_ADAPTERS_PROXY = 'oracle_adapters_proxy',\n MULTICALL = 'multicall',\n}\n\nconst addresses: Record<ReyaChainId, Record<ContractType, Address>> = {\n [ReyaChainId.reyaCronos]: {\n [ContractType.CORE_PROXY]: '0xc6fb022962e1426f4e0ec9d2f8861c57926e9f72',\n [ContractType.PASSIVE_POOL_PROXY]:\n '0x9a3a664987b88790a6fdc1632e3b607813fd94ff',\n [ContractType.PERIPHERY_PROXY]:\n '0x94ccae812f1647696754412082dd6684c2366a7f',\n [ContractType.CONDITIONAL_ORDERS_PROXY]:\n '0x5a0ac2f89e0bdeafc5c549e354842210a3e87ca5',\n [ContractType.PASSIVE_PERP_PROXY]:\n '0x9ec177fed042ef2307928be2f5cdbf663b20244b',\n [ContractType.ORACLE_ADAPTERS_PROXY]:\n '0xc501a2356703cd351703d68963c6f4136120f7cf',\n [ContractType.MULTICALL]: '0xd9f0f399f5264faac91476dbd950574726d18633',\n },\n [ReyaChainId.reyaNetwork]: {\n [ContractType.CORE_PROXY]: '0xa763b6a5e09378434406c003dae6487fbbdc1a80',\n [ContractType.PASSIVE_POOL_PROXY]:\n '0xb4b77d6180cc14472a9a7bdff01cc2459368d413',\n [ContractType.PERIPHERY_PROXY]:\n '0xcd2869d1eb1bc8991bc55de9e9b779e912faf736',\n [ContractType.CONDITIONAL_ORDERS_PROXY]:\n '0xfc8c96be87da63cecddbf54abfa7b13ee8044739',\n [ContractType.PASSIVE_PERP_PROXY]:\n '0x27e5cb712334e101b3c232eb0be198baaa595f5f',\n [ContractType.ORACLE_ADAPTERS_PROXY]:\n '0x32edabc058c1207fe0ec5f8557643c28e4ff379e',\n [ContractType.MULTICALL]: '0x82a55eb2346277d85d5d0a60101ebd0f02680b0d',\n },\n};\nexport const getAddress = (\n chainId: number,\n contractName: ContractType,\n): Address => {\n const keyChainId = chainId.toString();\n\n if (!Object.keys(addresses).includes(keyChainId)) {\n throw new Error(`Unspecified addresses for chain id ${keyChainId}`);\n }\n\n const networkAddresses = addresses[chainId as ReyaChainId];\n if (!Object.keys(networkAddresses).includes(contractName)) {\n throw new Error(`Unspecified address for ${contractName} contract`);\n }\n\n return networkAddresses[contractName];\n};\n"]}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encodeStorkFulfillOracleQuery = void 0;
4
+ var ethers_1 = require("ethers");
5
+ var OracleAdaptersProxy_json_1 = require("./abis/OracleAdaptersProxy.json");
6
+ var encodeStorkFulfillOracleQuery = function (signedPricePayload) {
7
+ var functionSignature = 'fulfillOracleQuery';
8
+ var encodedPricePayload = ethers_1.ethers.AbiCoder.defaultAbiCoder().encode([
9
+ 'tuple(address, tuple(string, uint256, uint256), bytes32, bytes32, uint8)',
10
+ ], [
11
+ [
12
+ signedPricePayload.oraclePubKey,
13
+ [
14
+ signedPricePayload.pricePayload.assetPairId,
15
+ String(Math.floor(signedPricePayload.pricePayload.timestamp / 1e9)),
16
+ String(signedPricePayload.pricePayload.price),
17
+ ],
18
+ signedPricePayload.r,
19
+ signedPricePayload.s,
20
+ signedPricePayload.v,
21
+ ],
22
+ ]);
23
+ var parameters = [encodedPricePayload];
24
+ var INTERFACE = new ethers_1.ethers.Interface(OracleAdaptersProxy_json_1.abi);
25
+ var calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);
26
+ return calldata;
27
+ };
28
+ exports.encodeStorkFulfillOracleQuery = encodeStorkFulfillOracleQuery;
29
+ //# sourceMappingURL=encodeStorkUpdateTx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encodeStorkUpdateTx.js","sourceRoot":"/","sources":["transactions/encodeStorkUpdateTx.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,4EAA2E;AAgBpE,IAAM,6BAA6B,GAAG,UAC3C,kBAAsC;IAEtC,IAAM,iBAAiB,GAAW,oBAAoB,CAAC;IACvD,IAAM,mBAAmB,GAAW,eAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC,MAAM,CAC1E;QACE,0EAA0E;KAC3E,EACD;QACE;YACE,kBAAkB,CAAC,YAAY;YAC/B;gBACE,kBAAkB,CAAC,YAAY,CAAC,WAAW;gBAC3C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,YAAY,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC;gBACnE,MAAM,CAAC,kBAAkB,CAAC,YAAY,CAAC,KAAK,CAAC;aAC9C;YACD,kBAAkB,CAAC,CAAC;YACpB,kBAAkB,CAAC,CAAC;YACpB,kBAAkB,CAAC,CAAC;SACrB;KACF,CACF,CAAC;IACF,IAAM,UAAU,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACzC,IAAM,SAAS,GAAG,IAAI,eAAM,CAAC,SAAS,CAAC,8BAAiB,CAAC,CAAC;IAC1D,IAAM,QAAQ,GAAG,SAAS,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;IAC7E,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AA1BW,QAAA,6BAA6B,iCA0BxC","sourcesContent":["import { ethers } from 'ethers';\nimport { abi as OracleAdaptersAbi } from './abis/OracleAdaptersProxy.json';\n\nexport type StorkPricePayload = {\n assetPairId: string;\n timestamp: number;\n price: string;\n};\n\nexport type StorkSignedPayload = {\n oraclePubKey: string;\n pricePayload: StorkPricePayload;\n r: string;\n s: string;\n v: number;\n};\n\nexport const encodeStorkFulfillOracleQuery = (\n signedPricePayload: StorkSignedPayload,\n): string => {\n const functionSignature: string = 'fulfillOracleQuery';\n const encodedPricePayload: string = ethers.AbiCoder.defaultAbiCoder().encode(\n [\n 'tuple(address, tuple(string, uint256, uint256), bytes32, bytes32, uint8)',\n ],\n [\n [\n signedPricePayload.oraclePubKey,\n [\n signedPricePayload.pricePayload.assetPairId,\n String(Math.floor(signedPricePayload.pricePayload.timestamp / 1e9)),\n String(signedPricePayload.pricePayload.price),\n ],\n signedPricePayload.r,\n signedPricePayload.s,\n signedPricePayload.v,\n ],\n ],\n );\n const parameters = [encodedPricePayload];\n const INTERFACE = new ethers.Interface(OracleAdaptersAbi);\n const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);\n return calldata;\n};\n"]}
@@ -34,4 +34,6 @@ __exportStar(require("./txHelpers"), exports);
34
34
  __exportStar(require("./consts"), exports);
35
35
  __exportStar(require("./executeTransaction"), exports);
36
36
  __exportStar(require("./permissions"), exports);
37
+ __exportStar(require("./buildMulticallTx"), exports);
38
+ __exportStar(require("./encodeStorkUpdateTx"), exports);
37
39
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["transactions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,wDAAuD;AAA9C,yGAAA,GAAG,OAAW;AACvB,4DAA8D;AAArD,gHAAA,GAAG,OAAgB;AAC5B,4EAA2E;AAAlE,6HAAA,GAAG,OAAqB;AACjC,wDAA4D;AAAnD,8GAAA,GAAG,OAAgB;AAC5B,6EAAwF;AAA/E,mIAAA,GAAG,OAA8B;AAC1C,sDAAoC;AACpC,mDAAiC;AACjC,yCAAuB;AACvB,0CAAwB;AACxB,8CAA4B;AAC5B,2CAAyB;AACzB,uDAAqC;AACrC,gDAA8B","sourcesContent":["export * from './action';\nexport { abi as CoreAbi } from './abis/CoreProxy.json';\nexport { abi as MulticallAbi } from './abis/MulticallV2.json';\nexport { abi as OracleAdaptersAbi } from './abis/OracleAdaptersProxy.json';\nexport { abi as PeripheryAbi } from './abis/Periphery.json';\nexport { abi as Socket_VaultWithPayloadAbi } from './abis/socket/VaultWithPayload.json';\nexport * from './contractAddresses';\nexport * from './routerCommands';\nexport * from './sign';\nexport * from './trade';\nexport * from './txHelpers';\nexport * from './consts';\nexport * from './executeTransaction';\nexport * from './permissions';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["transactions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,wDAAuD;AAA9C,yGAAA,GAAG,OAAW;AACvB,4DAA8D;AAArD,gHAAA,GAAG,OAAgB;AAC5B,4EAA2E;AAAlE,6HAAA,GAAG,OAAqB;AACjC,wDAA4D;AAAnD,8GAAA,GAAG,OAAgB;AAC5B,6EAAwF;AAA/E,mIAAA,GAAG,OAA8B;AAC1C,sDAAoC;AACpC,mDAAiC;AACjC,yCAAuB;AACvB,0CAAwB;AACxB,8CAA4B;AAC5B,2CAAyB;AACzB,uDAAqC;AACrC,gDAA8B;AAC9B,qDAAmC;AACnC,wDAAsC","sourcesContent":["export * from './action';\nexport { abi as CoreAbi } from './abis/CoreProxy.json';\nexport { abi as MulticallAbi } from './abis/MulticallV2.json';\nexport { abi as OracleAdaptersAbi } from './abis/OracleAdaptersProxy.json';\nexport { abi as PeripheryAbi } from './abis/Periphery.json';\nexport { abi as Socket_VaultWithPayloadAbi } from './abis/socket/VaultWithPayload.json';\nexport * from './contractAddresses';\nexport * from './routerCommands';\nexport * from './sign';\nexport * from './trade';\nexport * from './txHelpers';\nexport * from './consts';\nexport * from './executeTransaction';\nexport * from './permissions';\nexport * from './buildMulticallTx';\nexport * from './encodeStorkUpdateTx';\n"]}
@@ -0,0 +1,7 @@
1
+ export type Call = {
2
+ target: string;
3
+ callData: string;
4
+ };
5
+ export declare const encodeStrictMulticall: (calls: Call[]) => string;
6
+ export declare const encodeOptionalMulticall: (calls: Call[]) => string;
7
+ //# sourceMappingURL=buildMulticallTx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildMulticallTx.d.ts","sourceRoot":"/","sources":["transactions/buildMulticallTx.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,IAAI,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAUF,eAAO,MAAM,qBAAqB,UAAW,IAAI,EAAE,WACrB,CAAC;AAE/B,eAAO,MAAM,uBAAuB,UAAW,IAAI,EAAE,WACtB,CAAC"}
@@ -4,7 +4,9 @@ export declare enum ContractType {
4
4
  PASSIVE_POOL_PROXY = "passive_pool_proxy",
5
5
  PERIPHERY_PROXY = "periphery_proxy",
6
6
  CONDITIONAL_ORDERS_PROXY = "conditional_orders_proxy",
7
- PASSIVE_PERP_PROXY = "passive_perp_proxy"
7
+ PASSIVE_PERP_PROXY = "passive_perp_proxy",
8
+ ORACLE_ADAPTERS_PROXY = "oracle_adapters_proxy",
9
+ MULTICALL = "multicall"
8
10
  }
9
11
  export declare const getAddress: (chainId: number, contractName: ContractType) => Address;
10
12
  //# sourceMappingURL=contractAddresses.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contractAddresses.d.ts","sourceRoot":"/","sources":["transactions/contractAddresses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,MAAM,UAAU,CAAC;AAEhD,oBAAY,YAAY;IACtB,UAAU,eAAe;IACzB,kBAAkB,uBAAuB;IACzC,eAAe,oBAAoB;IACnC,wBAAwB,6BAA6B;IACrD,kBAAkB,uBAAuB;CAC1C;AA0BD,eAAO,MAAM,UAAU,YACZ,MAAM,gBACD,YAAY,KACzB,OAaF,CAAC"}
1
+ {"version":3,"file":"contractAddresses.d.ts","sourceRoot":"/","sources":["transactions/contractAddresses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,MAAM,UAAU,CAAC;AAEhD,oBAAY,YAAY;IACtB,UAAU,eAAe;IACzB,kBAAkB,uBAAuB;IACzC,eAAe,oBAAoB;IACnC,wBAAwB,6BAA6B;IACrD,kBAAkB,uBAAuB;IACzC,qBAAqB,0BAA0B;IAC/C,SAAS,cAAc;CACxB;AAgCD,eAAO,MAAM,UAAU,YACZ,MAAM,gBACD,YAAY,KACzB,OAaF,CAAC"}
@@ -0,0 +1,14 @@
1
+ export type StorkPricePayload = {
2
+ assetPairId: string;
3
+ timestamp: number;
4
+ price: string;
5
+ };
6
+ export type StorkSignedPayload = {
7
+ oraclePubKey: string;
8
+ pricePayload: StorkPricePayload;
9
+ r: string;
10
+ s: string;
11
+ v: number;
12
+ };
13
+ export declare const encodeStorkFulfillOracleQuery: (signedPricePayload: StorkSignedPayload) => string;
14
+ //# sourceMappingURL=encodeStorkUpdateTx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encodeStorkUpdateTx.d.ts","sourceRoot":"/","sources":["transactions/encodeStorkUpdateTx.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,iBAAiB,CAAC;IAChC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,eAAO,MAAM,6BAA6B,uBACpB,kBAAkB,KACrC,MAwBF,CAAC"}
@@ -12,4 +12,6 @@ export * from './txHelpers';
12
12
  export * from './consts';
13
13
  export * from './executeTransaction';
14
14
  export * from './permissions';
15
+ export * from './buildMulticallTx';
16
+ export * from './encodeStorkUpdateTx';
15
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["transactions/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,GAAG,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,GAAG,IAAI,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,GAAG,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,GAAG,IAAI,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACxF,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["transactions/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,GAAG,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,GAAG,IAAI,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,GAAG,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,GAAG,IAAI,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACxF,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/common",
3
- "version": "0.168.5",
3
+ "version": "0.168.7",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -43,5 +43,5 @@
43
43
  "generate:coverage-badges": "npx istanbul-badges-readme --silent"
44
44
  },
45
45
  "packageManager": "pnpm@8.3.1",
46
- "gitHead": "38a8eb3a316010e74dd081bac8286eba6efd56b1"
46
+ "gitHead": "4acfe912b467d56ef689ba244a18df00fbb35321"
47
47
  }
@@ -0,0 +1,21 @@
1
+ import { ethers } from 'ethers';
2
+ import { abi as MulticallAbi } from './abis/MulticallV2.json';
3
+
4
+ export type Call = {
5
+ target: string;
6
+ callData: string;
7
+ };
8
+
9
+ const encodeMulticall = (requireSuccess: boolean, calls: Call[]): string => {
10
+ const functionSignature = 'tryAggregate';
11
+ const parameters: [boolean, Call[]] = [requireSuccess, calls];
12
+ const INTERFACE = new ethers.Interface(MulticallAbi);
13
+ const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);
14
+ return calldata;
15
+ };
16
+
17
+ export const encodeStrictMulticall = (calls: Call[]) =>
18
+ encodeMulticall(true, calls);
19
+
20
+ export const encodeOptionalMulticall = (calls: Call[]) =>
21
+ encodeMulticall(false, calls);
@@ -6,6 +6,8 @@ export enum ContractType {
6
6
  PERIPHERY_PROXY = 'periphery_proxy',
7
7
  CONDITIONAL_ORDERS_PROXY = 'conditional_orders_proxy',
8
8
  PASSIVE_PERP_PROXY = 'passive_perp_proxy',
9
+ ORACLE_ADAPTERS_PROXY = 'oracle_adapters_proxy',
10
+ MULTICALL = 'multicall',
9
11
  }
10
12
 
11
13
  const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
@@ -19,6 +21,9 @@ const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
19
21
  '0x5a0ac2f89e0bdeafc5c549e354842210a3e87ca5',
20
22
  [ContractType.PASSIVE_PERP_PROXY]:
21
23
  '0x9ec177fed042ef2307928be2f5cdbf663b20244b',
24
+ [ContractType.ORACLE_ADAPTERS_PROXY]:
25
+ '0xc501a2356703cd351703d68963c6f4136120f7cf',
26
+ [ContractType.MULTICALL]: '0xd9f0f399f5264faac91476dbd950574726d18633',
22
27
  },
23
28
  [ReyaChainId.reyaNetwork]: {
24
29
  [ContractType.CORE_PROXY]: '0xa763b6a5e09378434406c003dae6487fbbdc1a80',
@@ -30,6 +35,9 @@ const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
30
35
  '0xfc8c96be87da63cecddbf54abfa7b13ee8044739',
31
36
  [ContractType.PASSIVE_PERP_PROXY]:
32
37
  '0x27e5cb712334e101b3c232eb0be198baaa595f5f',
38
+ [ContractType.ORACLE_ADAPTERS_PROXY]:
39
+ '0x32edabc058c1207fe0ec5f8557643c28e4ff379e',
40
+ [ContractType.MULTICALL]: '0x82a55eb2346277d85d5d0a60101ebd0f02680b0d',
33
41
  },
34
42
  };
35
43
  export const getAddress = (
@@ -0,0 +1,44 @@
1
+ import { ethers } from 'ethers';
2
+ import { abi as OracleAdaptersAbi } from './abis/OracleAdaptersProxy.json';
3
+
4
+ export type StorkPricePayload = {
5
+ assetPairId: string;
6
+ timestamp: number;
7
+ price: string;
8
+ };
9
+
10
+ export type StorkSignedPayload = {
11
+ oraclePubKey: string;
12
+ pricePayload: StorkPricePayload;
13
+ r: string;
14
+ s: string;
15
+ v: number;
16
+ };
17
+
18
+ export const encodeStorkFulfillOracleQuery = (
19
+ signedPricePayload: StorkSignedPayload,
20
+ ): string => {
21
+ const functionSignature: string = 'fulfillOracleQuery';
22
+ const encodedPricePayload: string = ethers.AbiCoder.defaultAbiCoder().encode(
23
+ [
24
+ 'tuple(address, tuple(string, uint256, uint256), bytes32, bytes32, uint8)',
25
+ ],
26
+ [
27
+ [
28
+ signedPricePayload.oraclePubKey,
29
+ [
30
+ signedPricePayload.pricePayload.assetPairId,
31
+ String(Math.floor(signedPricePayload.pricePayload.timestamp / 1e9)),
32
+ String(signedPricePayload.pricePayload.price),
33
+ ],
34
+ signedPricePayload.r,
35
+ signedPricePayload.s,
36
+ signedPricePayload.v,
37
+ ],
38
+ ],
39
+ );
40
+ const parameters = [encodedPricePayload];
41
+ const INTERFACE = new ethers.Interface(OracleAdaptersAbi);
42
+ const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);
43
+ return calldata;
44
+ };
@@ -12,3 +12,5 @@ export * from './txHelpers';
12
12
  export * from './consts';
13
13
  export * from './executeTransaction';
14
14
  export * from './permissions';
15
+ export * from './buildMulticallTx';
16
+ export * from './encodeStorkUpdateTx';