hedge-web3 0.1.29 → 0.1.31

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. package/declarations/idl/vault.d.ts +99 -99
  2. package/declarations/index.d.ts +1 -0
  3. package/declarations/instructions/claimLiquidationPoolPosition.d.ts +3 -2
  4. package/declarations/instructions/claimStakingPoolPosition.d.ts +3 -2
  5. package/declarations/instructions/closeLiquidationPoolPosition.d.ts +3 -2
  6. package/declarations/instructions/createStakingPool.d.ts +3 -2
  7. package/declarations/instructions/createVault.d.ts +6 -5
  8. package/declarations/instructions/depositLiquidationPool.d.ts +3 -2
  9. package/declarations/instructions/depositStakingPool.d.ts +3 -2
  10. package/declarations/instructions/depositVault.d.ts +3 -2
  11. package/declarations/instructions/initHedgeFoundation.d.ts +3 -2
  12. package/declarations/instructions/liquidateVault.d.ts +3 -2
  13. package/declarations/instructions/loanVault.d.ts +3 -2
  14. package/declarations/instructions/redeemVault.d.ts +3 -2
  15. package/declarations/instructions/refreshOraclePrice.d.ts +3 -2
  16. package/declarations/instructions/repayVault.d.ts +3 -2
  17. package/declarations/instructions/setHalted.d.ts +3 -2
  18. package/declarations/instructions/setVaultTypeStatus.d.ts +3 -2
  19. package/declarations/instructions/withdrawStakingPool.d.ts +3 -2
  20. package/declarations/instructions/withdrawVault.d.ts +3 -2
  21. package/declarations/state/VaultAccount.d.ts +1 -1
  22. package/declarations/utils/getLinkedListAccounts.d.ts +3 -1
  23. package/lib/idl/vault.js +99 -99
  24. package/lib/index.js +1 -0
  25. package/lib/instructions/claimLiquidationPoolPosition.js +19 -22
  26. package/lib/instructions/claimStakingPoolPosition.js +19 -19
  27. package/lib/instructions/closeLiquidationPoolPosition.js +22 -22
  28. package/lib/instructions/createStakingPool.js +17 -18
  29. package/lib/instructions/createVault.js +28 -31
  30. package/lib/instructions/depositLiquidationPool.js +17 -18
  31. package/lib/instructions/depositStakingPool.js +16 -18
  32. package/lib/instructions/depositVault.js +25 -27
  33. package/lib/instructions/initHedgeFoundation.js +17 -19
  34. package/lib/instructions/initHedgeFoundationTokens.js +15 -15
  35. package/lib/instructions/liquidateVault.js +32 -33
  36. package/lib/instructions/loanVault.js +23 -23
  37. package/lib/instructions/redeemVault.js +24 -24
  38. package/lib/instructions/refreshOraclePrice.js +17 -17
  39. package/lib/instructions/repayVault.js +23 -23
  40. package/lib/instructions/setHalted.js +8 -9
  41. package/lib/instructions/setVaultTypeStatus.js +9 -10
  42. package/lib/instructions/withdrawStakingPool.js +22 -24
  43. package/lib/instructions/withdrawVault.js +23 -23
  44. package/lib/state/LiquidationPoolEra.js +3 -1
  45. package/lib/state/LiquidationPosition.js +0 -7
  46. package/lib/state/StakingPool.js +3 -4
  47. package/lib/state/VaultAccount.js +2 -5
  48. package/lib/utils/getLinkedListAccounts.js +24 -16
  49. package/package.json +2 -2
  50. package/src/idl/vault.ts +198 -198
  51. package/src/index.ts +1 -0
  52. package/src/instructions/claimLiquidationPoolPosition.ts +39 -29
  53. package/src/instructions/claimStakingPoolPosition.ts +45 -25
  54. package/src/instructions/closeLiquidationPoolPosition.ts +62 -32
  55. package/src/instructions/createStakingPool.ts +37 -35
  56. package/src/instructions/createVault.ts +81 -125
  57. package/src/instructions/depositLiquidationPool.ts +45 -26
  58. package/src/instructions/depositStakingPool.ts +32 -24
  59. package/src/instructions/depositVault.ts +57 -86
  60. package/src/instructions/initHedgeFoundation.ts +42 -43
  61. package/src/instructions/initHedgeFoundationTokens.ts +38 -39
  62. package/src/instructions/liquidateVault.ts +42 -65
  63. package/src/instructions/loanVault.ts +51 -69
  64. package/src/instructions/redeemVault.ts +83 -47
  65. package/src/instructions/refreshOraclePrice.ts +41 -32
  66. package/src/instructions/repayVault.ts +45 -65
  67. package/src/instructions/setHalted.ts +32 -24
  68. package/src/instructions/setVaultTypeStatus.ts +32 -24
  69. package/src/instructions/withdrawStakingPool.ts +44 -30
  70. package/src/instructions/withdrawVault.ts +58 -82
  71. package/src/state/LiquidationPoolEra.ts +4 -3
  72. package/src/state/LiquidationPosition.ts +0 -27
  73. package/src/state/StakingPool.ts +4 -7
  74. package/src/state/StakingPoolPosition.ts +2 -3
  75. package/src/state/VaultAccount.ts +9 -28
  76. package/src/state/VaultHistoryEvent.ts +1 -2
  77. package/src/utils/getLinkedListAccounts.ts +31 -30
