@carrot-protocol/http-client 0.2.51 → 0.2.52-add-wallet-performance-dev-96dfa50
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 +25 -0
- package/dist/index.js +20 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare class Client {
|
|
|
10
10
|
getVaultPerformance(vault: anchor.web3.PublicKey, useCache: boolean): Promise<VaultPerformance>;
|
|
11
11
|
getUser(vault: anchor.web3.PublicKey): Promise<UserResponse>;
|
|
12
12
|
getHistoricalVaultApy(vault: anchor.web3.PublicKey, interval: VaultHistoricalInterval): Promise<HistoricalVaultApyResponse>;
|
|
13
|
+
getUserPerformance(vault: anchor.web3.PublicKey, wallets: anchor.web3.PublicKey[]): Promise<UserPerformanceResponse>;
|
|
13
14
|
getHistoricalVaultNav(vault: anchor.web3.PublicKey, interval: VaultHistoricalInterval): Promise<HistoricalVaultNavResponse>;
|
|
14
15
|
issue(vault: anchor.web3.PublicKey, assetMint: anchor.web3.PublicKey, amount: anchor.BN): Promise<string>;
|
|
15
16
|
redeem(vault: anchor.web3.PublicKey, assetMint: anchor.web3.PublicKey, amount: anchor.BN): Promise<string>;
|
|
@@ -88,4 +89,28 @@ declare const allowedIntervals: readonly ["HOUR", "DAY", "WEEK"];
|
|
|
88
89
|
export type VaultHistoricalInterval = (typeof allowedIntervals)[number];
|
|
89
90
|
export declare function isValidVaultHistoricalInterval(interval: string): interval is VaultHistoricalInterval;
|
|
90
91
|
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>;
|
|
92
|
+
export interface UserPerformanceResponse {
|
|
93
|
+
vault: anchor.web3.PublicKey;
|
|
94
|
+
wallets: anchor.web3.PublicKey[];
|
|
95
|
+
data: PerformanceData;
|
|
96
|
+
}
|
|
97
|
+
export interface PerformanceData {
|
|
98
|
+
crtAmountUi: number;
|
|
99
|
+
crtCurrentPrice: number;
|
|
100
|
+
crtCurrentValue: number;
|
|
101
|
+
holderSince: Date;
|
|
102
|
+
stats: Stat[];
|
|
103
|
+
portfolioTracker: PortfolioValue[];
|
|
104
|
+
}
|
|
105
|
+
export interface Stat {
|
|
106
|
+
label: string;
|
|
107
|
+
value: number;
|
|
108
|
+
}
|
|
109
|
+
export interface PortfolioValue {
|
|
110
|
+
date: Date;
|
|
111
|
+
crtPriceUsd: number;
|
|
112
|
+
runningTotalCRT: number;
|
|
113
|
+
runningTotalDepositsUsd: number;
|
|
114
|
+
portfolioValueUsd: number;
|
|
115
|
+
}
|
|
91
116
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -161,6 +161,26 @@ class Client {
|
|
|
161
161
|
};
|
|
162
162
|
return historicalVaultApyResponse;
|
|
163
163
|
}
|
|
164
|
+
async getUserPerformance(vault, wallets) {
|
|
165
|
+
const walletsString = wallets.map((wallet) => wallet.toString()).join(",");
|
|
166
|
+
const url = new URL(`${this.baseUrl}/userPerformance?vault=${vault.toString()}&users=${walletsString}`);
|
|
167
|
+
const response = await (0, cross_fetch_1.default)(url, {
|
|
168
|
+
method: "GET",
|
|
169
|
+
headers: this.headers,
|
|
170
|
+
});
|
|
171
|
+
checkResponse(response);
|
|
172
|
+
let body = await response.json();
|
|
173
|
+
body.holderSince = new Date(body.holderSince);
|
|
174
|
+
body.portfolioTracker.forEach((value) => {
|
|
175
|
+
value.date = new Date(value.date);
|
|
176
|
+
});
|
|
177
|
+
const getUserPerformanceResponse = {
|
|
178
|
+
vault,
|
|
179
|
+
wallets,
|
|
180
|
+
data: body,
|
|
181
|
+
};
|
|
182
|
+
return getUserPerformanceResponse;
|
|
183
|
+
}
|
|
164
184
|
async getHistoricalVaultNav(vault, interval) {
|
|
165
185
|
const url = new URL(`${this.baseUrl}/historicalVaultNav?vault=${vault.toString()}&interval=${interval}`);
|
|
166
186
|
const response = await (0, cross_fetch_1.default)(url, {
|