hedge-web3 0.1.34 → 0.1.35

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.
@@ -1,5 +1,5 @@
1
1
  import { PublicKey } from '@solana/web3.js';
2
- export declare const HEDGE_PROGRAM_ID = "HDG3uyafYaKxSYRW37ZBTdxaUCoyzaqbuirYucAeaPFY";
2
+ export declare const HEDGE_PROGRAM_ID = "HDG4FDos8fyrB79qMCe98gaFjNEy5kpxGNjMc5V8M6TJ";
3
3
  export declare const HEDGE_PROGRAM_PUBLICKEY: PublicKey;
4
4
  export declare const CHAINLINK_SOL_USD_ID = "FmAmfoyPXiA8Vhhe6MZTr3U6rZfEZ1ctEHay1ysqCqcf";
5
5
  export declare const CHAINLINK_SOL_USD_PUBLICKEY: PublicKey;
@@ -1,5 +1,5 @@
1
- import { Program } from '@project-serum/anchor';
1
+ import { Program, Provider } from '@project-serum/anchor';
2
2
  import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
3
3
  import { Vault } from 'idl/vault';
4
- export declare function claimStakingPoolPosition(program: Program<Vault>, poolPosition: PublicKey, payer: Signer, collateralType: string): Promise<PublicKey>;
4
+ export declare function claimStakingPoolPosition(program: Program<Vault>, provider: Provider, poolPosition: PublicKey, payer: Signer, collateralType: string): Promise<PublicKey>;
5
5
  export declare function claimStakingPoolPositionInstruction(program: Program<Vault>, feePool: PublicKey, feePoolAssociatedTokenAccount: PublicKey, stakedTokenMint: PublicKey, vaultTypeAccount: PublicKey, collateralMint: PublicKey, poolPosition: PublicKey, payer: PublicKey, payerAssociatedTokenAccount: PublicKey): Promise<TransactionInstruction>;
package/lib/Constants.js CHANGED
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.findAssociatedTokenAddress = exports.findVaultAddress = exports.getVaultTypeOracleAccountPublicKey = exports.getVaultTypeAccountPublicKey = exports.getPoolPublicKeyForMint = exports.getHedgeMintPublicKey = exports.getVaultSystemStatePublicKey = exports.getUshMintPublicKey = exports.getLiquidationPoolUshAccountPublicKey = exports.getLiquidationPoolStatePublicKey = exports.CHAINLINK_SOL_USD_PUBLICKEY = exports.CHAINLINK_SOL_USD_ID = exports.HEDGE_PROGRAM_PUBLICKEY = exports.HEDGE_PROGRAM_ID = void 0;
13
13
  const spl_token_1 = require("@solana/spl-token");
14
14
  const web3_js_1 = require("@solana/web3.js");
15
- exports.HEDGE_PROGRAM_ID = 'HDG3uyafYaKxSYRW37ZBTdxaUCoyzaqbuirYucAeaPFY';
15
+ exports.HEDGE_PROGRAM_ID = 'HDG4FDos8fyrB79qMCe98gaFjNEy5kpxGNjMc5V8M6TJ';
16
16
  exports.HEDGE_PROGRAM_PUBLICKEY = new web3_js_1.PublicKey(exports.HEDGE_PROGRAM_ID);
17
17
  exports.CHAINLINK_SOL_USD_ID = 'FmAmfoyPXiA8Vhhe6MZTr3U6rZfEZ1ctEHay1ysqCqcf';
18
18
  exports.CHAINLINK_SOL_USD_PUBLICKEY = new web3_js_1.PublicKey(exports.CHAINLINK_SOL_USD_ID);
@@ -14,17 +14,17 @@ const spl_token_1 = require("@solana/spl-token");
14
14
  const web3_js_1 = require("@solana/web3.js");
15
15
  const Errors_1 = require("../utils/Errors");
16
16
  const Constants_1 = require("../Constants");
17
- function claimStakingPoolPosition(program, poolPosition, payer, collateralType) {
17
+ function claimStakingPoolPosition(program, provider, poolPosition, payer, collateralType) {
18
18
  return __awaiter(this, void 0, void 0, function* () {
19
19
  const vaultTypeAccount = yield (0, Constants_1.getVaultTypeAccountPublicKey)(collateralType);
20
20
  const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultTypeAccount);
21
21
  const collateralMint = vaultTypeAccountInfo.collateralMint;
22
22
  const stakedTokenMint = yield (0, Constants_1.getHedgeMintPublicKey)();
23
23
  const [feePool] = yield (0, Constants_1.getPoolPublicKeyForMint)(stakedTokenMint);
24
- const feePoolAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(program.provider.connection, payer, collateralMint, feePool, true);
25
- const payerAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(program.provider.connection, payer, collateralMint, payer.publicKey);
24
+ const feePoolAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, feePool, true);
25
+ const payerAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, payer.publicKey);
26
26
  const transaction = new web3_js_1.Transaction().add(yield claimStakingPoolPositionInstruction(program, feePool, feePoolAssociatedTokenAccount.address, stakedTokenMint, vaultTypeAccount, collateralMint, poolPosition, payer.publicKey, payerAssociatedTokenAccount.address));
27
- yield (0, web3_js_1.sendAndConfirmTransaction)(program.provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
27
+ yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
28
28
  return payerAssociatedTokenAccount.address;
29
29
  });