@@ -19,7 +19,7 @@ function depositStakingPool(program, provider, payer, mintPublicKey, depositAmou
19
19
  return __awaiter(this, void 0, void 0, function* () {
20
20
  const poolPosition = web3_js_1.Keypair.generate();
21
21
  const transaction = new web3_js_1.Transaction().add(yield depositStakingPoolInstruction(program, payer.publicKey, poolPosition.publicKey, mintPublicKey, depositAmount, overrideStartTime));
22
- yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, poolPosition], provider.opts).catch(Errors_1.parseAnchorErrors);
22
+ yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, poolPosition]).catch(Errors_1.parseAnchorErrors);
23
23
  return poolPosition.publicKey;
24
24
  });
25
25
  }
@@ -30,23 +30,21 @@ function depositStakingPoolInstruction(program, payerPublicKey, poolPositionPubl
30
30
  const poolAssociatedStakedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(poolPublickey, stakedTokenMintPublicKey);
31
31
  const payersArbitraryTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, stakedTokenMintPublicKey);
32
32
  const vaultSystemState = yield (0, Constants_1.getVaultSystemStatePublicKey)();
33
- return program.instruction.depositStakingPool(new anchor_1.BN(depositAmount), new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Math.floor(Date.now() / 1000)), // override current time
34
- {
35
- accounts: {
36
- payer: payerPublicKey,
37
- vaultSystemState: vaultSystemState,
38
- pool: poolPublickey,
39
- poolPosition: poolPositionPublicKey,
40
- stakedTokenMintInfo: stakedTokenMintPublicKey,
41
- poolAssociatedStakedTokenAccount: poolAssociatedStakedTokenAccount,
42
- payerAssociatedStakedTokenAccount: payersArbitraryTokenAccount,
43
- rent: web3_js_1.SYSVAR_RENT_PUBKEY,
44
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
45
- associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
46
- systemProgram: web3_js_1.SystemProgram.programId
47
- },
48
- signers: []
49
- });
33
+ return yield program.methods
34
+ .depositStakingPool(new anchor_1.BN(depositAmount), new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Math.floor(Date.now() / 1000)) // override current time
35
+ )
36
+ .accounts({
37
+ payer: payerPublicKey,
38
+ vaultSystemState: vaultSystemState,
39
+ pool: poolPublickey,
40
+ poolPosition: poolPositionPublicKey,
41
+ stakedTokenMintInfo: stakedTokenMintPublicKey,
42
+ poolAssociatedStakedTokenAccount: poolAssociatedStakedTokenAccount,
43
+ payerAssociatedStakedTokenAccount: payersArbitraryTokenAccount,
44
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
45
+ systemProgram: web3_js_1.SystemProgram.programId,
46
+ })
47
+ .instruction();
50
48
  });
51
49
  }
52
50
  exports.depositStakingPoolInstruction = depositStakingPoolInstruction;
@@ -49,9 +49,7 @@ function depositVault(program, provider, payer, vaultPublicKey, depositAmount, o
49
49
  }));
50
50
  signers.push(wrappedSolAccount);
51
51
  }
52
- transaction.add(yield depositVaultInstruction(program, vaultSystemStatePublicKey, payer.publicKey, vaultAccount.collateralType === 'SOL'
53
- ? wrappedSolAccount.publicKey
54
- : payerTokenAccount, vaultPublicKey, vaultAssociatedCollateralAccountPublicKey, history.publicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount.address, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUshTokenAccount, vaultTypeAccountInfo.collateralMint, ushMintPublickey, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, depositAmount, overrideTime));
52
+ transaction.add(yield depositVaultInstruction(program, vaultSystemStatePublicKey, payer.publicKey, vaultAccount.collateralType === 'SOL' ? wrappedSolAccount.publicKey : payerTokenAccount, vaultPublicKey, vaultAssociatedCollateralAccountPublicKey, history.publicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount.address, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUshTokenAccount, vaultTypeAccountInfo.collateralMint, ushMintPublickey, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, depositAmount, overrideTime));
55
53
  if (vaultAccount.collateralType === 'SOL') {
56
54
  transaction.add(serum_1.TokenInstructions.closeAccount({
57
55
  source: wrappedSolAccount.publicKey,
@@ -59,36 +57,36 @@ function depositVault(program, provider, payer, vaultPublicKey, depositAmount, o
59
57
  owner: payer.publicKey,
60
58
  }));
61
59
  }
62
- yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, signers, provider.opts);
60
+ yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, signers);
63
61
  return vaultPublicKey;
