@carrot-protocol/http-client 0.2.78-drift-apy-fix-dev-2256d2a → 0.2.78-drift-apy-fix-dev-f27de8d

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,6 @@
1
1
  import * as anchor from "@coral-xyz/anchor";
2
2
  import { Vault, VaultPerformance } from "@carrot-protocol/common";
3
- import { CheckWalletResponse, ClaimReferralCodeResponse, GetCarrotBoostJitDepositIxnsRequest, GetCarrotBoostJitDepositIxnsResponse, GetCarrotBoostJitWithdrawIxnsRequest, GetCarrotBoostJitWithdrawIxnsResponse, GetLatestPoolApyResponse, GetReferralCodesResponse, HistoricalVaultApyResponse, HistoricalVaultNavResponse, UserPerformanceResponse, UserResponse, VaultHistoricalInterval, VaultOhlcResponse } from "./types";
3
+ import { CheckWalletResponse, ClaimReferralCodeResponse, GetCarrotBoostJitDepositIxnsRequest, GetCarrotBoostJitDepositIxnsResponse, GetCarrotBoostJitWithdrawIxnsRequest, GetCarrotBoostJitWithdrawIxnsResponse, GetLatestPoolApyResponse, GetReferralCodesResponse, HistoricalVaultApyResponse, HistoricalVaultNavResponse, IssueResponse, RedeemResponse, UserPerformanceResponse, UserResponse, VaultHistoricalInterval, VaultOhlcResponse } from "./types";
4
4
  export * as Common from "@carrot-protocol/common";
5
5
  export * from "./types";
6
6
  export declare class Client {
@@ -17,13 +17,15 @@ export declare class Client {
17
17
  getHistoricalVaultNav(vault: anchor.web3.PublicKey, interval: VaultHistoricalInterval): Promise<HistoricalVaultNavResponse>;
18
18
  getVaultOhlc(vault: anchor.web3.PublicKey): Promise<VaultOhlcResponse>;
19
19
  issue(vault: anchor.web3.PublicKey, assetMint: anchor.web3.PublicKey, amount: anchor.BN): Promise<string>;
20
+ prepareIssue(vault: anchor.web3.PublicKey, assetMint: anchor.web3.PublicKey, amount: anchor.BN, user: anchor.web3.PublicKey): Promise<IssueResponse>;
20
21
  redeem(vault: anchor.web3.PublicKey, assetMint: anchor.web3.PublicKey, amount: anchor.BN): Promise<string>;
22
+ prepareRedeem(vault: anchor.web3.PublicKey, assetMint: anchor.web3.PublicKey, amount: anchor.BN, user: anchor.web3.PublicKey): Promise<RedeemResponse>;
21
23
  getLatestPoolApy(poolNames: string[]): Promise<GetLatestPoolApyResponse>;
22
24
  checkWallet(wallet: anchor.web3.PublicKey): Promise<CheckWalletResponse>;
23
25
  claimReferralCode(wallet: anchor.web3.PublicKey, code: string): Promise<ClaimReferralCodeResponse>;
24
26
  getReferralCodes(wallet: anchor.web3.PublicKey): Promise<GetReferralCodesResponse>;
25
27
  getCarrotBoostJitDepositIxns(request: GetCarrotBoostJitDepositIxnsRequest): Promise<GetCarrotBoostJitDepositIxnsResponse>;
26
28
  getCarrotBoostJitWithdrawIxns(request: GetCarrotBoostJitWithdrawIxnsRequest): Promise<GetCarrotBoostJitWithdrawIxnsResponse>;
27
- private send;
29
+ send(base64Tx: string): Promise<string>;
28
30
  }
29
31
  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>;
package/dist/index.js CHANGED
@@ -227,9 +227,14 @@ class Client {
227
227
  async issue(vault, assetMint, amount) {
228
228
  // error if provider is undefined
229
229
  requireProvider(this.provider);
230
+ const issueResponse = await this.prepareIssue(vault, assetMint, amount, this.provider.publicKey);
231
+ const txSig = await this.send(issueResponse.tx);
232
+ return txSig;
233
+ }
234
+ async prepareIssue(vault, assetMint, amount, user) {
230
235
  const url = new URL(`${this.baseUrl}/issue`);
231
236
  const body = {
232
- user: this.provider.publicKey,
237
+ user,
233
238
  vault,
234
239
  amount,
235
240
  assetMint,
@@ -242,16 +247,21 @@ class Client {
242
247
  checkResponse(response);
243
248
  const responseBody = await response.json();
244
249
  const issueResponse = JSON.parse(JSON.stringify(responseBody));
245
- const txSig = await this.send(issueResponse.tx);
246
- return txSig;
250
+ return issueResponse;
247
251
  }
248
252
  // Redeems assets from a specified vault
249
253
  async redeem(vault, assetMint, amount) {
250
254
  // error if provider is undefined
251
255
  requireProvider(this.provider);
256
+ const redeemResponse = await this.prepareRedeem(vault, assetMint, amount, this.provider.publicKey);
257
+ const txSig = await this.send(redeemResponse.tx);
258
+ return txSig;
259
+ }
260
+ // Redeems assets from a specified vault
261
+ async prepareRedeem(vault, assetMint, amount, user) {
252
262
  const url = new URL(`${this.baseUrl}/redeem`);
253
263
  const body = {
254
- user: this.provider.publicKey,
264
+ user,
255
265
  vault,
256
266
  amount,
257
267
  assetMint,
@@ -264,8 +274,7 @@ class Client {
264
274
  checkResponse(response);
265
275
  const responseBody = await response.json();
266
276
  const redeemResponse = JSON.parse(JSON.stringify(responseBody));
267
- const txSig = await this.send(redeemResponse.tx);
268
- return txSig;
277
+ return redeemResponse;
269
278
  }
270
279
  async getLatestPoolApy(poolNames) {
271
280
  const url = new URL(`${this.baseUrl}/latestPoolApy?poolNames=${poolNames.join(",")}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carrot-protocol/http-client",
3
- "version": "0.2.78-drift-apy-fix-dev-2256d2a",
3
+ "version": "0.2.78-drift-apy-fix-dev-f27de8d",
4
4
  "description": "interact with carrot api",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",