hedge-web3 0.2.24 → 0.2.26

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.
Files changed (73) hide show
  1. package/declarations/Constants.d.ts +13 -15
  2. package/declarations/idl/vault.d.ts +36 -0
  3. package/declarations/instructions/createReferralAccount.d.ts +1 -1
  4. package/declarations/instructions/depositLiquidationPool.d.ts +1 -1
  5. package/declarations/instructions/referralClaimFees.d.ts +1 -1
  6. package/declarations/state/VaultAccount.d.ts +15 -2
  7. package/declarations/utils/getLinkedListAccounts.d.ts +2 -2
  8. package/lib/Constants.js +28 -34
  9. package/lib/idl/vault.js +36 -0
  10. package/lib/instructions/claimLiquidationPoolPosition.js +10 -7
  11. package/lib/instructions/claimStakingPoolPosition.js +5 -5
  12. package/lib/instructions/closeClaimedLiquidationPoolPosition.js +1 -1
  13. package/lib/instructions/closeLiquidationPoolPosition.js +13 -13
  14. package/lib/instructions/createReferralAccount.js +8 -8
  15. package/lib/instructions/createStakingPool.js +7 -7
  16. package/lib/instructions/createUserReferralAccount.js +6 -6
  17. package/lib/instructions/createVault.js +16 -16
  18. package/lib/instructions/depositLiquidationPool.js +9 -9
  19. package/lib/instructions/depositStakingPool.js +5 -5
  20. package/lib/instructions/depositVault.js +11 -9
  21. package/lib/instructions/initHedgeFoundation.js +8 -8
  22. package/lib/instructions/initHedgeFoundationTokens.js +5 -5
  23. package/lib/instructions/liquidateVault.js +8 -8
  24. package/lib/instructions/loanVault.js +12 -12
  25. package/lib/instructions/psmEditAccount.js +5 -5
  26. package/lib/instructions/psmMintUsh.js +14 -14
  27. package/lib/instructions/psmRedeemUsh.js +14 -14
  28. package/lib/instructions/redeemVault.js +7 -7
  29. package/lib/instructions/referralClaimFees.js +8 -8
  30. package/lib/instructions/refreshOraclePrice.js +3 -3
  31. package/lib/instructions/repayVault.js +9 -9
  32. package/lib/instructions/setHalted.js +1 -1
  33. package/lib/instructions/updateReferralAccount.js +2 -2
  34. package/lib/instructions/updateReferralState.js +2 -2
  35. package/lib/instructions/updateVaultType.js +1 -1
  36. package/lib/instructions/withdrawStakingPool.js +11 -11
  37. package/lib/instructions/withdrawVault.js +5 -5
  38. package/lib/state/VaultAccount.js +16 -16
  39. package/lib/utils/getLinkedListAccounts.js +20 -4
  40. package/package.json +1 -1
  41. package/src/Constants.ts +44 -85
  42. package/src/idl/vault.ts +72 -0
  43. package/src/instructions/claimLiquidationPoolPosition.ts +31 -29
  44. package/src/instructions/claimStakingPoolPosition.ts +10 -15
  45. package/src/instructions/closeClaimedLiquidationPoolPosition.ts +4 -2
  46. package/src/instructions/closeLiquidationPoolPosition.ts +18 -24
  47. package/src/instructions/createReferralAccount.ts +17 -29
  48. package/src/instructions/createStakingPool.ts +11 -13
  49. package/src/instructions/createUserReferralAccount.ts +13 -24
  50. package/src/instructions/createVault.ts +44 -21
  51. package/src/instructions/depositLiquidationPool.ts +16 -23
  52. package/src/instructions/depositStakingPool.ts +18 -14
  53. package/src/instructions/depositVault.ts +23 -18
  54. package/src/instructions/initHedgeFoundation.ts +16 -14
  55. package/src/instructions/initHedgeFoundationTokens.ts +12 -14
  56. package/src/instructions/liquidateVault.ts +15 -20
  57. package/src/instructions/loanVault.ts +18 -27
  58. package/src/instructions/psmEditAccount.ts +10 -18
  59. package/src/instructions/psmMintUsh.ts +19 -41
  60. package/src/instructions/psmRedeemUsh.ts +21 -45
  61. package/src/instructions/redeemVault.ts +12 -15
  62. package/src/instructions/referralClaimFees.ts +17 -31
  63. package/src/instructions/refreshOraclePrice.ts +6 -8
  64. package/src/instructions/repayVault.ts +18 -16
  65. package/src/instructions/setHalted.ts +5 -24
  66. package/src/instructions/transferVault.ts +4 -9
  67. package/src/instructions/updateReferralAccount.ts +7 -14
  68. package/src/instructions/updateReferralState.ts +7 -14
  69. package/src/instructions/updateVaultType.ts +9 -23
  70. package/src/instructions/withdrawStakingPool.ts +17 -21
  71. package/src/instructions/withdrawVault.ts +10 -16
  72. package/src/state/VaultAccount.ts +31 -17
  73. package/src/utils/getLinkedListAccounts.ts +20 -7