64
62
  });
65
63
  }
66
64
  exports.depositVault = depositVault;
67
65
  function depositVaultInstruction(program, vaultSystemStatePublicKey, vaultOwner, vaultOwnerTokenAccount, vaultPublicKey, vaultAssociatedTokenAccount, historyPublicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUshTokenAccount, collateralMint, ushMintPublickey, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, depositAmount, overrideTime) {
68
66
  return __awaiter(this, void 0, void 0, function* () {
69
- return program.instruction.depositVault(new anchor_1.BN(depositAmount), new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)), // override override time
70
- {
71
- accounts: {
72
- vaultSystemState: vaultSystemStatePublicKey,
73
- vaultTypeAccount: vaultTypeAccountPublicKey,
74
- vaultTypeAssociatedTokenAccount: vaultTypeAssociatedTokenAccount,
75
- collateralTokenMint: collateralMint,
76
- vault: vaultPublicKey,
77
- vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
78
- feePool: hedgeStakingPoolPublicKey,
79
- feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
80
- history: historyPublicKey,
81
- vaultOwner: vaultOwner,
82
- vaultOwnerTokenAccount: vaultOwnerTokenAccount,
83
- ushMint: ushMintPublickey,
84
- oldSmallerVaultInfo: oldSmallerPublicKey,
85
- newSmallerVaultInfo: newSmallerPublicKey,
86
- newLargerVaultInfo: newLargerPublicKey,
87
- systemProgram: web3_js_1.SystemProgram.programId,
88
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
89
- },
90
- signers: [],
91
- });
67
+ return yield program.methods
68
+ .depositVault(new anchor_1.BN(depositAmount), new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override time
69
+ )
70
+ .accounts({
71
+ vaultSystemState: vaultSystemStatePublicKey,
72
+ vaultTypeAccount: vaultTypeAccountPublicKey,
73
+ vaultTypeAssociatedTokenAccount: vaultTypeAssociatedTokenAccount,
74
+ collateralTokenMint: collateralMint,
75
+ vault: vaultPublicKey,
76
+ vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
77
+ feePool: hedgeStakingPoolPublicKey,
78
+ feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
79
+ history: historyPublicKey,
80
+ vaultOwner: vaultOwner,
81
+ vaultOwnerTokenAccount: vaultOwnerTokenAccount,
82
+ ushMint: ushMintPublickey,
83
+ oldSmallerVaultInfo: oldSmallerPublicKey,
84
+ newSmallerVaultInfo: newSmallerPublicKey,
85
+ newLargerVaultInfo: newLargerPublicKey,
86
+ systemProgram: web3_js_1.SystemProgram.programId,
87
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
88
+ })
89
+ .instruction();
92
90
  });
93
91
  }
94
92
  exports.depositVaultInstruction = depositVaultInstruction;
@@ -18,7 +18,7 @@ function initHedgeFoundation(program, provider, payer) {
18
18
  return __awaiter(this, void 0, void 0, function* () {
19
19
  const poolEra = web3_js_1.Keypair.generate();
20
20
  const transaction = new web3_js_1.Transaction().add(yield initHedgeFoundationInstruction(program, poolEra.publicKey, payer.publicKey));
21
- yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, poolEra], provider.opts).catch(Errors_1.parseAnchorErrors);
21
+ yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, poolEra]).catch(Errors_1.parseAnchorErrors);
22
22
  return payer.publicKey;
23
23
  });
24
24
  }
@@ -32,24 +32,22 @@ function initHedgeFoundationInstruction(program, poolEraPublicKey, payerPublicKe
32
32
  const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
33
33
  const founderHedgeTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, hedgeMintPublickey);
34
34
  const communityHedgeTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(vaultSystemStatePublicKey, hedgeMintPublickey);
35
- return program.instruction.initHedgeFoundation({
36
- accounts: {
37
- vaultSystemState: vaultSystemStatePublicKey,
38
- poolState: poolStatePublickey,
39
- poolEra: poolEraPublicKey,
40
- poolUshAccount: poolUshTokenAccount,
41
- founder: payerPublicKey,
42
- ushMint: ushMintPublickey,
43
- hedgeMint: hedgeMintPublickey,
44
- founderAssociatedHedgeTokenAccount: founderHedgeTokenAccount,
45
- communityAssociatedHedgeTokenAccount: communityHedgeTokenAccount,
46
- rent: web3_js_1.SYSVAR_RENT_PUBKEY,
47
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
48
- associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
49
- systemProgram: web3_js_1.SystemProgram.programId
50
- },
51
- signers: []
52
- });
35
+ return yield program.methods
36
+ .initHedgeFoundation()
37
+ .accounts({
38
+ vaultSystemState: vaultSystemStatePublicKey,
39
+ poolState: poolStatePublickey,
40
+ poolEra: poolEraPublicKey,
41
+ poolUshAccount: poolUshTokenAccount,
42
+ founder: payerPublicKey,
43
+ ushMint: ushMintPublickey,
44
+ hedgeMint: hedgeMintPublickey,
45
+ rent: web3_js_1.SYSVAR_RENT_PUBKEY,
46
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
47
+ associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
48
+ systemProgram: web3_js_1.SystemProgram.programId,
49
+ })
50
+ .instruction();
53
51
  });
