@carrot-protocol/http-client 0.2.31 → 0.2.32
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 +12 -3
- package/dist/index.js +16 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ export declare class Client {
|
|
|
9
9
|
getVault(vault: anchor.web3.PublicKey, useCache: boolean): Promise<Vault>;
|
|
10
10
|
getVaultPerformance(vault: anchor.web3.PublicKey, useCache: boolean): Promise<VaultPerformance>;
|
|
11
11
|
getUser(vault: anchor.web3.PublicKey): Promise<UserResponse>;
|
|
12
|
-
getHistoricalVaultApy(vault: anchor.web3.PublicKey, interval:
|
|
12
|
+
getHistoricalVaultApy(vault: anchor.web3.PublicKey, interval: VaultHistoricalInterval): Promise<HistoricalVaultApyResponse>;
|
|
13
|
+
getHistoricalVaultNav(vault: anchor.web3.PublicKey, interval: VaultHistoricalInterval): Promise<HistoricalVaultNavResponse>;
|
|
13
14
|
issue(vault: anchor.web3.PublicKey, assetMint: anchor.web3.PublicKey, amount: anchor.BN): Promise<string>;
|
|
14
15
|
redeem(vault: anchor.web3.PublicKey, assetMint: anchor.web3.PublicKey, amount: anchor.BN): Promise<string>;
|
|
15
16
|
checkWallet(wallet: anchor.web3.PublicKey): Promise<CheckWalletResponse>;
|
|
@@ -58,6 +59,14 @@ export interface VaultApy {
|
|
|
58
59
|
time: number;
|
|
59
60
|
apy: number;
|
|
60
61
|
}
|
|
62
|
+
export interface HistoricalVaultNavResponse {
|
|
63
|
+
vault: anchor.web3.PublicKey;
|
|
64
|
+
data: VaultNav[];
|
|
65
|
+
}
|
|
66
|
+
export interface VaultNav {
|
|
67
|
+
time: number;
|
|
68
|
+
nav: number;
|
|
69
|
+
}
|
|
61
70
|
export interface CheckWalletResponse {
|
|
62
71
|
isWhitelisted: boolean;
|
|
63
72
|
claimedReferralCode: boolean;
|
|
@@ -75,7 +84,7 @@ export interface ReferralCode {
|
|
|
75
84
|
remainingUses: number;
|
|
76
85
|
}
|
|
77
86
|
declare const allowedIntervals: readonly ["HOUR", "DAY", "WEEK"];
|
|
78
|
-
export type
|
|
79
|
-
export declare function
|
|
87
|
+
export type VaultHistoricalInterval = (typeof allowedIntervals)[number];
|
|
88
|
+
export declare function isValidVaultHistoricalInterval(interval: string): interval is VaultHistoricalInterval;
|
|
80
89
|
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>;
|
|
81
90
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.Client = void 0;
|
|
30
30
|
exports.isWalletAllowed = isWalletAllowed;
|
|
31
|
-
exports.
|
|
31
|
+
exports.isValidVaultHistoricalInterval = isValidVaultHistoricalInterval;
|
|
32
32
|
exports.prepareUnsignedTx = prepareUnsignedTx;
|
|
33
33
|
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
34
34
|
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
@@ -144,6 +144,20 @@ class Client {
|
|
|
144
144
|
};
|
|
145
145
|
return historicalVaultApyResponse;
|
|
146
146
|
}
|
|
147
|
+
async getHistoricalVaultNav(vault, interval) {
|
|
148
|
+
const url = new URL(`${this.baseUrl}/historicalVaultNav?vault=${vault.toString()}&interval=${interval}`);
|
|
149
|
+
const response = await (0, cross_fetch_1.default)(url, {
|
|
150
|
+
method: "GET",
|
|
151
|
+
headers: this.headers,
|
|
152
|
+
});
|
|
153
|
+
checkResponse(response);
|
|
154
|
+
const body = await response.json();
|
|
155
|
+
const historicalVaultNavResponse = {
|
|
156
|
+
vault,
|
|
157
|
+
data: body,
|
|
158
|
+
};
|
|
159
|
+
return historicalVaultNavResponse;
|
|
160
|
+
}
|
|
147
161
|
async issue(vault, assetMint, amount) {
|
|
148
162
|
// error if provider is undefined
|
|
149
163
|
requireProvider(this.provider);
|
|
@@ -253,7 +267,7 @@ function isWalletAllowed(response) {
|
|
|
253
267
|
return response.isWhitelisted || response.claimedReferralCode;
|
|
254
268
|
}
|
|
255
269
|
const allowedIntervals = ["HOUR", "DAY", "WEEK"];
|
|
256
|
-
function
|
|
270
|
+
function isValidVaultHistoricalInterval(interval) {
|
|
257
271
|
return allowedIntervals.includes(interval);
|
|
258
272
|
}
|
|
259
273
|
async function prepareUnsignedTx(connection, payer, ixns, lutAddr, additionalSigner) {
|