@evaafi/sdk 0.6.4-b → 0.7.0

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.
@@ -64,7 +64,7 @@ exports.MAINNET_LP_POOL_CONFIG = {
64
64
  masterConstants: general_1.MASTER_CONSTANTS,
65
65
  oracles: general_1.ORACLES_LP,
66
66
  minimalOracles: 3,
67
- poolAssetsConfig: [assets_1.TON_MAINNET, assets_1.USDT_MAINNET, assets_1.TONUSDT_DEDUST_MAINNET, assets_1.TON_STORM_MAINNET, assets_1.USDT_STORM_MAINNET /*, TONUSDT_STONFI_MAINNET*/],
67
+ poolAssetsConfig: [assets_1.TON_MAINNET, assets_1.USDT_MAINNET, assets_1.TONUSDT_DEDUST_MAINNET, assets_1.TON_STORM_MAINNET, assets_1.USDT_STORM_MAINNET, assets_1.TONUSDT_STONFI_MAINNET],
68
68
  lendingCode: general_1.LENDING_CODE,
69
69
  };
70
70
  exports.MAINNET_ALTS_POOL_CONFIG = {
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import { Cell, Dictionary } from '@ton/core';
4
3
  /**
5
4
  * Configuration for price source endpoints.
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import { Cell, Dictionary, Slice } from "@ton/core";
4
3
  import { OraclePricesData, PriceData, PriceSource, PriceSourcesConfig, RawPriceData } from "..";
5
4
  import { Oracle, OracleNFT, PoolConfig } from "../types/Master";
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import { Address, Cell, Contract, ContractProvider, Sender, StateInit } from '@ton/ton';
4
3
  import { Maybe } from '@ton/ton/dist/utils/maybe';
5
4
  import { EvaaRewardsConfig } from '../types/MasterRewards';
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import { Address, Cell, Contract, ContractProvider, Sender, StateInit } from '@ton/ton';
4
3
  import { Maybe } from '@ton/ton/dist/utils/maybe';
5
4
  import { EvaaUserRewardsConfig } from '../types/UserRewards';
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import { Address, Cell, Dictionary } from '@ton/core';
4
3
  export type MasterConstants = {
5
4
  FACTOR_SCALE: bigint;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import { Address, Cell } from '@ton/ton';
4
3
  import { PoolAssetConfig } from './Master';
5
4
  export type EvaaRewardsConfig = {
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import { Address, Cell } from '@ton/ton';
4
3
  import { PoolAssetConfig } from './Master';
5
4
  export type EvaaUserRewardsConfig = {
@@ -1,4 +1,3 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  export declare function sha256Hash(input: string): bigint;
4
3
  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.6.4-b",
3
+ "version": "0.7.0",
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": [
@@ -40,5 +40,6 @@
40
40
  "dependencies": {
41
41
  "@ton/ton": "14.0.0",
42
42
  "dotenv": "16.4.5"
43
- }
43
+ },
44
+ "packageManager": "yarn@4.9.2+sha512.1fc009bc09d13cfd0e19efa44cbfc2b9cf6ca61482725eb35bbc5e257e093ebf4130db6dfe15d604ff4b79efd8e1e8e99b25fa7d0a6197c9f9826358d4d65c3c"
44
45
  }
@@ -115,7 +115,7 @@ export const MAINNET_LP_POOL_CONFIG: PoolConfig = {
115
115
  masterConstants: MASTER_CONSTANTS,
116
116
  oracles: ORACLES_LP,
117
117
  minimalOracles: 3,
118
- poolAssetsConfig: [TON_MAINNET, USDT_MAINNET, TONUSDT_DEDUST_MAINNET, TON_STORM_MAINNET, USDT_STORM_MAINNET/*, TONUSDT_STONFI_MAINNET*/],
118
+ poolAssetsConfig: [TON_MAINNET, USDT_MAINNET, TONUSDT_DEDUST_MAINNET, TON_STORM_MAINNET, USDT_STORM_MAINNET, TONUSDT_STONFI_MAINNET],
119
119
  lendingCode: LENDING_CODE,