54
52
  }
55
53
  exports.initHedgeFoundationInstruction = initHedgeFoundationInstruction;
@@ -18,7 +18,7 @@ function initHedgeFoundationTokens(program, provider, payer) {
18
18
  return __awaiter(this, void 0, void 0, function* () {
19
19
  const poolEra = web3_js_1.Keypair.generate();
20
20
  const transaction = new web3_js_1.Transaction().add(yield initHedgeFoundationTokensInstruction(program, payer.publicKey));
21
- yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer], provider.opts).catch(Errors_1.parseAnchorErrors);
21
+ yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
22
22
  return payer.publicKey;
23
23
  });
24
24
  }
@@ -29,20 +29,20 @@ function initHedgeFoundationTokensInstruction(program, payerPublicKey) {
29
29
  const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
30
30
  const founderHedgeTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, hedgeMintPublickey);
31
31
  const communityHedgeTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(vaultSystemStatePublicKey, hedgeMintPublickey);
32
- return program.instruction.initHedgeFoundationTokens({
33
- accounts: {
34
- vaultSystemState: vaultSystemStatePublicKey,
35
- founder: payerPublicKey,
36
- hedgeMint: hedgeMintPublickey,
37
- founderAssociatedHedgeTokenAccount: founderHedgeTokenAccount,
38
- communityAssociatedHedgeTokenAccount: communityHedgeTokenAccount,
39
- rent: web3_js_1.SYSVAR_RENT_PUBKEY,
40
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
41
- associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
42
- systemProgram: web3_js_1.SystemProgram.programId
43
- },
44
- signers: []
45
- });
32
+ return yield program.methods
33
+ .initHedgeFoundationTokens()
34
+ .accounts({
35
+ vaultSystemState: vaultSystemStatePublicKey,
36
+ founder: payerPublicKey,
37
+ hedgeMint: hedgeMintPublickey,
38
+ founderAssociatedHedgeTokenAccount: founderHedgeTokenAccount,
39
+ communityAssociatedHedgeTokenAccount: communityHedgeTokenAccount,
40
+ rent: web3_js_1.SYSVAR_RENT_PUBKEY,
41
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
42
+ associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
43
+ systemProgram: web3_js_1.SystemProgram.programId,
44
+ })
45
+ .instruction();
46
46
  });
47
47
  }
48
48
  exports.initHedgeFoundationTokensInstruction = initHedgeFoundationTokensInstruction;
@@ -37,7 +37,7 @@ function liquidateVault(program, provider, payer, vaultPublicKey, overrideTime)
37
37
  const newEra = web3_js_1.Keypair.generate();
38
38
  const transaction = new web3_js_1.Transaction();
39
39
  transaction.add(yield liquidateVaultInstruction(program, payer.publicKey, payerAssociatedTokenAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, liquidationPoolStatePublicKey, poolStateInfo.currentEra, poolAssociatedTokenAccount.address, history.publicKey, newEra.publicKey, hedgeStakingPoolPublicKey, feePoolAssociatedTokenAccount.address, hedgeStakingPoolAssociatedUshTokenAccount.address, collateralMint, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, vaultAccount.collateralType, overrideTime));
40
- yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history, newEra], provider.opts);
40
+ yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history, newEra]);
41
41
  return vaultPublicKey;
42
42
  });
43
43
  }
