hedge-web3 0.1.23 → 0.1.27

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. package/declarations/Constants.d.ts +3 -3
  2. package/declarations/idl/vault.d.ts +889 -752
  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 +10 -10
  18. package/lib/idl/vault.js +922 -785
  19. package/lib/instructions/closeLiquidationPoolPosition.js +9 -9
  20. package/lib/instructions/createStakingPool.js +4 -4
  21. package/lib/instructions/createVault.js +11 -11
  22. package/lib/instructions/depositLiquidationPool.js +9 -9
  23. package/lib/instructions/depositVault.js +8 -8
  24. package/lib/instructions/initHedgeFoundation.js +4 -4
  25. package/lib/instructions/liquidateVault.js +9 -9
  26. package/lib/instructions/loanVault.js +9 -9
  27. package/lib/instructions/redeemVault.js +10 -10
  28. package/lib/instructions/repayVault.js +10 -10
  29. package/lib/instructions/withdrawStakingPool.js +6 -6
  30. package/lib/instructions/withdrawVault.js +8 -8
  31. package/lib/state/LiquidationPosition.js +2 -2
  32. package/lib/state/StakingPool.js +1 -1
  33. package/lib/state/StakingPoolPosition.js +3 -3
  34. package/lib/state/VaultAccount.js +2 -2
  35. package/lib/state/VaultHistoryEvent.js +2 -2
  36. package/lib/utils/Errors.js +2 -2
  37. package/package.json +8 -9
  38. package/src/Constants.ts +73 -31
  39. package/src/idl/vault.ts +1848 -1574
  40. package/src/instructions/closeLiquidationPoolPosition.ts +10 -10
  41. package/src/instructions/createStakingPool.ts +5 -5
  42. package/src/instructions/createVault.ts +17 -17
  43. package/src/instructions/depositLiquidationPool.ts +10 -10
  44. package/src/instructions/depositVault.ts +12 -12
  45. package/src/instructions/initHedgeFoundation.ts +5 -5
  46. package/src/instructions/initHedgeFoundationTokens.ts +1 -1
  47. package/src/instructions/liquidateVault.ts +10 -10
  48. package/src/instructions/loanVault.ts +11 -11
  49. package/src/instructions/redeemVault.ts +12 -12
  50. package/src/instructions/repayVault.ts +12 -12
  51. package/src/instructions/setHalted.ts +1 -1
  52. package/src/instructions/withdrawStakingPool.ts +7 -7
  53. package/src/instructions/withdrawVault.ts +12 -12
  54. package/src/state/LiquidationPosition.ts +3 -3
  55. package/src/state/StakingPool.ts +2 -6
  56. package/src/state/StakingPoolPosition.ts +4 -4
  57. package/src/state/VaultAccount.ts +3 -3
  58. package/src/state/VaultHistoryEvent.ts +4 -4
  59. package/src/utils/Errors.ts +2 -2
  60. package/declarations/idl/idl.d.ts +0 -2
  61. package/lib/idl/idl.js +0 -1475
  62. package/src/idl/idl.ts +0 -1474
