-
Notifications
You must be signed in to change notification settings - Fork 204
Expand file tree
/
Copy pathChainGrpcInsuranceFundApi.ts
More file actions
105 lines (86 loc) · 3.48 KB
/
ChainGrpcInsuranceFundApi.ts
File metadata and controls
105 lines (86 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import * as InjectiveInsuranceV1Beta1QueryPb from '@injectivelabs/core-proto-ts-v2/generated/injective/insurance/v1beta1/query_pb'
import { QueryClient as InjectiveInsuranceV1Beta1QueryClient } from '@injectivelabs/core-proto-ts-v2/generated/injective/insurance/v1beta1/query_pb.client'
import { ChainModule } from '../types/index.js'
import BaseGrpcConsumer from '../../base/BaseGrpcConsumer.js'
import { ChainGrpcInsuranceFundTransformer } from '../transformers/ChainGrpcInsuranceFundTransformer.js'
/**
* @category Chain Grpc API
*/
export class ChainGrpcInsuranceFundApi extends BaseGrpcConsumer {
protected module: string = ChainModule.InsuranceFund
private get client() {
return this.initClient(InjectiveInsuranceV1Beta1QueryClient)
}
async fetchModuleParams() {
const request =
InjectiveInsuranceV1Beta1QueryPb.QueryInsuranceParamsRequest.create()
const response = await this.executeGrpcCall<
InjectiveInsuranceV1Beta1QueryPb.QueryInsuranceParamsRequest,
InjectiveInsuranceV1Beta1QueryPb.QueryInsuranceParamsResponse
>(request, this.client.insuranceParams.bind(this.client))
return ChainGrpcInsuranceFundTransformer.moduleParamsResponseToModuleParams(
response,
)
}
async fetchInsuranceFunds() {
const request =
InjectiveInsuranceV1Beta1QueryPb.QueryInsuranceFundsRequest.create()
const response = await this.executeGrpcCall<
InjectiveInsuranceV1Beta1QueryPb.QueryInsuranceFundsRequest,
InjectiveInsuranceV1Beta1QueryPb.QueryInsuranceFundsResponse
>(request, this.client.insuranceFunds.bind(this.client))
return ChainGrpcInsuranceFundTransformer.insuranceFundsResponseToInsuranceFunds(
response,
)
}
async fetchInsuranceFund(marketId: string) {
const request =
InjectiveInsuranceV1Beta1QueryPb.QueryInsuranceFundRequest.create()
request.marketId = marketId
const response = await this.executeGrpcCall<
InjectiveInsuranceV1Beta1QueryPb.QueryInsuranceFundRequest,
InjectiveInsuranceV1Beta1QueryPb.QueryInsuranceFundResponse
>(request, this.client.insuranceFund.bind(this.client))
return ChainGrpcInsuranceFundTransformer.insuranceFundResponseToInsuranceFund(
response,
)
}
async fetchEstimatedRedemptions({
marketId,
address,
}: {
marketId: string
address: string
}) {
const request =
InjectiveInsuranceV1Beta1QueryPb.QueryEstimatedRedemptionsRequest.create()
request.marketId = marketId
request.address = address
const response = await this.executeGrpcCall<
InjectiveInsuranceV1Beta1QueryPb.QueryEstimatedRedemptionsRequest,
InjectiveInsuranceV1Beta1QueryPb.QueryEstimatedRedemptionsResponse
>(request, this.client.estimatedRedemptions.bind(this.client))
return ChainGrpcInsuranceFundTransformer.estimatedRedemptionsResponseToEstimatedRedemptions(
response,
)
}
async fetchPendingRedemptions({
marketId,
address,
}: {
marketId: string
address: string
}) {
const request =
InjectiveInsuranceV1Beta1QueryPb.QueryPendingRedemptionsRequest.create()
request.marketId = marketId
request.address = address
const response = await this.executeGrpcCall<
InjectiveInsuranceV1Beta1QueryPb.QueryPendingRedemptionsRequest,
InjectiveInsuranceV1Beta1QueryPb.QueryPendingRedemptionsResponse
>(request, this.client.pendingRedemptions.bind(this.client))
return ChainGrpcInsuranceFundTransformer.redemptionsResponseToRedemptions(
response,
)
}
}