@@ -48,38 +48,37 @@ function liquidateVaultInstruction(program, payerPublicKey, payerAssociatedToken
48
48
  const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
49
49
  const liquidationPoolUshAccountPublickey = yield (0, Constants_1.getLiquidationPoolUshAccountPublicKey)();
50
50
  const vaultTypeAccount = yield (0, Constants_1.getVaultTypeAccountPublicKey)(collateralType);
51
- const payload = {
52
- accounts: {
53
- vaultSystemState: vaultSystemStatePublicKey,
54
- vaultTypeAccount: vaultTypeAccount,
55
- vaultTypeAssociatedTokenAccount: vaultTypeAssociatedTokenAccount,
56
- collateralMint: collateralMint,
57
- poolEra: poolEra,
58
- vaultAccount: vaultPublickey,
59
- vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
60
- poolState: poolState,
61
- poolAssociatedTokenAccount: poolAssociatedTokenAccount,
62
- ushMint: ushMintPublickey,
63
- history: historyPublicKey,
64
- payer: payerPublicKey,
65
- payerAssociatedTokenAccount: payerAssociatedTokenAccount,
66
- feePool: feePool,
67
- feePoolAssociatedTokenAccount: feePoolAssociatedTokenAccount,
68
- feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
69
- liquidationPoolUshAccount: liquidationPoolUshAccountPublickey,
70
- newEra: newEraPublicKey,
71
- oldSmallerVaultInfo: oldSmallerPublicKey,
72
- newSmallerVaultInfo: newSmallerPublicKey,
73
- newLargerVaultInfo: newLargerPublicKey,
74
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
75
- systemProgram: web3_js_1.SystemProgram.programId,
76
- associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
77
- rent: web3_js_1.SYSVAR_RENT_PUBKEY,
78
- },
79
- signers: [],
80
- };
81
- return program.instruction.liquidateVault(new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)), // override override time
82
- payload);
51
+ return program.methods
52
+ .liquidateVault(new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override time
53
+ )
54
+ .accounts({
55
+ vaultSystemState: vaultSystemStatePublicKey,
56
+ vaultTypeAccount: vaultTypeAccount,
57
+ vaultTypeAssociatedTokenAccount: vaultTypeAssociatedTokenAccount,
58
+ collateralMint: collateralMint,
59
+ poolEra: poolEra,
60
+ vaultAccount: vaultPublickey,
61
+ vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
62
+ poolState: poolState,
63
+ poolAssociatedTokenAccount: poolAssociatedTokenAccount,
64
+ ushMint: ushMintPublickey,
65
+ history: historyPublicKey,
66
+ payer: payerPublicKey,
67
+ payerAssociatedTokenAccount: payerAssociatedTokenAccount,
68
+ feePool: feePool,
69
+ feePoolAssociatedTokenAccount: feePoolAssociatedTokenAccount,
70
+ feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
71
+ liquidationPoolUshAccount: liquidationPoolUshAccountPublickey,
72
+ newEra: newEraPublicKey,
73
+ oldSmallerVaultInfo: oldSmallerPublicKey,
74
+ newSmallerVaultInfo: newSmallerPublicKey,
75
+ newLargerVaultInfo: newLargerPublicKey,
76
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
77
+ systemProgram: web3_js_1.SystemProgram.programId,
78
+ associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
79
+ rent: web3_js_1.SYSVAR_RENT_PUBKEY,
80
+ })
81
+ .instruction();
83
82
  });
84
83
  }
85
84
  exports.liquidateVaultInstruction = liquidateVaultInstruction;
@@ -27,7 +27,7 @@ function loanVault(program, provider, payer, vaultPublicKey, loanAmount, overrid
27
27
  const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultTypeAccountPublicKey, vaultPublicKey, 0, loanAmount, false, false);
28
28
  const history = web3_js_1.Keypair.generate();
29
29
  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], provider.opts);
30
+ yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history]);
31
31
  return vaultPublicKey;
32
32
  });
33
33
  }
@@ -39,28 +39,28 @@ function loanVaultInstruction(program, payerPublicKey, ownerUshAccount, vaultPub
39
39
  const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
40
40
  const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(hedgeMintPublickey);
41
41
  const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
42
- return program.instruction.loanVault(new anchor_1.BN(loanAmount), new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)), // override override time
43
- {
44
- accounts: {
45
- vaultSystemState: vaultSystemStatePublicKey,
46
- vaultTypeAccount: vaultTypeAccount,
47
- vaultTypeAssociatedTokenAccount: vaultTypeAssociatedTokenAccount,
48
- vaultAccount: vaultPublickey,
49
- vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
50
- history: historyPublicKey,
51
- feePool: hedgeStakingPoolPublicKey,
52
- feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
53
- ushMint: ushMintPublickey,
54
- vaultOwner: payerPublicKey,
55
- ownerUshAccount: ownerUshAccount,
56
- oldSmallerVaultInfo: oldSmallerPublicKey,
57
- newSmallerVaultInfo: newSmallerPublicKey,
58
- newLargerVaultInfo: newLargerPublicKey,
59
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
60
- systemProgram: web3_js_1.SystemProgram.programId,
61
- },
62
- signers: [],
63
- });
42
+ return program.methods
43
+ .loanVault(new anchor_1.BN(loanAmount), new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override time
44
+ )
45
+ .accounts({
46
+ vaultSystemState: vaultSystemStatePublicKey,
47
+ vaultTypeAccount: vaultTypeAccount,
48
+ vaultTypeAssociatedTokenAccount: vaultTypeAssociatedTokenAccount,
49
+ vaultAccount: vaultPublickey,
50
+ vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
51
+ history: historyPublicKey,
52
+ feePool: hedgeStakingPoolPublicKey,
53
+ feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
54
+ ushMint: ushMintPublickey,
55
+ vaultOwner: payerPublicKey,
56
+ ownerUshAccount: ownerUshAccount,
57
+ oldSmallerVaultInfo: oldSmallerPublicKey,
58
+ newSmallerVaultInfo: newSmallerPublicKey,
59
+ newLargerVaultInfo: newLargerPublicKey,
60
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
61
+ systemProgram: web3_js_1.SystemProgram.programId,
62
+ })
63
+ .instruction();
64
64
  });
