UNPKG

pulsar_sdk_js

Version:

A convenient way for you to interact with Pulsar's Third Party APIs, using typified classes.

36 lines (35 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const class_transformer_1 = require("class-transformer"); const base_1 = require("./base"); const schema_1 = require("../data/dataclasses/schema"); class ProtocolRestClient extends base_1.RestClient { async list_protocols(chain) { const response = await this._request(`/protocols/all-protocols`, 'GET', {}, { chain, }); return response.map((protocol) => (0, class_transformer_1.plainToInstance)(schema_1.ProtocolData, protocol)); } async get_number_protocols() { return await this._request(`/protocols/total-protocols`, 'GET'); } async get_filtered_protocols(options = {}) { const { chains = undefined, name = undefined, tvl = undefined, sort_by = undefined, offset = 0, limit = 10, } = options; const response = await this._request(`/protocols`, 'GET', {}, { chains, name, tvl, sort_by, offset, limit, }); return (0, class_transformer_1.plainToInstance)(schema_1.PaginatedProtocolWithStats, response); } async get_protocol_timeseries(protocol_key, tier_name) { const response = await this._request(`/protocols/${protocol_key}/timeseries`, 'GET', {}, { tier_name, }); return (0, class_transformer_1.plainToInstance)(schema_1.ProtocolTimeseries, response); } } exports.default = ProtocolRestClient;