import { setPaginationParams } from "../../helpers"; import { LCDClient } from "@osmonauts/lcd"; import { ModuleToDistributeCoinsRequest, ModuleToDistributeCoinsResponseSDKType, ModuleDistributedCoinsRequest, ModuleDistributedCoinsResponseSDKType, GaugeByIDRequest, GaugeByIDResponseSDKType, GaugesRequest, GaugesResponseSDKType, ActiveGaugesRequest, ActiveGaugesResponseSDKType, ActiveGaugesPerDenomRequest, ActiveGaugesPerDenomResponseSDKType, UpcomingGaugesRequest, UpcomingGaugesResponseSDKType, UpcomingGaugesPerDenomRequest, UpcomingGaugesPerDenomResponseSDKType, RewardsEstRequest, RewardsEstResponseSDKType, QueryLockableDurationsRequest, QueryLockableDurationsResponseSDKType } from "./query"; export class LCDQueryClient { req: LCDClient; constructor({ requestClient }: { requestClient: LCDClient; }) { this.req = requestClient; this.moduleToDistributeCoins = this.moduleToDistributeCoins.bind(this); this.moduleDistributedCoins = this.moduleDistributedCoins.bind(this); this.gaugeByID = this.gaugeByID.bind(this); this.gauges = this.gauges.bind(this); this.activeGauges = this.activeGauges.bind(this); this.activeGaugesPerDenom = this.activeGaugesPerDenom.bind(this); this.upcomingGauges = this.upcomingGauges.bind(this); this.upcomingGaugesPerDenom = this.upcomingGaugesPerDenom.bind(this); this.rewardsEst = this.rewardsEst.bind(this); this.lockableDurations = this.lockableDurations.bind(this); } /* ModuleToDistributeCoins returns coins that are going to be distributed */ async moduleToDistributeCoins(_params: ModuleToDistributeCoinsRequest = {}): Promise { const endpoint = `osmosis/incentives/v1beta1/module_to_distribute_coins`; return await this.req.get(endpoint); } /* ModuleDistributedCoins returns coins that are distributed by the module so far */ async moduleDistributedCoins(_params: ModuleDistributedCoinsRequest = {}): Promise { const endpoint = `osmosis/incentives/v1beta1/module_distributed_coins`; return await this.req.get(endpoint); } /* GaugeByID returns gauges by their respective ID */ async gaugeByID(params: GaugeByIDRequest): Promise { const endpoint = `osmosis/incentives/v1beta1/gauge_by_id/${params.id}`; return await this.req.get(endpoint); } /* Gauges returns both upcoming and active gauges */ async gauges(params: GaugesRequest = { pagination: undefined }): Promise { const options: any = { params: {} }; if (typeof params?.pagination !== "undefined") { setPaginationParams(options, params.pagination); } const endpoint = `osmosis/incentives/v1beta1/gauges`; return await this.req.get(endpoint, options); } /* ActiveGauges returns active gauges */ async activeGauges(params: ActiveGaugesRequest = { pagination: undefined }): Promise { const options: any = { params: {} }; if (typeof params?.pagination !== "undefined") { setPaginationParams(options, params.pagination); } const endpoint = `osmosis/incentives/v1beta1/active_gauges`; return await this.req.get(endpoint, options); } /* ActiveGaugesPerDenom returns active gauges by denom */ async activeGaugesPerDenom(params: ActiveGaugesPerDenomRequest): Promise { const options: any = { params: {} }; if (typeof params?.denom !== "undefined") { options.params.denom = params.denom; } if (typeof params?.pagination !== "undefined") { setPaginationParams(options, params.pagination); } const endpoint = `osmosis/incentives/v1beta1/active_gauges_per_denom`; return await this.req.get(endpoint, options); } /* Returns scheduled gauges that have not yet occured */ async upcomingGauges(params: UpcomingGaugesRequest = { pagination: undefined }): Promise { const options: any = { params: {} }; if (typeof params?.pagination !== "undefined") { setPaginationParams(options, params.pagination); } const endpoint = `osmosis/incentives/v1beta1/upcoming_gauges`; return await this.req.get(endpoint, options); } /* UpcomingGaugesPerDenom returns scheduled gauges that have not yet occured by denom */ async upcomingGaugesPerDenom(params: UpcomingGaugesPerDenomRequest): Promise { const options: any = { params: {} }; if (typeof params?.denom !== "undefined") { options.params.denom = params.denom; } if (typeof params?.pagination !== "undefined") { setPaginationParams(options, params.pagination); } const endpoint = `osmosis/incentives/v1beta1/upcoming_gauges_per_denom`; return await this.req.get(endpoint, options); } /* RewardsEst returns an estimate of the rewards from now until a specified time in the future The querier either provides an address or a set of locks for which they want to find the associated rewards */ async rewardsEst(params: RewardsEstRequest): Promise { const options: any = { params: {} }; if (typeof params?.lockIds !== "undefined") { options.params.lock_ids = params.lockIds; } if (typeof params?.endEpoch !== "undefined") { options.params.end_epoch = params.endEpoch; } const endpoint = `osmosis/incentives/v1beta1/rewards_est/${params.owner}`; return await this.req.get(endpoint, options); } /* LockableDurations returns lockable durations that are valid to distribute incentives for */ async lockableDurations(_params: QueryLockableDurationsRequest = {}): Promise { const endpoint = `osmosis/incentives/v1beta1/lockable_durations`; return await this.req.get(endpoint); } }