65
65
  }
66
66
  exports.loanVaultInstruction = loanVaultInstruction;
@@ -30,7 +30,7 @@ function redeemVault(program, provider, payer, vaultPublicKey, redeemAmount, tra
30
30
  const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultTypeAccountPublicKey, vaultPublicKey, 0, 0, true, false);
31
31
  const history = web3_js_1.Keypair.generate();
32
32
  const transaction = new web3_js_1.Transaction().add(yield redeemVaultInstruction(program, payer.publicKey, payerUshAccount.address, payerTokenAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, redeemAmount, transactionOverrideTime));
33
- yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history], provider.opts);
33
+ yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history]);
34
34
  return vaultPublicKey;
35
35
  });
36
36
  }
@@ -42,29 +42,29 @@ function redeemVaultInstruction(program, payerPublicKey, payerUshAccount, destin
42
42
  const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
43
43
  const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(hedgeMintPublickey);
44
44
  const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
45
- return program.instruction.redeemVault(new anchor_1.BN(redeemAmount), new anchor_1.BN(transactionOverrideTime !== null && transactionOverrideTime !== void 0 ? transactionOverrideTime : (Date.now() / 1000)), // override start time
46
- {
47
- accounts: {
48
- vaultSystemState: vaultSystemStatePublicKey,
49
- vaultTypeAccount: vaultTypeAccount,
50
- vaultTypeAssociatedTokenAccount: vaultTypeAssociatedTokenAccount,
51
- vault: vaultPublickey,
52
- vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
53
- history: historyPublicKey,
54
- feePool: hedgeStakingPoolPublicKey,
55
- feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
56
- ushMint: ushMintPublickey,
57
- payer: payerPublicKey,
58
- payerUshAccount: payerUshAccount,
59
- destinationTokenAccount: destinationTokenAccount,
60
- oldSmallerVaultInfo: oldSmallerPublicKey,
61
- newSmallerVaultInfo: newSmallerPublicKey,
62
- newLargerVaultInfo: newLargerPublicKey,
63
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
64
- systemProgram: web3_js_1.SystemProgram.programId
65
- },
66
- signers: []
67
- });
45
+ return yield program.methods
46
+ .redeemVault(new anchor_1.BN(redeemAmount), new anchor_1.BN(transactionOverrideTime !== null && transactionOverrideTime !== void 0 ? transactionOverrideTime : Date.now() / 1000) // override start time
47
+ )
48
+ .accounts({
49
+ vaultSystemState: vaultSystemStatePublicKey,
50
+ vaultTypeAccount: vaultTypeAccount,
51
+ vaultTypeAssociatedTokenAccount: vaultTypeAssociatedTokenAccount,
52
+ vault: vaultPublickey,
53
+ vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
54
+ history: historyPublicKey,
55
+ feePool: hedgeStakingPoolPublicKey,
56
+ feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
57
+ ushMint: ushMintPublickey,
58
+ payer: payerPublicKey,
59
+ payerUshAccount: payerUshAccount,
60
+ destinationTokenAccount: destinationTokenAccount,
61
+ oldSmallerVaultInfo: oldSmallerPublicKey,
62
+ newSmallerVaultInfo: newSmallerPublicKey,
63
+ newLargerVaultInfo: newLargerPublicKey,
64
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
65
+ systemProgram: web3_js_1.SystemProgram.programId,
66
+ })
67
+ .instruction();
68
68
  });
69
69
  }
70
70
  exports.redeemVaultInstruction = redeemVaultInstruction;
@@ -16,7 +16,7 @@ const Constants_1 = require("../Constants");
16
16
  function refreshOraclePrice(program, provider, payer, collateralType, network, overridePrice, overrideTime) {
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
18
  const transaction = new web3_js_1.Transaction().add(yield refreshOraclePriceInstruction(program, collateralType, network, overridePrice, overrideTime));
19
- return yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer], provider.opts);
19
+ return yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer]);
20
20
  });
21
21
  }
22
22
  exports.refreshOraclePrice = refreshOraclePrice;
