@carrot-protocol/http-client 0.2.53-add-wallet-performance-dev-e6aacf5 → 0.2.53-switchboard-oracle-dev-ff5b0ad
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 +8 -29
- package/dist/index.js +9 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +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,
|
|
13
|
+
getUserPerformance(vault: anchor.web3.PublicKey, wallets: anchor.web3.PublicKey[]): Promise<UserPerformanceResponse>;
|
|
14
14
|
getHistoricalVaultNav(vault: anchor.web3.PublicKey, interval: VaultHistoricalInterval): Promise<HistoricalVaultNavResponse>;
|
|
15
15
|
issue(vault: anchor.web3.PublicKey, assetMint: anchor.web3.PublicKey, amount: anchor.BN): Promise<string>;
|
|
16
16
|
redeem(vault: anchor.web3.PublicKey, assetMint: anchor.web3.PublicKey, amount: anchor.BN): Promise<string>;
|
|
@@ -91,47 +91,26 @@ export declare function isValidVaultHistoricalInterval(interval: string): interv
|
|
|
91
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
92
|
export interface UserPerformanceResponse {
|
|
93
93
|
vault: anchor.web3.PublicKey;
|
|
94
|
-
|
|
94
|
+
wallets: anchor.web3.PublicKey[];
|
|
95
95
|
data: PerformanceData;
|
|
96
96
|
}
|
|
97
97
|
export interface PerformanceData {
|
|
98
98
|
crtAmountUi: number;
|
|
99
99
|
crtCurrentPrice: number;
|
|
100
100
|
crtCurrentValue: number;
|
|
101
|
-
holderSince:
|
|
101
|
+
holderSince: Date;
|
|
102
102
|
stats: Stat[];
|
|
103
|
-
|
|
104
|
-
txList: Transaction[];
|
|
105
|
-
runningCrtTotals: RunningTotal[];
|
|
106
|
-
portfolioValue: PortfolioValue[];
|
|
103
|
+
portfolioTracker: PortfolioValue[];
|
|
107
104
|
}
|
|
108
105
|
export interface Stat {
|
|
109
106
|
label: string;
|
|
110
107
|
value: number;
|
|
111
108
|
}
|
|
112
|
-
export interface Transaction {
|
|
113
|
-
block_time: number;
|
|
114
|
-
time: string;
|
|
115
|
-
activity_type: string;
|
|
116
|
-
amount: number;
|
|
117
|
-
flow: string;
|
|
118
|
-
trans_id: string;
|
|
119
|
-
wallet: string;
|
|
120
|
-
crtPrice: number;
|
|
121
|
-
crtValue: number;
|
|
122
|
-
cashFlow: number;
|
|
123
|
-
dateObject: string;
|
|
124
|
-
}
|
|
125
|
-
export interface RunningTotal {
|
|
126
|
-
date: string;
|
|
127
|
-
runningTotalCRT: number;
|
|
128
|
-
runningTotalDeposits: number;
|
|
129
|
-
}
|
|
130
109
|
export interface PortfolioValue {
|
|
131
|
-
date:
|
|
132
|
-
|
|
110
|
+
date: Date;
|
|
111
|
+
crtPriceUsd: number;
|
|
133
112
|
runningTotalCRT: number;
|
|
134
|
-
|
|
135
|
-
|
|
113
|
+
runningTotalDepositsUsd: number;
|
|
114
|
+
portfolioValueUsd: number;
|
|
136
115
|
}
|
|
137
116
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -161,17 +161,22 @@ class Client {
|
|
|
161
161
|
};
|
|
162
162
|
return historicalVaultApyResponse;
|
|
163
163
|
}
|
|
164
|
-
async getUserPerformance(vault,
|
|
165
|
-
const
|
|
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()}&wallets=${walletsString}`);
|
|
166
167
|
const response = await (0, cross_fetch_1.default)(url, {
|
|
167
168
|
method: "GET",
|
|
168
169
|
headers: this.headers,
|
|
169
170
|
});
|
|
170
171
|
checkResponse(response);
|
|
171
|
-
|
|
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
|
+
});
|
|
172
177
|
const getUserPerformanceResponse = {
|
|
173
178
|
vault,
|
|
174
|
-
|
|
179
|
+
wallets,
|
|
175
180
|
data: body,
|
|
176
181
|
};
|
|
177
182
|
return getUserPerformanceResponse;
|