@@ -20,21 +20,21 @@ const Constants_1 = require("../Constants");
20
20
  const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
21
21
  function psmMintUsh(program, provider, payer, collateralMint, collateralAmount, overrideTime, referrer) {
22
22
  return __awaiter(this, void 0, void 0, function* () {
23
- const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
23
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
24
24
  const payerUshAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
25
25
  const payerCollateralAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, payer.publicKey);
26
26
  const enc = new TextEncoder();
27
- const [psmAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralMint.toString().slice(0, 12)), enc.encode('PSM')], Constants_1.HEDGE_PROGRAM_PUBLICKEY);
27
+ const [psmAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralMint.toString().slice(0, 12)), enc.encode('PSM')], program.programId);
28
28
  const psmAccountAta = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, psmAccount, true);
29
29
  let referralAccountPublicKey;
30
- const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
30
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
31
31
  if (!referrer) {
32
- referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(vaultSystemStatePublicKey);
32
+ referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(program.programId, vaultSystemStatePublicKey);
33
33
  }
34
34
  else {
35
- referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(referrer);
35
+ referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(program.programId, referrer);
36
36
  }
37
- const referralStatePublicKey = yield (0, Constants_1.getReferralStatePublicKey)();
37
+ const referralStatePublicKey = yield (0, Constants_1.getReferralStatePublicKey)(program.programId);
38
38
  const transaction = new web3_js_1.Transaction().add(yield psmMintUshInstruction(program, payer.publicKey, psmAccount, collateralMint, new anchor_1.BN(collateralAmount), referralStatePublicKey, referralAccountPublicKey, overrideTime));
39
39
  yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]);
40
40
  return payer.publicKey;
@@ -43,14 +43,14 @@ function psmMintUsh(program, provider, payer, collateralMint, collateralAmount,
43
43
  exports.psmMintUsh = psmMintUsh;
44
44
  function psmMintUshInstruction(program, payerPublicKey, psmAccount, collateralMint, collateralAmount, referralStatePublicKey, referralAccountPublicKey, overrideTime) {
45
45
  return __awaiter(this, void 0, void 0, function* () {
46
- const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
47
- const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
48
- const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
49
- const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(hedgeMintPublickey);
50
- const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
51
- const psmAccountAta = yield (0, Constants_1.findAssociatedTokenAddress)(psmAccount, collateralMint);
52
- const ownerCollateralAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, collateralMint);
53
- const ownerUshAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, ushMintPublickey);
46
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
47
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
48
+ const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)(program.programId);
49
+ const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(program.programId, hedgeMintPublickey);
50
+ const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, hedgeStakingPoolPublicKey, ushMintPublickey);
51
+ const psmAccountAta = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, psmAccount, collateralMint);
52
+ const ownerCollateralAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, payerPublicKey, collateralMint);
53
+ const ownerUshAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, payerPublicKey, ushMintPublickey);
54
54
  return yield program.methods
55
55
  .psmMintUsh(collateralAmount, new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override time
56
56
  )
@@ -20,21 +20,21 @@ const Constants_1 = require("../Constants");
20
20
  const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