@@ -25,19 +25,19 @@ function refreshOraclePriceInstruction(program, collateralType, network, overrid
25
25
  const enc = new TextEncoder();
26
26
  const [oracleInfoAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralType), enc.encode('Oracle')], Constants_1.HEDGE_PROGRAM_PUBLICKEY);
27
27
  const [vaultTypeAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralType), enc.encode('State')], Constants_1.HEDGE_PROGRAM_PUBLICKEY);
28
- return program.instruction.refreshOraclePrice(new anchor_1.BN(overridePrice !== null && overridePrice !== void 0 ? overridePrice : web3_js_1.LAMPORTS_PER_SOL * 150), // override usd/sol price
29
- new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000) - 1), // override override time
30
- {
31
- accounts: {
32
- oracleInfoAccount: oracleInfoAccount,
33
- vaultTypeAccount: vaultTypeAccount,
34
- oracleChainlink: chainlinkAccunts[network],
35
- oraclePyth: pythAccounts[network],
36
- oracleSwitchboard: switchboardAccounts[network],
37
- systemProgram: web3_js_1.SystemProgram.programId
38
- },
39
- signers: []
40
- });
28
+ return yield program.methods
29
+ .refreshOraclePrice(new anchor_1.BN(overridePrice !== null && overridePrice !== void 0 ? overridePrice : web3_js_1.LAMPORTS_PER_SOL * 150), // override usd/sol price
30
+ new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000) - 1) // override override time
31
+ )
32
+ .accounts({
33
+ oracleInfoAccount: oracleInfoAccount,
34
+ vaultTypeAccount: vaultTypeAccount,
35
+ oracleChainlink: chainlinkAccunts[network],
36
+ oraclePyth: pythAccounts[network],
37
+ oracleSwitchboard: switchboardAccounts[network],
38
+ systemProgram: web3_js_1.SystemProgram.programId,
39
+ })
40
+ .instruction();
41
41
  });
42
42
  }
43
43
  exports.refreshOraclePriceInstruction = refreshOraclePriceInstruction;
@@ -50,16 +50,16 @@ var Cluster;
50
50
  const pythAccounts = {
51
51
  Testing: web3_js_1.SystemProgram.programId,
52
52
  Devnet: new web3_js_1.PublicKey('J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix'),
53
- MainnetBeta: new web3_js_1.PublicKey('H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG')
53
+ MainnetBeta: new web3_js_1.PublicKey('H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG'),
54
54
  };
55
55
  const chainlinkAccunts = {
56
56
  Testing: web3_js_1.SystemProgram.programId,
57
57
  Devnet: new web3_js_1.PublicKey('FmAmfoyPXiA8Vhhe6MZTr3U6rZfEZ1ctEHay1ysqCqcf'),
58
- MainnetBeta: web3_js_1.SystemProgram.programId // CHAINLINK NOT ON MAINNET YET
58
+ MainnetBeta: web3_js_1.SystemProgram.programId, // CHAINLINK NOT ON MAINNET YET
59
59
  };
60
60
  const switchboardAccounts = {
61
61
  Testing: web3_js_1.SystemProgram.programId,
62
62
  // Devnet: new PublicKey('GvDMxPzN1sCj7L26YDK2HnMRXEQmQ2aemov8YBtPS7vR'),
63
63
  Devnet: new web3_js_1.PublicKey('DpoK8Zz69APV9ntjuY9C4LZCxANYMV56M2cbXEdkjxME'),
64
- MainnetBeta: web3_js_1.SystemProgram.programId // Switchboard V2 NOT ON MAINNET YET
64
+ MainnetBeta: web3_js_1.SystemProgram.programId, // Switchboard V2 NOT ON MAINNET YET
65
65
  };
@@ -28,7 +28,7 @@ function repayVault(program, provider, payer, vaultPublicKey, repayAmount, overr
28
28
  const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultTypeAccountPublicKey, vaultPublicKey, 0, repayAmount * -1, false, false);
29
29
  const history = web3_js_1.Keypair.generate();
30
30
  const transaction = new web3_js_1.Transaction().add(yield repayVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount, history.publicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, repayAmount, overrideTime));
31
- yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history], provider.opts);
31
+ yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history]);
32
32
  return vaultPublicKey;
33
33
  });
34
34
  }