30
30
  }
@@ -15,6 +15,7 @@ const spl_token_1 = require("@solana/spl-token");
15
15
  const web3_js_1 = require("@solana/web3.js");
16
16
  const getLinkedListAccounts_1 = require("../utils/getLinkedListAccounts");
17
17
  const Constants_1 = require("../Constants");
18
+ const Errors_1 = require("utils/Errors");
18
19
  function loanVault(program, provider, payer, vaultPublicKey, loanAmount, overrideTime) {
19
20
  return __awaiter(this, void 0, void 0, function* () {
20
21
  const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
@@ -27,7 +28,7 @@ function loanVault(program, provider, payer, vaultPublicKey, loanAmount, overrid
27
28
  const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultTypeAccountPublicKey, vaultPublicKey, 0, loanAmount, false, false);
28
29
  const history = web3_js_1.Keypair.generate();
29
30
  const transaction = new web3_js_1.Transaction().add(yield loanVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, loanAmount, overrideTime));
30
- yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history]);
31
+ yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history]).catch(Errors_1.parseAnchorErrors);
31
32
  return vaultPublicKey;
32
33
  });
33
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedge-web3",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "description": "Hedge Javascript Web3 API",
5
5
  "main": "lib/index.js",
6
6
  "types": "declarations/index.d.ts",
package/src/Constants.ts CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  } from '@solana/spl-token'
5
5
  import { PublicKey } from '@solana/web3.js'
6
6
 
7
- export const HEDGE_PROGRAM_ID = 'HDG3uyafYaKxSYRW37ZBTdxaUCoyzaqbuirYucAeaPFY'
7
+ export const HEDGE_PROGRAM_ID = 'HDG4FDos8fyrB79qMCe98gaFjNEy5kpxGNjMc5V8M6TJ'
8
8
  export const HEDGE_PROGRAM_PUBLICKEY = new PublicKey(HEDGE_PROGRAM_ID)
9
9
 
10
10
  export const CHAINLINK_SOL_USD_ID =
@@ -21,6 +21,7 @@ import { Vault } from 'idl/vault'
21
21
 
22
22
  export async function claimStakingPoolPosition(
23
23
  program: Program<Vault>,
24
+ provider: Provider,
24
25
  poolPosition: PublicKey,
25
26
  payer: Signer,
26
27
  collateralType: string
@@ -31,14 +32,14 @@ export async function claimStakingPoolPosition(
31
32
  const stakedTokenMint = await getHedgeMintPublicKey()
32
33
  const [feePool] = await getPoolPublicKeyForMint(stakedTokenMint)
33
34
  const feePoolAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(
34
- program.provider.connection,
35
+ provider.connection,
35
36
  payer,
36
37
  collateralMint,
37
38
  feePool,
38
39
  true
39
40
  )
40
41
  const payerAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(
41
- program.provider.connection,
42
+ provider.connection,
42
43
  payer,
43
44
  collateralMint,
44
45
  payer.publicKey
@@ -57,7 +58,7 @@ export async function claimStakingPoolPosition(
57
58
  payerAssociatedTokenAccount.address
58
59
  )
59
60
  )
60
- await sendAndConfirmTransaction(program.provider.connection, transaction, [payer]).catch(parseAnchorErrors)
61
+ await sendAndConfirmTransaction(provider.connection, transaction, [payer]).catch(parseAnchorErrors)
61
62
  return payerAssociatedTokenAccount.address
62
63
  }
63
64
 
@@ -19,6 +19,7 @@ import {
19
19
  getVaultSystemStatePublicKey,
20
20
  } from '../Constants'
21
21
  import { Vault } from 'idl/vault'
22
+ import { parseAnchorErrors } from 'utils/Errors'
22
23
 
23
24
  export async function loanVault(
24
25
  program: Program<Vault>,
@@ -84,7 +85,7 @@ export async function loanVault(
84
85
  overrideTime
85
86
  )
86
87
  )
87
- await sendAndConfirmTransaction(provider.connection, transaction, [payer, history])
88
+ await sendAndConfirmTransaction(provider.connection, transaction, [payer, history]).catch(parseAnchorErrors)
88
89
  return vaultPublicKey
89
90
  }
90
91