21
21
  function psmRedeemUsh(program, provider, payer, collateralMint, ushAmount, overrideTime, referrer) {
22
22
  return __awaiter(this, void 0, void 0, function* () {
23
- const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
23
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
24
24
  const payerUshAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
25
25
  const payerCollateralAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, payer.publicKey);
26
26
  const enc = new TextEncoder();
27
- const [psmAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralMint.toString().slice(0, 12)), enc.encode('PSM')], Constants_1.HEDGE_PROGRAM_PUBLICKEY);
27
+ const [psmAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralMint.toString().slice(0, 12)), enc.encode('PSM')], program.programId);
28
28
  const psmAccountAta = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, psmAccount, true);
29
29
  let referralAccountPublicKey;
30
- const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
30
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
31
31
  if (!referrer) {
32
- referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(vaultSystemStatePublicKey);
32
+ referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(program.programId, vaultSystemStatePublicKey);
33
33
  }
34
34
  else {
35
- referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(referrer);
35
+ referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(program.programId, referrer);
36
36
  }
37
- const referralStatePublicKey = yield (0, Constants_1.getReferralStatePublicKey)();
37
+ const referralStatePublicKey = yield (0, Constants_1.getReferralStatePublicKey)(program.programId);
38
38
  const transaction = new web3_js_1.Transaction().add(yield psmRedeemUshInstruction(program, payer.publicKey, psmAccount, collateralMint, new anchor_1.BN(ushAmount), referralStatePublicKey, referralAccountPublicKey, overrideTime));
39
39
  yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]);
40
40
  return payer.publicKey;
@@ -43,14 +43,14 @@ function psmRedeemUsh(program, provider, payer, collateralMint, ushAmount, overr
43
43
  exports.psmRedeemUsh = psmRedeemUsh;
44
44
  function psmRedeemUshInstruction(program, payerPublicKey, psmAccount, collateralMint, ushAmount, referralStatePublicKey, referralAccountPublicKey, overrideTime) {
45
45
  return __awaiter(this, void 0, void 0, function* () {
46
- const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
47
- const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
48
- const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
49
- const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(hedgeMintPublickey);
50
- const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
51
- const psmAccountAta = yield (0, Constants_1.findAssociatedTokenAddress)(psmAccount, collateralMint);
52
- const ownerCollateralAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, collateralMint);
53
- const ownerUshAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, ushMintPublickey);
46
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
47
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
48
+ const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)(program.programId);
49
+ const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(program.programId, hedgeMintPublickey);
50
+ const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, hedgeStakingPoolPublicKey, ushMintPublickey);
51
+ const psmAccountAta = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, psmAccount, collateralMint);
52
+ const ownerCollateralAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, payerPublicKey, collateralMint);
53
+ const ownerUshAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, payerPublicKey, ushMintPublickey);
54
54
  return yield program.methods
55
55
  .psmRedeemUsh(ushAmount, new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override time
56
56
  )
@@ -17,12 +17,12 @@ const anchor_1 = require("@project-serum/anchor");
17
17
  const spl_token_1 = require("@solana/spl-token");
18
18
  // import { TokenInstructions } from '@project-serum/serum'
19
19
  const web3_js_1 = require("@solana/web3.js");
20
- const getLinkedListAccounts_1 = require("../utils/getLinkedListAccounts");
21
20
  const Constants_1 = require("../Constants");
21
+ const getLinkedListAccounts_1 = require("../utils/getLinkedListAccounts");
22
22
  const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
