hedge-web3 0.1.25 → 0.1.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. package/declarations/Constants.d.ts +3 -3
  2. package/declarations/idl/vault.d.ts +43 -43
  3. package/declarations/instructions/closeLiquidationPoolPosition.d.ts +1 -1
  4. package/declarations/instructions/createVault.d.ts +1 -1
  5. package/declarations/instructions/depositLiquidationPool.d.ts +1 -1
  6. package/declarations/instructions/depositVault.d.ts +1 -1
  7. package/declarations/instructions/liquidateVault.d.ts +1 -1
  8. package/declarations/instructions/loanVault.d.ts +1 -1
  9. package/declarations/instructions/redeemVault.d.ts +1 -1
  10. package/declarations/instructions/repayVault.d.ts +1 -1
  11. package/declarations/instructions/withdrawVault.d.ts +1 -1
  12. package/declarations/state/LiquidationPosition.d.ts +2 -2
  13. package/declarations/state/StakingPool.d.ts +1 -1
  14. package/declarations/state/StakingPoolPosition.d.ts +2 -2
  15. package/declarations/state/VaultAccount.d.ts +3 -3
  16. package/declarations/state/VaultHistoryEvent.d.ts +2 -2
  17. package/lib/Constants.js +8 -8
  18. package/lib/idl/idl.js +30 -30
  19. package/lib/idl/vault.js +43 -43
  20. package/lib/instructions/closeLiquidationPoolPosition.js +9 -9
  21. package/lib/instructions/createStakingPool.js +4 -4
  22. package/lib/instructions/createVault.js +11 -11
  23. package/lib/instructions/depositLiquidationPool.js +9 -9
  24. package/lib/instructions/depositVault.js +8 -8
  25. package/lib/instructions/initHedgeFoundation.js +4 -4
  26. package/lib/instructions/liquidateVault.js +9 -9
  27. package/lib/instructions/loanVault.js +9 -9
  28. package/lib/instructions/redeemVault.js +10 -10
  29. package/lib/instructions/repayVault.js +10 -10
  30. package/lib/instructions/withdrawStakingPool.js +6 -6
  31. package/lib/instructions/withdrawVault.js +8 -8
  32. package/lib/state/LiquidationPosition.js +2 -2
  33. package/lib/state/StakingPool.js +1 -1
  34. package/lib/state/StakingPoolPosition.js +3 -3
  35. package/lib/state/VaultAccount.js +2 -2
  36. package/lib/state/VaultHistoryEvent.js +2 -2
  37. package/package.json +1 -1
  38. package/src/Constants.ts +5 -5
  39. package/src/idl/idl.ts +30 -30
  40. package/src/idl/vault.ts +86 -86
  41. package/src/instructions/closeLiquidationPoolPosition.ts +10 -10
  42. package/src/instructions/createStakingPool.ts +5 -5
  43. package/src/instructions/createVault.ts +17 -17
  44. package/src/instructions/depositLiquidationPool.ts +10 -10
  45. package/src/instructions/depositVault.ts +12 -12
  46. package/src/instructions/initHedgeFoundation.ts +5 -5
  47. package/src/instructions/initHedgeFoundationTokens.ts +1 -1
  48. package/src/instructions/liquidateVault.ts +10 -10
  49. package/src/instructions/loanVault.ts +11 -11
  50. package/src/instructions/redeemVault.ts +12 -12
  51. package/src/instructions/repayVault.ts +12 -12
  52. package/src/instructions/setHalted.ts +1 -1
  53. package/src/instructions/withdrawStakingPool.ts +7 -7
  54. package/src/instructions/withdrawVault.ts +12 -12
  55. package/src/state/LiquidationPosition.ts +3 -3
  56. package/src/state/StakingPool.ts +2 -2
  57. package/src/state/StakingPoolPosition.ts +4 -4
  58. package/src/state/VaultAccount.ts +3 -3
  59. package/src/state/VaultHistoryEvent.ts +4 -4
@@ -19,12 +19,12 @@ const uuid_1 = require("uuid");
19
19
  const Errors_1 = require("../utils/Errors");
20
20
  function createVault(program, provider, payer, collateralType, depositAmount, overrideTime) {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
- const usdhMintPublickey = yield (0, Constants_1.getUsdhMintPublicKey)();
22
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
23
23
  const salt = (0, uuid_1.v4)().substring(0, 8);
24
24
  const newVaultPublicKey = yield (0, Constants_1.findVaultAddress)(salt);
25
25
  const history = web3_js_1.Keypair.generate();
26
- // Prep the user to get USDH back out at some point
27
- yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, usdhMintPublickey, payer.publicKey);
26
+ // Prep the user to get USH back out at some point
27
+ yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
28
28
  const vaultTypeAccountPublicKey = yield (0, Constants_1.getVaultTypeAccountPublicKey)(collateralType);
29
29
  const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
30
30
  const payerTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payer.publicKey, vaultTypeAccountInfo.collateralMint);