120
120
  };
121
121
 
@@ -1,27 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { Buffer } from "buffer";
4
- import { Dictionary } from "@ton/ton";
5
- export declare const PYTH_TON_PRICE_FEED_ID = "0x8963217838ab4cf5cadc172203c1f0b763fbaa45f346d8ee50ba994bbcac3026";
6
- export declare const PYTH_NOT_PRICE_FEED_ID = "0x75ec6f04d4bded6afdc1440689be4402dd1e23d2ff2c21e081871eb2739ceb36";
7
- export declare const PYTH_DOGS_PRICE_FEED_ID = "0x3b75dbeeb6310f6264c812dd8411a6b30dc6d02cec4bca2447c88335127564f4";
8
- export declare const PYTH_USDT_PRICE_FEED_ID = "0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b";
9
- export declare const PYTH_STTON_PRICE_FEED_ID = "0x9145e059026a4d5a46f3b96408f7e572e33b3257b9c2dbe8dba551c772762002";
10
- export declare const PYTH_TSTON_PRICE_FEED_ID = "0x3d1784128eeab5961ec60648fe497d3901eebd211b7f51e4bb0db9f024977d25";
11
- export declare const PYTH_USDC_PRICE_FEED_ID = "0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a";
12
- export declare function bigintToBuffer(value: bigint, size: number): Buffer;
13
- export declare const packConnectedFeeds: (evaa_id: bigint, reffered_id: bigint) => Buffer;
14
- export declare const EVAA_TON_PRICE_FEED_ID: bigint;
15
- export declare const EVAA_NOT_PRICE_FEED_ID: bigint;
16
- export declare const EVAA_DOGS_PRICE_FEED_ID: bigint;
17
- export declare const EVAA_USDT_PRICE_FEED_ID: bigint;
18
- export declare const EVAA_STTON_PRICE_FEED_ID: bigint;
19
- export declare const EVAA_TSTON_PRICE_FEED_ID: bigint;
20
- export declare const EVAA_USDC_PRICE_FEED_ID: bigint;
21
- export declare const DEFAULT_FEEDS_MAP: Dictionary<bigint, Buffer>;
22
- export declare const TEST_FEEDS_MAP: Dictionary<bigint, Buffer>;
23
- export type FeedMapItem = {
24
- evaaId: bigint;
25
- referredPythFeed: bigint;
26
- };
27
- export declare function parseFeedsMapDict(dict: Dictionary<bigint, Buffer>): Map<bigint, FeedMapItem>;
package/dist/api/feeds.js DELETED
@@ -1,67 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseFeedsMapDict = exports.TEST_FEEDS_MAP = exports.DEFAULT_FEEDS_MAP = exports.EVAA_USDC_PRICE_FEED_ID = exports.EVAA_TSTON_PRICE_FEED_ID = exports.EVAA_STTON_PRICE_FEED_ID = exports.EVAA_USDT_PRICE_FEED_ID = exports.EVAA_DOGS_PRICE_FEED_ID = exports.EVAA_NOT_PRICE_FEED_ID = exports.EVAA_TON_PRICE_FEED_ID = exports.packConnectedFeeds = exports.bigintToBuffer = exports.PYTH_USDC_PRICE_FEED_ID = exports.PYTH_TSTON_PRICE_FEED_ID = exports.PYTH_STTON_PRICE_FEED_ID = exports.PYTH_USDT_PRICE_FEED_ID = exports.PYTH_DOGS_PRICE_FEED_ID = exports.PYTH_NOT_PRICE_FEED_ID = exports.PYTH_TON_PRICE_FEED_ID = void 0;
4
- const buffer_1 = require("buffer");
5
- const ton_1 = require("@ton/ton");
6
- const assets_1 = require("../constants/assets");
7
- exports.PYTH_TON_PRICE_FEED_ID = "0x8963217838ab4cf5cadc172203c1f0b763fbaa45f346d8ee50ba994bbcac3026";
8
- exports.PYTH_NOT_PRICE_FEED_ID = "0x75ec6f04d4bded6afdc1440689be4402dd1e23d2ff2c21e081871eb2739ceb36";
9
- exports.PYTH_DOGS_PRICE_FEED_ID = "0x3b75dbeeb6310f6264c812dd8411a6b30dc6d02cec4bca2447c88335127564f4";
10
- exports.PYTH_USDT_PRICE_FEED_ID = "0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b";
11
- exports.PYTH_STTON_PRICE_FEED_ID = "0x9145e059026a4d5a46f3b96408f7e572e33b3257b9c2dbe8dba551c772762002";
12
- exports.PYTH_TSTON_PRICE_FEED_ID = "0x3d1784128eeab5961ec60648fe497d3901eebd211b7f51e4bb0db9f024977d25";
13
- exports.PYTH_USDC_PRICE_FEED_ID = "0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a";
14
- function bigintToBuffer(value, size) {
15
- if (value < 0n) {
16
- throw new Error('Only non-negative bigint is supported');
17
- }
18
- // it's questionable whether it stores in LE or BE
19
- // and what option will TVM use, now by default it's BE
20
- const hex = value.toString(16);
21
- const padded = hex.padStart(size * 2, '0');
22
- return buffer_1.Buffer.from(padded, 'hex');
23
- }
24
- exports.bigintToBuffer = bigintToBuffer;
25
- const packConnectedFeeds = (evaa_id, reffered_id) => {
26
- return buffer_1.Buffer.concat([bigintToBuffer(evaa_id, 32), bigintToBuffer(reffered_id, 32)]);
27
- };
28
- exports.packConnectedFeeds = packConnectedFeeds;
29
- exports.EVAA_TON_PRICE_FEED_ID = assets_1.ASSET_ID.TON;
30
- exports.EVAA_NOT_PRICE_FEED_ID = assets_1.ASSET_ID.NOT;
31
- exports.EVAA_DOGS_PRICE_FEED_ID = assets_1.ASSET_ID.DOGS;
32
- exports.EVAA_USDT_PRICE_FEED_ID = assets_1.ASSET_ID.USDT;
33
- exports.EVAA_STTON_PRICE_FEED_ID = assets_1.ASSET_ID.stTON;
34
- exports.EVAA_TSTON_PRICE_FEED_ID = assets_1.ASSET_ID.tsTON;
35
- exports.EVAA_USDC_PRICE_FEED_ID = assets_1.ASSET_ID.jUSDC;
36
- exports.DEFAULT_FEEDS_MAP = (() => {
37
- const map = ton_1.Dictionary.empty();
38
- map.set(BigInt(exports.PYTH_TON_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_TON_PRICE_FEED_ID, 0n));
39
- map.set(BigInt(exports.PYTH_USDT_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_USDT_PRICE_FEED_ID, 0n));
40
- map.set(BigInt(exports.PYTH_NOT_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_NOT_PRICE_FEED_ID, 0n));
41
- map.set(BigInt(exports.PYTH_DOGS_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_DOGS_PRICE_FEED_ID, 0n));
42
- map.set(BigInt(exports.PYTH_STTON_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_STTON_PRICE_FEED_ID, BigInt(exports.PYTH_TON_PRICE_FEED_ID)));
43
- map.set(BigInt(exports.PYTH_TSTON_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_TSTON_PRICE_FEED_ID, BigInt(exports.PYTH_TON_PRICE_FEED_ID)));
44
- return map;
45
- })();
46
- exports.TEST_FEEDS_MAP = (() => {
47
- const map = ton_1.Dictionary.empty();
48
- map.set(BigInt(exports.PYTH_TON_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_TON_PRICE_FEED_ID, 0n));
49
- map.set(BigInt(exports.PYTH_USDT_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_USDT_PRICE_FEED_ID, 0n));
50
- map.set(BigInt(exports.PYTH_STTON_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_STTON_PRICE_FEED_ID, BigInt(exports.PYTH_TON_PRICE_FEED_ID)));
51
- map.set(BigInt(exports.PYTH_TSTON_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_TSTON_PRICE_FEED_ID, BigInt(exports.PYTH_TON_PRICE_FEED_ID)));
52
- map.set(BigInt(exports.PYTH_USDC_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_USDC_PRICE_FEED_ID, 0n));
53
- return map;
54
- })();
55
- function parseFeedsMapDict(dict) {
56
- const parsedData = new Map();
57
- for (const key of dict.keys()) {
58
- const buffer = dict.get(key);
59
- const hex1 = '0x' + buffer.toString('hex', 0, 32);
60
- const hex2 = '0x' + buffer.toString('hex', 32);
61
- const evaaId = BigInt(hex1);
62
- const referredPythFeed = BigInt(hex2);
63
- parsedData.set(key, { evaaId, referredPythFeed });
64
- }
65
- return parsedData;
66
- }
67
- exports.parseFeedsMapDict = parseFeedsMapDict;
@@ -1,16 +0,0 @@
1
- import { Address } from "@ton/ton";
2
- import { Cell } from "@ton/core";
3
- export declare function makePythProxyMessage(pythAddress: Address, targetAddress: Address, attachedTons: bigint, priceUpdateData: Cell, targetPythFeeds: Cell, minPublishTime: number | bigint, maxPublishTime: number | bigint, operationPayload: Cell): Cell;
4
- /**
5
- * This operation jetton transfer notification sends to master address
6
- * @param args
7
- */
8
- export declare function makeOnchainGetterMasterMessage(args: {
9
- queryId: number | bigint;
10
- opCode: number | bigint;
11
- updateDataCell: Cell;
12
- targetFeedsCell: Cell;
13
- publishGap: number | bigint;
14
- maxStaleness: number | bigint;
15
- operationPayload: Cell;
16
- }): Cell;
package/dist/api/pyth.js DELETED
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeOnchainGetterMasterMessage = exports.makePythProxyMessage = void 0;
4
- // user --> pyth --> target
5
- const ton_1 = require("@ton/ton");
6
- function makePythProxyMessage(pythAddress, targetAddress, attachedTons, priceUpdateData, targetPythFeeds, minPublishTime, maxPublishTime, operationPayload) {
7
- return (0, ton_1.beginCell)()
8
- .storeUint(0x18, 6)
9
- .storeAddress(pythAddress)
10
- .storeCoins(attachedTons)
11
- .storeUint(0, 107)
12
- .storeUint(5, 32) // pyth::op_parse_price_feed_updates
13
- .storeRef(priceUpdateData)
14
- .storeRef(targetPythFeeds)
15
- .storeUint(minPublishTime, 64)
16
- .storeUint(maxPublishTime, 64)
17
- .storeAddress(targetAddress) // inform pyth where to send positive response
18
- .storeRef(operationPayload)
19
- .endCell();
20
- }
21
- exports.makePythProxyMessage = makePythProxyMessage;
22
- /**
23
- * This operation jetton transfer notification sends to master address
24
- * @param args
25
- */
26
- function makeOnchainGetterMasterMessage(args) {
27
- return (0, ton_1.beginCell)()
28
- .storeUint(args.opCode, 32)
29
- .storeUint(args.queryId, 64)
30
- .storeRef((0, ton_1.beginCell)()
31
- .storeRef(args.updateDataCell)
32
- .storeRef(args.targetFeedsCell)
33
- .storeUint(args.publishGap, 64)
34
- .storeUint(args.maxStaleness, 64)
35
- .endCell())
36
- .storeRef(args.operationPayload)
37
- .endCell();
38
- }
39
- exports.makeOnchainGetterMasterMessage = makeOnchainGetterMasterMessage;
@@ -1,39 +0,0 @@
1
- import { PriceSource } from "./PriceSource";
2
- import { RawPriceData } from "..";
3
- export declare class IotaPriceSource extends PriceSource {
4
- protected priceSourceName: string;
5
- getPrices(): Promise<RawPriceData[]>;
6
- loadOracleData(oracleNftId: String): Promise<OutputData>;
7
- parsePrices(outputData: OutputData, oracleId: number): RawPriceData;
8
- }
9
- type OutputData = {
10
- metadata: {
11
- blockId: string;
12
- transactionId: string;
13
- outputIndex: number;
14
- isSpent: boolean;
15
- milestoneIndexSpent: number;
16
- milestoneTimestampSpent: number;
17
- transactionIdSpent: string;
18
- milestoneIndexBooked: number;
19
- milestoneTimestampBooked: number;
20
- ledgerIndex: number;
21
- };
22
- output: {
23
- type: number;
24
- amount: string;
25
- nftId: string;
26
- unlockConditions: {
27
- type: number;
28
- address: {
29
- type: number;
30
- pubKeyHash: string;
31
- };
32
- }[];
33
- features: {
34
- type: number;
35
- data: string;
36
- }[];
37
- };
38
- };
39
- export {};
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IotaPriceSource = void 0;
4
- const core_1 = require("@ton/core");
5
- const PriceSource_1 = require("./PriceSource");
6
- class IotaPriceSource extends PriceSource_1.PriceSource {
7
- constructor() {
8
- super(...arguments);
9
- this.priceSourceName = 'IotaPriceSource';
10
- }
11
- async getPrices() {
12
- return await Promise.all(this.nfts.map(nft => this.loadOracleData(nft.address)
13
- .then(x => this.parsePrices(x, nft.id))));
14
- }
15
- async loadOracleData(oracleNftId) {
16
- let result = await fetch(`https://${this._endpoint}/api/indexer/v1/outputs/nft/${oracleNftId}`, {
17
- headers: { accept: 'application/json' },
18
- signal: AbortSignal.timeout(5000)
19
- });
20
- let outputId = (await result.json());
21
- result = await fetch(`https://${this._endpoint}/api/core/v2/outputs/${outputId.items[0]}`, {
22
- headers: { accept: 'application/json' },
23
- signal: AbortSignal.timeout(5000)
24
- });
25
- return await result.json();
26
- }
27
- parsePrices(outputData, oracleId) {
28
- const data = JSON.parse(decodeURIComponent(outputData.output.features[0].data.replace('0x', '').replace(/[0-9a-f]{2}/g, '%$&')));
29
- try {
30
- const pricesCell = core_1.Cell.fromBoc(Buffer.from(data['packedPrices'], 'hex'))[0];
31
- const signature = Buffer.from(data['signature'], 'hex');
32
- const publicKey = Buffer.from(data['publicKey'], 'hex');
33
- const timestamp = Number(data['timestamp']);
34
- return {
35
- dict: pricesCell.beginParse().loadRef().beginParse().loadDictDirect(core_1.Dictionary.Keys.BigUint(256), core_1.Dictionary.Values.BigVarUint(4)),
36
- dataCell: (0, core_1.beginCell)().storeRef(pricesCell).storeBuffer(signature).endCell(),
37
- oracleId: oracleId,
38
- signature: signature,
39
- pubkey: publicKey,
40
- timestamp: timestamp,
41
- };
42
- }
43
- catch (error) {
44
- //console.debug(`Price source error ${this.priceSourceName} ${outputData} ${error}`);
45
- throw error;
46
- }
47
- }
48
- }
49
- exports.IotaPriceSource = IotaPriceSource;