@evaafi/sdk 0.6.2 → 0.6.3-b

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 (61) hide show
  1. package/CHANGELOG.md +57 -17
  2. package/README.md +2 -1
  3. package/dist/api/math.d.ts +12 -2
  4. package/dist/api/math.js +56 -4
  5. package/dist/api/parser.js +48 -20
  6. package/dist/constants/assets.d.ts +9 -1
  7. package/dist/constants/assets.js +38 -9
  8. package/dist/constants/general.d.ts +18 -0
  9. package/dist/constants/general.js +20 -2
  10. package/dist/constants/pools.d.ts +7 -1
  11. package/dist/constants/pools.js +60 -26
  12. package/dist/index.d.ts +10 -3
  13. package/dist/index.js +26 -2
  14. package/dist/prices/PricesCollector.d.ts +2 -2
  15. package/dist/prices/PricesCollector.js +8 -6
  16. package/dist/prices/utils.js +1 -1
  17. package/dist/rewards/EvaaRewards.d.ts +10 -0
  18. package/dist/rewards/EvaaRewards.js +21 -0
  19. package/dist/rewards/JettonMinter.d.ts +30 -0
  20. package/dist/rewards/JettonMinter.js +83 -0
  21. package/dist/rewards/JettonWallet.d.ts +23 -0
  22. package/dist/rewards/JettonWallet.js +60 -0
  23. package/dist/rewards/RewardMaster.d.ts +26 -0
  24. package/dist/rewards/RewardMaster.js +83 -0
  25. package/dist/rewards/RewardUser.d.ts +23 -0
  26. package/dist/rewards/RewardUser.js +70 -0
  27. package/dist/types/MasterRewards.d.ts +13 -0
  28. package/dist/types/User.d.ts +11 -1
  29. package/dist/types/UserRewards.d.ts +10 -0
  30. package/dist/types/UserRewards.js +2 -0
  31. package/dist/utils/sha256BigInt.d.ts +2 -0
  32. package/dist/utils/sha256BigInt.js +9 -1
  33. package/dist/utils/userJettonWallet.js +17 -0
  34. package/package.json +42 -42
  35. package/src/api/math.ts +78 -3
  36. package/src/api/parser.ts +57 -22
  37. package/src/constants/assets.ts +117 -65
  38. package/src/constants/general.ts +33 -2
  39. package/src/constants/pools.ts +110 -28
  40. package/src/index.ts +24 -2
  41. package/src/prices/PricesCollector.ts +10 -6
  42. package/src/prices/utils.ts +1 -1
  43. package/src/rewards/EvaaRewards.ts +23 -0
  44. package/src/rewards/JettonMinter.ts +113 -0
  45. package/src/rewards/JettonWallet.ts +77 -0
  46. package/src/rewards/RewardMaster.ts +110 -0
  47. package/src/rewards/RewardUser.ts +90 -0
  48. package/src/types/Master.ts +1 -1
  49. package/src/types/MasterRewards.ts +13 -0
  50. package/src/types/User.ts +13 -3
  51. package/src/types/UserRewards.ts +10 -0
  52. package/src/utils/sha256BigInt.ts +8 -0
  53. package/src/utils/userJettonWallet.ts +43 -27
  54. package/dist/config.d.ts +0 -1
  55. package/dist/config.js +0 -4
  56. package/dist/constants.d.ts +0 -69
  57. package/dist/constants.js +0 -83
  58. package/dist/types/Common.d.ts +0 -14
  59. package/dist/utils/priceUtils.d.ts +0 -55
  60. package/dist/utils/priceUtils.js +0 -117
  61. /package/dist/types/{Common.js → MasterRewards.js} +0 -0
@@ -0,0 +1,90 @@
1
+ import { sign } from '@ton/crypto';
2
+ import {
3
+ Address,
4
+ beginCell,
5
+ Cell,
6
+ Contract,
7
+ contractAddress,
8
+ ContractProvider,
9
+ fromNano,
10
+ Sender,
11
+ SendMode,
12
+ StateInit,
13
+ } from '@ton/ton';
14
+ import { Maybe } from '@ton/ton/dist/utils/maybe';
15
+ import { FEES, OPCODES } from '../constants/general';
16
+ import { EvaaUserRewardsConfig } from '../types/UserRewards';
17
+ import { bigIntToBuffer } from '../utils/sha256BigInt';
18
+
19
+ export class RewardUser implements Contract {
20
+ constructor(
21
+ readonly address: Address,
22
+ readonly init?: Maybe<StateInit>,
23
+ ) {}
24
+
25
+ static createFromAddress(address: Address) {
26
+ return new RewardUser(address);
27
+ }
28
+
29
+ static rewardUserConfigToCell(config: EvaaUserRewardsConfig): Cell {
30
+ return beginCell()
31
+ .storeAddress(config.userAddress)
32
+ .storeCoins(0)
33
+ .storeRef(
34
+ beginCell()
35
+ .storeAddress(config.rewardMasterAddress)
36
+ .storeBuffer(bigIntToBuffer(config.asset.assetId), 256 / 8)
37
+ .storeBuffer(config.publicKey, 256 / 8)
38
+ .endCell(),
39
+ )
40
+ .endCell();
41
+ }
42
+
43
+ static createFromConfig(config: EvaaUserRewardsConfig, workchain = 0) {
44
+ const data = this.rewardUserConfigToCell(config);
45
+ const init = { code: config.rewardUserCode, data };
46
+ return new RewardUser(contractAddress(workchain, init), init);
47
+ }
48
+
49
+ async sendDeploy(provider: ContractProvider, via: Sender) {
50
+ await provider.internal(via, {
51
+ value: FEES.REWARD_MASTER_DEPLOY,
52
+ sendMode: SendMode.PAY_GAS_SEPARATELY,
53
+ body: beginCell().endCell(),
54
+ });
55
+ }
56
+
57
+ claimMessageToCell(claimAmount: bigint): Cell {
58
+ return beginCell().storeAddress(this.address).storeCoins(claimAmount).endCell();
59
+ }
60
+
61
+ signClaimMessage(claimBody: Cell, privateKey: Buffer): Cell {
62
+ return beginCell()
63
+ .storeUint(OPCODES.REWARD_CLAIM, 32)
64
+ .storeUint(0, 64)
65
+ .storeBuffer(sign(claimBody.hash(), privateKey))
66
+ .storeRef(claimBody)
67
+ .endCell();
68
+ }
69
+
70
+ async sendClaim(provider: ContractProvider, via: Sender, signedClaimMessage: Cell) {
71
+ await provider.internal(via, {
72
+ value: FEES.REWARD_USER_CLAIM,
73
+ sendMode: SendMode.PAY_GAS_SEPARATELY,
74
+ body: signedClaimMessage,
75
+ });
76
+ }
77
+
78
+ async getData(provider: ContractProvider) {
79
+ const result = await provider.get('load_data', []);
80
+ // TODO: maybe it will be typed
81
+ const data = {
82
+ userAddress: result.stack.readAddress(),
83
+ baseTrackingAccrued: Number(fromNano(result.stack.readBigNumber())),
84
+ rewardMasterAddress: result.stack.readAddress(),
85
+ assetId: Buffer.from(result.stack.readBigNumber().toString(16), 'hex'),
86
+ publicKey: Buffer.from(result.stack.readBigNumber().toString(16), 'hex'),
87
+ };
88
+ return data;
89
+ }
90
+ }
@@ -1,4 +1,4 @@
1
- import { Address, Cell, Dictionary } from '@ton/core';
1
+ import { Address, Cell, Dictionary } from '@ton/core'
2
2
 