@@ -35,7 +35,7 @@ function createVault(program, provider, payer, collateralType, depositAmount, ov
35
35
  const isWrappedSol = vaultTypeAccountInfo.collateralMint.toString() ===
36
36
  serum_1.TokenInstructions.WRAPPED_SOL_MINT.toString();
37
37
  const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(yield (0, Constants_1.getHedgeMintPublicKey)());
38
- const feePoolAssociatedUsdhTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, usdhMintPublickey);
38
+ const feePoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
39
39
  if (isWrappedSol) {
40
40
  transaction.add(web3_js_1.SystemProgram.createAccount({
41
41
  fromPubkey: payer.publicKey,
@@ -50,7 +50,7 @@ function createVault(program, provider, payer, collateralType, depositAmount, ov
50
50
  }));
51
51
  signers.push(wrappedSolAccount);
52
52
  }
53
- transaction.add(yield createVaultInstruction(program, salt, payer.publicKey, isWrappedSol ? wrappedSolAccount.publicKey : payerTokenAccount, newVaultPublicKey, vaultAssociatedTokenAccount, hedgeStakingPoolPublicKey, feePoolAssociatedUsdhTokenAccount, vaultTypeAccountPublicKey, vaultTypeAccountInfo.collateralMint, history.publicKey, usdhMintPublickey, depositAmount, overrideTime));
53
+ transaction.add(yield createVaultInstruction(program, salt, payer.publicKey, isWrappedSol ? wrappedSolAccount.publicKey : payerTokenAccount, newVaultPublicKey, vaultAssociatedTokenAccount, hedgeStakingPoolPublicKey, feePoolAssociatedUshTokenAccount, vaultTypeAccountPublicKey, vaultTypeAccountInfo.collateralMint, history.publicKey, ushMintPublickey, depositAmount, overrideTime));
54
54
  if (isWrappedSol) {
55
55
  transaction.add(serum_1.TokenInstructions.closeAccount({
56
56
  source: wrappedSolAccount.publicKey,
@@ -66,7 +66,7 @@ exports.createVault = createVault;
66
66
  function buildCreateVaultTransaction(program, collateralType, depositAmount, overrideTime) {
67
67
  return __awaiter(this, void 0, void 0, function* () {
68
68
  console.log("HEDGE SDK: buildCreateVaultTransaction");
69
- const usdhMintPublickey = yield (0, Constants_1.getUsdhMintPublicKey)();
69
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
70
70
  const payerPublicKey = program.provider.wallet.publicKey;
71
71
  const salt = (0, uuid_1.v4)().substring(0, 8);
72
72
  const newVaultPublicKey = yield (0, Constants_1.findVaultAddress)(salt);
@@ -89,7 +89,7 @@ function buildCreateVaultTransaction(program, collateralType, depositAmount, ove
89
89
  const payerTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, vaultTypeAccountInfo.collateralMint);
90
90
  const vaultAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(newVaultPublicKey, vaultTypeAccountInfo.collateralMint);
91
91
  const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(yield (0, Constants_1.getHedgeMintPublicKey)());
92
- const feePoolAssociatedUsdhTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, usdhMintPublickey);
92
+ const feePoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
93
93
  console.log('about to start building transaction');
94
94
  // If wrapped SOL collateral, we convert the SOL to wSOL to use in the instruction
95
95
  if (isWrappedSol) {
@@ -107,7 +107,7 @@ function buildCreateVaultTransaction(program, collateralType, depositAmount, ove
107
107
  signers.push(wrappedSolAccount);
108
108
  }
109
109
  console.log("hedgeStakingPoolPublicKey", hedgeStakingPoolPublicKey.toString());
110
- transaction.add(yield createVaultInstruction(program, salt, payerPublicKey, isWrappedSol ? wrappedSolAccount.publicKey : payerTokenAccount, newVaultPublicKey, vaultAssociatedTokenAccount, hedgeStakingPoolPublicKey, feePoolAssociatedUsdhTokenAccount, vaultTypeAccountPublicKey, vaultTypeAccountInfo.collateralMint, history.publicKey, usdhMintPublickey, depositAmount, overrideTime));
110
+ transaction.add(yield createVaultInstruction(program, salt, payerPublicKey, isWrappedSol ? wrappedSolAccount.publicKey : payerTokenAccount, newVaultPublicKey, vaultAssociatedTokenAccount, hedgeStakingPoolPublicKey, feePoolAssociatedUshTokenAccount, vaultTypeAccountPublicKey, vaultTypeAccountInfo.collateralMint, history.publicKey, ushMintPublickey, depositAmount, overrideTime));
111
111
  if (isWrappedSol) {
112
112
  transaction.add(serum_1.TokenInstructions.closeAccount({
113
113
  source: wrappedSolAccount.publicKey,
@@ -122,7 +122,7 @@ function buildCreateVaultTransaction(program, collateralType, depositAmount, ove
122
122
  });
123
123
  }
124
124
  exports.buildCreateVaultTransaction = buildCreateVaultTransaction;
125
- function createVaultInstruction(program, salt, payerPublicKey, payerTokenAccountPublicKey, vaultPublicKey, vaultAssociatedTokenAccount, feePool, feePoolAssociatedUsdhTokenAccount, vaultTypeAccount, collateralMint, historyPublicKey, usdhMintPublickey, depositAmount, overrideTime) {
125
+ function createVaultInstruction(program, salt, payerPublicKey, payerTokenAccountPublicKey, vaultPublicKey, vaultAssociatedTokenAccount, feePool, feePoolAssociatedUshTokenAccount, vaultTypeAccount, collateralMint, historyPublicKey, ushMintPublickey, depositAmount, overrideTime) {
126
126
  return __awaiter(this, void 0, void 0, function* () {
127
127
  const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
128
128
  const ix = program.instruction.createVault(salt, new anchor_1.BN(depositAmount), new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)), // override override time
@@ -133,12 +133,12 @@ function createVaultInstruction(program, salt, payerPublicKey, payerTokenAccount
133
133
  vault: vaultPublicKey,
134
134
  vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
135
135
  feePool: feePool,
136
- feePoolAssociatedUsdhTokenAccount: feePoolAssociatedUsdhTokenAccount,
136
+ feePoolAssociatedUshTokenAccount: feePoolAssociatedUshTokenAccount,
137
137
  history: historyPublicKey,
138
138
  payer: payerPublicKey,
139
139
  payerTokenAccount: payerTokenAccountPublicKey,
140
140
  collateralMint: collateralMint,
141
- usdhMint: usdhMintPublickey,
141
+ ushMint: ushMintPublickey,
142
142
  systemProgram: web3_js_1.SystemProgram.programId,
143
143
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
144
144
  associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -17,21 +17,21 @@ const Errors_1 = require("../utils/Errors");
17
17
  const Constants_1 = require("../Constants");
18
18
  function depositLiquidationPool(program, provider, payer, depositAmount, overrideStartTime) {
19
19
  return __awaiter(this, void 0, void 0, function* () {
20
- const usdhMintPublickey = yield (0, Constants_1.getUsdhMintPublicKey)();
21
- const payerUsdhAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, usdhMintPublickey, payer.publicKey);
20
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
21
+ const payerUshAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
22
22
  const poolPosition = web3_js_1.Keypair.generate();
23
- const transaction = new web3_js_1.Transaction().add(yield depositLiquidationPoolInstruction(program, payer.publicKey, payerUsdhAccount.address, poolPosition.publicKey, depositAmount, overrideStartTime));
23
+ const transaction = new web3_js_1.Transaction().add(yield depositLiquidationPoolInstruction(program, payer.publicKey, payerUshAccount.address, poolPosition.publicKey, depositAmount, overrideStartTime));
24
24
  yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, poolPosition], provider.opts).catch(Errors_1.parseAnchorErrors);
25
25
  return poolPosition.publicKey;
26
26
  });
27
27
  }
28
28
  exports.depositLiquidationPool = depositLiquidationPool;
29
- function depositLiquidationPoolInstruction(program, payerPublicKey, payerUsdhAccount, poolPositionPublicKey, depositAmount, overrideStartTime) {
29
+ function depositLiquidationPoolInstruction(program, payerPublicKey, payerUshAccount, poolPositionPublicKey, depositAmount, overrideStartTime) {
30
30
  return __awaiter(this, void 0, void 0, function* () {
31
31
  const liquidationPoolStatePublicKey = yield (0, Constants_1.getLiquidationPoolStatePublicKey)();
32
32
  const liquidationPoolState = yield program.account.liquidationPoolState.fetch(liquidationPoolStatePublicKey);
33
- const poolUSDHAccount = yield (0, Constants_1.getLiquidationPoolUsdhAccountPublicKey)();
34
- const usdhMint = yield (0, Constants_1.getUsdhMintPublicKey)();
33
+ const poolUSHAccount = yield (0, Constants_1.getLiquidationPoolUshAccountPublicKey)();
34
+ const ushMint = yield (0, Constants_1.getUshMintPublicKey)();
35
35
  const vaultSystemState = yield (0, Constants_1.getVaultSystemStatePublicKey)();
36
36
  return program.instruction.depositLiquidationPool(new anchor_1.BN(depositAmount), new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Math.floor(Date.now() / 1000)), // override current time
37
37
  {
@@ -40,10 +40,10 @@ function depositLiquidationPoolInstruction(program, payerPublicKey, payerUsdhAcc
40
40
  poolState: liquidationPoolStatePublicKey,
41
41
  poolEra: liquidationPoolState.currentEra,
42
42
  poolPosition: poolPositionPublicKey,
43
- poolUsdhAccount: poolUSDHAccount,
44
- usdhMint: usdhMint,
43
+ poolUshAccount: poolUSHAccount,
44
+ ushMint: ushMint,
45
45
  payer: payerPublicKey,
46
- ownerUsdhAccount: payerUsdhAccount,
46
+ ownerUshAccount: payerUshAccount,
47
47
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
48
48
  systemProgram: web3_js_1.SystemProgram.programId,
49
49
  rent: web3_js_1.SYSVAR_RENT_PUBKEY
@@ -17,9 +17,9 @@ const web3_js_1 = require("@solana/web3.js");
17
17
  const Constants_1 = require("../Constants");
18
18
  function depositVault(program, provider, payer, vaultPublicKey, depositAmount, overrideTime) {
19
19
  return __awaiter(this, void 0, void 0, function* () {
20
- const usdhMintPublickey = yield (0, Constants_1.getUsdhMintPublicKey)();
21
- // Prep the user to get USDH back out at some point
22
- yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, usdhMintPublickey, payer.publicKey);
20
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
21
+ // Prep the user to get USH back out at some point
22
+ yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
23
23
  const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
24
24
  const vaultTypeAccountPublicKey = yield (0, Constants_1.getVaultTypeAccountPublicKey)(vaultAccount.collateralType);
25
25
  const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
@@ -30,7 +30,7 @@ function depositVault(program, provider, payer, vaultPublicKey, depositAmount, o
30
30
  const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
31
31
  const wrappedSolAccount = web3_js_1.Keypair.generate();
32
32
  const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(yield (0, Constants_1.getHedgeMintPublicKey)());
33
- const hedgeStakingPoolAssociatedUsdhTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, usdhMintPublickey);
33
+ const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
34
34
  const transaction = new web3_js_1.Transaction();
35
35
  const signers = [payer, history];
36
36
  if (vaultAccount.collateralType === 'SOL') {
@@ -47,7 +47,7 @@ function depositVault(program, provider, payer, vaultPublicKey, depositAmount, o
47
47
  }));
48
48
  signers.push(wrappedSolAccount);
49
49
  }
50
- transaction.add(yield depositVaultInstruction(program, vaultSystemStatePublicKey, payer.publicKey, vaultAccount.collateralType === 'SOL' ? wrappedSolAccount.publicKey : payerTokenAccount, vaultPublicKey, vaultAssociatedCollateralAccountPublicKey, history.publicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount.address, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUsdhTokenAccount, vaultTypeAccountInfo.collateralMint, usdhMintPublickey, depositAmount, overrideTime));
50
+ 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, depositAmount, overrideTime));
51
51
  if (vaultAccount.collateralType === 'SOL') {
52
52
  transaction.add(serum_1.TokenInstructions.closeAccount({
53
53
  source: wrappedSolAccount.publicKey,
@@ -60,7 +60,7 @@ function depositVault(program, provider, payer, vaultPublicKey, depositAmount, o
60
60
  });
61
61
  }
62
62
  exports.depositVault = depositVault;
63
- function depositVaultInstruction(program, vaultSystemStatePublicKey, vaultOwner, vaultOwnerTokenAccount, vaultPublicKey, vaultAssociatedTokenAccount, historyPublicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUsdhTokenAccount, collateralMint, usdhMintPublickey, depositAmount, overrideTime) {
63
+ function depositVaultInstruction(program, vaultSystemStatePublicKey, vaultOwner, vaultOwnerTokenAccount, vaultPublicKey, vaultAssociatedTokenAccount, historyPublicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUshTokenAccount, collateralMint, ushMintPublickey, depositAmount, overrideTime) {
64
64
  return __awaiter(this, void 0, void 0, function* () {
65
65
  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
66
66
  {
@@ -72,11 +72,11 @@ function depositVaultInstruction(program, vaultSystemStatePublicKey, vaultOwner,
72
72
  vault: vaultPublicKey,
73
73
  vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
74
74
  feePool: hedgeStakingPoolPublicKey,
75
- feePoolAssociatedUsdhTokenAccount: hedgeStakingPoolAssociatedUsdhTokenAccount,
75
+ feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
76
76
  history: historyPublicKey,
77
77
  vaultOwner: vaultOwner,
78
78
  vaultOwnerTokenAccount: vaultOwnerTokenAccount,
79
- usdhMint: usdhMintPublickey,
79
+ ushMint: ushMintPublickey,
80
80
  systemProgram: web3_js_1.SystemProgram.programId,
81
81
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID
82
82
  },
@@ -27,8 +27,8 @@ function initHedgeFoundationInstruction(program, poolEraPublicKey, payerPublicKe
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
28
  const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
29
29
  const poolStatePublickey = yield (0, Constants_1.getLiquidationPoolStatePublicKey)();
30
- const poolUsdhTokenAccount = yield (0, Constants_1.getLiquidationPoolUsdhAccountPublicKey)();
31
- const usdhMintPublickey = yield (0, Constants_1.getUsdhMintPublicKey)();
30
+ const poolUshTokenAccount = yield (0, Constants_1.getLiquidationPoolUshAccountPublicKey)();
31
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
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);
@@ -37,9 +37,9 @@ function initHedgeFoundationInstruction(program, poolEraPublicKey, payerPublicKe
37
37
  vaultSystemState: vaultSystemStatePublicKey,
38
38
  poolState: poolStatePublickey,
39
39
  poolEra: poolEraPublicKey,
40
- poolUsdhAccount: poolUsdhTokenAccount,
40
+ poolUshAccount: poolUshTokenAccount,
41
41
  founder: payerPublicKey,
42
- usdhMint: usdhMintPublickey,
42
+ ushMint: ushMintPublickey,
43
43
  hedgeMint: hedgeMintPublickey,
44
44
  founderAssociatedHedgeTokenAccount: founderHedgeTokenAccount,
45
45
  communityAssociatedHedgeTokenAccount: communityHedgeTokenAccount,
@@ -21,7 +21,7 @@ function liquidateVault(program, provider, payer, vaultPublicKey, overrideTime)
21
21
  const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
22
22
  const collateralMint = vaultTypeAccountInfo.collateralMint;
23
23
  const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
24
- const usdhMintPublickey = yield (0, Constants_1.getUsdhMintPublicKey)();
24
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
25
25
  const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(hedgeMintPublickey);
26
26
  const liquidationPoolStatePublicKey = yield (0, Constants_1.getLiquidationPoolStatePublicKey)();
27
27
  const poolStateInfo = yield program.account.liquidationPoolState.fetch(liquidationPoolStatePublicKey);
@@ -30,21 +30,21 @@ function liquidateVault(program, provider, payer, vaultPublicKey, overrideTime)
30
30
  const vaultAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, vaultPublicKey, true);
31
31
  const poolAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, liquidationPoolStatePublicKey, true);
32
32
  const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, vaultTypeAccountPublicKey, true);
33
- const hedgeStakingPoolAssociatedUsdhTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, usdhMintPublickey, hedgeStakingPoolPublicKey, true);
33
+ const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, hedgeStakingPoolPublicKey, true);
34
34
  const history = web3_js_1.Keypair.generate();
35
35
  const newEra = web3_js_1.Keypair.generate();
36
36
  const transaction = new web3_js_1.Transaction();
37
- transaction.add(yield liquidateVaultInstruction(program, payer.publicKey, payerAssociatedTokenAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, liquidationPoolStatePublicKey, poolStateInfo.currentEra, poolAssociatedTokenAccount.address, history.publicKey, newEra.publicKey, hedgeStakingPoolPublicKey, feePoolAssociatedTokenAccount.address, hedgeStakingPoolAssociatedUsdhTokenAccount.address, collateralMint, vaultTypeAssociatedTokenAccount.address, vaultAccount.collateralType, overrideTime));
37
+ 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, vaultAccount.collateralType, overrideTime));
38
38
  yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history, newEra], provider.opts);
39
39
  return vaultPublicKey;
40
40
  });
41
41
  }
42
42
  exports.liquidateVault = liquidateVault;
43
- function liquidateVaultInstruction(program, payerPublicKey, payerAssociatedTokenAccount, vaultPublickey, vaultAssociatedTokenAccount, poolState, poolEra, poolAssociatedTokenAccount, historyPublicKey, newEraPublicKey, feePool, feePoolAssociatedTokenAccount, hedgeStakingPoolAssociatedUsdhTokenAccount, collateralMint, vaultTypeAssociatedTokenAccount, collateralType, overrideTime) {
43
+ function liquidateVaultInstruction(program, payerPublicKey, payerAssociatedTokenAccount, vaultPublickey, vaultAssociatedTokenAccount, poolState, poolEra, poolAssociatedTokenAccount, historyPublicKey, newEraPublicKey, feePool, feePoolAssociatedTokenAccount, hedgeStakingPoolAssociatedUshTokenAccount, collateralMint, vaultTypeAssociatedTokenAccount, collateralType, overrideTime) {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
45
  const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
46
- const usdhMintPublickey = yield (0, Constants_1.getUsdhMintPublicKey)();
47
- const liquidationPoolUsdhAccountPublickey = yield (0, Constants_1.getLiquidationPoolUsdhAccountPublicKey)();
46
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
47
+ const liquidationPoolUshAccountPublickey = yield (0, Constants_1.getLiquidationPoolUshAccountPublicKey)();
48
48
  const vaultTypeAccount = yield (0, Constants_1.getVaultTypeAccountPublicKey)(collateralType);
49
49
  const payload = {
50
50
  accounts: {
@@ -57,14 +57,14 @@ function liquidateVaultInstruction(program, payerPublicKey, payerAssociatedToken
57
57
  vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
58
58
  poolState: poolState,
59
59
  poolAssociatedTokenAccount: poolAssociatedTokenAccount,
60
- usdhMint: usdhMintPublickey,
60
+ ushMint: ushMintPublickey,
61
61
  history: historyPublicKey,
62
62
  payer: payerPublicKey,
63
63
  payerAssociatedTokenAccount: payerAssociatedTokenAccount,
64
64
  feePool: feePool,
65
65
  feePoolAssociatedTokenAccount: feePoolAssociatedTokenAccount,
66
- feePoolAssociatedUsdhTokenAccount: hedgeStakingPoolAssociatedUsdhTokenAccount,
67
- liquidationPoolUsdhAccount: liquidationPoolUsdhAccountPublickey,
66
+ feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
67
+ liquidationPoolUshAccount: liquidationPoolUshAccountPublickey,
68
68
  newEra: newEraPublicKey,
69
69
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
70
70
  systemProgram: web3_js_1.SystemProgram.programId,
@@ -16,27 +16,27 @@ const web3_js_1 = require("@solana/web3.js");
16
16
  const Constants_1 = require("../Constants");
17
17
  function loanVault(program, provider, payer, vaultPublicKey, loanAmount, overrideTime) {
18
18
  return __awaiter(this, void 0, void 0, function* () {
19
- const usdhMintPublickey = yield (0, Constants_1.getUsdhMintPublicKey)();
20
- const payerUsdhAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, usdhMintPublickey, payer.publicKey);
19
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
20
+ const payerUshAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
21
21
  const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
22
22
  const vaultTypeAccountPublicKey = yield (0, Constants_1.getVaultTypeAccountPublicKey)(vaultAccount.collateralType);
23
23
  const vaultTypeAccount = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
24
24
  const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccount.collateralMint, vaultTypeAccountPublicKey, true);
25
25
  const vaultAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccount.collateralMint, vaultPublicKey, true);
26
26
  const history = web3_js_1.Keypair.generate();
27
- const transaction = new web3_js_1.Transaction().add(yield loanVaultInstruction(program, payer.publicKey, payerUsdhAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount.address, loanAmount, overrideTime));
27
+ const transaction = new web3_js_1.Transaction().add(yield loanVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount.address, loanAmount, overrideTime));
28
28
  yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history], provider.opts);
29
29
  return vaultPublicKey;
30
30
  });
31
31
  }
32
32
  exports.loanVault = loanVault;
33
- function loanVaultInstruction(program, payerPublicKey, ownerUsdhAccount, vaultPublickey, vaultAssociatedTokenAccount, historyPublicKey, vaultTypeAccount, vaultTypeAssociatedTokenAccount, loanAmount, overrideTime) {
33
+ function loanVaultInstruction(program, payerPublicKey, ownerUshAccount, vaultPublickey, vaultAssociatedTokenAccount, historyPublicKey, vaultTypeAccount, vaultTypeAssociatedTokenAccount, loanAmount, overrideTime) {
34
34
  return __awaiter(this, void 0, void 0, function* () {
35
35
  const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
36
- const usdhMintPublickey = yield (0, Constants_1.getUsdhMintPublicKey)();
36
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
37
37
  const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
38
38
  const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(hedgeMintPublickey);
39
- const hedgeStakingPoolAssociatedUsdhTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, usdhMintPublickey);
39
+ const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
40
40
  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
41
41
  {
42
42
  accounts: {
@@ -47,10 +47,10 @@ function loanVaultInstruction(program, payerPublicKey, ownerUsdhAccount, vaultPu
47
47
  vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
48
48
  history: historyPublicKey,
49
49
  feePool: hedgeStakingPoolPublicKey,
50
- feePoolAssociatedUsdhTokenAccount: hedgeStakingPoolAssociatedUsdhTokenAccount,
51
- usdhMint: usdhMintPublickey,
50
+ feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
51
+ ushMint: ushMintPublickey,
52
52
  vaultOwner: payerPublicKey,
53
- ownerUsdhAccount: ownerUsdhAccount,
53
+ ownerUshAccount: ownerUshAccount,
54
54
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
55
55
  systemProgram: web3_js_1.SystemProgram.programId
56
56
  },
@@ -17,9 +17,9 @@ const web3_js_1 = require("@solana/web3.js");
17
17
  const Constants_1 = require("../Constants");
18
18
  function redeemVault(program, provider, payer, vaultPublicKey, redeemAmount, transactionOverrideTime) {
19
19
  return __awaiter(this, void 0, void 0, function* () {
20
- const usdhMintPublickey = yield (0, Constants_1.getUsdhMintPublicKey)();
21
- // Prep the user to get USDH back out at some point
22
- const payerUsdhAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, usdhMintPublickey, payer.publicKey);
20
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
21
+ // Prep the user to get USH back out at some point
22
+ const payerUshAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
23
23
  const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
24
24
  const vaultTypeAccountPublicKey = yield (0, Constants_1.getVaultTypeAccountPublicKey)(vaultAccount.collateralType);
25
25
  const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
@@ -27,19 +27,19 @@ function redeemVault(program, provider, payer, vaultPublicKey, redeemAmount, tra
27
27
  const vaultAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, vaultPublicKey, true);
28
28
  const payerTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, payer.publicKey);
29
29
  const history = web3_js_1.Keypair.generate();
30
- const transaction = new web3_js_1.Transaction().add(yield redeemVaultInstruction(program, payer.publicKey, payerUsdhAccount.address, payerTokenAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount.address, redeemAmount, transactionOverrideTime));
30
+ 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, redeemAmount, transactionOverrideTime));
31
31
  yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history], provider.opts);
32
32
  return vaultPublicKey;
33
33
  });
34
34
  }
35
35
  exports.redeemVault = redeemVault;
36
- function redeemVaultInstruction(program, payerPublicKey, payerUsdhAccount, destinationTokenAccount, vaultPublickey, vaultAssociatedTokenAccount, historyPublicKey, vaultTypeAccount, vaultTypeAssociatedTokenAccount, redeemAmount, transactionOverrideTime) {
36
+ function redeemVaultInstruction(program, payerPublicKey, payerUshAccount, destinationTokenAccount, vaultPublickey, vaultAssociatedTokenAccount, historyPublicKey, vaultTypeAccount, vaultTypeAssociatedTokenAccount, redeemAmount, transactionOverrideTime) {
37
37
  return __awaiter(this, void 0, void 0, function* () {
38
38
  const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
39
- const usdhMintPublickey = yield (0, Constants_1.getUsdhMintPublicKey)();
39
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
40
40
  const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
41
41
  const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(hedgeMintPublickey);
42
- const hedgeStakingPoolAssociatedUsdhTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, usdhMintPublickey);
42
+ const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
43
43
  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
44
44
  {
45
45
  accounts: {
@@ -50,10 +50,10 @@ function redeemVaultInstruction(program, payerPublicKey, payerUsdhAccount, desti
50
50
  vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
51
51
  history: historyPublicKey,
52
52
  feePool: hedgeStakingPoolPublicKey,
53
- feePoolAssociatedUsdhTokenAccount: hedgeStakingPoolAssociatedUsdhTokenAccount,
54
- usdhMint: usdhMintPublickey,
53
+ feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
54
+ ushMint: ushMintPublickey,
55
55
  payer: payerPublicKey,
56
- payerUsdhAccount: payerUsdhAccount,
56
+ payerUshAccount: payerUshAccount,
57
57
  destinationTokenAccount: destinationTokenAccount,
58
58
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
59
59
  systemProgram: web3_js_1.SystemProgram.programId
@@ -16,28 +16,28 @@ const web3_js_1 = require("@solana/web3.js");
16
16
  const Constants_1 = require("../Constants");
17
17
  function repayVault(program, provider, payer, vaultPublicKey, repayAmount, overrideTime) {
18
18
  return __awaiter(this, void 0, void 0, function* () {
19
- const usdhMintPublickey = yield (0, Constants_1.getUsdhMintPublicKey)();
20
- // Prep the user to get USDH back out at some point
21
- const payerUsdhAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, usdhMintPublickey, payer.publicKey);
19
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
20
+ // Prep the user to get USH back out at some point
21
+ const payerUshAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
22
22
  const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
23
23
  const vaultTypeAccountPublicKey = yield (0, Constants_1.getVaultTypeAccountPublicKey)(vaultAccount.collateralType);
24
24
  const vaultTypeAccount = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
25
25
  const vaultTypeAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(vaultTypeAccountPublicKey, vaultTypeAccount.collateralMint);
26
26
  const vaultAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(vaultPublicKey, vaultTypeAccount.collateralMint);
27
27
  const history = web3_js_1.Keypair.generate();
28
- const transaction = new web3_js_1.Transaction().add(yield repayVaultInstruction(program, payer.publicKey, payerUsdhAccount.address, vaultPublicKey, vaultAssociatedTokenAccount, history.publicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount, repayAmount, overrideTime));
28
+ const transaction = new web3_js_1.Transaction().add(yield repayVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount, history.publicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount, repayAmount, overrideTime));
29
29
  yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history], provider.opts);
30
30
  return vaultPublicKey;
31
31
  });
32
32
  }
33
33
  exports.repayVault = repayVault;
34
- function repayVaultInstruction(program, payerPublicKey, ownerUsdhAccount, vaultPublickey, vaultAssociatedTokenAccount, historyPublicKey, vaultTypeAccount, vaultTypeAssociatedTokenAccount, repayAmount, overrideTime) {
34
+ function repayVaultInstruction(program, payerPublicKey, ownerUshAccount, vaultPublickey, vaultAssociatedTokenAccount, historyPublicKey, vaultTypeAccount, vaultTypeAssociatedTokenAccount, repayAmount, overrideTime) {
35
35
  return __awaiter(this, void 0, void 0, function* () {
36
36
  const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
37
- const usdhMintPublickey = yield (0, Constants_1.getUsdhMintPublicKey)();
37
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
38
38
  const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
39
39
  const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(hedgeMintPublickey);
40
- const hedgeStakingPoolAssociatedUsdhTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, usdhMintPublickey);
40
+ const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
41
41
  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
42
42
  {
43
43
  accounts: {
@@ -48,10 +48,10 @@ function repayVaultInstruction(program, payerPublicKey, ownerUsdhAccount, vaultP
48
48
  vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
49
49
  history: historyPublicKey,
50
50
  feePool: hedgeStakingPoolPublicKey,
51
- feePoolAssociatedUsdhTokenAccount: hedgeStakingPoolAssociatedUsdhTokenAccount,
52
- usdhMint: usdhMintPublickey,
51
+ feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
52
+ ushMint: ushMintPublickey,
53
53
  vaultOwner: payerPublicKey,
54
- ownerUsdhAccount: ownerUsdhAccount,
54
+ ownerUshAccount: ownerUshAccount,
55
55
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
56
56
  systemProgram: web3_js_1.SystemProgram.programId
57
57
  },
@@ -27,14 +27,14 @@ exports.withdrawStakingPool = withdrawStakingPool;
27
27
  function withdrawStakingPoolInstruction(program, payerPublicKey, poolPositionPublicKey, stakedTokenMintPublicKey, overrideStartTime) {
28
28
  return __awaiter(this, void 0, void 0, function* () {
29
29
  const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
30
- const usdhMintPublickey = yield (0, Constants_1.getUsdhMintPublicKey)();
30
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
31
31
  const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
32
32
  const [poolPublickey] = yield (0, Constants_1.getPoolPublicKeyForMint)(stakedTokenMintPublicKey);
33
33
  const poolAssociatedStakedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(poolPublickey, stakedTokenMintPublicKey);
34
- const poolAssociatedUsdhTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(poolPublickey, usdhMintPublickey);
34
+ const poolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(poolPublickey, ushMintPublickey);
35
35
  const payerAssociatedStakedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, stakedTokenMintPublicKey);
36
36
  const payerAssociatedHedgeAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, hedgeMintPublickey);
37
- const payerAssociatedUsdhAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, usdhMintPublickey);
37
+ const payerAssociatedUshAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, ushMintPublickey);
38
38
  const communityHedgeTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(vaultSystemStatePublicKey, hedgeMintPublickey);
39
39
  return program.instruction.withdrawStakingPool(new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Math.floor(Date.now() / 1000)), // override current time
40
40
  {
@@ -44,14 +44,14 @@ function withdrawStakingPoolInstruction(program, payerPublicKey, poolPositionPub
44
44
  pool: poolPublickey,
45
45
  poolPosition: poolPositionPublicKey,
46
46
  poolAssociatedStakedTokenAccount: poolAssociatedStakedTokenAccount,
47
- poolAssociatedUsdhTokenAccount: poolAssociatedUsdhTokenAccount,
47
+ poolAssociatedUshTokenAccount: poolAssociatedUshTokenAccount,
48
48
  payerAssociatedStakedTokenAccount: payerAssociatedStakedTokenAccount,
49
49
  payerAssociatedHedgeAccount: payerAssociatedHedgeAccount,
50
- payerAssociatedUsdhAccount: payerAssociatedUsdhAccount,
50
+ payerAssociatedUshAccount: payerAssociatedUshAccount,
51
51
  communityAssociatedHedgeTokenAccount: communityHedgeTokenAccount,
52
52
  hedgeMint: hedgeMintPublickey,
53
53
  stakedTokenMint: stakedTokenMintPublicKey,
54
- usdhMint: usdhMintPublickey,
54
+ ushMint: ushMintPublickey,
55
55
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
56
56
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
57
57
  associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -17,9 +17,9 @@ const web3_js_1 = require("@solana/web3.js");
17
17
  const Constants_1 = require("../Constants");
18
18
  function withdrawVault(program, provider, payer, vaultPublicKey, withdrawAmount, overrideTime) {
19
19
  return __awaiter(this, void 0, void 0, function* () {
20
- const usdhMintPublickey = yield (0, Constants_1.getUsdhMintPublicKey)();
21
- // Prep the user to get USDH back out at some point
22
- yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, usdhMintPublickey, payer.publicKey);
20
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
21
+ // Prep the user to get USH back out at some point
22
+ yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
23
23
  const history = web3_js_1.Keypair.generate();
24
24
  const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
25
25
  const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
@@ -29,14 +29,14 @@ function withdrawVault(program, provider, payer, vaultPublicKey, withdrawAmount,
29
29
  const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, vaultTypeAccount, true);
30
30
  const destinationTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, payer.publicKey);
31
31
  const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(yield (0, Constants_1.getHedgeMintPublicKey)());
32
- const hedgeStakingPoolAssociatedUsdhTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, usdhMintPublickey);
33
- const transaction = new web3_js_1.Transaction().add(yield withdrawVaultInstruction(program, vaultSystemStatePublicKey, payer.publicKey, destinationTokenAccount.address, vaultPublicKey, vaultAssociatedCollateralAccount.address, vaultTypeAccount, vaultTypeAssociatedTokenAccount.address, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUsdhTokenAccount, usdhMintPublickey, history.publicKey, withdrawAmount, overrideTime));
32
+ const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
33
+ const transaction = new web3_js_1.Transaction().add(yield withdrawVaultInstruction(program, vaultSystemStatePublicKey, payer.publicKey, destinationTokenAccount.address, vaultPublicKey, vaultAssociatedCollateralAccount.address, vaultTypeAccount, vaultTypeAssociatedTokenAccount.address, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUshTokenAccount, ushMintPublickey, history.publicKey, withdrawAmount, overrideTime));
34
34
  yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history], provider.opts);
35
35
  return vaultPublicKey;
36
36
  });
37
37
  }
38
38
  exports.withdrawVault = withdrawVault;
39
- function withdrawVaultInstruction(program, vaultSystemStatePublicKey, payerPublicKey, destinationTokenAccount, vaultPublickey, vaultAssociatedCollateralPublicKey, vaultTypeAccount, vaultTypeAssociatedTokenAccount, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUsdhTokenAccount, usdhMint, historyPublicKey, withdrawAmount, overrideTime) {
39
+ function withdrawVaultInstruction(program, vaultSystemStatePublicKey, payerPublicKey, destinationTokenAccount, vaultPublickey, vaultAssociatedCollateralPublicKey, vaultTypeAccount, vaultTypeAssociatedTokenAccount, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUshTokenAccount, ushMint, historyPublicKey, withdrawAmount, overrideTime) {
40
40
  return __awaiter(this, void 0, void 0, function* () {
41
41
  return program.instruction.withdrawVault(new anchor_1.BN(withdrawAmount), new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)), // override override time
42
42
  {
@@ -47,8 +47,8 @@ function withdrawVaultInstruction(program, vaultSystemStatePublicKey, payerPubli
47
47
  vault: vaultPublickey,
48
48
  vaultAssociatedTokenAccount: vaultAssociatedCollateralPublicKey,
49
49
  feePool: hedgeStakingPoolPublicKey,
50
- feePoolAssociatedUsdhTokenAccount: hedgeStakingPoolAssociatedUsdhTokenAccount,
51
- usdhMint: usdhMint,
50
+ feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
51
+ ushMint: ushMint,
52
52
  history: historyPublicKey,
53
53
  vaultOwner: payerPublicKey,
54
54
  destinationTokenAccount: destinationTokenAccount,
@@ -12,7 +12,7 @@ class LiquidationPosition {
12
12
  this.eraPublicKey = poolPositionInfo.era;
13
13
  this.ownerAccount = poolPositionInfo.ownerAccount;
14
14
  this.deposit = poolPositionInfo.deposit.toNumber();
15
- this.closedUsdh = poolPositionInfo.closedUsdh.toNumber();
15
+ this.closedUsh = poolPositionInfo.closedUsh.toNumber();
16
16
  this.timestampOpened = poolPositionInfo.timestampOpened.toNumber();
17
17
  this.timestampClosed = poolPositionInfo.timestampClosed.toNumber();
18
18
  this.productSnapshotEntry = (0, HedgeDecimal_1.DecimalFromU128)(poolPositionInfo.productSnapshotEntry);
@@ -23,7 +23,7 @@ class LiquidationPosition {
23
23
  this.open = poolPositionInfo.state === 1;
24
24
  console.log("poolPositionInfo.state, poolPositionInfo.state");
25
25
  }
26
- getUsdhAvailable(era) {
26
+ getUshAvailable(era) {
27
27
  return (era.product.div(this.productSnapshotEntry)).mul(new decimal_js_1.default(this.deposit));
28
28
  }
29
29
  getTokensAvailable(era, index) {
@@ -14,7 +14,7 @@ class StakingPool {
14
14
  this.halfLifeInDays = poolInfo.halfLifeInDays.toNumber();
15
15
  this.totalHedgeReward = poolInfo.totalHedgeReward.toNumber();
16
16
  this.hedgeRewardAccumulator = (0, HedgeDecimal_1.DecimalFromU128)(poolInfo.hedgeRewardAccumulator);
17
- this.usdhFeeAccumulator = (0, HedgeDecimal_1.DecimalFromU128)(poolInfo.usdhFeeAccumulator);
17
+ this.ushFeeAccumulator = (0, HedgeDecimal_1.DecimalFromU128)(poolInfo.ushFeeAccumulator);
18
18
  this.collateralFeeAccumulator = poolInfo.collateralFeeAccumulator.map((sum) => { return (0, HedgeDecimal_1.DecimalFromU128)(sum); });
19
19
  // this.currentRewardsPerDay = DecimalFromU128(poolInfo.currentRewardsPerDay)
20
20
  }
@@ -17,12 +17,12 @@ class StakingPoolPosition {
17
17
  this.timestampClosed = poolPositionInfo.timestampClosed.toNumber();
18
18
  this.closedRewardedTokens = poolPositionInfo.closedRewardedTokens.toNumber();
19
19
  this.startHedgeRewardAccumulator = (0, HedgeDecimal_1.DecimalFromU128)(poolPositionInfo.startHedgeRewardAccumulator);
20
- this.startUsdhFeeAccumulator = (0, HedgeDecimal_1.DecimalFromU128)(poolPositionInfo.startUsdhFeeAccumulator);
20
+ this.startUshFeeAccumulator = (0, HedgeDecimal_1.DecimalFromU128)(poolPositionInfo.startUshFeeAccumulator);
21
21
  this.startSolFeeAccumulator = (0, HedgeDecimal_1.DecimalFromU128)(poolPositionInfo.startSolFeeAccumulator);
22
22
  this.open = poolPositionInfo.state.open !== undefined;
23
23
  }
24
- getCurrentUsdhFeeReward() {
25
- return this.pool.usdhFeeAccumulator.minus(this.startUsdhFeeAccumulator).times(new decimal_js_1.default(this.deposited));
24
+ getCurrentUshFeeReward() {
25
+ return this.pool.ushFeeAccumulator.minus(this.startUshFeeAccumulator).times(new decimal_js_1.default(this.deposited));
26
26
  }
27
27
  }
28
28
  exports.StakingPoolPosition = StakingPoolPosition;
@@ -36,9 +36,9 @@ class VaultAccount {
36
36
  return this.deposited / web3_js_1.LAMPORTS_PER_SOL;
37
37
  }
38
38
  /**
39
- * Get the debt value in USDH
39
+ * Get the debt value in USH
40
40
  *
41
- * @returns debt value in USDH
41
+ * @returns debt value in USH
42
42
  */
43
43
  inUsd() {
44
44
  return this.denormalizedDebt / web3_js_1.LAMPORTS_PER_SOL;
@@ -8,8 +8,8 @@ class VaultHistoryEvent {
8
8
  this.publicKey = publicKey;
9
9
  this.actorAccount = account.actorAccount;
10
10
  this.usdSolPrice = (0, HedgeDecimal_1.DecimalFromU128)(account.usdSolPrice.toString());
11
- this.usdhDebtBefore = account.usdhDebtBefore.toNumber();
12
- this.usdhDebtAfter = account.usdhDebtAfter.toNumber();
11
+ this.ushDebtBefore = account.ushDebtBefore.toNumber();
12
+ this.ushDebtAfter = account.ushDebtAfter.toNumber();
13
13
  this.collateralBalanceBefore = account.collateralBalanceBefore.toNumber();
14
14
  this.collateralBalanceAfter = account.collateralBalanceAfter.toNumber();
15
15
  this.minCollateralRatioBefore = (0, HedgeDecimal_1.DecimalFromU128)(account.minCollateralRatioBefore);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedge-web3",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
4
4
  "description": "Hedge Javascript Web3 API",
5
5
  "main": "lib/index.js",
6
6
  "types": "declarations/index.d.ts",