UNPKG

@ixily/activ

Version:

Alpha Capture Trade Idea Verification. Blockchain ownership proven trade ideas and strategies.

77 lines 2.88 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GET_PRICE_BINANCE_V2 = void 0; const testPricing = async (params) => { const headers = // params.key !== undefined && params.key !== '' // ? { // 'X-MBX-APIKEY': params.key!, // 'X-MBX-APISECRET': params.secret!, // accept: '*/*', // Origin: 'https://api.binance.com/', // } : { accept: '*/*', Origin: 'https://api.binance.com/', }; const fetcherOptionHeaders = { url: 'https://api.binance.com/api/v3/ticker/bookTicker?symbol=' + params.symbol, method: 'GET', headers, }; const data = await fetch(fetcherOptionHeaders.url, fetcherOptionHeaders).then((res) => res.json()); if (data?.msg) { if (data?.msg?.length > 0) { throw new Error('Binance Api Error:' + data.msg); } } // must be alphabetical order // const globalPrice = parseFloat(data.price); const ask = parseFloat(data.askPrice); const bid = parseFloat(data.bidPrice); let globalPrice = (ask + bid) / 2; const askAfterDot = ask.toString().split('.'); let askDecimals = 0; if (askAfterDot.length > 1) { askDecimals = askAfterDot[1].length; } const bidAfterDot = bid.toString().split('.'); let bidDecimals = 0; if (bidAfterDot.length > 1) { bidDecimals = bidAfterDot[1].length; } const decimals = Math.max(askDecimals, bidDecimals); globalPrice = parseFloat(globalPrice.toFixed(decimals)); const timestamp = Date.now(); // Math.floor(Date.now() / 10000) * 10000; // to seconds downscaled const priceObj = { ask, bid, globalPrice, // nonce: nonce(timestamp, "Binance", symbol, globalPrice), provider: 'Binance', symbol: params.symbol, timestamp, }; if (params.useProxy === true) { priceObj.fromProxy = 'https://api.ixily.io/v1/proxy'; } return priceObj; }; /* Final action: Network: Lit Chronicle Onwer Account Wallet: FIRED! => Mint&Grant&Burned! => SECURED! PKP id: 54926627617813999926323273579003809785133112092147275613318244148720832946777 PKP public key: 0x044a922c8424ebc1e51144c2552d782ae4322a3091fb2b783f054eae83a44ae3282e66d23d27ffea491376c88b8bd931742cbc5a4cd49ddeb9e6f7c9f4fc419fee PKP ETH: 0x62555428470948d1861D91701b6C54f53501076a Action ipfsId: QmfLHpfQ5LRg2m3DCeuPLteXnrc24C5KH9UyeFywYfZwfD granted?: true */ exports.GET_PRICE_BINANCE_V2 = { ipfsId: 'QmfLHpfQ5LRg2m3DCeuPLteXnrc24C5KH9UyeFywYfZwfD', publicKey: '0x044a922c8424ebc1e51144c2552d782ae4322a3091fb2b783f054eae83a44ae3282e66d23d27ffea491376c88b8bd931742cbc5a4cd49ddeb9e6f7c9f4fc419fee', keyEthAddress: '0x62555428470948d1861D91701b6C54f53501076a', testPricing, }; //# sourceMappingURL=get-price-binance-v2.js.map