23
23
  function redeemVault(program, provider, payer, vaultPublicKey, redeemAmount, transactionOverrideTime) {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
- const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
25
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
26
26
  // Prep the user to get USH back out at some point
27
27
  const payerUshAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
28
28
  const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
@@ -40,11 +40,11 @@ function redeemVault(program, provider, payer, vaultPublicKey, redeemAmount, tra
40
40
  exports.redeemVault = redeemVault;
41
41
  function redeemVaultInstruction(program, payerPublicKey, payerUshAccount, destinationTokenAccount, vaultPublickey, vaultAssociatedTokenAccount, historyPublicKey, vaultTypeAccount, vaultTypeAssociatedTokenAccount, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, redeemAmount, transactionOverrideTime) {
42
42
  return __awaiter(this, void 0, void 0, function* () {
43
- const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
44
- const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
45
- const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
46
- const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(hedgeMintPublickey);
47
- const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
43
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
44
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
45
+ const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)(program.programId);
46
+ const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(program.programId, hedgeMintPublickey);
47
+ const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, hedgeStakingPoolPublicKey, ushMintPublickey);
48
48
  return yield program.methods
49
49
  .redeemVault(redeemAmount, new anchor_1.BN(transactionOverrideTime !== null && transactionOverrideTime !== void 0 ? transactionOverrideTime : Date.now() / 1000) // override start time
50
50
  )
@@ -28,28 +28,28 @@ const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfi
28
28
  * - payer: Signer : who we are creating the referral account for
29
29
  * - poolPublicKey: PublicKey : a key to a pool position. If the position is closed or does not belong to the signer it will be ignored
30
30
  * - referrer: PublicKey
31
- */
31
+ */
32
32
  function referralClaimFees(program, provider, payer, poolPosition) {
33
33
  return __awaiter(this, void 0, void 0, function* () {
34
- // setup transaction
34
+ // setup transaction
35
35
  const transaction = new web3_js_1.Transaction();
36
36
  const signers = [payer];
37
37
  // General variables
38
- const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
38
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
39
39
  // Find referrer account
40
40
  const referrer = yield payer.publicKey;
41
- const referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(referrer);
41
+ const referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(program.programId, referrer);
42
42
  // Derive the user referral account public key
43
- const referallStatePublicKey = yield (0, Constants_1.getReferralStatePublicKey)();
44
- const hedgeMintPublicKey = yield (0, Constants_1.getHedgeMintPublicKey)();
43
+ const referallStatePublicKey = yield (0, Constants_1.getReferralStatePublicKey)(program.programId);
44
+ const hedgeMintPublicKey = yield (0, Constants_1.getHedgeMintPublicKey)(program.programId);
45
45
  // Get HDG account of signer
46
46
  const payerHdgAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, hedgeMintPublicKey, payer.publicKey);
47
- const ushMintPublicKey = yield (0, Constants_1.getUshMintPublicKey)();
47
+ const ushMintPublicKey = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
48
48
  // Get USH account of signer
49
49
  const payerUshAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublicKey, payer.publicKey);
50
50
  // Get community_associated_hedge_token_account
51
51
  const communityAssociatedHedgeTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, hedgeMintPublicKey, vaultSystemStatePublicKey, true);
52
- const [feePoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(hedgeMintPublicKey);
52
+ const [feePoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(program.programId, hedgeMintPublicKey);
53
53
  const feePoolAssociatedUshTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublicKey, feePoolPublicKey, true);
54
54
  transaction.add(yield referralClaimFeesInstruction(program, payer.publicKey, vaultSystemStatePublicKey, poolPosition, referralAccountPublicKey, referallStatePublicKey, hedgeMintPublicKey, payerHdgAssociatedTokenAccount.address, ushMintPublicKey, payerUshAssociatedTokenAccount.address, communityAssociatedHedgeTokenAccount.address, feePoolPublicKey, feePoolAssociatedUshTokenAccount.address));
55
55
  yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, signers).catch(Errors_1.parseAnchorErrors);
@@ -15,8 +15,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.Cluster = exports.refreshOraclePriceInstruction = exports.refreshOraclePrice = void 0;
16
16
  const anchor_1 = require("@project-serum/anchor");
17
17
  const web3_js_1 = require("@solana/web3.js");
18
- const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
19
18
  const Constants_1 = require("../Constants");
19
+ const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
20
20
  function refreshOraclePrice(program, provider, payer, collateralType, network, overridePrice, overrideTime) {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
22
  const transaction = new web3_js_1.Transaction().add(yield refreshOraclePriceInstruction(program, collateralType, network, overridePrice, overrideTime));
@@ -27,8 +27,8 @@ exports.refreshOraclePrice = refreshOraclePrice;
27
27
  function refreshOraclePriceInstruction(program, collateralType, network, overridePrice, overrideTime) {
28
28
  return __awaiter(this, void 0, void 0, function* () {
29
29
  const enc = new TextEncoder();
30
- const [oracleInfoAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralType), enc.encode('Oracle')], Constants_1.HEDGE_PROGRAM_PUBLICKEY);
31
- const [vaultTypeAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralType), enc.encode('State')], Constants_1.HEDGE_PROGRAM_PUBLICKEY);
30
+ const [oracleInfoAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralType), enc.encode('Oracle')], program.programId);
31
+ const [vaultTypeAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralType), enc.encode('State')], program.programId);
32
32
  const oracleInfo = yield program.account.oracleInfoForCollateralType.fetch(oracleInfoAccount);
