@render-foundation/utils 0.0.259 → 0.0.260
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/lib/cjs/client/price.js +15 -22
- package/lib/cjs/client/price.js.map +1 -1
- package/lib/esm/src/client/price.js +15 -22
- package/lib/esm/src/client/price.js.map +1 -1
- package/lib/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/src/client/price.d.ts.map +1 -1
- package/package.json +2 -2
- package/lib/cjs/tsconfig.cjs.tsbuildinfo +0 -1
package/lib/cjs/client/price.js
CHANGED
|
@@ -16,7 +16,9 @@ exports.priceClient = void 0;
|
|
|
16
16
|
const coingecko_api_v3_1 = require("coingecko-api-v3");
|
|
17
17
|
const ccxt_1 = __importDefault(require("ccxt"));
|
|
18
18
|
const priceClient = () => {
|
|
19
|
-
|
|
19
|
+
// binanceus removed 2026-08: api.binance.us is decommissioned (DNS gone) — and its uncaught fetch
|
|
20
|
+
// failure threw BEFORE the coinbase fallback could run, breaking buy-and-burn pricing entirely.
|
|
21
|
+
// coinbase (RENDER/USD) is the primary source now.
|
|
20
22
|
const cb = new ccxt_1.default.coinbase({});
|
|
21
23
|
const client = new coingecko_api_v3_1.CoinGeckoClient({
|
|
22
24
|
timeout: 10000,
|
|
@@ -46,32 +48,23 @@ const priceClient = () => {
|
|
|
46
48
|
var _a;
|
|
47
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
50
|
const symbol = (_a = p.symbol) !== null && _a !== void 0 ? _a : 'RENDER/USDT';
|
|
49
|
-
// coinbase lists RENDER as RENDER/USD, not RENDER/USDT —
|
|
51
|
+
// coinbase lists RENDER as RENDER/USD, not RENDER/USDT — callers still pass the USDT form.
|
|
50
52
|
const cbSymbol = symbol.replace('/USDT', '/USD');
|
|
51
53
|
const since = p.ts.getTime();
|
|
52
|
-
// 1) Historical: the 1m candle at/after ts
|
|
53
|
-
|
|
54
|
-
if (ticks.length == 0)
|
|
55
|
-
ticks = yield cb.fetchOHLCV(cbSymbol, '1m', since, 1);
|
|
54
|
+
// 1) Historical: the 1m candle at/after ts.
|
|
55
|
+
const ticks = yield cb.fetchOHLCV(cbSymbol, '1m', since, 1);
|
|
56
56
|
if (ticks.length > 0)
|
|
57
57
|
return Number(ticks[0][4]);
|
|
58
|
-
// 2) OHLCV empty — typically ts ≈ now (the current minute has no closed candle yet)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const t = yield ex.fetchTicker(sym);
|
|
67
|
-
if (t.last)
|
|
68
|
-
return Number(t.last);
|
|
69
|
-
}
|
|
70
|
-
catch (_b) {
|
|
71
|
-
/* try next source */
|
|
72
|
-
}
|
|
58
|
+
// 2) OHLCV empty — typically ts ≈ now (the current minute has no closed candle yet): live ticker.
|
|
59
|
+
try {
|
|
60
|
+
const t = yield cb.fetchTicker(cbSymbol);
|
|
61
|
+
if (t.last)
|
|
62
|
+
return Number(t.last);
|
|
63
|
+
}
|
|
64
|
+
catch (_b) {
|
|
65
|
+
/* fall through to the error below */
|
|
73
66
|
}
|
|
74
|
-
throw new Error(`failed fetching RENDER price for ${
|
|
67
|
+
throw new Error(`failed fetching RENDER price for ${cbSymbol} at ${p.ts.toISOString()}`);
|
|
75
68
|
});
|
|
76
69
|
},
|
|
77
70
|
getCurrPrice() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price.js","sourceRoot":"","sources":["../../../src/client/price.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAAkD;AAClD,gDAAuB;AAgBhB,MAAM,WAAW,GAAG,GAAgB,EAAE;IAC3C,
|
|
1
|
+
{"version":3,"file":"price.js","sourceRoot":"","sources":["../../../src/client/price.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAAkD;AAClD,gDAAuB;AAgBhB,MAAM,WAAW,GAAG,GAAgB,EAAE;IAC3C,kGAAkG;IACl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AAE,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;gBAC3D,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;oBAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;gBAEhD,kGAAkG;gBAClG,IAAI;oBACF,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;oBACxC,IAAI,CAAC,CAAC,IAAI;wBAAE,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;iBAClC;gBAAC,WAAM;oBACN,qCAAqC;iBACtC;gBACD,MAAM,IAAI,KAAK,CACb,oCAAoC,QAAQ,OAAO,CAAC,CAAC,EAAE,CAAC,WAAW,EAAE,EAAE,CACxE,CAAA;;SACF;QACK,YAAY;;;gBAChB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,cAAc,EAAE,CAAC,CAAA;gBACvD,OAAO,MAAA,GAAG,CAAC,WAAW,0CAAE,aAAa,CAAE,KAAK,CAAE,CAAA;;SAC/C;KACF,CAAA;AACH,CAAC,CAAA;AAzDY,QAAA,WAAW,eAyDvB"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { CoinGeckoClient } from 'coingecko-api-v3';
|
|
2
2
|
import ccxt from 'ccxt';
|
|
3
3
|
export const priceClient = () => {
|
|
4
|
-
|
|
4
|
+
// binanceus removed 2026-08: api.binance.us is decommissioned (DNS gone) — and its uncaught fetch
|
|
5
|
+
// failure threw BEFORE the coinbase fallback could run, breaking buy-and-burn pricing entirely.
|
|
6
|
+
// coinbase (RENDER/USD) is the primary source now.
|
|
5
7
|
const cb = new ccxt.coinbase({});
|
|
6
8
|
const client = new CoinGeckoClient({
|
|
7
9
|
timeout: 10000,
|
|
@@ -27,32 +29,23 @@ export const priceClient = () => {
|
|
|
27
29
|
},
|
|
28
30
|
async getRenderPriceAtDate(p) {
|
|
29
31
|
const symbol = p.symbol ?? 'RENDER/USDT';
|
|
30
|
-
// coinbase lists RENDER as RENDER/USD, not RENDER/USDT —
|
|
32
|
+
// coinbase lists RENDER as RENDER/USD, not RENDER/USDT — callers still pass the USDT form.
|
|
31
33
|
const cbSymbol = symbol.replace('/USDT', '/USD');
|
|
32
34
|
const since = p.ts.getTime();
|
|
33
|
-
// 1) Historical: the 1m candle at/after ts
|
|
34
|
-
|
|
35
|
-
if (ticks.length == 0)
|
|
36
|
-
ticks = await cb.fetchOHLCV(cbSymbol, '1m', since, 1);
|
|
35
|
+
// 1) Historical: the 1m candle at/after ts.
|
|
36
|
+
const ticks = await cb.fetchOHLCV(cbSymbol, '1m', since, 1);
|
|
37
37
|
if (ticks.length > 0)
|
|
38
38
|
return Number(ticks[0][4]);
|
|
39
|
-
// 2) OHLCV empty — typically ts ≈ now (the current minute has no closed candle yet)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const t = await ex.fetchTicker(sym);
|
|
48
|
-
if (t.last)
|
|
49
|
-
return Number(t.last);
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
52
|
-
/* try next source */
|
|
53
|
-
}
|
|
39
|
+
// 2) OHLCV empty — typically ts ≈ now (the current minute has no closed candle yet): live ticker.
|
|
40
|
+
try {
|
|
41
|
+
const t = await cb.fetchTicker(cbSymbol);
|
|
42
|
+
if (t.last)
|
|
43
|
+
return Number(t.last);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
/* fall through to the error below */
|
|
54
47
|
}
|
|
55
|
-
throw new Error(`failed fetching RENDER price for ${
|
|
48
|
+
throw new Error(`failed fetching RENDER price for ${cbSymbol} at ${p.ts.toISOString()}`);
|
|
56
49
|
},
|
|
57
50
|
async getCurrPrice() {
|
|
58
51
|
const res = await client.coinId({ id: 'render-token' });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price.js","sourceRoot":"","sources":["../../../../src/client/price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,IAAI,MAAM,MAAM,CAAA;AAgBvB,MAAM,CAAC,MAAM,WAAW,GAAG,GAAgB,EAAE;IAC3C,
|
|
1
|
+
{"version":3,"file":"price.js","sourceRoot":"","sources":["../../../../src/client/price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,IAAI,MAAM,MAAM,CAAA;AAgBvB,MAAM,CAAC,MAAM,WAAW,GAAG,GAAgB,EAAE;IAC3C,kGAAkG;IAClG,gGAAgG;IAChG,mDAAmD;IACnD,MAAM,EAAE,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAEhC,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC;QACjC,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,IAAI;KAChB,CAAC,CAAA;IAEF,OAAO;QACL,KAAK,CAAC,SAAS,CAAC,EAAQ;YACtB,oEAAoE;YACpE,IAAI,UAA8B,CAAA;YAClC,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;YACpE,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;gBAAE,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;iBACjD;gBACH,uFAAuF;gBACvF,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAA;gBAC1C,IAAI,CAAC,CAAC,IAAI;oBAAE,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;aACxC;YACD,IAAI,CAAC,UAA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