@@ -40,28 +40,28 @@ function repayVaultInstruction(program, payerPublicKey, ownerUshAccount, vaultPu
40
40
  const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
41
41
  const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(hedgeMintPublickey);
42
42
  const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
43
- return program.instruction.repayVault(new anchor_1.BN(repayAmount), new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)), // override override time
44
- {
45
- accounts: {
46
- vaultSystemState: vaultSystemStatePublicKey,
47
- vaultTypeAccount: vaultTypeAccount,
48
- vaultTypeAssociatedTokenAccount: vaultTypeAssociatedTokenAccount,
49
- vaultAccount: vaultPublickey,
50
- vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
51
- history: historyPublicKey,
52
- feePool: hedgeStakingPoolPublicKey,
53
- feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
54
- ushMint: ushMintPublickey,
55
- vaultOwner: payerPublicKey,
56
- oldSmallerVaultInfo: oldSmallerPublicKey,
57
- newSmallerVaultInfo: newSmallerPublicKey,
58
- newLargerVaultInfo: newLargerPublicKey,
59
- ownerUshAccount: ownerUshAccount,
60
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
61
- systemProgram: web3_js_1.SystemProgram.programId,
62
- },
63
- signers: [],
64
- });
43
+ return yield program.methods
44
+ .repayVault(new anchor_1.BN(repayAmount), new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override time
45
+ )
46
+ .accounts({
47
+ vaultSystemState: vaultSystemStatePublicKey,
48
+ vaultTypeAccount: vaultTypeAccount,
49
+ vaultTypeAssociatedTokenAccount: vaultTypeAssociatedTokenAccount,
50
+ vaultAccount: vaultPublickey,
51
+ vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
52
+ history: historyPublicKey,
53
+ feePool: hedgeStakingPoolPublicKey,
54
+ feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
55
+ ushMint: ushMintPublickey,
56
+ vaultOwner: payerPublicKey,
57
+ oldSmallerVaultInfo: oldSmallerPublicKey,
58
+ newSmallerVaultInfo: newSmallerPublicKey,
59
+ newLargerVaultInfo: newLargerPublicKey,
60
+ ownerUshAccount: ownerUshAccount,
61
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
62
+ systemProgram: web3_js_1.SystemProgram.programId,
63
+ })
64
+ .instruction();
65
65
  });
66
66
  }
67
67
  exports.repayVaultInstruction = repayVaultInstruction;
@@ -17,21 +17,20 @@ function setHalted(program, provider, payer, halted) {
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
18
  const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
19
19
  const transaction = new web3_js_1.Transaction().add(yield setHaltedInstruction(program, vaultSystemStatePublicKey, payer.publicKey, halted));
20
- yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer], provider === null || provider === void 0 ? void 0 : provider.opts).catch(Errors_1.parseAnchorErrors);
20
+ yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
21
21
  return vaultSystemStatePublicKey;
22
22
  });
23
23
  }
24
24
  exports.setHalted = setHalted;
25
25
  function setHaltedInstruction(program, vaultSystemStatePublicKey, payerPublicKey, halted) {
26
26
  return __awaiter(this, void 0, void 0, function* () {
27
- const ix = program.instruction.setHalted(halted, {
28
- accounts: {
29
- payer: payerPublicKey,
30
- vaultSystemState: vaultSystemStatePublicKey,
31
- },
32
- signers: []
33
- });
34
- return ix;
27
+ return yield program.methods
28
+ .setHalted(halted)
29
+ .accounts({
30
+ payer: payerPublicKey,
31
+ vaultSystemState: vaultSystemStatePublicKey,
32
+ })
33
+ .instruction();
35
34
  });
36
35
  }
37
36
  exports.setHaltedInstruction = setHaltedInstruction;
@@ -17,22 +17,21 @@ function setVaultTypeStatus(program, provider, payer, vaultTypeAccount, deprecat
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
18
  const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
19
19
  const transaction = new web3_js_1.Transaction().add(yield setVaultTypeStatusInstruction(program, vaultSystemStatePublicKey, payer.publicKey, vaultTypeAccount, deprecated));
20
- yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer], provider === null || provider === void 0 ? void 0 : provider.opts).catch(Errors_1.parseAnchorErrors);
20
+ yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
21
21
  return vaultSystemStatePublicKey;
22
22
  });
23
23
  }
24
24
  exports.setVaultTypeStatus = setVaultTypeStatus;
25
25
  function setVaultTypeStatusInstruction(program, vaultSystemStatePublicKey, payerPublicKey, vaultTypeAccount, deprecated) {
26
26
  return __awaiter(this, void 0, void 0, function* () {
27
- const ix = program.instruction.setVaultTypeStatus(deprecated, {
28
- accounts: {
29
- payer: payerPublicKey,
30
- vaultSystemState: vaultSystemStatePublicKey,
31
- vaultType: vaultTypeAccount,
32
- },
33
- signers: []
34
- });
35
- return ix;
27
+ return yield program.methods
28
+ .setVaultTypeStatus(deprecated)
29
+ .accounts({
30
+ payer: payerPublicKey,
31
+ vaultSystemState: vaultSystemStatePublicKey,
32
+ vaultType: vaultTypeAccount,
33
+ })
34
+ .instruction();
36
35
  });
37
36
  }
38
37
  exports.setVaultTypeStatusInstruction = setVaultTypeStatusInstruction;