3
3
  export type MasterConstants = {
4
4
  FACTOR_SCALE: bigint,
@@ -0,0 +1,13 @@
1
+ import { Address, Cell } from '@ton/ton';
2
+ import { PoolAssetConfig } from './Master';
3
+
4
+ export type EvaaRewardsConfig = {
5
+ workchain?: number;
6
+ adminAddress: Address;
7
+ evaaMasterAddress: Address;
8
+ availableReward: number;
9
+ asset: PoolAssetConfig;
10
+ rewardMasterCode: Cell;
11
+ rewardUserCode: Cell;
12
+ publicKey: Buffer;
13
+ };
package/src/types/User.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Address, Cell, Dictionary } from '@ton/core';
2
- import { AssetConfig, ExtendedAssetData, ExtendedAssetsConfig, ExtendedAssetsData, MasterConfig, MasterConstants, PoolAssetConfig, PoolConfig } from './Master';
1
+ import { Address, BitBuilder, Cell, Dictionary } from '@ton/core';
2
+ import { AssetConfig, AssetData, ExtendedAssetData, ExtendedAssetsConfig, ExtendedAssetsData, MasterConfig, MasterConstants, PoolAssetConfig, PoolConfig } from './Master';
3
3
 
4
4
  export enum BalanceType {
5
5
  supply = 'supply',
@@ -38,6 +38,7 @@ export type UserLiteData = {
38
38
  masterAddress: Address;
39
39
  ownerAddress: Address;
40
40
  principals: Dictionary<bigint, bigint>;
41
+ realPrincipals: Dictionary<bigint, bigint>; // principals before applying dusts
41
42
  state: number;
42
43
  balances: Dictionary<bigint, UserBalance>;
43
44
  trackingSupplyIndex: bigint;
@@ -47,6 +48,7 @@ export type UserLiteData = {
47
48
  rewards: Dictionary<bigint, UserRewards>;
48
49
  backupCell1: Cell | null;
49
50
  backupCell2: Cell | null;
51
+ fullyParsed: boolean;
50
52
  };
51
53
 
52
54
  export type UserDataActive = UserLiteData & {
@@ -59,8 +61,8 @@ export type UserDataActive = UserLiteData & {
59
61
  limitUsedPercent: number;
60
62
  limitUsed: bigint;
61
63
  healthFactor: number;
62
-
63
64
  liquidationData: LiquidationData;
65
+ havePrincipalWithoutPrice: boolean;
64
66
  };
65
67
 
66
68
  export type UserDataInactive = {
@@ -99,3 +101,11 @@ export type PredictHealthFactorArgs = {
99
101
  assetsConfig: ExtendedAssetsConfig;
100
102
  poolConfig: PoolConfig;
101
103
  };
104
+
105
+ export type PredictAPYArgs = {
106
+ balanceChangeType: BalanceChangeType;
107
+ amount: bigint; // always positive
108
+ assetData: AssetData;
109
+ assetConfig: AssetConfig;
110
+ masterConstants: MasterConstants;
111
+ };
@@ -0,0 +1,10 @@
1
+ import { Address, Cell } from '@ton/ton';
2
+ import { PoolAssetConfig } from './Master';
3
+
4
+ export type EvaaUserRewardsConfig = {
5
+ userAddress: Address;
6
+ rewardUserCode: Cell;
7
+ rewardMasterAddress: Address;
8
+ asset: PoolAssetConfig;
9
+ publicKey: Buffer;
10
+ };
@@ -5,3 +5,11 @@ export function sha256Hash(input: string): bigint {
5
5
  const hashHex = hash.toString();
6
6
  return BigInt('0x' + hashHex);
7
7
  }
8
+
9
+ export function bigIntToBuffer(value: bigint): Buffer {
10
+ let hex = value.toString(16);
11
+ if (hex.length % 2) {
12
+ hex = '0' + hex;
13
+ }
14
+ return Buffer.from(hex, 'hex');
15
+ }
@@ -4,39 +4,55 @@ import { UNDEFINED_ASSET } from '../constants/assets';
4
4
 
5
5
  function getUserJettonData(ownerAddress: Address, assetName: string, jettonWalletCode: Cell, jettonMasterAddress: Address) {
6
6
  switch (assetName) {
7
- case 'uTON':
8
- return beginCell()
9
- .storeCoins(0)
10
- .storeUint(0, 64)
11
- .storeAddress(ownerAddress)
12
- .storeAddress(jettonMasterAddress)
13
- .storeRef(jettonWalletCode)
14
- .endCell();
15
- case 'DOGS':
16
- case 'NOT':
17
- case 'USDT':
18
- return beginCell()
19
- .storeUint(0, 4)
20
- .storeCoins(0)
21
- .storeAddress(ownerAddress)
22
- .storeAddress(jettonMasterAddress)
23
- .endCell();
24
- case 'tsTON':
7
+ case 'uTON':
8
+ return beginCell()
9
+ .storeCoins(0)
10
+ .storeUint(0, 64)
11
+ .storeAddress(ownerAddress)
12
+ .storeAddress(jettonMasterAddress)
13
+ .storeRef(jettonWalletCode)
14
+ .endCell();
15
+ case 'DOGS':
16
+ case 'NOT':
17
+ case 'USDT':
18
+ case 'USDe':
19
+ return beginCell()
20
+ .storeUint(0, 4)
21
+ .storeCoins(0)
22
+ .storeAddress(ownerAddress)
23
+ .storeAddress(jettonMasterAddress)
24
+ .endCell();
25
+ case 'tsUSDe':
25
26
  return beginCell()
27
+ .storeUint(0, 4)
26
28
  .storeCoins(0)
27
29
  .storeAddress(ownerAddress)
28
30
  .storeAddress(jettonMasterAddress)
29
- .storeRef(jettonWalletCode)
30
31
  .storeCoins(0)
31
- .storeUint(0, 48)
32
+ .storeUint(0, 64)
32
33
  .endCell();
33
- default:
34
- return beginCell().storeCoins(0)
35
- .storeAddress(ownerAddress)
36
- .storeAddress(jettonMasterAddress)
37
- .storeRef(jettonWalletCode)
38
- .endCell();
39
-
34
+ case 'tsTON':
35
+ return beginCell()
36
+ .storeCoins(0)
37
+ .storeAddress(ownerAddress)
38
+ .storeAddress(jettonMasterAddress)
39
+ .storeRef(jettonWalletCode)
40
+ .storeCoins(0)
41
+ .storeUint(0, 48)
42
+ .endCell();
43
+ case 'tgBTC':
44
+ return beginCell()
45
+ .storeUint(0, 4)
46
+ .storeCoins(0)
47
+ .storeAddress(ownerAddress)
48
+ .storeAddress(jettonMasterAddress)
49
+ .endCell();
50
+ default:
51
+ return beginCell().storeCoins(0)
52
+ .storeAddress(ownerAddress)
53
+ .storeAddress(jettonMasterAddress)
54
+ .storeRef(jettonWalletCode)
55
+ .endCell();
40
56
  }
41
57
  }
42
58
  export function getUserJettonWallet(ownerAddress: Address, poolAssetConfig: PoolAssetConfig) {
package/dist/config.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const TTL_ORACLE_DATA_SEC = 120;
package/dist/config.js DELETED
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TTL_ORACLE_DATA_SEC = void 0;
4
- exports.TTL_ORACLE_DATA_SEC = 120; // todo back to 120
@@ -1,69 +0,0 @@
1
- import { Address, Cell } from '@ton/core';
2
- import { OracleNFT } from './types/Master';
3
- export declare const EVAA_MASTER_MAINNET: Address;
4
- export declare const MAINNET_VERSION = 0;
5
- export declare const EVAA_MASTER_TESTNET: Address;
6
- export declare const TESTNET_VERSION = 6;
7
- export declare const ORACLE_NFTS: OracleNFT[];
8
- export declare const MAINNET_ASSETS_ID: {
9
- TON: bigint;
10
- jUSDT: bigint;
11
- jUSDC: bigint;
12
- stTON: bigint;
13
- tsTON: bigint;
14
- };
15
- export declare const TESTNET_ASSETS_ID: {
16
- TON: bigint;
17
- jUSDT: bigint;
18
- jUSDC: bigint;
19
- stTON: bigint;
20
- };
21
- export declare const JETTON_MASTER_ADDRESSES: {
22
- jUSDT_MAINNET: Address;
23
- jUSDT_TESTNET: Address;
24
- jUSDC_MAINNET: Address;
25
- jUSDC_TESTNET: Address;
26
- stTON_MAINNET: Address;
27
- stTON_TESTNET: Address;
28
- tsTON_MAINNET: Address;
29
- tsTON_TESTNET: null;
30
- USDT_MAINNET: Address;
31
- USDT_TESTNET: null;
32
- };
33
- export declare const MASTER_CONSTANTS: {
34
- FACTOR_SCALE: bigint;
35
- ASSET_COEFFICIENT_SCALE: bigint;
36
- ASSET_PRICE_SCALE: bigint;
37
- ASSET_RESERVE_FACTOR_SCALE: bigint;
38
- ASSET_LIQUIDATION_RESERVE_FACTOR_SCALE: bigint;
39
- ASSET_ORIGINATION_FEE_SCALE: bigint;
40
- };
41
- export declare const LENDING_CODE: Cell;
42
- export declare const JETTON_WALLETS_CODE: {
43
- jUSDT_MAINNET: Cell;
44
- jUSDT_TESTNET: Cell;
45
- jUSDC_MAINNET: Cell;
46
- jUSDC_TESTNET: Cell;
47
- stTON_MAINNET: Cell;
48
- stTON_TESTNET: Cell;
49
- tsTON_MAINNET: Cell;
50
- tsTON_TESTNET: null;
51
- USDT_MAINNET: Cell;
52
- USDT_TESTNET: null;
53
- };
54
- export declare const OPCODES: {
55
- SUPPLY: number;
56
- WITHDRAW: number;
57
- LIQUIDATE: number;
58
- JETTON_TRANSFER: number;
59
- ONCHAIN_GETTER: number;
60
- };
61
- export declare const FEES: {
62
- SUPPLY: bigint;
63
- WITHDRAW: bigint;
64
- SUPPLY_JETTON: bigint;
65
- SUPPLY_JETTON_FWD: bigint;
66
- LIQUIDATION: bigint;
67
- LIQUIDATION_JETTON: bigint;
68
- LIQUIDATION_JETTON_FWD: bigint;
69
- };
package/dist/constants.js DELETED
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FEES = exports.OPCODES = exports.JETTON_WALLETS_CODE = exports.LENDING_CODE = exports.MASTER_CONSTANTS = exports.JETTON_MASTER_ADDRESSES = exports.TESTNET_ASSETS_ID = exports.MAINNET_ASSETS_ID = exports.ORACLE_NFTS = exports.TESTNET_VERSION = exports.EVAA_MASTER_TESTNET = exports.MAINNET_VERSION = exports.EVAA_MASTER_MAINNET = void 0;
4
- const core_1 = require("@ton/core");
5
- const sha256BigInt_1 = require("./utils/sha256BigInt");
6
- //todo set back to EQC8rUZqR_pWV1BylWUlPNBzyiTYVoBEmQkMIQDZXICfnuRr
7
- exports.EVAA_MASTER_MAINNET = core_1.Address.parse('EQC_hR5L4G3vkPG0VODURYoohp_3hlMW-gZiGp89HwyulZK4');
8
- //todo set back to 5 (todo set at 6 on 10.10.2024)
9
- exports.MAINNET_VERSION = 0;
10
- exports.EVAA_MASTER_TESTNET = core_1.Address.parse('kQC92pF4XWatZY9-ZS6SGW6s-dCpjk9NtEkdXQ7vFHJUAdT9');
11
- exports.TESTNET_VERSION = 6;
12
- exports.ORACLE_NFTS = [
13
- { id: 0, address: '0xd3a8c0b9fd44fd25a49289c631e3ac45689281f2f8cf0744400b4c65bed38e5d' },
14
- { id: 1, address: '0x2c21cabdaa89739de16bde7bc44e86401fac334a3c7e55305fe5e7563043e191' },
15
- { id: 2, address: '0x2eb258ce7b5d02466ab8a178ad8b0ba6ffa7b58ef21de3dc3b6dd359a1e16af0' },
16
- { id: 3, address: '0xf9a0769954b4430bca95149fb3d876deb7799d8f74852e0ad4ccc5778ce68b52' },
17
- ];
18
- exports.MAINNET_ASSETS_ID = {
19
- TON: (0, sha256BigInt_1.sha256Hash)('TON'),
20
- jUSDT: (0, sha256BigInt_1.sha256Hash)('jUSDT'),
21
- jUSDC: (0, sha256BigInt_1.sha256Hash)('jUSDC'),
22
- stTON: (0, sha256BigInt_1.sha256Hash)('stTON'),
23
- tsTON: (0, sha256BigInt_1.sha256Hash)('tsTON'),
24
- //todo uncomment
25
- // USDT: sha256Hash('USDT'),
26
- };
27
- exports.TESTNET_ASSETS_ID = {
28
- TON: (0, sha256BigInt_1.sha256Hash)('TON'),
29
- jUSDT: (0, sha256BigInt_1.sha256Hash)('jUSDT'),
30
- jUSDC: (0, sha256BigInt_1.sha256Hash)('jUSDC'),
31
- stTON: (0, sha256BigInt_1.sha256Hash)('stTON'),
32
- // tsTON: sha256Hash('tsTON'),
33
- // USDT: sha256Hash('USDT'),
34
- };
35
- exports.JETTON_MASTER_ADDRESSES = {
36
- jUSDT_MAINNET: core_1.Address.parse('EQBynBO23ywHy_CgarY9NK9FTz0yDsG82PtcbSTQgGoXwiuA'),
37
- jUSDT_TESTNET: core_1.Address.parse('kQBe4gtSQMxM5RpMYLr4ydNY72F8JkY-icZXG1NJcsju8XM7'),
38
- jUSDC_MAINNET: core_1.Address.parse('EQB-MPwrd1G6WKNkLz_VnV6WqBDd142KMQv-g1O-8QUA3728'),
39
- jUSDC_TESTNET: core_1.Address.parse('kQDaY5yUatYnHei73HBqRX_Ox9LK2XnR7XuCY9MFC2INbfYI'),
40
- stTON_MAINNET: core_1.Address.parse('EQDNhy-nxYFgUqzfUzImBEP67JqsyMIcyk2S5_RwNNEYku0k'),
41
- stTON_TESTNET: core_1.Address.parse('kQC3Duw3dg8k98xf5S7Bm7YOWVJ5QW8hm3iLqFfJfa_g9h07'),
42
- tsTON_MAINNET: core_1.Address.parse('EQC98_qAmNEptUtPc7W6xdHh_ZHrBUFpw5Ft_IzNU20QAJav'),
43
- tsTON_TESTNET: null,
44
- USDT_MAINNET: core_1.Address.parse('EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs'),
45
- USDT_TESTNET: null,
46
- };
47
- exports.MASTER_CONSTANTS = {
48
- FACTOR_SCALE: BigInt(1e12),
49
- ASSET_COEFFICIENT_SCALE: 10000n,
50
- ASSET_PRICE_SCALE: BigInt(1e8),
51
- ASSET_RESERVE_FACTOR_SCALE: 10000n,
52
- ASSET_LIQUIDATION_RESERVE_FACTOR_SCALE: 10000n,
53
- ASSET_ORIGINATION_FEE_SCALE: BigInt(1e9)
54
- };
55
- exports.LENDING_CODE = core_1.Cell.fromBoc(Buffer.from('b5ee9c72c1010e0100fd000d12182a555a6065717691969efd0114ff00f4a413f4bcf2c80b010202c8050202039f740403001ff2f8276a2687d2018fd201800f883b840051d38642c678b64e4400780e58fc10802faf07f80e59fa801e78b096664c02078067c07c100627a7978402014807060007a0ddb0c60201c709080013a0fd007a026900aa90400201200b0a0031b8e1002191960aa00b9e2ca007f4042796d225e8019203f6010201200d0c000bf7c147d2218400b9d10e86981fd201840b07f8138d809797976a2687d2029116382f970fd9178089910374daf81b619fd20182c7883b8701981684100627910eba56001797a6a6ba610fd8200e8768f76a9f6aa00cc2a32a8292878809bef2f1889f883bbcdeb86f01', 'hex'))[0];
56
- exports.JETTON_WALLETS_CODE = {
57
- jUSDT_MAINNET: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021301000385000114ff00f4a413f4bcf2c80b0102016202030202cb0405001ba0f605da89a1f401f481f481a9a30201ce06070201580a0b02f70831c02497c138007434c0c05c6c2544d7c0fc07783e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7c076cf16cc8d0d0d09208403e29fa96ea68c1b088d978c4408fc06b809208405e351466ea6cc1b08978c840910c03c06f80dd6cda0841657c1ef2ea7c09c6c3cb4b01408eebcb8b1807c073817c160080900113e910c30003cb85360005c804ff833206e953080b1f833de206ef2d29ad0d30731d3ffd3fff404d307d430d0fa00fa00fa00fa00fa00fa00300008840ff2f00201580c0d020148111201f70174cfc0407e803e90087c007b51343e803e903e903534544da8548b31c17cb8b04ab0bffcb8b0950d109c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c032481c007e401d3232c084b281f2fff274013e903d010c7e800835d270803cb8b13220060072c15401f3c59c3e809dc072dae00e02f33b51343e803e903e90353442b4cfc0407e80145468017e903e9014d771c1551cdbdc150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0325c007e401d3232c084b281f2fff2741403f1c147ac7cb8b0c33e801472a84a6d8206685401e8062849a49b1578c34975c2c070c00870802c200f1000aa13ccc88210178d4519580a02cb1fcb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25007a813a008aa005004a017a014bcf2e2c501c98040fb004300c85004fa0258cf1601cf16ccc9ed5400725269a018a1c882107362d09c2902cb1fcb3f5007fa025004cf165007cf16c9c8801001cb0527cf165004fa027101cb6a13ccc971fb0050421300748e23c8801001cb055006cf165005fa027001cb6a8210d53276db580502cb1fcb3fc972fb00925b33e24003c85004fa0258cf1601cf16ccc9ed5400eb3b51343e803e903e9035344174cfc0407e800870803cb8b0be903d01007434e7f440745458a8549631c17cb8b049b0bffcb8b0b220841ef765f7960100b2c7f2cfc07e8088f3c58073c584f2e7f27220060072c148f3c59c3e809c4072dab33260103ec01004f214013e809633c58073c5b3327b55200087200835c87b51343e803e903e9035344134c7c06103c8608405e351466e80a0841ef765f7ae84ac7cbd34cfc04c3e800c04e81408f214013e809633c58073c5b3327b5520', 'hex'))[0],
58
- jUSDT_TESTNET: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021101000323000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020120080900c30831c02497c138007434c0c05c6c2544d7c0fc03383e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7e08403e29fa954882ea54c4d167c0278208405e3514654882ea58c511100fc02b80d60841657c1ef2ea4d67c02f817c12103fcbc2000113e910c1c2ebcb853600201200a0b0083d40106b90f6a2687d007d207d206a1802698fc1080bc6a28ca9105d41083deecbef09dd0958f97162e99f98fd001809d02811e428027d012c678b00e78b6664f6aa401f1503d33ffa00fa4021f001ed44d0fa00fa40fa40d4305136a1522ac705f2e2c128c2fff2e2c254344270542013541403c85004fa0258cf1601cf16ccc922c8cb0112f400f400cb00c920f9007074c8cb02ca07cbffc9d004fa40f40431fa0020d749c200f2e2c4778018c8cb055008cf1670fa0217cb6b13cc80c0201200d0e009e8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a08209c9c380a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5402f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a019ad822860822625a028062849e5c412440e0dd7c138c34975c2c0600f1000d73b51343e803e903e90350c01f4cffe803e900c145468549271c17cb8b049f0bffcb8b08160824c4b402805af3cb8b0e0841ef765f7b232c7c572cfd400fe8088b3c58073c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b552000705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023007cc30023c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed54', 'hex'))[0],
59
- jUSDC_MAINNET: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021301000385000114ff00f4a413f4bcf2c80b0102016202030202cb0405001ba0f605da89a1f401f481f481a9a30201ce06070201580a0b02f70831c02497c138007434c0c05c6c2544d7c0fc07783e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7c076cf16cc8d0d0d09208403e29fa96ea68c1b088d978c4408fc06b809208405e351466ea6cc1b08978c840910c03c06f80dd6cda0841657c1ef2ea7c09c6c3cb4b01408eebcb8b1807c073817c160080900113e910c30003cb85360005c804ff833206e953080b1f833de206ef2d29ad0d30731d3ffd3fff404d307d430d0fa00fa00fa00fa00fa00fa00300008840ff2f00201580c0d020148111201f70174cfc0407e803e90087c007b51343e803e903e903534544da8548b31c17cb8b04ab0bffcb8b0950d109c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c032481c007e401d3232c084b281f2fff274013e903d010c7e800835d270803cb8b13220060072c15401f3c59c3e809dc072dae00e02f33b51343e803e903e90353442b4cfc0407e80145468017e903e9014d771c1551cdbdc150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0325c007e401d3232c084b281f2fff2741403f1c147ac7cb8b0c33e801472a84a6d8206685401e8062849a49b1578c34975c2c070c00870802c200f1000aa13ccc88210178d4519580a02cb1fcb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25007a813a008aa005004a017a014bcf2e2c501c98040fb004300c85004fa0258cf1601cf16ccc9ed5400725269a018a1c882107362d09c2902cb1fcb3f5007fa025004cf165007cf16c9c8801001cb0527cf165004fa027101cb6a13ccc971fb0050421300748e23c8801001cb055006cf165005fa027001cb6a8210d53276db580502cb1fcb3fc972fb00925b33e24003c85004fa0258cf1601cf16ccc9ed5400eb3b51343e803e903e9035344174cfc0407e800870803cb8b0be903d01007434e7f440745458a8549631c17cb8b049b0bffcb8b0b220841ef765f7960100b2c7f2cfc07e8088f3c58073c584f2e7f27220060072c148f3c59c3e809c4072dab33260103ec01004f214013e809633c58073c5b3327b55200087200835c87b51343e803e903e9035344134c7c06103c8608405e351466e80a0841ef765f7ae84ac7cbd34cfc04c3e800c04e81408f214013e809633c58073c5b3327b5520', 'hex'))[0],
60
- jUSDC_TESTNET: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021101000323000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020120080900c30831c02497c138007434c0c05c6c2544d7c0fc03383e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7e08403e29fa954882ea54c4d167c0278208405e3514654882ea58c511100fc02b80d60841657c1ef2ea4d67c02f817c12103fcbc2000113e910c1c2ebcb853600201200a0b0083d40106b90f6a2687d007d207d206a1802698fc1080bc6a28ca9105d41083deecbef09dd0958f97162e99f98fd001809d02811e428027d012c678b00e78b6664f6aa401f1503d33ffa00fa4021f001ed44d0fa00fa40fa40d4305136a1522ac705f2e2c128c2fff2e2c254344270542013541403c85004fa0258cf1601cf16ccc922c8cb0112f400f400cb00c920f9007074c8cb02ca07cbffc9d004fa40f40431fa0020d749c200f2e2c4778018c8cb055008cf1670fa0217cb6b13cc80c0201200d0e009e8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a08209c9c380a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5402f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a019ad822860822625a028062849e5c412440e0dd7c138c34975c2c0600f1000d73b51343e803e903e90350c01f4cffe803e900c145468549271c17cb8b049f0bffcb8b08160824c4b402805af3cb8b0e0841ef765f7b232c7c572cfd400fe8088b3c58073c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b552000705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023007cc30023c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed54', 'hex'))[0],
61
- stTON_MAINNET: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021201000362000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020120090a01cf0831c02497c138007434c0c05c6c2544d7c0fc03783e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7c8608403e29fa96ea54c4d167c02b808608405e351466ea58c511100fc02f80860841657c1ef2ea54c4d167c03380517c1300138c08c2103fcbc200800113e910c30003cb85360007ced44d0fa00fa40fa40d43010235f03018208989680a16d801072226eb32091719170e203c8cb055006cf165004fa02cb6a039358cc019130e201c901fb000201580b0c020148101101f100f4cffe803e90087c007b51343e803e903e90350c144da8548ab1c17cb8b04a30bffcb8b0950d109c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c032483e401c1d3232c0b281f2fff274013e903d010c7e800835d270803cb8b11de0063232c1540233c59c3e8085f2dac4f3200d02f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a019ad8228608239387028062849e5c412440e0dd7c138c34975c2c0600e0f009e8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a0820a625a00a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5400705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023007cc30023c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed5400c90c3b51343e803e903e90350c01b4cffe800c145128548df1c17cb8b04970bffcb8b0812082e4e1c02fbcb8b160841ef765f7b232c7c532cfd63e808873c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b55200081200835c87b51343e803e903e90350c0134c7c8608405e351466e80a0841ef765f7ae84ac7cb83234cfcc7e800c04e81408f214013e809633c58073c5b3327b5520', 'hex'))[0],
62
- stTON_TESTNET: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021201000362000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020120090a01cf0831c02497c138007434c0c05c6c2544d7c0fc03383e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7c8608403e29fa96ea54c4d167c027808608405e351466ea58c511100fc02b80860841657c1ef2ea54c4d167c02f80517c1300138c08c2103fcbc200800113e910c30003cb85360007ced44d0fa00fa40fa40d43010235f03018208989680a16d801072226eb32091719170e203c8cb055006cf165004fa02cb6a039358cc019130e201c901fb000201200b0c0081d40106b90f6a2687d007d207d206a1802698f90c1080bc6a28cdd0141083deecbef5d0958f97064699f98fd001809d02811e428027d012c678b00e78b6664f6aa401f1503d33ffa00fa4021f001ed44d0fa00fa40fa40d4305136a1522ac705f2e2c128c2fff2e2c254344270542013541403c85004fa0258cf1601cf16ccc922c8cb0112f400f400cb00c920f9007074c8cb02ca07cbffc9d004fa40f40431fa0020d749c200f2e2c4778018c8cb055008cf1670fa0217cb6b13cc80d0201200e0f009e8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a0820a625a00a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5402f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a019ad8228608239387028062849e5c412440e0dd7c138c34975c2c060101100c90c3b51343e803e903e90350c01b4cffe800c145128548df1c17cb8b04970bffcb8b0812082e4e1c02fbcb8b160841ef765f7b232c7c532cfd63e808873c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b552000705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023007cc30023c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed54', 'hex'))[0],
63
- tsTON_MAINNET: core_1.Cell.fromBoc(Buffer.from('b5ee9c720101010100230000420212bebb0dc8e202b7e26f721e2547e16bb9ebaec934f657d19f22e76d62bec878', 'hex'))[0],
64
- tsTON_TESTNET: null,
65
- USDT_MAINNET: core_1.Cell.fromBoc(Buffer.from('b5ee9c72010101010023000042028f452d7a4dfd74066b682365177259ed05734435be76b5fd4bd5d8af2b7c3d68', 'hex'))[0],
66
- USDT_TESTNET: null,
67
- };
68
- exports.OPCODES = {
69
- SUPPLY: 0x1,
70
- WITHDRAW: 0x2,
71
- LIQUIDATE: 0x3,
72
- JETTON_TRANSFER: 0xf8a7ea5,
73
- ONCHAIN_GETTER: 0x9998,
74
- };
75
- exports.FEES = {
76
- SUPPLY: (0, core_1.toNano)('0.3'),
77
- WITHDRAW: (0, core_1.toNano)('0.5'),
78
- SUPPLY_JETTON: (0, core_1.toNano)('0.8'),
79
- SUPPLY_JETTON_FWD: (0, core_1.toNano)('0.5'),
80
- LIQUIDATION: (0, core_1.toNano)('0.8'),
81
- LIQUIDATION_JETTON: (0, core_1.toNano)('1'),
82
- LIQUIDATION_JETTON_FWD: (0, core_1.toNano)('0.8'),
83
- };
@@ -1,14 +0,0 @@
1
- /// <reference types="node" />
2
- import { Cell, Dictionary } from '@ton/core';
3
- export type RawPriceData = {
4
- dict: Dictionary<bigint, bigint>;
5
- dataCell: Cell;
6
- oracleId: number;
7
- signature: Buffer;
8
- pubkey: Buffer;
9
- timestamp: number;
10
- };
11
- export type PriceData = {
12
- dict: Dictionary<bigint, bigint>;
13
- dataCell: Cell;
14
- };
@@ -1,55 +0,0 @@
1
- /// <reference types="node" />
2
- import { Cell, Dictionary, Slice } from "@ton/core";
3
- import { PriceData, RawPriceData } from "../types/Common";
4
- import { Oracle, PoolAssetsConfig } from "../types/Master";
5
- type OutputData = {
6
- metadata: {
7
- blockId: string;
8
- transactionId: string;
9
- outputIndex: number;
10
- isSpent: boolean;
11
- milestoneIndexSpent: number;
12
- milestoneTimestampSpent: number;
13
- transactionIdSpent: string;
14
- milestoneIndexBooked: number;
15
- milestoneTimestampBooked: number;
16
- ledgerIndex: number;
17
- };
18
- output: {
19
- type: number;
20
- amount: string;
21
- nftId: string;
22
- unlockConditions: {
23
- type: number;
24
- address: {
25
- type: number;
26
- pubKeyHash: string;
27
- };
28
- }[];
29
- features: {
30
- type: number;
31
- data: string;
32
- }[];
33
- };
34
- };
35
- export type OraclePricesData = {
36
- timestamp: number;
37
- prices: Dictionary<bigint, bigint>;
38
- };
39
- export declare function loadPrices(oracleNftId: String, endpoints: String[]): Promise<OutputData>;
40
- export declare function parsePrices(outputData: OutputData, oracleId: number): Promise<RawPriceData>;
41
- export declare function verifyPrices(assets: PoolAssetsConfig): (priceData: RawPriceData) => boolean;
42
- export declare function getMedianPrice(pricesData: PriceData[], asset: bigint): bigint;
43
- export declare function packAssetsData(assetsData: {
44
- assetId: bigint;
45
- medianPrice: bigint;
46
- }[]): Cell;
47
- export declare function packPrices(assetsDataCell: Cell, oraclesDataCell: Cell): Cell;
48
- export declare function createOracleDataProof(oracle: Oracle, data: OraclePricesData, signature: Buffer, assets: Array<bigint>): Slice;
49
- export declare function packOraclesData(oraclesData: {
50
- oracle: Oracle;
51
- data: OraclePricesData;
52
- signature: Buffer;
53
- }[], assets: Array<bigint>): Cell;
54
- export declare function sumDicts(result: Dictionary<bigint, bigint>, addendum: Dictionary<bigint, bigint>): void;
55
- export {};
@@ -1,117 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sumDicts = exports.packOraclesData = exports.createOracleDataProof = exports.packPrices = exports.packAssetsData = exports.getMedianPrice = exports.verifyPrices = exports.parsePrices = exports.loadPrices = void 0;
4
- const core_1 = require("@ton/core");
5
- const config_1 = require("../config");
6
- const merkleProof_1 = require("./merkleProof");
7
- async function loadPrices(oracleNftId, endpoints) {
8
- return await Promise.any(endpoints.map(x => loadOracleData(oracleNftId, x)));
9
- }
10
- exports.loadPrices = loadPrices;
11
- async function loadOracleData(oracleNftId, endpoint) {
12
- let result = await fetch(`https://${endpoint}/api/indexer/v1/outputs/nft/${oracleNftId}`, {
13
- headers: { accept: 'application/json' },
14
- signal: AbortSignal.timeout(5000)
15
- });
16
- let outputId = (await result.json());
17
- result = await fetch(`https://${endpoint}/api/core/v2/outputs/${outputId.items[0]}`, {
18
- headers: { accept: 'application/json' },
19
- signal: AbortSignal.timeout(5000)
20
- });
21
- return await result.json();
22
- }
23
- async function parsePrices(outputData, oracleId) {
24
- const data = JSON.parse(decodeURIComponent(outputData.output.features[0].data.replace('0x', '').replace(/[0-9a-f]{2}/g, '%$&')));
25
- try {
26
- const pricesCell = core_1.Cell.fromBoc(Buffer.from(data['packedPrices'], 'hex'))[0];
27
- const signature = Buffer.from(data['signature'], 'hex');
28
- const publicKey = Buffer.from(data['publicKey'], 'hex');
29
- const timestamp = Number(data['timestamp']);
30
- return {
31
- dict: pricesCell.beginParse().loadRef().beginParse().loadDictDirect(core_1.Dictionary.Keys.BigUint(256), core_1.Dictionary.Values.BigVarUint(4)),
32
- dataCell: (0, core_1.beginCell)().storeRef(pricesCell).storeBuffer(signature).endCell(),
33
- oracleId: oracleId,
34
- signature: signature,
35
- pubkey: publicKey,
36
- timestamp: timestamp,
37
- };
38
- }
39
- catch (error) {
40
- console.log(oracleId, data, error);
41
- throw Error();
42
- }
43
- }
44
- exports.parsePrices = parsePrices;
45
- function verifyPrices(assets) {
46
- return function (priceData) {
47
- const timestamp = Date.now() / 1000;
48
- const pricesTime = priceData.timestamp;
49
- for (const asset of assets) {
50
- if (!priceData.dict.has(asset.assetId)) {
51
- return false;
52
- }
53
- }
54
- // console.log('timestamp', timestamp, 'pricestime', pricesTime, timestamp - pricesTime);
55
- return timestamp - pricesTime < config_1.TTL_ORACLE_DATA_SEC;
56
- };
57
- }
58
- exports.verifyPrices = verifyPrices;
59
- function getMedianPrice(pricesData, asset) {
60
- const sorted = pricesData.map(x => x.dict.get(asset)).sort((a, b) => Number(a) - Number(b));
61
- const mid = Math.floor(sorted.length / 2);
62
- if (sorted.length % 2 === 0) {
63
- return (sorted[mid - 1] + sorted[mid]) / 2n;
64
- }
65
- else {
66
- return sorted[mid];
67
- }
68
- }
69
- exports.getMedianPrice = getMedianPrice;
70
- function packAssetsData(assetsData) {
71
- if (assetsData.length == 0) {
72
- throw new Error("No assets data to pack");
73
- }
74
- return assetsData.reduceRight((acc, { assetId, medianPrice }) => (0, core_1.beginCell)()
75
- .storeUint(assetId, 256)
76
- .storeCoins(medianPrice)
77
- .storeMaybeRef(acc)
78
- .endCell(), null);
79
- }
80
- exports.packAssetsData = packAssetsData;
81
- function packPrices(assetsDataCell, oraclesDataCell) {
82
- let pricesCell = (0, core_1.beginCell)()
83
- .storeRef(assetsDataCell)
84
- .storeRef(oraclesDataCell)
85
- .endCell();
86
- return pricesCell;
87
- }
88
- exports.packPrices = packPrices;
89
- function createOracleDataProof(oracle, data, signature, assets) {
90
- let prunedDict = (0, merkleProof_1.generateMerkleProofDirect)(data.prices, assets, core_1.Dictionary.Keys.BigUint(256));
91
- let prunedData = (0, core_1.beginCell)().storeUint(data.timestamp, 32).storeMaybeRef(prunedDict).endCell();
92
- let merkleProof = (0, merkleProof_1.convertToMerkleProof)(prunedData);
93
- let oracleDataProof = (0, core_1.beginCell)().storeUint(oracle.id, 32).storeRef(merkleProof).storeBuffer(signature).asSlice();
94
- return oracleDataProof;
95
- }
96
- exports.createOracleDataProof = createOracleDataProof;
97
- function packOraclesData(oraclesData, assets) {
98
- if (oraclesData.length == 0) {
99
- throw new Error("no oracles data to pack");
100
- }
101
- let proofs = oraclesData.sort((d1, d2) => d1.oracle.id - d2.oracle.id).map(({ oracle, data, signature }) => createOracleDataProof(oracle, data, signature, assets));
102
- return proofs.reduceRight((acc, val) => (0, core_1.beginCell)().storeSlice(val).storeMaybeRef(acc).endCell(), null);
103
- }
104
- exports.packOraclesData = packOraclesData;
105
- // : String = "api.stardust-mainnet.iotaledger.net"
106
- function sumDicts(result, addendum) {
107
- for (const key of addendum.keys()) {
108
- const current = result.get(key);
109
- const value = addendum.get(key);
110
- if (current === undefined) {
111
- result.set(key, value);
112
- continue;
113
- }
114
- result.set(key, current + value);
115
- }
116
- }
117
- exports.sumDicts = sumDicts;
File without changes