@cryptorubic/core 1.0.0-alpha.no-sdk.11 → 1.0.0-alpha.no-sdk.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptorubic/core",
3
- "version": "1.0.0-alpha.no-sdk.11",
3
+ "version": "1.0.0-alpha.no-sdk.13",
4
4
  "dependencies": {
5
5
  "bignumber.js": "9.1.2",
6
6
  "tslib": "*"
@@ -9,4 +9,18 @@ export declare class PriceToken<Blockchain extends BlockchainName = BlockchainNa
9
9
  get asStructWithPrice(): PriceTokenStruct<Blockchain>;
10
10
  constructor(tokenStruct: PriceTokenStruct<Blockchain>);
11
11
  clone(tokenStruct?: Partial<PriceTokenStruct>): PriceToken;
12
+ /**
13
+ * Fetches current token price and saves it into token.
14
+ * @param coingeckoApi {path to type @type rubic-app/src/app/core/services/sdk/sdk-legacy/coingecko/coingecko.service.ts}
15
+ * coingeckoApi should implement
16
+ * @interface {
17
+ * getTokenPrice({address: string; blockchain: BlockchainName}): Promise<BigNumber>
18
+ * }
19
+ * returns BigNumber usd price of token in human-readable format ex. 1.09
20
+ */
21
+ getAndUpdateTokenPrice(coingeckoApi: any): Promise<BigNumber>;
22
+ /**
23
+ * @param coingeckoApi {path to type @type rubic-app/src/app/core/services/sdk/sdk-legacy/coingecko/coingecko.service.ts}
24
+ */
25
+ private updateTokenPrice;
12
26
  }
@@ -26,5 +26,24 @@ class PriceToken extends token_1.Token {
26
26
  clone(tokenStruct) {
27
27
  return new PriceToken({ ...this, ...tokenStruct });
28
28
  }
29
+ /**
30
+ * Fetches current token price and saves it into token.
31
+ * @param coingeckoApi {path to type @type rubic-app/src/app/core/services/sdk/sdk-legacy/coingecko/coingecko.service.ts}
32
+ * coingeckoApi should implement
33
+ * @interface {
34
+ * getTokenPrice({address: string; blockchain: BlockchainName}): Promise<BigNumber>
35
+ * }
36
+ * returns BigNumber usd price of token in human-readable format ex. 1.09
37
+ */
38
+ async getAndUpdateTokenPrice(coingeckoApi) {
39
+ await this.updateTokenPrice(coingeckoApi);
40
+ return this.price;
41
+ }
42
+ /**
43
+ * @param coingeckoApi {path to type @type rubic-app/src/app/core/services/sdk/sdk-legacy/coingecko/coingecko.service.ts}
44
+ */
45
+ async updateTokenPrice(coingeckoApi) {
46
+ this._price = await coingeckoApi.getTokenPrice({ ...this }).catch(() => this._price);
47
+ }
29
48
  }
30
49
  exports.PriceToken = PriceToken;