@carrot-protocol/http-client 0.2.69 → 0.2.70-carrot-boost-jit-dev-72ce5b2

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,8 @@
1
1
  import * as anchor from "@coral-xyz/anchor";
2
2
  import { Vault, VaultPerformance } from "@carrot-protocol/common";
3
+ import { CheckWalletResponse, ClaimReferralCodeResponse, GetCarrotBoostJitInstructionsRequest, GetCarrotBoostJitInstructionsResponse, GetReferralCodesResponse, HistoricalVaultApyResponse, HistoricalVaultNavResponse, UserPerformanceResponse, UserResponse, VaultHistoricalInterval, VaultOhlcResponse } from "./types";
3
4
  export * as Common from "@carrot-protocol/common";
5
+ export * from "./types";
4
6
  export declare class Client {
5
7
  readonly baseUrl: string;
6
8
  readonly provider: anchor.AnchorProvider | undefined;
@@ -19,117 +21,7 @@ export declare class Client {
19
21
  checkWallet(wallet: anchor.web3.PublicKey): Promise<CheckWalletResponse>;
20
22
  claimReferralCode(wallet: anchor.web3.PublicKey, code: string): Promise<ClaimReferralCodeResponse>;
21
23
  getReferralCodes(wallet: anchor.web3.PublicKey): Promise<GetReferralCodesResponse>;
24
+ getCarrotBoostJitInstructions(request: GetCarrotBoostJitInstructionsRequest): Promise<GetCarrotBoostJitInstructionsResponse>;
22
25
  private send;
23
26
  }
24
- export interface SendRequest {
25
- tx: string;
26
- }
27
- export interface RedeemRequest {
28
- vault: anchor.web3.PublicKey;
29
- assetMint: anchor.web3.PublicKey;
30
- amount: anchor.BN;
31
- user: anchor.web3.PublicKey;
32
- }
33
- export interface IssueRequest {
34
- vault: anchor.web3.PublicKey;
35
- assetMint: anchor.web3.PublicKey;
36
- amount: anchor.BN;
37
- user: anchor.web3.PublicKey;
38
- }
39
- export interface RedeemResponse {
40
- tx: string;
41
- }
42
- export interface IssueResponse {
43
- tx: string;
44
- }
45
- export interface UserResponse {
46
- solAmount: anchor.BN;
47
- solAmountUi: number;
48
- sharesAmount: anchor.BN;
49
- sharesAmountUi: number;
50
- assets: UserAssetBalance[];
51
- allDomainsDns: string | undefined;
52
- }
53
- export interface UserAssetBalance {
54
- mint: anchor.web3.PublicKey;
55
- amount: anchor.BN;
56
- amountUi: number;
57
- }
58
- export interface HistoricalVaultApyResponse {
59
- vault: anchor.web3.PublicKey;
60
- data: HistoricalVaultApy[];
61
- }
62
- export interface HistoricalVaultApy {
63
- time: number;
64
- avgApy1: number;
65
- avgApy7: number;
66
- avgApy14: number;
67
- avgApy30: number;
68
- }
69
- export interface VaultApy {
70
- time: number;
71
- apy: number;
72
- }
73
- export interface HistoricalVaultNavResponse {
74
- vault: anchor.web3.PublicKey;
75
- data: VaultNav[];
76
- }
77
- export interface VaultNav {
78
- time: number;
79
- nav: number;
80
- }
81
- export interface CheckWalletResponse {
82
- isWhitelisted: boolean;
83
- claimedReferralCode: boolean;
84
- }
85
- export declare function isWalletAllowed(response: CheckWalletResponse): boolean;
86
- export interface ClaimReferralCodeResponse {
87
- success: boolean;
88
- }
89
- export interface GetReferralCodesResponse {
90
- codes: ReferralCode[];
91
- }
92
- export interface ReferralCode {
93
- code: string;
94
- maxUses: number;
95
- remainingUses: number;
96
- }
97
- declare const allowedIntervals: readonly ["HOUR", "DAY", "WEEK"];
98
- export type VaultHistoricalInterval = (typeof allowedIntervals)[number];
99
- export declare function isValidVaultHistoricalInterval(interval: string): interval is VaultHistoricalInterval;
100
27
  export declare function prepareUnsignedTx(connection: anchor.web3.Connection, payer: anchor.web3.PublicKey, ixns: anchor.web3.TransactionInstruction[], lutAddr?: anchor.web3.PublicKey, additionalSigner?: anchor.AnchorProvider): Promise<string>;
101
- export interface UserPerformanceResponse {
102
- vault: anchor.web3.PublicKey;
103
- wallets: anchor.web3.PublicKey[];
104
- data: PerformanceData;
105
- }
106
- export interface PerformanceData {
107
- crtAmountUi: number;
108
- crtCurrentPrice: number;
109
- crtCurrentValue: number;
110
- holderSince: Date;
111
- stats: Stat[];
112
- portfolioTracker: PortfolioValue[];
113
- }
114
- export interface Stat {
115
- label: string;
116
- value: number;
117
- }
118
- export interface PortfolioValue {
119
- date: Date;
120
- crtPriceUsd: number;
121
- runningTotalCRT: number;
122
- runningTotalDepositsUsd: number;
123
- portfolioValueUsd: number;
124
- }
125
- export interface VaultOhlcResponse {
126
- vault: anchor.web3.PublicKey;
127
- data: OhlcEntry[];
128
- }
129
- export interface OhlcEntry {
130
- time: number;
131
- open: number;
132
- high: number;
133
- low: number;
134
- close: number;
135
- }
package/dist/index.js CHANGED
@@ -32,19 +32,22 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
+ };
35
38
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
40
  };