@@ -2,7 +2,7 @@ import { BN, Program, Provider } from '@project-serum/anchor'
2
2
  import { ASSOCIATED_TOKEN_PROGRAM_ID, getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  import { PublicKey, sendAndConfirmTransaction, Signer, SystemProgram, SYSVAR_RENT_PUBKEY, Transaction, TransactionInstruction } from '@solana/web3.js'
4
4
  import { parseAnchorErrors } from '../utils/Errors'
5
- import { getHedgeMintPublicKey, getLiquidationPoolStatePublicKey, getLiquidationPoolUsdhAccountPublicKey, getUsdhMintPublicKey, getVaultSystemStatePublicKey } from '../Constants'
5
+ import { getHedgeMintPublicKey, getLiquidationPoolStatePublicKey, getLiquidationPoolUshAccountPublicKey, getUshMintPublicKey, getVaultSystemStatePublicKey } from '../Constants'
6
6
 
7
7
  export async function closeLiquidationPoolPosition (
8
8
  program: Program,
@@ -11,8 +11,8 @@ export async function closeLiquidationPoolPosition (
11
11
  payer: Signer,
12
12
  overrideStartTime?: number
13
13
  ): Promise<PublicKey> {
14
- const usdhMintPublickey = await getUsdhMintPublicKey()
15
- const payerUsdhAccount = await getOrCreateAssociatedTokenAccount(provider.connection, payer, usdhMintPublickey, payer.publicKey)
14
+ const ushMintPublickey = await getUshMintPublicKey()
15
+ const payerUshAccount = await getOrCreateAssociatedTokenAccount(provider.connection, payer, ushMintPublickey, payer.publicKey)
16
16
  const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey()
17
17
  const liquidationPositionAccount = await program.account.liquidationPosition.fetch(poolPosition)
18
18
  const poolEra = liquidationPositionAccount.era
@@ -27,7 +27,7 @@ export async function closeLiquidationPoolPosition (
27
27
  poolEra,
28
28
  poolPosition,
29
29
  payer.publicKey,
30
- payerUsdhAccount.address,
30
+ payerUshAccount.address,
31
31
  payerAssociatedHedgeAccount.address,
32
32
  communityAssociatedHedgeTokenAccount.address,
33
33
  overrideStartTime
@@ -42,16 +42,16 @@ export async function closeLiquidationPoolPositionInstruction (
42
42
  poolEra: PublicKey,
43
43
  poolPosition: PublicKey,
44
44
  payerPublicKey: PublicKey,
45
- payerUsdhAccount: PublicKey,
45
+ payerUshAccount: PublicKey,
46
46
  payerAssociatedHedgeAccount: PublicKey,
47
47
  communityAssociatedHedgeTokenAccount: PublicKey,
48
48
  overrideStartTime?: number
49
49
  ): Promise<TransactionInstruction> {
50
50
 
51
51
  const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey()
52
- const usdhMint = await getUsdhMintPublicKey()
52
+ const ushMint = await getUshMintPublicKey()
53
53
  const hedgeMint = await getHedgeMintPublicKey()
54
- const poolUsdhAccount = await getLiquidationPoolUsdhAccountPublicKey()
54
+ const poolUshAccount = await getLiquidationPoolUshAccountPublicKey()
55
55
  const poolState = await getLiquidationPoolStatePublicKey()
56
56
 
57
57
  return program.instruction.closeLiquidationPoolPosition(
@@ -62,11 +62,11 @@ export async function closeLiquidationPoolPositionInstruction (
62
62
  poolState: poolState,
63
63
  poolEra: poolEra,
64
64
  poolPosition: poolPosition,
65
- poolUsdhAccount: poolUsdhAccount,
65
+ poolUshAccount: poolUshAccount,
66
66
  payer: payerPublicKey,
67
- ownerUsdhAccount: payerUsdhAccount,
67
+ ownerUshAccount: payerUshAccount,
68
68
  hedgeMint: hedgeMint,
69
- usdhMint: usdhMint,
69
+ ushMint: ushMint,
70
70
  payerAssociatedHedgeAccount: payerAssociatedHedgeAccount,
71
71
  communityAssociatedHedgeTokenAccount: communityAssociatedHedgeTokenAccount,
72
72
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -2,7 +2,7 @@ import { BN, Program, Provider } from '@project-serum/anchor'
2
2
  import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  import { PublicKey, sendAndConfirmTransaction, Signer, SystemProgram, SYSVAR_RENT_PUBKEY, Transaction, TransactionInstruction } from '@solana/web3.js'
4
4
  import { parseAnchorErrors } from '../utils/Errors'
5
- import { findAssociatedTokenAddress, getPoolPublicKeyForMint, getUsdhMintPublicKey, getVaultSystemStatePublicKey } from '../Constants'
5
+ import { findAssociatedTokenAddress, getPoolPublicKeyForMint, getUshMintPublicKey, getVaultSystemStatePublicKey } from '../Constants'
6
6
 
7
7
  export async function createStakingPool (
8
8
  program: Program,
@@ -35,11 +35,11 @@ export async function createStakingPoolInstruction (
35
35
  ): Promise<TransactionInstruction> {
36
36
  console.log("createStakingPoolInstruction program ID", program.programId.toString())
37
37
  const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey()
38
- const usdhMintPublickey = await getUsdhMintPublicKey()
38
+ const ushMintPublickey = await getUshMintPublicKey()
39
39
  const [poolPublickey, poolBump, poolSeedPhrase] = await getPoolPublicKeyForMint(mintPublicKey)
40
40
 
41
41
  const poolAssociatedStakedTokenAccount = await findAssociatedTokenAddress(poolPublickey, mintPublicKey)
42
- const poolAssociatedUsdhTokenAccount = await findAssociatedTokenAddress(poolPublickey, usdhMintPublickey)
42
+ const poolAssociatedUshTokenAccount = await findAssociatedTokenAddress(poolPublickey, ushMintPublickey)
43
43
 
44
44
  return program.instruction.createStakingPool(
45
45
  poolBump,
@@ -52,9 +52,9 @@ export async function createStakingPoolInstruction (
52
52
  vaultSystemState: vaultSystemStatePublicKey,
53
53
  pool: poolPublickey,
54
54
  stakedTokenMintInfo: mintPublicKey,
55
- usdhMint: usdhMintPublickey,
55
+ ushMint: ushMintPublickey,
56
56
  poolAssociatedStakedTokenAccount: poolAssociatedStakedTokenAccount,
57
- poolAssociatedUsdhTokenAccount: poolAssociatedUsdhTokenAccount,
57
+ poolAssociatedUshTokenAccount: poolAssociatedUshTokenAccount,
58
58
  rent: SYSVAR_RENT_PUBKEY,
59
59
  tokenProgram: TOKEN_PROGRAM_ID,
60
60
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -19,7 +19,7 @@ import {
19
19
  findAssociatedTokenAddress,
20
20
  findVaultAddress,
21
21
  getVaultTypeAccountPublicKey,
22
- getUsdhMintPublicKey,
22
+ getUshMintPublicKey,
23
23
  getVaultSystemStatePublicKey,
24
24
  getPoolPublicKeyForMint,
25
25
  getHedgeMintPublicKey,
@@ -36,17 +36,17 @@ export async function createVault(
36
36
  depositAmount: number,
37
37
  overrideTime?: number
38
38
  ): Promise<PublicKey> {
39
- const usdhMintPublickey = await getUsdhMintPublicKey();
39
+ const ushMintPublickey = await getUshMintPublicKey();
40
40
 
41
41
  const salt = uuidv4().substring(0, 8);
42
42
  const newVaultPublicKey = await findVaultAddress(salt);
43
43
  const history = Keypair.generate();
44
44
 
45
- // Prep the user to get USDH back out at some point
45
+ // Prep the user to get USH back out at some point
46
46
  await getOrCreateAssociatedTokenAccount(
47
47
  provider.connection,
48
48
  payer,
49
- usdhMintPublickey,
49
+ ushMintPublickey,
50
50
  payer.publicKey
51
51
  );
52
52
 
@@ -78,9 +78,9 @@ export async function createVault(
78
78
  const [hedgeStakingPoolPublicKey] = await getPoolPublicKeyForMint(
79
79
  await getHedgeMintPublicKey()
80
80
  );
81
- const feePoolAssociatedUsdhTokenAccount = await findAssociatedTokenAddress(
81
+ const feePoolAssociatedUshTokenAccount = await findAssociatedTokenAddress(
82
82
  hedgeStakingPoolPublicKey,
83
- usdhMintPublickey
83
+ ushMintPublickey
84
84
  );
85
85
 
86
86
  if (isWrappedSol) {
@@ -109,11 +109,11 @@ export async function createVault(
109
109
  newVaultPublicKey,
110
110
  vaultAssociatedTokenAccount,
111
111
  hedgeStakingPoolPublicKey,
112
- feePoolAssociatedUsdhTokenAccount,
112
+ feePoolAssociatedUshTokenAccount,
113
113
  vaultTypeAccountPublicKey,
114
114
  vaultTypeAccountInfo.collateralMint,
115
115
  history.publicKey,
116
- usdhMintPublickey,
116
+ ushMintPublickey,
117
117
  depositAmount,
118
118
  overrideTime
119
119
  )
@@ -145,7 +145,7 @@ export async function buildCreateVaultTransaction(
145
145
  ): Promise<[Transaction, Signer[], PublicKey]> {
146
146
 
147
147
  console.log("HEDGE SDK: buildCreateVaultTransaction")
148
- const usdhMintPublickey = await getUsdhMintPublicKey();
148
+ const ushMintPublickey = await getUshMintPublicKey();
149
149
  const payerPublicKey = program.provider.wallet.publicKey;
150
150
 
151
151
  const salt = uuidv4().substring(0, 8);
@@ -189,9 +189,9 @@ export async function buildCreateVaultTransaction(
189
189
  const [hedgeStakingPoolPublicKey] = await getPoolPublicKeyForMint(
190
190
  await getHedgeMintPublicKey()
191
191
  );
192
- const feePoolAssociatedUsdhTokenAccount = await findAssociatedTokenAddress(
192
+ const feePoolAssociatedUshTokenAccount = await findAssociatedTokenAddress(
193
193
  hedgeStakingPoolPublicKey,
194
- usdhMintPublickey
194
+ ushMintPublickey
195
195
  );
196
196
 
197
197
  console.log('about to start building transaction')
@@ -224,11 +224,11 @@ export async function buildCreateVaultTransaction(
224
224
  newVaultPublicKey,
225
225
  vaultAssociatedTokenAccount,
226
226
  hedgeStakingPoolPublicKey,
227
- feePoolAssociatedUsdhTokenAccount,
227
+ feePoolAssociatedUshTokenAccount,
228
228
  vaultTypeAccountPublicKey,
229
229
  vaultTypeAccountInfo.collateralMint,
230
230
  history.publicKey,
231
- usdhMintPublickey,
231
+ ushMintPublickey,
232
232
  depositAmount,
233
233
  overrideTime
234
234
  )
@@ -258,11 +258,11 @@ export async function createVaultInstruction(
258
258
  vaultPublicKey: PublicKey,
259
259
  vaultAssociatedTokenAccount: PublicKey,
260
260
  feePool: PublicKey,
261
- feePoolAssociatedUsdhTokenAccount: PublicKey,
261
+ feePoolAssociatedUshTokenAccount: PublicKey,
262
262
  vaultTypeAccount: PublicKey,
263
263
  collateralMint: PublicKey,
264
264
  historyPublicKey: PublicKey,
265
- usdhMintPublickey: PublicKey,
265
+ ushMintPublickey: PublicKey,
266
266
  depositAmount: number,
267
267
  overrideTime?: number
268
268
  ): Promise<TransactionInstruction> {
@@ -279,12 +279,12 @@ export async function createVaultInstruction(
279
279
  vault: vaultPublicKey,
280
280
  vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
281
281
  feePool: feePool,
282
- feePoolAssociatedUsdhTokenAccount: feePoolAssociatedUsdhTokenAccount,
282
+ feePoolAssociatedUshTokenAccount: feePoolAssociatedUshTokenAccount,
283
283
  history: historyPublicKey,
284
284
  payer: payerPublicKey,
285
285
  payerTokenAccount: payerTokenAccountPublicKey,
286
286
  collateralMint: collateralMint,
287
- usdhMint: usdhMintPublickey,
287
+ ushMint: ushMintPublickey,
288
288
  systemProgram: SystemProgram.programId,
289
289
  tokenProgram: TOKEN_PROGRAM_ID,
290
290
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -2,7 +2,7 @@ import { BN, Program, Provider } from '@project-serum/anchor'
2
2
  import { getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  import { Keypair, PublicKey, sendAndConfirmTransaction, Signer, SystemProgram, SYSVAR_RENT_PUBKEY, Transaction, TransactionInstruction } from '@solana/web3.js'
4
4
  import { parseAnchorErrors } from '../utils/Errors'
5
- import { getLiquidationPoolStatePublicKey, getLiquidationPoolUsdhAccountPublicKey, getUsdhMintPublicKey, getVaultSystemStatePublicKey } from '../Constants'
5
+ import { getLiquidationPoolStatePublicKey, getLiquidationPoolUshAccountPublicKey, getUshMintPublicKey, getVaultSystemStatePublicKey } from '../Constants'
6
6
 
7
7
  export async function depositLiquidationPool (
8
8
  program: Program,
@@ -11,15 +11,15 @@ export async function depositLiquidationPool (
11
11
  depositAmount: number,
12
12
  overrideStartTime?: number
13
13
  ): Promise<PublicKey> {
14
- const usdhMintPublickey = await getUsdhMintPublicKey()
15
- const payerUsdhAccount = await getOrCreateAssociatedTokenAccount(provider.connection, payer, usdhMintPublickey, payer.publicKey)
14
+ const ushMintPublickey = await getUshMintPublicKey()
15
+ const payerUshAccount = await getOrCreateAssociatedTokenAccount(provider.connection, payer, ushMintPublickey, payer.publicKey)
16
16
 
17
17
  const poolPosition = Keypair.generate()
18
18
  const transaction = new Transaction().add(
19
19
  await depositLiquidationPoolInstruction(
20
20
  program,
21
21
  payer.publicKey,
22
- payerUsdhAccount.address,
22
+ payerUshAccount.address,
23
23
  poolPosition.publicKey,
24
24
  depositAmount,
25
25
  overrideStartTime
@@ -32,7 +32,7 @@ export async function depositLiquidationPool (
32
32
  export async function depositLiquidationPoolInstruction (
33
33
  program: Program,
34
34
  payerPublicKey: PublicKey,
35
- payerUsdhAccount: PublicKey,
35
+ payerUshAccount: PublicKey,
36
36
  poolPositionPublicKey: PublicKey,
37
37
  depositAmount: number,
38
38
  overrideStartTime?: number
@@ -40,8 +40,8 @@ export async function depositLiquidationPoolInstruction (
40
40
  const liquidationPoolStatePublicKey = await getLiquidationPoolStatePublicKey()
41
41
  const liquidationPoolState = await program.account.liquidationPoolState.fetch(liquidationPoolStatePublicKey)
42
42
 
43
- const poolUSDHAccount = await getLiquidationPoolUsdhAccountPublicKey()
44
- const usdhMint = await getUsdhMintPublicKey()
43
+ const poolUSHAccount = await getLiquidationPoolUshAccountPublicKey()
44
+ const ushMint = await getUshMintPublicKey()
45
45
 
46
46
  const vaultSystemState = await getVaultSystemStatePublicKey()
47
47
 
@@ -54,10 +54,10 @@ export async function depositLiquidationPoolInstruction (
54
54
  poolState: liquidationPoolStatePublicKey,
55
55
  poolEra: liquidationPoolState.currentEra,
56
56
  poolPosition: poolPositionPublicKey,
57
- poolUsdhAccount: poolUSDHAccount,
58
- usdhMint: usdhMint,
57
+ poolUshAccount: poolUSHAccount,
58
+ ushMint: ushMint,
59
59
  payer: payerPublicKey,
60
- ownerUsdhAccount: payerUsdhAccount,
60
+ ownerUshAccount: payerUshAccount,
61
61
  tokenProgram: TOKEN_PROGRAM_ID,
62
62
  systemProgram: SystemProgram.programId,
63
63
  rent: SYSVAR_RENT_PUBKEY
@@ -2,7 +2,7 @@ import { BN, Program, Provider } from '@project-serum/anchor'
2
2
  import { TokenInstructions } from '@project-serum/serum'
3
3
  import { getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
4
4
  import { Keypair, PublicKey, sendAndConfirmTransaction, Signer, SystemProgram, Transaction, TransactionInstruction } from '@solana/web3.js'
5
- import { findAssociatedTokenAddress, getVaultTypeAccountPublicKey, getUsdhMintPublicKey, getVaultSystemStatePublicKey, getPoolPublicKeyForMint, getHedgeMintPublicKey } from '../Constants'
5
+ import { findAssociatedTokenAddress, getVaultTypeAccountPublicKey, getUshMintPublicKey, getVaultSystemStatePublicKey, getPoolPublicKeyForMint, getHedgeMintPublicKey } from '../Constants'
6
6
 
7
7
  export async function depositVault(
8
8
  program: Program,
@@ -12,10 +12,10 @@ export async function depositVault(
12
12
  depositAmount: number,
13
13
  overrideTime?: number
14
14
  ): Promise<PublicKey> {
15
- const usdhMintPublickey = await getUsdhMintPublicKey()
15
+ const ushMintPublickey = await getUshMintPublicKey()
16
16
 
17
- // Prep the user to get USDH back out at some point
18
- await getOrCreateAssociatedTokenAccount(provider.connection, payer, usdhMintPublickey, payer.publicKey)
17
+ // Prep the user to get USH back out at some point
18
+ await getOrCreateAssociatedTokenAccount(provider.connection, payer, ushMintPublickey, payer.publicKey)
19
19
 
20
20
  const vaultAccount = await program.account.vault.fetch(vaultPublicKey)
21
21
  const vaultTypeAccountPublicKey = await getVaultTypeAccountPublicKey(vaultAccount.collateralType)
@@ -31,9 +31,9 @@ export async function depositVault(
31
31
  const wrappedSolAccount = Keypair.generate()
32
32
 
33
33
  const [hedgeStakingPoolPublicKey] = await getPoolPublicKeyForMint(await getHedgeMintPublicKey())
34
- const hedgeStakingPoolAssociatedUsdhTokenAccount = await findAssociatedTokenAddress(
34
+ const hedgeStakingPoolAssociatedUshTokenAccount = await findAssociatedTokenAddress(
35
35
  hedgeStakingPoolPublicKey,
36
- usdhMintPublickey
36
+ ushMintPublickey
37
37
  )
38
38
 
39
39
  const transaction = new Transaction()
@@ -68,9 +68,9 @@ export async function depositVault(
68
68
  vaultTypeAccountPublicKey,
69
69
  vaultTypeAssociatedTokenAccount.address,
70
70
  hedgeStakingPoolPublicKey,
71
- hedgeStakingPoolAssociatedUsdhTokenAccount,
71
+ hedgeStakingPoolAssociatedUshTokenAccount,
72
72
  vaultTypeAccountInfo.collateralMint,
73
- usdhMintPublickey,
73
+ ushMintPublickey,
74
74
  depositAmount,
75
75
  overrideTime
76
76
  )
@@ -100,9 +100,9 @@ export async function depositVaultInstruction(
100
100
  vaultTypeAccountPublicKey: PublicKey,
101
101
  vaultTypeAssociatedTokenAccount: PublicKey,
102
102
  hedgeStakingPoolPublicKey: PublicKey,
103
- hedgeStakingPoolAssociatedUsdhTokenAccount: PublicKey,
103
+ hedgeStakingPoolAssociatedUshTokenAccount: PublicKey,
104
104
  collateralMint: PublicKey,
105
- usdhMintPublickey: PublicKey,
105
+ ushMintPublickey: PublicKey,
106
106
  depositAmount: number,
107
107
  overrideTime?: number
108
108
  ): Promise<TransactionInstruction> {
@@ -118,11 +118,11 @@ export async function depositVaultInstruction(
118
118
  vault: vaultPublicKey,
119
119
  vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
120
120
  feePool: hedgeStakingPoolPublicKey,
121
- feePoolAssociatedUsdhTokenAccount: hedgeStakingPoolAssociatedUsdhTokenAccount,
121
+ feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
122
122
  history: historyPublicKey,
123
123
  vaultOwner: vaultOwner,
124
124
  vaultOwnerTokenAccount: vaultOwnerTokenAccount,
125
- usdhMint: usdhMintPublickey,
125
+ ushMint: ushMintPublickey,
126
126
  systemProgram: SystemProgram.programId,
127
127
  tokenProgram: TOKEN_PROGRAM_ID
128
128
  },
@@ -2,7 +2,7 @@ import { Program, Provider } from '@project-serum/anchor'
2
2
  import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  import { Keypair, PublicKey, sendAndConfirmTransaction, Signer, SystemProgram, SYSVAR_RENT_PUBKEY, Transaction, TransactionInstruction } from '@solana/web3.js'
4
4
  import { parseAnchorErrors } from '../utils/Errors'
5
- import { findAssociatedTokenAddress, getHedgeMintPublicKey, getLiquidationPoolStatePublicKey, getLiquidationPoolUsdhAccountPublicKey, getUsdhMintPublicKey, getVaultSystemStatePublicKey } from '../Constants'
5
+ import { findAssociatedTokenAddress, getHedgeMintPublicKey, getLiquidationPoolStatePublicKey, getLiquidationPoolUshAccountPublicKey, getUshMintPublicKey, getVaultSystemStatePublicKey } from '../Constants'
6
6
 
7
7
  export async function initHedgeFoundation(
8
8
  program: Program,
@@ -30,8 +30,8 @@ export async function initHedgeFoundationInstruction (
30
30
  ): Promise<TransactionInstruction> {
31
31
  const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey()
32
32
  const poolStatePublickey = await getLiquidationPoolStatePublicKey()
33
- const poolUsdhTokenAccount = await getLiquidationPoolUsdhAccountPublicKey()
34
- const usdhMintPublickey = await getUsdhMintPublicKey()
33
+ const poolUshTokenAccount = await getLiquidationPoolUshAccountPublicKey()
34
+ const ushMintPublickey = await getUshMintPublicKey()
35
35
  const hedgeMintPublickey = await getHedgeMintPublicKey()
36
36
  const founderHedgeTokenAccount = await findAssociatedTokenAddress(
37
37
  payerPublicKey,
@@ -48,9 +48,9 @@ export async function initHedgeFoundationInstruction (
48
48
  vaultSystemState: vaultSystemStatePublicKey,
49
49
  poolState: poolStatePublickey,
50
50
  poolEra: poolEraPublicKey,
51
- poolUsdhAccount: poolUsdhTokenAccount,
51
+ poolUshAccount: poolUshTokenAccount,
52
52
  founder: payerPublicKey,
53
- usdhMint: usdhMintPublickey,
53
+ ushMint: ushMintPublickey,
54
54
  hedgeMint: hedgeMintPublickey,
55
55
  founderAssociatedHedgeTokenAccount: founderHedgeTokenAccount,
56
56
  communityAssociatedHedgeTokenAccount: communityHedgeTokenAccount,
@@ -2,7 +2,7 @@ import { Program, Provider } from '@project-serum/anchor'
2
2
  import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  import { Keypair, PublicKey, sendAndConfirmTransaction, Signer, SystemProgram, SYSVAR_RENT_PUBKEY, Transaction, TransactionInstruction } from '@solana/web3.js'
4
4
  import { parseAnchorErrors } from '../utils/Errors'
5
- import { findAssociatedTokenAddress, getHedgeMintPublicKey, getLiquidationPoolStatePublicKey, getLiquidationPoolUsdhAccountPublicKey, getUsdhMintPublicKey, getVaultSystemStatePublicKey } from '../Constants'
5
+ import { findAssociatedTokenAddress, getHedgeMintPublicKey, getLiquidationPoolStatePublicKey, getLiquidationPoolUshAccountPublicKey, getUshMintPublicKey, getVaultSystemStatePublicKey } from '../Constants'
6
6
 
7
7
  export async function initHedgeFoundationTokens(
8
8
  program: Program,
@@ -1,7 +1,7 @@
1
1
  import { BN, Program, Provider } from '@project-serum/anchor'
2
2
  import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, getOrCreateAssociatedTokenAccount } from '@solana/spl-token'
3
3
  import { Keypair, PublicKey, sendAndConfirmTransaction, Signer, SystemProgram, SYSVAR_RENT_PUBKEY, Transaction, TransactionInstruction } from '@solana/web3.js'
4
- import { getHedgeMintPublicKey, getLiquidationPoolStatePublicKey, getLiquidationPoolUsdhAccountPublicKey, getPoolPublicKeyForMint, getVaultTypeAccountPublicKey, getUsdhMintPublicKey, getVaultSystemStatePublicKey } from '../Constants'
4
+ import { getHedgeMintPublicKey, getLiquidationPoolStatePublicKey, getLiquidationPoolUshAccountPublicKey, getPoolPublicKeyForMint, getVaultTypeAccountPublicKey, getUshMintPublicKey, getVaultSystemStatePublicKey } from '../Constants'
5
5
 
6
6
  export async function liquidateVault (
7
7
  program: Program,
@@ -17,7 +17,7 @@ export async function liquidateVault (
17
17
  const collateralMint = vaultTypeAccountInfo.collateralMint
18
18
 
19
19
  const hedgeMintPublickey = await getHedgeMintPublicKey()
20
- const usdhMintPublickey = await getUsdhMintPublicKey()
20
+ const ushMintPublickey = await getUshMintPublicKey()
21
21
  const [hedgeStakingPoolPublicKey] = await getPoolPublicKeyForMint(hedgeMintPublickey)
22
22
  const liquidationPoolStatePublicKey = await getLiquidationPoolStatePublicKey()
23
23
  const poolStateInfo = await program.account.liquidationPoolState.fetch(liquidationPoolStatePublicKey)
@@ -27,7 +27,7 @@ export async function liquidateVault (
27
27
  const vaultAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(provider.connection, payer, collateralMint, vaultPublicKey, true)
28
28
  const poolAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(provider.connection, payer, collateralMint, liquidationPoolStatePublicKey, true)
29
29
  const vaultTypeAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(provider.connection, payer, collateralMint, vaultTypeAccountPublicKey, true)
30
- const hedgeStakingPoolAssociatedUsdhTokenAccount = await getOrCreateAssociatedTokenAccount(provider.connection, payer, usdhMintPublickey, hedgeStakingPoolPublicKey, true)
30
+ const hedgeStakingPoolAssociatedUshTokenAccount = await getOrCreateAssociatedTokenAccount(provider.connection, payer, ushMintPublickey, hedgeStakingPoolPublicKey, true)
31
31
 
32
32
  const history = Keypair.generate()
33
33
  const newEra = Keypair.generate()
@@ -47,7 +47,7 @@ export async function liquidateVault (
47
47
  newEra.publicKey,
48
48
  hedgeStakingPoolPublicKey,
49
49
  feePoolAssociatedTokenAccount.address,
50
- hedgeStakingPoolAssociatedUsdhTokenAccount.address,
50
+ hedgeStakingPoolAssociatedUshTokenAccount.address,
51
51
  collateralMint,
52
52
  vaultTypeAssociatedTokenAccount.address,
53
53
  vaultAccount.collateralType,
@@ -71,15 +71,15 @@ export async function liquidateVaultInstruction (
71
71
  newEraPublicKey: PublicKey,
72
72
  feePool: PublicKey,
73
73
  feePoolAssociatedTokenAccount: PublicKey,
74
- hedgeStakingPoolAssociatedUsdhTokenAccount: PublicKey,
74
+ hedgeStakingPoolAssociatedUshTokenAccount: PublicKey,
75
75
  collateralMint: PublicKey,
76
76
  vaultTypeAssociatedTokenAccount: PublicKey,
77
77
  collateralType: string,
78
78
  overrideTime?: number
79
79
  ): Promise<TransactionInstruction> {
80
80
  const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey()
81
- const usdhMintPublickey = await getUsdhMintPublicKey()
82
- const liquidationPoolUsdhAccountPublickey = await getLiquidationPoolUsdhAccountPublicKey()
81
+ const ushMintPublickey = await getUshMintPublicKey()
82
+ const liquidationPoolUshAccountPublickey = await getLiquidationPoolUshAccountPublicKey()
83
83
  const vaultTypeAccount = await getVaultTypeAccountPublicKey(collateralType)
84
84
 
85
85
  const payload = {
@@ -93,14 +93,14 @@ export async function liquidateVaultInstruction (
93
93
  vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
94
94
  poolState: poolState,
95
95
  poolAssociatedTokenAccount: poolAssociatedTokenAccount,
96
- usdhMint: usdhMintPublickey,
96
+ ushMint: ushMintPublickey,
97
97
  history: historyPublicKey,
98
98
  payer: payerPublicKey,
99
99
  payerAssociatedTokenAccount: payerAssociatedTokenAccount,
100
100
  feePool: feePool,
101
101
  feePoolAssociatedTokenAccount: feePoolAssociatedTokenAccount,
102
- feePoolAssociatedUsdhTokenAccount: hedgeStakingPoolAssociatedUsdhTokenAccount,
103
- liquidationPoolUsdhAccount: liquidationPoolUsdhAccountPublickey,
102
+ feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
103
+ liquidationPoolUshAccount: liquidationPoolUshAccountPublickey,
104
104
  newEra: newEraPublicKey,
105
105
  tokenProgram: TOKEN_PROGRAM_ID,
106
106
  systemProgram: SystemProgram.programId,
@@ -1,7 +1,7 @@
1
1
  import { BN, Program, Provider } from '@project-serum/anchor'
2
2
  import { getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  import { Keypair, PublicKey, sendAndConfirmTransaction, Signer, SystemProgram, Transaction, TransactionInstruction } from '@solana/web3.js'
4
- import { findAssociatedTokenAddress, getHedgeMintPublicKey, getPoolPublicKeyForMint, getVaultTypeAccountPublicKey, getUsdhMintPublicKey, getVaultSystemStatePublicKey } from '../Constants'
4
+ import { findAssociatedTokenAddress, getHedgeMintPublicKey, getPoolPublicKeyForMint, getVaultTypeAccountPublicKey, getUshMintPublicKey, getVaultSystemStatePublicKey } from '../Constants'
5
5
 
6
6
  export async function loanVault (
7
7
  program: Program,
@@ -11,9 +11,9 @@ export async function loanVault (
11
11
  loanAmount: number,
12
12
  overrideTime?: number
13
13
  ): Promise<PublicKey> {
14
- const usdhMintPublickey = await getUsdhMintPublicKey()
14
+ const ushMintPublickey = await getUshMintPublicKey()
15
15
 
16
- const payerUsdhAccount = await getOrCreateAssociatedTokenAccount(provider.connection, payer, usdhMintPublickey, payer.publicKey)
16
+ const payerUshAccount = await getOrCreateAssociatedTokenAccount(provider.connection, payer, ushMintPublickey, payer.publicKey)
17
17
 
18
18
  const vaultAccount = await program.account.vault.fetch(vaultPublicKey)
19
19
  const vaultTypeAccountPublicKey = await getVaultTypeAccountPublicKey(vaultAccount.collateralType)
@@ -26,7 +26,7 @@ export async function loanVault (
26
26
  await loanVaultInstruction(
27
27
  program,
28
28
  payer.publicKey,
29
- payerUsdhAccount.address,
29
+ payerUshAccount.address,
30
30
  vaultPublicKey,
31
31
  vaultAssociatedTokenAccount.address,
32
32
  history.publicKey,
@@ -43,7 +43,7 @@ export async function loanVault (
43
43
  export async function loanVaultInstruction (
44
44
  program: Program,
45
45
  payerPublicKey: PublicKey,
46
- ownerUsdhAccount: PublicKey,
46
+ ownerUshAccount: PublicKey,
47
47
  vaultPublickey: PublicKey,
48
48
  vaultAssociatedTokenAccount: PublicKey,
49
49
  historyPublicKey: PublicKey,
@@ -53,12 +53,12 @@ export async function loanVaultInstruction (
53
53
  overrideTime?: number
54
54
  ): Promise<TransactionInstruction> {
55
55
  const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey()
56
- const usdhMintPublickey = await getUsdhMintPublicKey()
56
+ const ushMintPublickey = await getUshMintPublicKey()
57
57
  const hedgeMintPublickey = await getHedgeMintPublicKey()
58
58
  const [hedgeStakingPoolPublicKey] = await getPoolPublicKeyForMint(hedgeMintPublickey)
59
- const hedgeStakingPoolAssociatedUsdhTokenAccount = await findAssociatedTokenAddress(
59
+ const hedgeStakingPoolAssociatedUshTokenAccount = await findAssociatedTokenAddress(
60
60
  hedgeStakingPoolPublicKey,
61
- usdhMintPublickey
61
+ ushMintPublickey
62
62
  )
63
63
 
64
64
  return program.instruction.loanVault(
@@ -73,10 +73,10 @@ export async function loanVaultInstruction (
73
73
  vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
74
74
  history: historyPublicKey,
75
75
  feePool: hedgeStakingPoolPublicKey,
76
- feePoolAssociatedUsdhTokenAccount: hedgeStakingPoolAssociatedUsdhTokenAccount,
77
- usdhMint: usdhMintPublickey,
76
+ feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
77
+ ushMint: ushMintPublickey,
78
78
  vaultOwner: payerPublicKey,
79
- ownerUsdhAccount: ownerUsdhAccount,
79
+ ownerUshAccount: ownerUshAccount,
80
80
  tokenProgram: TOKEN_PROGRAM_ID,
81
81
  systemProgram: SystemProgram.programId
82
82
  },
@@ -2,7 +2,7 @@ import { BN, Program, Provider } from '@project-serum/anchor'
2
2
  import { getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  // import { TokenInstructions } from '@project-serum/serum'
4
4
  import { Keypair, PublicKey, sendAndConfirmTransaction, Signer, SystemProgram, Transaction, TransactionInstruction } from '@solana/web3.js'
5
- import { findAssociatedTokenAddress, getHedgeMintPublicKey, getPoolPublicKeyForMint, getVaultTypeAccountPublicKey, getUsdhMintPublicKey, getVaultSystemStatePublicKey } from '../Constants'
5
+ import { findAssociatedTokenAddress, getHedgeMintPublicKey, getPoolPublicKeyForMint, getVaultTypeAccountPublicKey, getUshMintPublicKey, getVaultSystemStatePublicKey } from '../Constants'
6
6
 
7
7
  export async function redeemVault (
8
8
  program: Program,
@@ -12,10 +12,10 @@ export async function redeemVault (
12
12
  redeemAmount: number,
13
13
  transactionOverrideTime?: number
14
14
  ): Promise<PublicKey> {
15
- const usdhMintPublickey = await getUsdhMintPublicKey()
15
+ const ushMintPublickey = await getUshMintPublicKey()
16
16
 
17
- // Prep the user to get USDH back out at some point
18
- const payerUsdhAccount = await getOrCreateAssociatedTokenAccount(provider.connection, payer, usdhMintPublickey, payer.publicKey)
17
+ // Prep the user to get USH back out at some point
18
+ const payerUshAccount = await getOrCreateAssociatedTokenAccount(provider.connection, payer, ushMintPublickey, payer.publicKey)
19
19
 
20
20
  const vaultAccount = await program.account.vault.fetch(vaultPublicKey)
21
21
  const vaultTypeAccountPublicKey = await getVaultTypeAccountPublicKey(vaultAccount.collateralType)
@@ -31,7 +31,7 @@ export async function redeemVault (
31
31
  await redeemVaultInstruction(
32
32
  program,
33
33
  payer.publicKey,
34
- payerUsdhAccount.address,
34
+ payerUshAccount.address,
35
35
  payerTokenAccount.address,
36
36
  vaultPublicKey,
37
37
  vaultAssociatedTokenAccount.address,
@@ -49,7 +49,7 @@ export async function redeemVault (
49
49
  export async function redeemVaultInstruction (
50
50
  program: Program,
51
51
  payerPublicKey: PublicKey,
52
- payerUsdhAccount: PublicKey,
52
+ payerUshAccount: PublicKey,
53
53
  destinationTokenAccount: PublicKey,
54
54
  vaultPublickey: PublicKey,
55
55
  vaultAssociatedTokenAccount: PublicKey,
@@ -60,12 +60,12 @@ export async function redeemVaultInstruction (
60
60
  transactionOverrideTime?: number
61
61
  ): Promise<TransactionInstruction> {
62
62
  const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey()
63
- const usdhMintPublickey = await getUsdhMintPublicKey()
63
+ const ushMintPublickey = await getUshMintPublicKey()
64
64
  const hedgeMintPublickey = await getHedgeMintPublicKey()
65
65
  const [hedgeStakingPoolPublicKey] = await getPoolPublicKeyForMint(hedgeMintPublickey)
66
- const hedgeStakingPoolAssociatedUsdhTokenAccount = await findAssociatedTokenAddress(
66
+ const hedgeStakingPoolAssociatedUshTokenAccount = await findAssociatedTokenAddress(
67
67
  hedgeStakingPoolPublicKey,
68
- usdhMintPublickey
68
+ ushMintPublickey
69
69
  )
70
70
  return program.instruction.redeemVault(
71
71
  new BN(redeemAmount),
@@ -79,10 +79,10 @@ export async function redeemVaultInstruction (
79
79
  vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
80
80
  history: historyPublicKey,
81
81
  feePool: hedgeStakingPoolPublicKey,
82
- feePoolAssociatedUsdhTokenAccount: hedgeStakingPoolAssociatedUsdhTokenAccount,
83
- usdhMint: usdhMintPublickey,
82
+ feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
83
+ ushMint: ushMintPublickey,
84
84
  payer: payerPublicKey,
85
- payerUsdhAccount: payerUsdhAccount,
85
+ payerUshAccount: payerUshAccount,
86
86
  destinationTokenAccount: destinationTokenAccount,
87
87
  tokenProgram: TOKEN_PROGRAM_ID,
88
88
  systemProgram: SystemProgram.programId