@clonegod/ttd-sol-common 1.0.145 → 1.0.146
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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/token/index.d.ts +4 -0
- package/dist/token/index.js +20 -0
- package/dist/token/util.d.ts +2 -0
- package/dist/token/util.js +27 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
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("./types"), exports);
|
|
18
|
+
__exportStar(require("./get_token_info"), exports);
|
|
19
|
+
__exportStar(require("./get_token_price"), exports);
|
|
20
|
+
__exportStar(require("./util"), exports);
|
package/dist/token/util.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
+
import { StandardTokenInfoType, TokenPriceWithAmountType } from "@clonegod/ttd-common";
|
|
1
2
|
export declare const is_token_2022: (programId: string) => programId is "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
3
|
+
export declare const calculate_token_amount: (token_info: StandardTokenInfoType, value_of_usd?: number) => Promise<TokenPriceWithAmountType>;
|
package/dist/token/util.js
CHANGED
|
@@ -1,7 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.is_token_2022 = void 0;
|
|
12
|
+
exports.calculate_token_amount = exports.is_token_2022 = void 0;
|
|
13
|
+
const dist_1 = require("@clonegod/ttd-common/dist");
|
|
14
|
+
const get_token_price_1 = require("./get_token_price");
|
|
4
15
|
const is_token_2022 = (programId) => {
|
|
5
16
|
return programId === 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
|
|
6
17
|
};
|
|
7
18
|
exports.is_token_2022 = is_token_2022;
|
|
19
|
+
const calculate_token_amount = (token_info_1, ...args_1) => __awaiter(void 0, [token_info_1, ...args_1], void 0, function* (token_info, value_of_usd = 100) {
|
|
20
|
+
var _a;
|
|
21
|
+
let out;
|
|
22
|
+
let { market_price } = token_info;
|
|
23
|
+
if (!market_price) {
|
|
24
|
+
let address = token_info.address;
|
|
25
|
+
let price_map = yield (0, get_token_price_1.get_token_price_info)([address]);
|
|
26
|
+
market_price = (_a = price_map.get(address)) === null || _a === void 0 ? void 0 : _a.price;
|
|
27
|
+
}
|
|
28
|
+
if (market_price) {
|
|
29
|
+
out = (0, dist_1.calc_amount_in_token)(value_of_usd, market_price, token_info);
|
|
30
|
+
}
|
|
31
|
+
return out;
|
|
32
|
+
});
|
|
33
|
+
exports.calculate_token_amount = calculate_token_amount;
|