33
33
  return yield program.methods
34
34
  .refreshOraclePrice(new anchor_1.BN(overridePrice !== null && overridePrice !== void 0 ? overridePrice : web3_js_1.LAMPORTS_PER_SOL * 150), // override usd/sol price
@@ -16,18 +16,18 @@ exports.repayVaultInstruction = exports.repayVault = void 0;
16
16
  const anchor_1 = require("@project-serum/anchor");
17
17
  const spl_token_1 = require("@solana/spl-token");
18
18
  const web3_js_1 = require("@solana/web3.js");
19
- const getLinkedListAccounts_1 = require("../utils/getLinkedListAccounts");
20
19
  const Constants_1 = require("../Constants");
20
+ const getLinkedListAccounts_1 = require("../utils/getLinkedListAccounts");
21
21
  const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
22
22
  function repayVault(program, provider, payer, vaultPublicKey, repayAmount, overrideTime) {
23
23
  return __awaiter(this, void 0, void 0, function* () {
24
- const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
24
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
25
25
  // Prep the user to get USH back out at some point
26
26
  const payerUshAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
27
27
  const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
28
28
  const vaultTypeAccount = yield program.account.vaultType.fetch(vaultAccount.vaultType);
29
- const vaultTypeAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(vaultAccount.vaultType, vaultTypeAccount.collateralMint);
30
- const vaultAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(vaultPublicKey, vaultTypeAccount.collateralMint);
29
+ const vaultTypeAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, vaultAccount.vaultType, vaultTypeAccount.collateralMint);
30
+ const vaultAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, vaultPublicKey, vaultTypeAccount.collateralMint);
31
31
  const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, vaultAccount.vaultType, vaultPublicKey, new anchor_1.BN(0), new anchor_1.BN(0), new anchor_1.BN(0), new anchor_1.BN(Math.abs(repayAmount)), false, false);
32
32
  const history = web3_js_1.Keypair.generate();
33
33
  const transaction = new web3_js_1.Transaction().add(yield repayVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount, history.publicKey, vaultAccount.vaultType, vaultTypeAssociatedTokenAccount, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, new anchor_1.BN(repayAmount), overrideTime));
