UNPKG

@ixily/activ

Version:

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

69 lines (62 loc) 1.95 kB
import { IActivDirectSearchAssetParams, ILitAction, CONTRACT_INTERFACES, } from '../../..' const testPricing = async ( params: IActivDirectSearchAssetParams, ): Promise<CONTRACT_INTERFACES.IPrice> => { const headers = { // 'Content-Type': 'application/default+json; charset=utf-8', 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*', Accept: '*/*', Connection: 'keep-alive', 'X-CMC_PRO_API_KEY': params.key, } const requestRecipe = { url: 'https://api.ixily.io/v1/proxy', method: 'POST', body: JSON.stringify({ url: 'https://pro-api.coinmarketcap.com/v2/cryptocurrency/quotes/latest?symbol=' + params.symbol, method: 'GET', headers, }), headers, } const data = ( await fetch( requestRecipe.url, requestRecipe as unknown as RequestInit, ).then((res) => res.json()) ).data[params.symbol][0].quote['USD'] // must be alphabetical order const globalPrice = data.price const timestamp = Date.now() const priceObj: CONTRACT_INTERFACES.IPrice = { globalPrice, provider: 'CoinMarketCap', symbol: params.symbol, timestamp, } return priceObj } /* Final action: Network: Lit Chronicle Onwer Account Wallet: FIRED! => Mint&Grant&Burned! => SECURED! PKP id: 2316232605630740772521655096411393640179305801596789871357650281153997400319 PKP public key: 0x0449fa44b5389a80cb1f11b01b8a7880ff71e4618d93943ede5b2bfe24152526596faa3b122c9eb1d1e46f736254828ed6202d697857058f240bcbe0c3ce7bc0d6 PKP ETH: 0xabeB4EEaFa61dd7600E1091BbAc363903355455e Action ipfsId: Qmd5AuhthaRoVZArX4sq9jLPm8QCKTeg6zwwYdxk7FMRCY granted?: true */ export const GET_PRICE_COINMARKETCAP_V2: ILitAction = { ipfsId: 'Qmd5AuhthaRoVZArX4sq9jLPm8QCKTeg6zwwYdxk7FMRCY', publicKey: '0x0449fa44b5389a80cb1f11b01b8a7880ff71e4618d93943ede5b2bfe24152526596faa3b122c9eb1d1e46f736254828ed6202d697857058f240bcbe0c3ce7bc0d6', keyEthAddress: '0xabeB4EEaFa61dd7600E1091BbAc363903355455e', testPricing, }