38
41
  Object.defineProperty(exports, "__esModule", { value: true });
39
42
  exports.Client = exports.Common = void 0;
40
- exports.isWalletAllowed = isWalletAllowed;
41
- exports.isValidVaultHistoricalInterval = isValidVaultHistoricalInterval;
42
43
  exports.prepareUnsignedTx = prepareUnsignedTx;
43
44
  const cross_fetch_1 = __importDefault(require("cross-fetch"));
44
45
  const anchor = __importStar(require("@coral-xyz/anchor"));
45
46
  const bs58_1 = require("bs58");
46
47
  // when pulling in http-client you will have access to Common as intended
47
48
  exports.Common = __importStar(require("@carrot-protocol/common"));
49
+ // export http types
50
+ __exportStar(require("./types"), exports);
48
51
  class Client {
49
52
  constructor(baseUrl, provider) {
50
53
  this.headers = { "Content-Type": "application/json" }; // Default headers for HTTP requests
@@ -304,6 +307,17 @@ class Client {
304
307
  const body = JSON.parse(JSON.stringify(responseBody));
305
308
  return body;
306
309
  }
310
+ async getCarrotBoostJitInstructions(request) {
311
+ const url = new URL(`${this.baseUrl}/carrotBoostJitInstructions?vault=${request.vault.toString()}&assetMint=${request.assetMint.toString()}&amount=${request.amount.toString()}`);
312
+ const response = await (0, cross_fetch_1.default)(url, {
313
+ method: "GET",
314
+ headers: this.headers,
315
+ });
316
+ checkResponse(response);
317
+ const responseBody = await response.json();
318
+ const body = JSON.parse(JSON.stringify(responseBody));
319
+ return body;
320
+ }
307
321
  // Sends a signed transaction to the network
308
322
  async send(base64Tx) {
309
323
  // error if provider is undefined
@@ -330,16 +344,6 @@ class Client {
330
344
  }
331
345
  }
332
346
  exports.Client = Client;
333
- // Checks if a wallet is allowed based on its status
334
- function isWalletAllowed(response) {
335
- return response.isWhitelisted || response.claimedReferralCode;
336
- }
337
- // Allowed intervals for historical data
338
- const allowedIntervals = ["HOUR", "DAY", "WEEK"];
339
- // Validates the provided historical interval
340
- function isValidVaultHistoricalInterval(interval) {
341
- return allowedIntervals.includes(interval);
342
- }
343
347
  // Prepares an unsigned transaction for submission
344
348
  async function prepareUnsignedTx(connection, payer, ixns, lutAddr, additionalSigner) {
345
349
  const lutAccounts = [];
@@ -0,0 +1,121 @@
1
+ import * as anchor from "@coral-xyz/anchor";
2
+ export interface SendRequest {
3
+ tx: string;
4
+ }
5
+ export interface RedeemRequest {
6
+ vault: anchor.web3.PublicKey;
7
+ assetMint: anchor.web3.PublicKey;
8
+ amount: anchor.BN;
9
+ user: anchor.web3.PublicKey;
10
+ }
11
+ export interface IssueRequest {
12
+ vault: anchor.web3.PublicKey;
13
+ assetMint: anchor.web3.PublicKey;
14
+ amount: anchor.BN;
15
+ user: anchor.web3.PublicKey;
16
+ }
17
+ export interface RedeemResponse {
18
+ tx: string;
19
+ }
20
+ export interface IssueResponse {
21
+ tx: string;
22
+ }
23
+ export interface UserResponse {
24
+ solAmount: anchor.BN;
25
+ solAmountUi: number;
26
+ sharesAmount: anchor.BN;
27
+ sharesAmountUi: number;
28
+ assets: UserAssetBalance[];
29
+ allDomainsDns: string | undefined;
30
+ }
31
+ export interface UserAssetBalance {
32
+ mint: anchor.web3.PublicKey;
33
+ amount: anchor.BN;
34
+ amountUi: number;
35
+ }
36
+ export interface HistoricalVaultApyResponse {
37
+ vault: anchor.web3.PublicKey;
38
+ data: HistoricalVaultApy[];
39
+ }
40
+ export interface HistoricalVaultApy {
41
+ time: number;
42
+ avgApy1: number;
43
+ avgApy7: number;
44
+ avgApy14: number;
45
+ avgApy30: number;
46
+ }
47
+ export interface VaultApy {
48
+ time: number;
49
+ apy: number;
50
+ }
51
+ export interface HistoricalVaultNavResponse {
52
+ vault: anchor.web3.PublicKey;
53
+ data: VaultNav[];
54
+ }
55
+ export interface VaultNav {
56
+ time: number;
57
+ nav: number;
58
+ }
59
+ export interface CheckWalletResponse {
60
+ isWhitelisted: boolean;
61
+ claimedReferralCode: boolean;
62
+ }
63
+ export declare function isWalletAllowed(response: CheckWalletResponse): boolean;
64
+ export interface ClaimReferralCodeResponse {
65
+ success: boolean;
66
+ }
67
+ export interface GetReferralCodesResponse {
68
+ codes: ReferralCode[];
69
+ }
70
+ export interface ReferralCode {
71
+ code: string;
72
+ maxUses: number;
73
+ remainingUses: number;
74
+ }
75
+ declare const allowedIntervals: readonly ["HOUR", "DAY", "WEEK"];
76
+ export type VaultHistoricalInterval = (typeof allowedIntervals)[number];
77
+ export declare function isValidVaultHistoricalInterval(interval: string): interval is VaultHistoricalInterval;
78
+ export interface UserPerformanceResponse {
79
+ vault: anchor.web3.PublicKey;
80
+ wallets: anchor.web3.PublicKey[];
81
+ data: PerformanceData;
82
+ }
83
+ export interface PerformanceData {
84
+ crtAmountUi: number;
85
+ crtCurrentPrice: number;
86
+ crtCurrentValue: number;
87
+ holderSince: Date;
88
+ stats: Stat[];
89
+ portfolioTracker: PortfolioValue[];
90
+ }
91
+ export interface Stat {
92
+ label: string;
93
+ value: number;
94
+ }
95
+ export interface PortfolioValue {
96
+ date: Date;
97
+ crtPriceUsd: number;
98
+ runningTotalCRT: number;
99
+ runningTotalDepositsUsd: number;
100
+ portfolioValueUsd: number;
101
+ }
102
+ export interface VaultOhlcResponse {
103
+ vault: anchor.web3.PublicKey;
104
+ data: OhlcEntry[];
105
+ }
106
+ export interface OhlcEntry {
107
+ time: number;
108
+ open: number;
109
+ high: number;
110
+ low: number;
111
+ close: number;
112
+ }
113
+ export interface GetCarrotBoostJitInstructionsRequest {
114
+ vault: anchor.web3.PublicKey;
115
+ assetMint: anchor.web3.PublicKey;
116
+ amount: anchor.BN;
117
+ }
118
+ export interface GetCarrotBoostJitInstructionsResponse {
119
+ instructions: anchor.web3.TransactionInstruction[];
120
+ }
121
+ export {};
package/dist/types.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isWalletAllowed = isWalletAllowed;
4
+ exports.isValidVaultHistoricalInterval = isValidVaultHistoricalInterval;
5
+ // Checks if a wallet is allowed based on its status
6
+ function isWalletAllowed(response) {
7
+ return response.isWhitelisted || response.claimedReferralCode;
8
+ }
9
+ // Allowed intervals for historical data
10
+ const allowedIntervals = ["HOUR", "DAY", "WEEK"];
11
+ // Validates the provided historical interval
12
+ function isValidVaultHistoricalInterval(interval) {
13
+ return allowedIntervals.includes(interval);
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carrot-protocol/http-client",
3
- "version": "0.2.69",
3
+ "version": "0.2.70-carrot-boost-jit-dev-72ce5b2",
4
4
  "description": "interact with carrot api",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",