@@ -38,11 +38,11 @@ function repayVault(program, provider, payer, vaultPublicKey, repayAmount, overr
38
38
  exports.repayVault = repayVault;
39
39
  function repayVaultInstruction(program, payerPublicKey, ownerUshAccount, vaultPublickey, vaultAssociatedTokenAccount, historyPublicKey, vaultTypeAccount, vaultTypeAssociatedTokenAccount, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, repayAmount, overrideTime) {
40
40
  return __awaiter(this, void 0, void 0, function* () {
41
- const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
42
- const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
43
- const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
44
- const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(hedgeMintPublickey);
45
- const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
41
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
42
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
43
+ const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)(program.programId);
44
+ const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(program.programId, hedgeMintPublickey);
45
+ const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, hedgeStakingPoolPublicKey, ushMintPublickey);
46
46
  return yield program.methods
47
47
  .repayVault(repayAmount, new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override time
48
48
  )
@@ -19,7 +19,7 @@ const Errors_1 = require("../utils/Errors");
19
19
  const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
20
20
  function setHalted(program, provider, payer, halted) {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
- const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
22
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
23
23
  const transaction = new web3_js_1.Transaction().add(yield setHaltedInstruction(program, vaultSystemStatePublicKey, payer.publicKey, halted));
24
24
  yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
25
25
  return vaultSystemStatePublicKey;
@@ -18,8 +18,8 @@ const Constants_1 = require("../Constants");
18
18
  const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
19
19
  function updateReferralAccount(program, provider, payer, referrer, config) {
20
20
  return __awaiter(this, void 0, void 0, function* () {
21
- const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
22
- const referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(referrer);
21
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
22
+ const referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(program.programId, referrer);
23
23
  const transaction = new web3_js_1.Transaction().add(yield updateReferralAccountInstruction(program, vaultSystemStatePublicKey, referralAccountPublicKey, payer.publicKey, config));
24
24
  yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]);
25
25
  return referralAccountPublicKey;
@@ -18,8 +18,8 @@ const Constants_1 = require("../Constants");
18
18
  const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
19
19
  function updateReferralState(program, provider, payer, config) {
20
20
  return __awaiter(this, void 0, void 0, function* () {
21
- const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
22
- const referralStatePublicKey = yield (0, Constants_1.getReferralStatePublicKey)();
21
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
22
+ const referralStatePublicKey = yield (0, Constants_1.getReferralStatePublicKey)(program.programId);
23
23
  const transaction = new web3_js_1.Transaction().add(yield updateReferralStateInstruction(program, vaultSystemStatePublicKey, referralStatePublicKey, payer.publicKey, config));
24
24
  yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]);
25
25
  return referralStatePublicKey;
@@ -18,7 +18,7 @@ const Constants_1 = require("../Constants");
18
18
  const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
19
19
  function updateVaultType(program, provider, payer, vaultTypeAccount, oracleInfoAccount, config) {
20
20
  return __awaiter(this, void 0, void 0, function* () {
21
- const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
21
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
22
22
  const transaction = new web3_js_1.Transaction().add(yield updateVaultTypeStatusInstruction(program, vaultSystemStatePublicKey, payer.publicKey, vaultTypeAccount, oracleInfoAccount, config));
23
23
  yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]);
24
24
  return vaultSystemStatePublicKey;
@@ -16,8 +16,8 @@ exports.withdrawStakingPoolInstruction = exports.withdrawStakingPool = void 0;
16
16
  const anchor_1 = require("@project-serum/anchor");
17
17
  const spl_token_1 = require("@solana/spl-token");
18
18
  const web3_js_1 = require("@solana/web3.js");
19
- const Errors_1 = require("../utils/Errors");
20
19
  const Constants_1 = require("../Constants");
20
+ const Errors_1 = require("../utils/Errors");
21
21
  const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
22
22
  function withdrawStakingPool(program, provider, payer, poolPositionPublicKey, stakedTokenMintPublicKey, overrideStartTime) {
23
23
  return __awaiter(this, void 0, void 0, function* () {
@@ -30,16 +30,16 @@ function withdrawStakingPool(program, provider, payer, poolPositionPublicKey, st
30
30
  exports.withdrawStakingPool = withdrawStakingPool;
31
31
  function withdrawStakingPoolInstruction(program, payerPublicKey, poolPositionPublicKey, stakedTokenMintPublicKey, overrideStartTime) {
32
32
  return __awaiter(this, void 0, void 0, function* () {
33
- const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
34
- const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
35
- const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
36
- const [poolPublickey] = yield (0, Constants_1.getPoolPublicKeyForMint)(stakedTokenMintPublicKey);
37
- const poolAssociatedStakedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(poolPublickey, stakedTokenMintPublicKey);
38
- const poolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(poolPublickey, ushMintPublickey);
39
- const payerAssociatedStakedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, stakedTokenMintPublicKey);
40
- const payerAssociatedHedgeAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, hedgeMintPublickey);
41
- const payerAssociatedUshAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, ushMintPublickey);
42
- const communityHedgeTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(vaultSystemStatePublicKey, hedgeMintPublickey);
33
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
34
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
35
+ const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)(program.programId);
36
+ const [poolPublickey] = yield (0, Constants_1.getPoolPublicKeyForMint)(program.programId, stakedTokenMintPublicKey);
37
+ const poolAssociatedStakedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, poolPublickey, stakedTokenMintPublicKey);
38
+ const poolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, poolPublickey, ushMintPublickey);
39
+ const payerAssociatedStakedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, payerPublicKey, stakedTokenMintPublicKey);
40
+ const payerAssociatedHedgeAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, payerPublicKey, hedgeMintPublickey);
41
+ const payerAssociatedUshAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, payerPublicKey, ushMintPublickey);
42
+ const communityHedgeTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, vaultSystemStatePublicKey, hedgeMintPublickey);
43
43
  return yield program.methods
44
44
  .withdrawStakingPool(new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Math.floor(Date.now() / 1000)) // override current time
45
45
  )
@@ -14,26 +14,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.withdrawVaultInstruction = exports.withdrawVault = void 0;
16
16
  const anchor_1 = require("@project-serum/anchor");
17
- const spl_token_1 = require("@solana/spl-token");
18
17
  const serum_1 = require("@project-serum/serum");
18
+ const spl_token_1 = require("@solana/spl-token");
19
19
  const web3_js_1 = require("@solana/web3.js");
20
20
  const Constants_1 = require("../Constants");
21
21
  const getLinkedListAccounts_1 = require("../utils/getLinkedListAccounts");
22
22
  const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
23
23
  function withdrawVault(program, provider, payer, vaultPublicKey, withdrawAmount, overrideTime) {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
- const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
25
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
26
26
  // Prep the user to get USH back out at some point
27
27
  yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
28
28
  const history = web3_js_1.Keypair.generate();
29
- const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
29
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
30
30
  const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
31
31
  const vaultAssociatedCollateralAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, serum_1.TokenInstructions.WRAPPED_SOL_MINT, vaultPublicKey, true);
32
32
  const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultAccount.vaultType);
33
33
  const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, vaultAccount.vaultType, true);
