@evaafi/sdk 0.9.0 → 0.9.1

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.
Files changed (117) hide show
  1. package/dist/api/feeds.d.ts +16 -24
  2. package/dist/api/feeds.js +22 -49
  3. package/dist/api/math.d.ts +1 -1
  4. package/dist/api/math.js +55 -38
  5. package/dist/api/parser.d.ts +2 -2
  6. package/dist/api/parser.js +3 -3
  7. package/dist/api/parsers/PythOracleParser.d.ts +3 -2
  8. package/dist/api/parsers/PythOracleParser.js +2 -1
  9. package/dist/api/prices.d.ts +1 -0
  10. package/dist/api/prices.js +2 -1
  11. package/dist/constants/general/index.d.ts +25 -11
  12. package/dist/constants/general/index.js +15 -1
  13. package/dist/constants/pools/mainnet.js +20 -18
  14. package/dist/constants/pools/testnet.js +14 -6
  15. package/dist/contracts/AbstractMaster.d.ts +239 -127
  16. package/dist/contracts/AbstractMaster.js +101 -16
  17. package/dist/contracts/ClassicMaster.d.ts +12 -12
  18. package/dist/contracts/PythMaster.d.ts +41 -24
  19. package/dist/contracts/PythMaster.js +61 -76
  20. package/dist/contracts/PythOracle.d.ts +16 -0
  21. package/dist/contracts/PythOracle.js +19 -0
  22. package/dist/contracts/index.d.ts +1 -0
  23. package/dist/contracts/index.js +1 -0
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.js +1 -1
  26. package/dist/{prices → oracles}/Types.d.ts +1 -4
  27. package/dist/oracles/collectors/AbstractCollector.d.ts +10 -0
  28. package/dist/oracles/collectors/AbstractCollector.js +6 -0
  29. package/dist/oracles/collectors/ClassicCollector.d.ts +22 -0
  30. package/dist/oracles/collectors/ClassicCollector.js +192 -0
  31. package/dist/oracles/collectors/PythCollector.d.ts +27 -0
  32. package/dist/oracles/collectors/PythCollector.js +252 -0
  33. package/dist/oracles/collectors/index.d.ts +3 -0
  34. package/dist/oracles/collectors/index.js +19 -0
  35. package/dist/{prices → oracles}/index.d.ts +2 -3
  36. package/dist/{prices → oracles}/index.js +2 -3
  37. package/dist/oracles/prices/AbstractPrices.d.ts +33 -0
  38. package/dist/oracles/prices/AbstractPrices.js +40 -0
  39. package/dist/oracles/prices/ClassicPrices.d.ts +19 -0
  40. package/dist/oracles/prices/ClassicPrices.js +48 -0
  41. package/dist/oracles/prices/PythPrices.d.ts +18 -0
  42. package/dist/oracles/prices/PythPrices.js +32 -0
  43. package/dist/oracles/prices/index.d.ts +3 -0
  44. package/dist/oracles/prices/index.js +19 -0
  45. package/dist/{prices → oracles}/utils.d.ts +7 -1
  46. package/dist/{prices → oracles}/utils.js +10 -1
  47. package/dist/rewards/RewardMaster.d.ts +1 -0
  48. package/dist/rewards/RewardUser.d.ts +1 -0
  49. package/dist/types/Master.d.ts +5 -5
  50. package/dist/types/MasterRewards.d.ts +1 -0
  51. package/dist/types/UserRewards.d.ts +1 -0
  52. package/dist/utils/sha256BigInt.d.ts +1 -0
  53. package/package.json +2 -3
  54. package/src/api/feeds.ts +24 -60
  55. package/src/api/math.ts +118 -90
  56. package/src/api/parser.ts +5 -5
  57. package/src/api/parsers/PythOracleParser.ts +6 -2
  58. package/src/api/prices.ts +2 -1
  59. package/src/constants/general/index.ts +16 -1
  60. package/src/constants/pools/mainnet.ts +20 -35
  61. package/src/constants/pools/testnet.ts +17 -8
  62. package/src/contracts/AbstractMaster.ts +272 -144
  63. package/src/contracts/ClassicMaster.ts +12 -12
  64. package/src/contracts/PythMaster.ts +130 -123
  65. package/src/contracts/PythOracle.ts +20 -0
  66. package/src/contracts/index.ts +2 -0
  67. package/src/index.ts +1 -1
  68. package/src/{prices → oracles}/Types.ts +0 -5
  69. package/src/oracles/collectors/AbstractCollector.ts +22 -0
  70. package/src/oracles/collectors/ClassicCollector.ts +263 -0
  71. package/src/oracles/collectors/PythCollector.ts +358 -0
  72. package/src/oracles/collectors/index.ts +3 -0
  73. package/src/{prices → oracles}/index.ts +2 -3
  74. package/src/oracles/prices/AbstractPrices.ts +59 -0
  75. package/src/oracles/prices/ClassicPrices.ts +52 -0
  76. package/src/oracles/prices/PythPrices.ts +40 -0
  77. package/src/oracles/prices/index.ts +3 -0
  78. package/src/{prices → oracles}/utils.ts +12 -1
  79. package/src/types/Master.ts +4 -6
  80. package/dist/api/pyth.d.ts +0 -16
  81. package/dist/api/pyth.js +0 -35
  82. package/dist/constants/assets.d.ts +0 -48
  83. package/dist/constants/assets.js +0 -176
  84. package/dist/constants/general.d.ts +0 -67
  85. package/dist/constants/general.js +0 -75
  86. package/dist/constants/pools.d.ts +0 -13
  87. package/dist/constants/pools.js +0 -120
  88. package/dist/contracts/MasterContract.d.ts +0 -156
  89. package/dist/contracts/MasterContract.js +0 -260
  90. package/dist/prices/Oracle.interface.d.ts +0 -9
  91. package/dist/prices/Oracle.interface.js +0 -2
  92. package/dist/prices/Prices.d.ts +0 -11
  93. package/dist/prices/Prices.js +0 -53
  94. package/dist/prices/PricesCollector.d.ts +0 -22
  95. package/dist/prices/PricesCollector.js +0 -146
  96. package/dist/prices/PythCollector.d.ts +0 -22
  97. package/dist/prices/PythCollector.js +0 -217
  98. package/src/prices/Oracle.interface.ts +0 -18
  99. package/src/prices/Prices.ts +0 -45
  100. package/src/prices/PricesCollector.ts +0 -169
  101. package/src/prices/PythCollector.ts +0 -294
  102. /package/dist/{prices → oracles}/Types.js +0 -0
  103. /package/dist/{prices → oracles}/constants.d.ts +0 -0
  104. /package/dist/{prices → oracles}/constants.js +0 -0
  105. /package/dist/{prices → oracles}/sources/Backend.d.ts +0 -0
  106. /package/dist/{prices → oracles}/sources/Backend.js +0 -0
  107. /package/dist/{prices → oracles}/sources/Icp.d.ts +0 -0
  108. /package/dist/{prices → oracles}/sources/Icp.js +0 -0
  109. /package/dist/{prices → oracles}/sources/PriceSource.d.ts +0 -0
  110. /package/dist/{prices → oracles}/sources/PriceSource.js +0 -0
  111. /package/dist/{prices → oracles}/sources/index.d.ts +0 -0
  112. /package/dist/{prices → oracles}/sources/index.js +0 -0
  113. /package/src/{prices → oracles}/constants.ts +0 -0
  114. /package/src/{prices → oracles}/sources/Backend.ts +0 -0
  115. /package/src/{prices → oracles}/sources/Icp.ts +0 -0
  116. /package/src/{prices → oracles}/sources/PriceSource.ts +0 -0
  117. /package/src/{prices → oracles}/sources/index.ts +0 -0
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClassicPrices = exports.ClassicPricesOffset = exports.ClassicPricesMode = void 0;
4
+ const core_1 = require("@ton/core");
5
+ const AbstractPrices_1 = require("./AbstractPrices");
6
+ var ClassicPricesMode;
7
+ (function (ClassicPricesMode) {
8
+ ClassicPricesMode["SPOT"] = "spot";
9
+ ClassicPricesMode["TWAP"] = "twap";
10
+ })(ClassicPricesMode || (exports.ClassicPricesMode = ClassicPricesMode = {}));
11
+ exports.ClassicPricesOffset = {
12
+ [ClassicPricesMode.SPOT]: 1n,
13
+ [ClassicPricesMode.TWAP]: 0n,
14
+ };
15
+ class ClassicPrices extends AbstractPrices_1.AbstractPrices {
16
+ constructor(params) {
17
+ super(params);
18
+ this.params = params;
19
+ }
20
+ static createEmptyTwapPrices() {
21
+ return new ClassicPrices({
22
+ mode: ClassicPricesMode.TWAP,
23
+ dict: core_1.Dictionary.empty(),
24
+ dataCell: core_1.Cell.EMPTY,
25
+ minPublishTime: undefined,
26
+ maxPublishTime: undefined,
27
+ });
28
+ }
29
+ static createEmptySpotPrices() {
30
+ return new ClassicPrices({
31
+ mode: ClassicPricesMode.SPOT,
32
+ dict: core_1.Dictionary.empty(),
33
+ dataCell: core_1.Cell.EMPTY,
34
+ minPublishTime: undefined,
35
+ maxPublishTime: undefined,
36
+ });
37
+ }
38
+ static createEmptyPrices() {
39
+ return new ClassicPrices({
40
+ mode: undefined,
41
+ dict: core_1.Dictionary.empty(),
42
+ dataCell: core_1.Cell.EMPTY,
43
+ minPublishTime: undefined,
44
+ maxPublishTime: undefined,
45
+ });
46
+ }
47
+ }
48
+ exports.ClassicPrices = ClassicPrices;
@@ -0,0 +1,18 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { HexString } from '@pythnetwork/hermes-client';
4
+ import { PoolAssetConfig } from '../../types/Master';
5
+ import { AbstractPrices, PriceParameters } from './AbstractPrices';
6
+ export interface PythPricesParams extends PriceParameters {
7
+ targetFeeds: HexString[];
8
+ refAssets: PoolAssetConfig[];
9
+ binaryUpdate: Buffer;
10
+ }
11
+ export declare class PythPrices extends AbstractPrices {
12
+ private readonly params;
13
+ constructor(params: PythPricesParams);
14
+ static createEmptyPrices(): PythPrices;
15
+ refAssets(): PoolAssetConfig[];
16
+ targetFeeds(): HexString[];
17
+ binaryUpdate(): Buffer;
18
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PythPrices = void 0;
4
+ const core_1 = require("@ton/core");
5
+ const AbstractPrices_1 = require("./AbstractPrices");
6
+ class PythPrices extends AbstractPrices_1.AbstractPrices {
7
+ constructor(params) {
8
+ super(params);
9
+ this.params = params;
10
+ }
11
+ static createEmptyPrices() {
12
+ return new PythPrices({
13
+ dict: core_1.Dictionary.empty(),
14
+ dataCell: core_1.Cell.EMPTY,
15
+ minPublishTime: undefined,
16
+ maxPublishTime: undefined,
17
+ targetFeeds: [],
18
+ refAssets: [],
19
+ binaryUpdate: Buffer.alloc(0),
20
+ });
21
+ }
22
+ refAssets() {
23
+ return this.params.refAssets;
24
+ }
25
+ targetFeeds() {
26
+ return this.params.targetFeeds;
27
+ }
28
+ binaryUpdate() {
29
+ return this.params.binaryUpdate;
30
+ }
31
+ }
32
+ exports.PythPrices = PythPrices;
@@ -0,0 +1,3 @@
1
+ export * from './AbstractPrices';
2
+ export * from './ClassicPrices';
3
+ export * from './PythPrices';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AbstractPrices"), exports);
18
+ __exportStar(require("./ClassicPrices"), exports);
19
+ __exportStar(require("./PythPrices"), exports);
@@ -1,9 +1,15 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { Cell, Dictionary, Slice } from '@ton/core';
3
4
  import { EvaaOracle, ExtendedEvaaOracle } from '../types/Master';
4
5
  import { FetchConfig } from '../utils/utils';
6
+ import { PriceData } from './prices';
5
7
  import { PriceSource } from './sources/PriceSource';
6
- import { OraclePricesData, PriceData, PriceSourcesConfig, RawPriceData } from './Types';
8
+ import { OraclePricesData, PriceSourcesConfig, RawPriceData } from './Types';
9
+ export declare const UPDATE_PRICE_FEEDS_BASE_GAS = 300000n;
10
+ export declare const UPDATE_PRICE_FEEDS_PER_UPDATE_GAS = 90000n;
11
+ export declare const GAS_PRICE_FACTOR = 400n;
12
+ export declare function calcPythUpdateFee(numUpdates: number): bigint;
7
13
  export declare function verifyPricesTimestamp(): (priceData: RawPriceData) => boolean;
8
14
  export declare function getMedianPrice(pricesData: PriceData[], asset: bigint): bigint | null;
9
15
  export declare function packAssetsData(assetsData: {
@@ -1,12 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.verifyRawPriceDataSign = exports.verifyPricesSign = exports.unpackMedianPrices = exports.collectAndFilterPrices = exports.generatePriceSources = exports.sumDicts = exports.packOraclesData = exports.createOracleDataProof = exports.packPrices = exports.packAssetsData = exports.getMedianPrice = exports.verifyPricesTimestamp = void 0;
3
+ exports.verifyRawPriceDataSign = exports.verifyPricesSign = exports.unpackMedianPrices = exports.collectAndFilterPrices = exports.generatePriceSources = exports.sumDicts = exports.packOraclesData = exports.createOracleDataProof = exports.packPrices = exports.packAssetsData = exports.getMedianPrice = exports.verifyPricesTimestamp = exports.calcPythUpdateFee = exports.GAS_PRICE_FACTOR = exports.UPDATE_PRICE_FEEDS_PER_UPDATE_GAS = exports.UPDATE_PRICE_FEEDS_BASE_GAS = void 0;
4
4
  const core_1 = require("@ton/core");
5
5
  const crypto_1 = require("@ton/crypto");
6
6
  const merkleProof_1 = require("../utils/merkleProof");
7
7
  const constants_1 = require("./constants");
8
8
  const Backend_1 = require("./sources/Backend");
9
9
  const Icp_1 = require("./sources/Icp");
10
+ exports.UPDATE_PRICE_FEEDS_BASE_GAS = 300000n;
11
+ exports.UPDATE_PRICE_FEEDS_PER_UPDATE_GAS = 90000n;
12
+ // Current settings in basechain are as follows: 1 unit of gas costs 400 nanotons
13
+ exports.GAS_PRICE_FACTOR = 400n;
14
+ // TODO: use PythContract for dynamic fee calc
15
+ function calcPythUpdateFee(numUpdates) {
16
+ return (exports.UPDATE_PRICE_FEEDS_BASE_GAS + exports.UPDATE_PRICE_FEEDS_PER_UPDATE_GAS * BigInt(numUpdates)) * exports.GAS_PRICE_FACTOR;
17
+ }
18
+ exports.calcPythUpdateFee = calcPythUpdateFee;
10
19
  function verifyPricesTimestamp() {
11
20
  return function (priceData) {
12
21
  const timestamp = Date.now() / 1000;
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { Address, Cell, Contract, ContractProvider, Sender, StateInit } from '@ton/ton';
3
4
  import { Maybe } from '@ton/ton/dist/utils/maybe';
4
5
  import { EvaaRewardsConfig } from '../types/MasterRewards';
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { Address, Cell, Contract, ContractProvider, Sender, StateInit } from '@ton/ton';
3
4
  import { Maybe } from '@ton/ton/dist/utils/maybe';
4
5
  import { EvaaUserRewardsConfig } from '../types/UserRewards';
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { Address, Cell, Dictionary } from '@ton/core';
3
- import { Oracle } from '../prices/Oracle.interface';
4
+ import { AbstractCollector } from '../oracles';
4
5
  export { FeedMapItem, parseFeedsMapDict } from '../api/feeds';
5
6
  export type MasterConstants = {
6
7
  FACTOR_SCALE: bigint;
@@ -15,7 +16,6 @@ export type MasterConstants = {
15
16
  ASSET_BRATE_SCALE: bigint;
16
17
  COLLATERAL_WORTH_THRESHOLD: bigint;
17
18
  };
18
- export type PoolAssetsConfig = PoolAssetConfig[];
19
19
  export type PoolAssetConfig = {
20
20
  name: string;
21
21
  assetId: bigint;
@@ -26,9 +26,9 @@ export type PoolConfig = {
26
26
  masterAddress: Address;
27
27
  masterVersion: number;
28
28
  masterConstants: MasterConstants;
29
- poolAssetsConfig: PoolAssetsConfig;
29
+ poolAssetsConfig: PoolAssetConfig[];
30
30
  lendingCode: Cell;
31
- oracles: Oracle;
31
+ collector: AbstractCollector;
32
32
  };
33
33
  export type UpgradeConfig = {
34
34
  masterCodeVersion: number;
@@ -70,7 +70,7 @@ export type AssetData = {
70
70
  bRate: bigint;
71
71
  totalSupply: bigint;
72
72
  totalBorrow: bigint;
73
- lastAccural: bigint;
73
+ lastAccrual: bigint;
74
74
  balance: bigint;
75
75
  trackingSupplyIndex: bigint;
76
76
  trackingBorrowIndex: bigint;
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { Address, Cell } from '@ton/ton';
3
4
  import { PoolAssetConfig } from './Master';
4
5
  export type EvaaRewardsConfig = {
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { Address, Cell } from '@ton/ton';
3
4
  import { PoolAssetConfig } from './Master';
4
5
  export type EvaaUserRewardsConfig = {
@@ -1,3 +1,4 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  export declare function sha256Hash(input: string): bigint;
3
4
  export declare function bigIntToBuffer(value: bigint): Buffer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evaafi/sdk",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "The EVAA SDK is designed to easily integrate with the EVAA lending protocol on TON blockchain.",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -41,6 +41,5 @@
41
41
  "@pythnetwork/pyth-ton-js": "^0.1.2",
42
42
  "@ton/ton": "14.0.0",
43
43
  "dotenv": "16.4.5"
44
- },
45
- "packageManager": "yarn@4.9.2+sha512.1fc009bc09d13cfd0e19efa44cbfc2b9cf6ca61482725eb35bbc5e257e093ebf4130db6dfe15d604ff4b79efd8e1e8e99b25fa7d0a6197c9f9826358d4d65c3c"
44
+ }
46
45
  }
package/src/api/feeds.ts CHANGED
@@ -1,14 +1,16 @@
1
+ import { HexString } from '@pythnetwork/hermes-client';
1
2
  import { Dictionary } from '@ton/ton';
2
3
  import { Buffer } from 'buffer';
3
- import { ASSET_ID } from '../constants/assets';
4
4
 
5
- export const PYTH_TON_PRICE_FEED_ID = '0x8963217838ab4cf5cadc172203c1f0b763fbaa45f346d8ee50ba994bbcac3026';
6
- export const PYTH_USDT_PRICE_FEED_ID = '0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b';
7
- export const PYTH_STTON_PRICE_FEED_ID = '0x9145e059026a4d5a46f3b96408f7e572e33b3257b9c2dbe8dba551c772762002';
8
- export const PYTH_TSTON_PRICE_FEED_ID = '0x3d1784128eeab5961ec60648fe497d3901eebd211b7f51e4bb0db9f024977d25';
9
- export const PYTH_USDC_PRICE_FEED_ID = '0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a';
10
- export const PYTH_USDE_PRICE_FEED_ID = '0x6ec879b1e9963de5ee97e9c8710b742d6228252a5e2ca12d4ae81d7fe5ee8c5d';
11
- export const PYTH_TSUSDE_PRICE_FEED_ID = '0xcbe184846426619a60f51056d26efecb0537ad3a73b1e965fe695d06a257cb19';
5
+ export const FEED_ID = {
6
+ TON: '0x8963217838ab4cf5cadc172203c1f0b763fbaa45f346d8ee50ba994bbcac3026',
7
+ USDT: '0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b',
8
+ stTON: '0x9145e059026a4d5a46f3b96408f7e572e33b3257b9c2dbe8dba551c772762002',
9
+ tsTON: '0x3d1784128eeab5961ec60648fe497d3901eebd211b7f51e4bb0db9f024977d25',
10
+ USDC: '0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a',
11
+ USDe: '0x6ec879b1e9963de5ee97e9c8710b742d6228252a5e2ca12d4ae81d7fe5ee8c5d',
12
+ tsUSDe: '0xcbe184846426619a60f51056d26efecb0537ad3a73b1e965fe695d06a257cb19',
13
+ };
12
14
 
13
15
  export function bigintToBuffer(value: bigint, size: number): Buffer {
14
16
  if (value < 0n) {
@@ -21,70 +23,32 @@ export function bigintToBuffer(value: bigint, size: number): Buffer {
21
23
  return Buffer.from(padded, 'hex');
22
24
  }
23
25
 
24
- export const packConnectedFeeds = (evaa_id: bigint, reffered_id: bigint) => {
25
- return Buffer.concat([bigintToBuffer(evaa_id, 32), bigintToBuffer(reffered_id, 32)]);
26
+ export const packConnectedFeeds = (evaa_id: bigint, feedId: HexString) => {
27
+ return Buffer.concat([bigintToBuffer(evaa_id, 32), bigintToBuffer(BigInt(feedId), 32)]);
26
28
  };
27
29
 
28
- export const EVAA_TON_PRICE_FEED_ID = ASSET_ID.TON;
29
- export const EVAA_NOT_PRICE_FEED_ID = ASSET_ID.NOT;
30
- export const EVAA_DOGS_PRICE_FEED_ID = ASSET_ID.DOGS;
31
- export const EVAA_USDT_PRICE_FEED_ID = ASSET_ID.USDT;
32
- export const EVAA_STTON_PRICE_FEED_ID = ASSET_ID.stTON;
33
- export const EVAA_TSTON_PRICE_FEED_ID = ASSET_ID.tsTON;
34
- export const EVAA_JUSDC_PRICE_FEED_ID = ASSET_ID.jUSDC;
35
- export const EVAA_JUSDT_PRICE_FEED_ID = ASSET_ID.jUSDT;
36
- export const EVAA_USDE_PRICE_FEED_ID = ASSET_ID.USDe;
37
- export const EVAA_TSUSDE_PRICE_FEED_ID = ASSET_ID.tsUSDe;
38
-
39
- export const MAIN_POOL_FEEDS_MAP: Dictionary<bigint, Buffer> = (() => {
40
- const map = Dictionary.empty<bigint, Buffer>();
41
- map.set(BigInt(PYTH_TON_PRICE_FEED_ID), packConnectedFeeds(EVAA_TON_PRICE_FEED_ID, 0n));
42
- map.set(BigInt(PYTH_USDT_PRICE_FEED_ID), packConnectedFeeds(EVAA_USDT_PRICE_FEED_ID, 0n));
43
- map.set(
44
- BigInt(PYTH_STTON_PRICE_FEED_ID),
45
- packConnectedFeeds(EVAA_STTON_PRICE_FEED_ID, BigInt(PYTH_TON_PRICE_FEED_ID)),
46
- );
47
- map.set(
48
- BigInt(PYTH_TSTON_PRICE_FEED_ID),
49
- packConnectedFeeds(EVAA_TSTON_PRICE_FEED_ID, BigInt(PYTH_TON_PRICE_FEED_ID)),
50
- );
51
- map.set(BigInt(PYTH_USDC_PRICE_FEED_ID), packConnectedFeeds(EVAA_JUSDC_PRICE_FEED_ID, 0n));
52
- map.set(BigInt(PYTH_USDT_PRICE_FEED_ID), packConnectedFeeds(EVAA_JUSDT_PRICE_FEED_ID, 0n));
53
- map.set(BigInt(PYTH_USDE_PRICE_FEED_ID), packConnectedFeeds(EVAA_USDE_PRICE_FEED_ID, 0n));
54
- map.set(BigInt(PYTH_TSUSDE_PRICE_FEED_ID), packConnectedFeeds(EVAA_TSUSDE_PRICE_FEED_ID, 0n));
55
- return map;
56
- })();
30
+ export const unpackConnectedFeeds = (buffer: Buffer): FeedMapItem => {
31
+ return {
32
+ assetId: BigInt(`0x${buffer.toString('hex', 0, 32)}`),
33
+ feedId: `0x${buffer.toString('hex', 32)}`,
34
+ };
35
+ };
57
36
 
58
37
  export type FeedMapItem = {
59
- evaaId: bigint;
60
- referredPythFeed: bigint;
38
+ assetId: bigint;
39
+ feedId: HexString;
61
40
  };
62
41
 
63
42
  export function parseFeedsMapDict(dict: Dictionary<bigint, Buffer>) {
64
- const parsedData = new Map<bigint, FeedMapItem>();
43
+ const parsedData = new Map<HexString, FeedMapItem>();
65
44
  for (const key of dict.keys()) {
66
45
  const buffer = dict.get(key)!;
67
46
 
68
- const hex1 = '0x' + buffer.toString('hex', 0, 32);
69
- const hex2 = '0x' + buffer.toString('hex', 32);
47
+ const assetId = BigInt(`0x${buffer.toString('hex', 0, 32)}`);
48
+ const feedId = `0x${buffer.toString('hex', 32)}`;
70
49
 
71
- const evaaId = BigInt(hex1);
72
- const referredPythFeed = BigInt(hex2);
73
-
74
- parsedData.set(key, { evaaId, referredPythFeed });
50
+ parsedData.set(`0x${key.toString(16)}`, { assetId, feedId });
75
51
  }
76
52
 
77
53
  return parsedData;
78
54
  }
79
-
80
- export const TESTNET_ALLOWED_REF_TOKENS: Dictionary<bigint, bigint> = (() => {
81
- const map = Dictionary.empty<bigint, bigint>();
82
- map.set(BigInt(EVAA_JUSDT_PRICE_FEED_ID), BigInt(EVAA_USDT_PRICE_FEED_ID));
83
- return map;
84
- })();
85
-
86
- export const TESTNET_FEEDS_MAP: Dictionary<bigint, Buffer> = (() => {
87
- const map = Dictionary.empty<bigint, Buffer>();
88
- map.set(BigInt(PYTH_TON_PRICE_FEED_ID), packConnectedFeeds(EVAA_TON_PRICE_FEED_ID, 0n));
89
- return map;
90
- })();