@carrot-protocol/http-client 0.2.11 → 0.2.12-hva-dev-8a6747f

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
@@ -9,6 +9,7 @@ export declare class Client {
9
9
  getVault(vault: anchor.web3.PublicKey): Promise<Vault>;
10
10
  getVaultPerformance(vault: anchor.web3.PublicKey): Promise<VaultPerformance>;
11
11
  getUser(vault: anchor.web3.PublicKey): Promise<UserResponse>;
12
+ getHistoricalVaultApy(vault: anchor.web3.PublicKey, interval: VaultHistoricalApyInterval): Promise<HistoricalVaultApyResponse>;
12
13
  issue(vault: anchor.web3.PublicKey, assetMint: anchor.web3.PublicKey, amount: anchor.BN): Promise<string>;
13
14
  redeem(vault: anchor.web3.PublicKey, assetMint: anchor.web3.PublicKey, amount: anchor.BN): Promise<string>;
14
15
  private send;
@@ -46,4 +47,16 @@ export interface UserAssetBalance {
46
47
  amount: anchor.BN;
47
48
  amountUi: number;
48
49
  }
50
+ export interface HistoricalVaultApyResponse {
51
+ vault: anchor.web3.PublicKey;
52
+ data: VaultApy[];
53
+ }
54
+ export interface VaultApy {
55
+ time: number;
56
+ apy: number;
57
+ }
58
+ declare const allowedIntervals: readonly ["HOUR", "DAY", "WEEK"];
59
+ export type VaultHistoricalApyInterval = (typeof allowedIntervals)[number];
60
+ export declare function isValidVaultHistoricalApyInterval(interval: string): interval is VaultHistoricalApyInterval;
49
61
  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>;
62
+ export {};
package/dist/index.js CHANGED
@@ -27,6 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.Client = void 0;
30
+ exports.isValidVaultHistoricalApyInterval = isValidVaultHistoricalApyInterval;
30
31
  exports.prepareUnsignedTx = prepareUnsignedTx;
31
32
  const cross_fetch_1 = __importDefault(require("cross-fetch"));
32
33
  const anchor = __importStar(require("@coral-xyz/anchor"));
@@ -120,6 +121,17 @@ class Client {
120
121
  }));
121
122
  return body;
122
123
  }
124
+ async getHistoricalVaultApy(vault, interval) {
125
+ const url = new URL(`${this.baseUrl}/historicalVaultApy?vault=${vault.toString()}&interval=${interval}`);
126
+ const response = await (0, cross_fetch_1.default)(url, {
127
+ method: "GET",
128
+ headers: this.headers,
129
+ });
130
+ checkResponse(response);
131
+ const body = JSON.parse(JSON.stringify(await response.json()));
132
+ body.vault = new anchor.web3.PublicKey(body.vault);
133
+ return body;
134
+ }
123
135
  async issue(vault, assetMint, amount) {
124
136
  const url = new URL(`${this.baseUrl}/issue`);
125
137
  const body = {
@@ -181,6 +193,10 @@ class Client {
181
193
  }
182
194
  }
183
195
  exports.Client = Client;
196
+ const allowedIntervals = ["HOUR", "DAY", "WEEK"];
197
+ function isValidVaultHistoricalApyInterval(interval) {
198
+ return allowedIntervals.includes(interval);
199
+ }
184
200
  async function prepareUnsignedTx(connection, payer, ixns, lutAddr, additionalSigner) {
185
201
  const lutAccounts = [];
186
202
  if (lutAddr) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carrot-protocol/http-client",
3
- "version": "0.2.11",
3
+ "version": "0.2.12-hva-dev-8a6747f",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",