@carrot-protocol/http-client 0.2.85 → 0.2.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as anchor from "@coral-xyz/anchor";
2
2
  import { Vault, VaultPerformance } from "@carrot-protocol/common";
3
- import { CheckWalletResponse, ClaimReferralCodeResponse, GetCarrotBoostJitDepositIxnsRequest, GetCarrotBoostJitDepositIxnsResponse, GetCarrotBoostJitWithdrawIxnsRequest, GetCarrotBoostJitWithdrawIxnsResponse, GetLatestPoolApyResponse, GetReferralCodesResponse, HistoricalVaultApyResponse, HistoricalVaultNavResponse, IssueResponse, RedeemResponse, UserPerformanceResponse, UserResponse, VaultHistoricalInterval, VaultOhlcResponse } from "./types";
3
+ import { CheckWalletResponse, ClaimReferralCodeResponse, GetCarrotBoostJitDepositIxnsRequest, GetCarrotBoostJitDepositIxnsResponse, GetCarrotBoostJitWithdrawIxnsRequest, GetCarrotBoostJitWithdrawIxnsResponse, GetLatestPoolApyResponse, GetReferralCodesResponse, GetVaultOHLCRequest, GetVaultOHLCResponse, HistoricalVaultApyResponse, HistoricalVaultNavResponse, IssueResponse, RedeemResponse, UserPerformanceResponse, UserResponse, VaultHistoricalInterval, VaultOhlcResponse } from "./types";
4
4
  export * as Common from "@carrot-protocol/common";
5
5
  export * from "./types";
6
6
  export declare class Client {
@@ -24,6 +24,7 @@ export declare class Client {
24
24
  checkWallet(wallet: anchor.web3.PublicKey): Promise<CheckWalletResponse>;
25
25
  claimReferralCode(wallet: anchor.web3.PublicKey, code: string): Promise<ClaimReferralCodeResponse>;
26
26
  getReferralCodes(wallet: anchor.web3.PublicKey): Promise<GetReferralCodesResponse>;
27
+ getVaultOHLC(vaultAddress: GetVaultOHLCRequest["vault"]): Promise<GetVaultOHLCResponse>;
27
28
  getCarrotBoostJitDepositIxns(request: GetCarrotBoostJitDepositIxnsRequest): Promise<GetCarrotBoostJitDepositIxnsResponse>;
28
29
  getCarrotBoostJitWithdrawIxns(request: GetCarrotBoostJitWithdrawIxnsRequest): Promise<GetCarrotBoostJitWithdrawIxnsResponse>;
29
30
  sendSignedTx(signedBase64Tx: string): Promise<string>;
package/dist/index.js CHANGED
@@ -336,6 +336,24 @@ class Client {
336
336
  const body = JSON.parse(JSON.stringify(responseBody));
337
337
  return body;
338
338
  }
339
+ /*
340
+ * Get vault OHLC graph data
341
+ * @param vaultAddress vault public key
342
+ * @returns OHLC graph data
343
+ */
344
+ async getVaultOHLC(vaultAddress) {
345
+ const url = new URL(`${this.baseUrl}/vaultOhlc?vault=${vaultAddress.toString()}`);
346
+ const response = await (0, cross_fetch_1.default)(url, {
347
+ method: "GET",
348
+ headers: this.headers,
349
+ });
350
+ checkResponse(response);
351
+ const responseBody = await response.json();
352
+ const body = {
353
+ data: JSON.parse(responseBody),
354
+ };
355
+ return body;
356
+ }
339
357
  async getCarrotBoostJitDepositIxns(request) {
340
358
  const url = new URL(`${this.baseUrl}/carrotBoostJitDepositIxns?vault=${request.vault.toString()}&carrotBoostStrategy=${request.carrotBoostStrategy.toString()}&amount=${request.amount.toString()}`);
341
359
  const response = await (0, cross_fetch_1.default)(url, {
package/dist/types.d.ts CHANGED
@@ -132,4 +132,17 @@ export interface GetLatestPoolApyResponse {
132
132
  borrowApy: number;
133
133
  time: Date;
134
134
  }
135
+ export interface GetVaultOHLCRequest {
136
+ vault: anchor.web3.PublicKey;
137
+ }
138
+ export interface VaultOHLCDataPoint {
139
+ time: number;
140
+ open: number;
141
+ high: number;
142
+ low: number;
143
+ close: number;
144
+ }
145
+ export interface GetVaultOHLCResponse {
146
+ data: VaultOHLCDataPoint[];
147
+ }
135
148
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carrot-protocol/http-client",
3
- "version": "0.2.85",
3
+ "version": "0.2.86",
4
4
  "description": "interact with carrot api",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",