34
34
  const destinationTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, payer.publicKey);
35
- const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(yield (0, Constants_1.getHedgeMintPublicKey)());
36
- const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
35
+ const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(program.programId, yield (0, Constants_1.getHedgeMintPublicKey)(program.programId));
36
+ const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, hedgeStakingPoolPublicKey, ushMintPublickey);
37
37
  const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, vaultAccount.vaultType, vaultPublicKey, new anchor_1.BN(0), new anchor_1.BN(Math.abs(withdrawAmount)), new anchor_1.BN(0), new anchor_1.BN(0), false, false);
38
38
  const transaction = new web3_js_1.Transaction().add(yield withdrawVaultInstruction(program, vaultSystemStatePublicKey, payer.publicKey, destinationTokenAccount.address, vaultPublicKey, vaultAssociatedCollateralAccount.address, vaultAccount.vaultType, vaultTypeAssociatedTokenAccount.address, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUshTokenAccount, ushMintPublickey, history.publicKey, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, new anchor_1.BN(withdrawAmount), overrideTime));
39
39
  yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, history]);
@@ -32,7 +32,7 @@ const bn_js_1 = __importDefault(require("bn.js"));
32
32
  * A class that represents an on-chian vault.
33
33
  */
34
34
  class VaultAccount {
35
- constructor(vault, publicKey) {
35
+ constructor(vaultData, publicKey) {
36
36
  /** The deposited collateral of the vault (in SOL Lamports). */
37
37
  this.deposited = new bn_js_1.default(0);
38
38
  /** The outstanding debt of the vault (in USH Lamports). Denormalized to time 0. */
@@ -46,25 +46,25 @@ class VaultAccount {
46
46
  /** Current State of the vault ("Open", "Closed", "Liquidated") */
47
47
  this.vaultStatus = '';
48
48
  this.publicKey = publicKey;
49
- this.vaultOwner = vault.vaultOwner;
50
- this.pdaSalt = vault.pdaSalt;
51
- this.deposited = vault.deposited;
52
- this.denormalizedDebt = vault.denormalizedDebt;
53
- if (vault.vaultNumber) {
54
- this.vaultNumber = vault.vaultNumber.toNumber();
49
+ this.vaultOwner = vaultData.vaultOwner;
50
+ this.pdaSalt = vaultData.pdaSalt;
51
+ this.deposited = vaultData.deposited;
52
+ this.denormalizedDebt = vaultData.denormalizedDebt;
53
+ if (vaultData.vaultNumber) {
54
+ this.vaultNumber = vaultData.vaultNumber.toNumber();
55
55
  }
56
- if (vault.debtProductSnapshotBytes) {
57
- this.debtProductSnapshotBytes = (0, HedgeDecimal_1.DecimalFromU128)(vault.debtProductSnapshotBytes.toString());
56
+ if (vaultData.debtProductSnapshotBytes) {
57
+ this.debtProductSnapshotBytes = (0, HedgeDecimal_1.DecimalFromU128)(vaultData.debtProductSnapshotBytes.toString());
58
58
  }
59
- if (vault.collateralAccumulatorSnapshotBytes) {
60
- this.collateralAccumulatorSnapshotBytes = (0, HedgeDecimal_1.DecimalFromU128)(vault.collateralAccumulatorSnapshotBytes.toString());
59
+ if (vaultData.collateralAccumulatorSnapshotBytes) {
60
+ this.collateralAccumulatorSnapshotBytes = (0, HedgeDecimal_1.DecimalFromU128)(vaultData.collateralAccumulatorSnapshotBytes.toString());
61
61
  }
62
- this.vaultTypeName = vault.vaultTypeName;
63
- this.nextVaultToRedeem = vault.nextVaultToRedeem;
64
- if (vault.vaultStatus) {
65
- this.vaultStatus = Object.keys(vault.vaultStatus)[0];
62
+ this.vaultTypeName = vaultData.vaultTypeName;
63
+ this.nextVaultToRedeem = vaultData.nextVaultToRedeem;
64
+ if (vaultData.vaultStatus) {
65
+ this.vaultStatus = Object.keys(vaultData.vaultStatus)[0];
66
66
  }
67
- this.vaultType = vault.vaultType;
67
+ this.vaultType = vaultData.vaultType;
68
68
  }
69
69
  /**
70
70
  * Check if some `PublicKey` is the owner
@@ -14,10 +14,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.getLinkedListAccounts = void 0;
16
16
  const anchor_1 = require("@project-serum/anchor");
17
+ const web3_js_1 = require("@solana/web3.js");
17
18
  const underscore_1 = __importDefault(require("underscore"));
18
- const Constants_1 = require("../Constants");
19
- const VaultAccount_1 = require("../state/VaultAccount");
20
19
  const decimal_js_1 = __importDefault(require("decimal.js"));
20
+ const VaultAccount_1 = require("../state/VaultAccount");
21
21
  const bs58_1 = __importDefault(require("bs58"));
22
22
  const VaultType_1 = __importDefault(require("../state/VaultType"));
23
23
  /**
@@ -43,7 +43,23 @@ function getLinkedListAccounts(program, vaultTypeAccountPublicKey, vaultPublicKe
43
43
  let oldSmallerPublicKey = vaultPublicKey;
44
44
  let newSmallerPublicKey = vaultPublicKey;
45
45
  let newLargerPublicKey = vaultPublicKey;
46
- const thisVaultData = yield program.account.vault.fetch(vaultPublicKey);
46
+ const thisVaultData = yield program.account.vault.fetch(vaultPublicKey)
47
+ .catch((e) => {
48
+ console.log('Error fetching vault account. Assuming it does not exist yet');
49
+ return {
50
+ vaultOwner: new web3_js_1.PublicKey('11111111111111111111111111111111'),
51
+ pdaSalt: 'foo',
52
+ deposited: new anchor_1.BN(0),
53
+ denormalizedDebt: new anchor_1.BN(0),
54
+ vaultNumber: new anchor_1.BN(0),
55
+ debtProductSnapshotBytes: new anchor_1.BN(0),
56
+ collateralAccumulatorSnapshotBytes: new anchor_1.BN(0),
57
+ vaultTypeName: vaultType.name,
58
+ nextVaultToRedeem: new web3_js_1.PublicKey('11111111111111111111111111111111'),
59
+ vaultStatus: { open: true },
60
+ vaultType: vaultTypeAccountPublicKey
61
+ };
62
+ });
47
63
  // const accountInfo = await program.provider.connection.getAccountInfo(vaultPublicKey)
48
64
  const thisVault = new VaultAccount_1.VaultAccount(thisVaultData, vaultPublicKey);
49
65
  // Load all the vaults
@@ -200,7 +216,7 @@ function getMiniVaults(program, vaultTypePublicKey) {
200
216
  },
201
217
  },
202
218
  ];
203
- const allAccounts = yield program.provider.connection.getProgramAccounts(Constants_1.HEDGE_PROGRAM_PUBLICKEY, {
219
+ const allAccounts = yield program.provider.connection.getProgramAccounts(program.programId, {
204
220
  filters: filters,
205
221
  // Slice the data only to grab the 3 u64's of size 8 bytes each
206
222
  dataSlice: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedge-web3",
3
- "version": "0.2.24",
3
+ "version": "0.2.26",
4
4
  "description": "Hedge Javascript Web3 API",
5
5
  "main": "lib/index.js",
6
6
  "types": "declarations/index.d.ts",