hedge-web3 0.1.21 → 0.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/declarations/Constants.d.ts +3 -3
  2. package/declarations/idl/vault.d.ts +43 -43
  3. package/declarations/index.d.ts +1 -0
  4. package/declarations/instructions/claimStakingPoolPosition.d.ts +4 -0
  5. package/declarations/instructions/closeLiquidationPoolPosition.d.ts +1 -1
  6. package/declarations/instructions/createVault.d.ts +1 -1
  7. package/declarations/instructions/depositLiquidationPool.d.ts +1 -1
  8. package/declarations/instructions/depositVault.d.ts +1 -1
  9. package/declarations/instructions/liquidateVault.d.ts +1 -1
  10. package/declarations/instructions/loanVault.d.ts +1 -1
  11. package/declarations/instructions/redeemVault.d.ts +1 -1
  12. package/declarations/instructions/repayVault.d.ts +1 -1
  13. package/declarations/instructions/withdrawVault.d.ts +1 -1
  14. package/declarations/state/LiquidationPosition.d.ts +2 -2
  15. package/declarations/state/StakingPool.d.ts +2 -2
  16. package/declarations/state/StakingPoolPosition.d.ts +2 -2
  17. package/declarations/state/VaultAccount.d.ts +3 -3
  18. package/declarations/state/VaultHistoryEvent.d.ts +4 -4
  19. package/lib/Constants.js +8 -8
  20. package/lib/idl/idl.js +30 -30
  21. package/lib/idl/vault.js +43 -43
  22. package/lib/index.js +1 -0
  23. package/lib/instructions/claimStakingPoolPosition.js +55 -0
  24. package/lib/instructions/closeLiquidationPoolPosition.js +10 -10
  25. package/lib/instructions/createStakingPool.js +5 -5
  26. package/lib/instructions/createVault.js +12 -12
  27. package/lib/instructions/depositLiquidationPool.js +10 -10
  28. package/lib/instructions/depositStakingPool.js +1 -1
  29. package/lib/instructions/depositVault.js +8 -8
  30. package/lib/instructions/initHedgeFoundation.js +4 -4
  31. package/lib/instructions/liquidateVault.js +9 -9
  32. package/lib/instructions/loanVault.js +9 -9
  33. package/lib/instructions/redeemVault.js +10 -10
  34. package/lib/instructions/refreshOraclePrice.js +1 -1
  35. package/lib/instructions/repayVault.js +10 -10
  36. package/lib/instructions/withdrawStakingPool.js +7 -7
  37. package/lib/instructions/withdrawVault.js +8 -8
  38. package/lib/state/LiquidationPosition.js +2 -2
  39. package/lib/state/StakingPool.js +2 -2
  40. package/lib/state/StakingPoolPosition.js +3 -3
  41. package/lib/state/VaultAccount.js +2 -2
  42. package/lib/state/VaultHistoryEvent.js +4 -4
  43. package/package.json +9 -9
  44. package/src/Constants.ts +5 -5
  45. package/src/idl/idl.ts +30 -30
  46. package/src/idl/vault.ts +86 -86
  47. package/src/index.ts +1 -0
  48. package/src/instructions/claimStakingPoolPosition.ts +76 -0
  49. package/src/instructions/closeLiquidationPoolPosition.ts +11 -11
  50. package/src/instructions/createStakingPool.ts +6 -6
  51. package/src/instructions/createVault.ts +19 -18
  52. package/src/instructions/depositLiquidationPool.ts +11 -11
  53. package/src/instructions/depositStakingPool.ts +1 -1
  54. package/src/instructions/depositVault.ts +12 -12
  55. package/src/instructions/initHedgeFoundation.ts +5 -5
  56. package/src/instructions/initHedgeFoundationTokens.ts +1 -1
  57. package/src/instructions/liquidateVault.ts +10 -10
  58. package/src/instructions/loanVault.ts +11 -11
  59. package/src/instructions/redeemVault.ts +12 -12
  60. package/src/instructions/refreshOraclePrice.ts +1 -1
  61. package/src/instructions/repayVault.ts +12 -12
  62. package/src/instructions/setHalted.ts +1 -1
  63. package/src/instructions/withdrawStakingPool.ts +8 -8
  64. package/src/instructions/withdrawVault.ts +12 -12
  65. package/src/state/LiquidationPosition.ts +3 -3
  66. package/src/state/StakingPool.ts +4 -4
  67. package/src/state/StakingPoolPosition.ts +4 -4
  68. package/src/state/VaultAccount.ts +3 -3
  69. package/src/state/VaultHistoryEvent.ts +8 -8
@@ -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
@@ -36,7 +36,7 @@ export async function refreshOraclePriceInstruction (
36
36
 
37
37
  return program.instruction.refreshOraclePrice(
38
38
  new BN(overridePrice ?? LAMPORTS_PER_SOL * 150), // override usd/sol price
39
- new BN(overrideTime ?? Math.floor(Date.now() / 1000)), // override override time
39
+ new BN(overrideTime ?? Math.floor(Date.now() / 1000)-1), // override override time
40
40
  {
41
41
  accounts: {
42
42
  oracleInfoAccount: oracleInfoAccount,
@@ -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 repayVault (
7
7
  program: Program,
@@ -11,10 +11,10 @@ export async function repayVault (
11
11
  repayAmount: number,
12
12
  overrideTime?: number
13
13
  ): Promise<PublicKey> {
14
- const usdhMintPublickey = await getUsdhMintPublicKey()
14
+ const ushMintPublickey = await getUshMintPublicKey()
15
15
 
16
- // Prep the user to get USDH back out at some point
17
- const payerUsdhAccount = await getOrCreateAssociatedTokenAccount(provider.connection, payer, usdhMintPublickey, payer.publicKey)
16
+ // Prep the user to get USH back out at some point
17
+ const payerUshAccount = await getOrCreateAssociatedTokenAccount(provider.connection, payer, ushMintPublickey, payer.publicKey)
18
18
  const vaultAccount = await program.account.vault.fetch(vaultPublicKey)
19
19
 
20
20
  const vaultTypeAccountPublicKey = await getVaultTypeAccountPublicKey(vaultAccount.collateralType)
@@ -27,7 +27,7 @@ export async function repayVault (
27
27
  await repayVaultInstruction(
28
28
  program,
29
29
  payer.publicKey,
30
- payerUsdhAccount.address,
30
+ payerUshAccount.address,
31
31
  vaultPublicKey,
32
32
  vaultAssociatedTokenAccount,
33
33
  history.publicKey,
@@ -44,7 +44,7 @@ export async function repayVault (
44
44
  export async function repayVaultInstruction (
45
45
  program: Program,
46
46
  payerPublicKey: PublicKey,
47
- ownerUsdhAccount: PublicKey,
47
+ ownerUshAccount: PublicKey,
48
48
  vaultPublickey: PublicKey,
49
49
  vaultAssociatedTokenAccount: PublicKey,
50
50
  historyPublicKey: PublicKey,
@@ -54,12 +54,12 @@ export async function repayVaultInstruction (
54
54
  overrideTime?: number
55
55
  ): Promise<TransactionInstruction> {
56
56
  const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey()
57
- const usdhMintPublickey = await getUsdhMintPublicKey()
57
+ const ushMintPublickey = await getUshMintPublicKey()
58
58
  const hedgeMintPublickey = await getHedgeMintPublicKey()
59
59
  const [hedgeStakingPoolPublicKey] = await getPoolPublicKeyForMint(hedgeMintPublickey)
60
- const hedgeStakingPoolAssociatedUsdhTokenAccount = await findAssociatedTokenAddress(
60
+ const hedgeStakingPoolAssociatedUshTokenAccount = await findAssociatedTokenAddress(
61
61
  hedgeStakingPoolPublicKey,
62
- usdhMintPublickey
62
+ ushMintPublickey
63
63
  )
64
64
 
65
65
  return program.instruction.repayVault(
@@ -74,10 +74,10 @@ export async function repayVaultInstruction (
74
74
  vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
75
75
  history: historyPublicKey,
76
76
  feePool: hedgeStakingPoolPublicKey,
77
- feePoolAssociatedUsdhTokenAccount: hedgeStakingPoolAssociatedUsdhTokenAccount,
78
- usdhMint: usdhMintPublickey,
77
+ feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
78
+ ushMint: ushMintPublickey,
79
79
  vaultOwner: payerPublicKey,
80
- ownerUsdhAccount: ownerUsdhAccount,
80
+ ownerUshAccount: ownerUshAccount,
81
81
  tokenProgram: TOKEN_PROGRAM_ID,
82
82
  systemProgram: SystemProgram.programId
83
83
  },
@@ -2,7 +2,7 @@ import { BN, Program, Provider } from '@project-serum/anchor'
2
2
  import { TokenInstructions } from '@project-serum/serum'
3
3
  import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, getOrCreateAssociatedTokenAccount } from '@solana/spl-token'
4
4
  import { Keypair, PublicKey, sendAndConfirmTransaction, Signer, SystemProgram, SYSVAR_RENT_PUBKEY, Transaction, TransactionInstruction } from '@solana/web3.js'
5
- import { findAssociatedTokenAddress, findVaultAddress, getVaultTypeAccountPublicKey, getUsdhMintPublicKey, getVaultSystemStatePublicKey, getPoolPublicKeyForMint, getHedgeMintPublicKey } from '../Constants'
5
+ import { findAssociatedTokenAddress, findVaultAddress, getVaultTypeAccountPublicKey, getUshMintPublicKey, getVaultSystemStatePublicKey, getPoolPublicKeyForMint, getHedgeMintPublicKey } from '../Constants'
6
6
 
7
7
  import { v4 as uuidv4 } from 'uuid'
8
8
  import { parseAnchorErrors } from '../utils/Errors'
@@ -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 { 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, getPoolPublicKeyForMint, getUsdhMintPublicKey, getVaultSystemStatePublicKey } from '../Constants'
5
+ import { findAssociatedTokenAddress, getHedgeMintPublicKey, getPoolPublicKeyForMint, getUshMintPublicKey, getVaultSystemStatePublicKey } from '../Constants'
6
6
 
7
7
  export async function withdrawStakingPool (
8
8
  program: Program,
@@ -34,18 +34,18 @@ export async function withdrawStakingPoolInstruction (
34
34
  overrideStartTime?: number
35
35
  ): Promise<TransactionInstruction> {
36
36
  const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey()
37
- const usdhMintPublickey = await getUsdhMintPublicKey()
37
+ const ushMintPublickey = await getUshMintPublicKey()
38
38
  const hedgeMintPublickey = await getHedgeMintPublicKey()
39
39
  const [poolPublickey] = await getPoolPublicKeyForMint(stakedTokenMintPublicKey)
40
40
  const poolAssociatedStakedTokenAccount = await findAssociatedTokenAddress(poolPublickey, stakedTokenMintPublicKey)
41
- const poolAssociatedUsdhTokenAccount = await findAssociatedTokenAddress(poolPublickey, usdhMintPublickey)
41
+ const poolAssociatedUshTokenAccount = await findAssociatedTokenAddress(poolPublickey, ushMintPublickey)
42
42
  const payerAssociatedStakedTokenAccount = await findAssociatedTokenAddress(payerPublicKey, stakedTokenMintPublicKey)
43
43
  const payerAssociatedHedgeAccount = await findAssociatedTokenAddress(payerPublicKey, hedgeMintPublickey)
44
- const payerAssociatedUsdhAccount = await findAssociatedTokenAddress(payerPublicKey, usdhMintPublickey)
44
+ const payerAssociatedUshAccount = await findAssociatedTokenAddress(payerPublicKey, ushMintPublickey)
45
45
  const communityHedgeTokenAccount = await findAssociatedTokenAddress(vaultSystemStatePublicKey, hedgeMintPublickey)
46
46
 
47
47
  return program.instruction.withdrawStakingPool(
48
- new BN(overrideStartTime ?? Date.now() / 1000), // override current time
48
+ new BN(overrideStartTime ?? Math.floor(Date.now() / 1000)), // override current time
49
49
  {
50
50
  accounts: {
51
51
  payer: payerPublicKey,
@@ -53,14 +53,14 @@ export async function withdrawStakingPoolInstruction (
53
53
  pool: poolPublickey,
54
54
  poolPosition: poolPositionPublicKey,
55
55
  poolAssociatedStakedTokenAccount: poolAssociatedStakedTokenAccount,
56
- poolAssociatedUsdhTokenAccount: poolAssociatedUsdhTokenAccount,
56
+ poolAssociatedUshTokenAccount: poolAssociatedUshTokenAccount,
57
57
  payerAssociatedStakedTokenAccount: payerAssociatedStakedTokenAccount,
58
58
  payerAssociatedHedgeAccount: payerAssociatedHedgeAccount,
59
- payerAssociatedUsdhAccount: payerAssociatedUsdhAccount,
59
+ payerAssociatedUshAccount: payerAssociatedUshAccount,
60
60
  communityAssociatedHedgeTokenAccount: communityHedgeTokenAccount,
61
61
  hedgeMint: hedgeMintPublickey,
62
62
  stakedTokenMint: stakedTokenMintPublicKey,
63
- usdhMint: usdhMintPublickey,
63
+ ushMint: ushMintPublickey,
64
64
  rent: SYSVAR_RENT_PUBKEY,
65
65
  tokenProgram: TOKEN_PROGRAM_ID,
66
66
  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 { TokenInstructions } from '@project-serum/serum'
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 withdrawVault (
8
8
  program: Program,
@@ -12,10 +12,10 @@ export async function withdrawVault (
12
12
  withdrawAmount: 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 history = Keypair.generate()
21
21
  const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey()
@@ -28,9 +28,9 @@ export async function withdrawVault (
28
28
 
29
29
  const destinationTokenAccount = await getOrCreateAssociatedTokenAccount(provider.connection, payer, vaultTypeAccountInfo.collateralMint, payer.publicKey)
30
30
  const [hedgeStakingPoolPublicKey] = await getPoolPublicKeyForMint(await getHedgeMintPublicKey())
31
- const hedgeStakingPoolAssociatedUsdhTokenAccount = await findAssociatedTokenAddress(
31
+ const hedgeStakingPoolAssociatedUshTokenAccount = await findAssociatedTokenAddress(
32
32
  hedgeStakingPoolPublicKey,
33
- usdhMintPublickey
33
+ ushMintPublickey
34
34
  )
35
35
 
36
36
  const transaction = new Transaction().add(
@@ -44,8 +44,8 @@ export async function withdrawVault (
44
44
  vaultTypeAccount,
45
45
  vaultTypeAssociatedTokenAccount.address,
46
46
  hedgeStakingPoolPublicKey,
47
- hedgeStakingPoolAssociatedUsdhTokenAccount,
48
- usdhMintPublickey,
47
+ hedgeStakingPoolAssociatedUshTokenAccount,
48
+ ushMintPublickey,
49
49
  history.publicKey,
50
50
  withdrawAmount,
51
51
  overrideTime
@@ -65,8 +65,8 @@ export async function withdrawVaultInstruction (
65
65
  vaultTypeAccount: PublicKey,
66
66
  vaultTypeAssociatedTokenAccount: PublicKey,
67
67
  hedgeStakingPoolPublicKey: PublicKey,
68
- hedgeStakingPoolAssociatedUsdhTokenAccount: PublicKey,
69
- usdhMint: PublicKey,
68
+ hedgeStakingPoolAssociatedUshTokenAccount: PublicKey,
69
+ ushMint: PublicKey,
70
70
  historyPublicKey: PublicKey,
71
71
  withdrawAmount: number,
72
72
  overrideTime?: number
@@ -82,8 +82,8 @@ export async function withdrawVaultInstruction (
82
82
  vault: vaultPublickey,
83
83
  vaultAssociatedTokenAccount: vaultAssociatedCollateralPublicKey,
84
84
  feePool: hedgeStakingPoolPublicKey,
85
- feePoolAssociatedUsdhTokenAccount: hedgeStakingPoolAssociatedUsdhTokenAccount,
86
- usdhMint: usdhMint,
85
+ feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
86
+ ushMint: ushMint,
87
87
  history: historyPublicKey,
88
88
  vaultOwner: payerPublicKey,
89
89
  destinationTokenAccount: destinationTokenAccount,
@@ -11,7 +11,7 @@ export class LiquidationPosition {
11
11
 
12
12
  public ownerAccount: PublicKey
13
13
  public deposit: number
14
- public closedUsdh: number
14
+ public closedUsh: number
15
15
  public timestampOpened: Date
16
16
  public timestampClosed: Date
17
17
 
@@ -27,7 +27,7 @@ export class LiquidationPosition {
27
27
  this.eraPublicKey = poolPositionInfo.era
28
28
  this.ownerAccount = poolPositionInfo.ownerAccount
29
29
  this.deposit = poolPositionInfo.deposit.toNumber()
30
- this.closedUsdh = poolPositionInfo.closedUsdh.toNumber()
30
+ this.closedUsh = poolPositionInfo.closedUsh.toNumber()
31
31
  this.timestampOpened = poolPositionInfo.timestampOpened.toNumber()
32
32
  this.timestampClosed = poolPositionInfo.timestampClosed.toNumber()
33
33
 
@@ -40,7 +40,7 @@ export class LiquidationPosition {
40
40
  console.log("poolPositionInfo.state, poolPositionInfo.state")
41
41
  }
42
42
 
43
- public getUsdhAvailable (era: LiquidationPoolEra): Decimal {
43
+ public getUshAvailable (era: LiquidationPoolEra): Decimal {
44
44
  return (era.product.div(this.productSnapshotEntry)).mul(new Decimal(this.deposit))
45
45
  }
46
46
 
@@ -12,8 +12,8 @@ export class StakingPool {
12
12
  totalHedgeReward: number
13
13
 
14
14
  hedgeRewardAccumulator: Decimal
15
- usdhFeeAccumulator: Decimal
16
- solFeeAccumulator: Decimal
15
+ ushFeeAccumulator: Decimal
16
+ collateralFeeAccumulator: [Decimal]
17
17
 
18
18
  constructor (public poolInfo: any, publicKey: PublicKey) {
19
19
  this.publicKey = publicKey
@@ -26,8 +26,8 @@ export class StakingPool {
26
26
  this.totalHedgeReward = poolInfo.totalHedgeReward.toNumber()
27
27
 
28
28
  this.hedgeRewardAccumulator = DecimalFromU128(poolInfo.hedgeRewardAccumulator)
29
- this.usdhFeeAccumulator = DecimalFromU128(poolInfo.usdhFeeAccumulator)
30
- this.solFeeAccumulator = DecimalFromU128(poolInfo.solFeeAccumulator)
29
+ this.ushFeeAccumulator = DecimalFromU128(poolInfo.ushFeeAccumulator)
30
+ this.collateralFeeAccumulator = poolInfo.collateralFeeAccumulator.map((sum: any) => { return DecimalFromU128(sum) })
31
31
  // this.currentRewardsPerDay = DecimalFromU128(poolInfo.currentRewardsPerDay)
32
32
  }
33
33
 
@@ -13,7 +13,7 @@ export class StakingPoolPosition {
13
13
  public timestampClosed: number
14
14
  public closedRewardedTokens: number
15
15
  public startHedgeRewardAccumulator: Decimal
16
- public startUsdhFeeAccumulator: Decimal
16
+ public startUshFeeAccumulator: Decimal
17
17
  public startSolFeeAccumulator: Decimal
18
18
  public open: boolean
19
19
 
@@ -27,13 +27,13 @@ export class StakingPoolPosition {
27
27
  this.closedRewardedTokens = poolPositionInfo.closedRewardedTokens.toNumber()
28
28
 
29
29
  this.startHedgeRewardAccumulator = DecimalFromU128(poolPositionInfo.startHedgeRewardAccumulator)
30
- this.startUsdhFeeAccumulator = DecimalFromU128(poolPositionInfo.startUsdhFeeAccumulator)
30
+ this.startUshFeeAccumulator = DecimalFromU128(poolPositionInfo.startUshFeeAccumulator)
31
31
  this.startSolFeeAccumulator = DecimalFromU128(poolPositionInfo.startSolFeeAccumulator)
32
32
 
33
33
  this.open = poolPositionInfo.state.open !== undefined
34
34
  }
35
35
 
36
- public getCurrentUsdhFeeReward (): Decimal {
37
- return this.pool.usdhFeeAccumulator.minus(this.startUsdhFeeAccumulator).times(new Decimal(this.deposited))
36
+ public getCurrentUshFeeReward (): Decimal {
37
+ return this.pool.ushFeeAccumulator.minus(this.startUshFeeAccumulator).times(new Decimal(this.deposited))
38
38
  }
39
39
  }
@@ -18,7 +18,7 @@ export class VaultAccount {
18
18
  /** The deposited collateral of the vault (in SOL Lamports). */
19
19
  deposited: number
20
20
 
21
- /** The outstanding debt of the vault (in USDH Lamports). Denormalized to time 0. */
21
+ /** The outstanding debt of the vault (in USH Lamports). Denormalized to time 0. */
22
22
  denormalizedDebt: number
23
23
 
24
24
  debtProductSnapshotBytes: Decimal
@@ -64,9 +64,9 @@ export class VaultAccount {
64
64
  }
65
65
 
66
66
  /**
67
- * Get the debt value in USDH
67
+ * Get the debt value in USH
68
68
  *
69
- * @returns debt value in USDH
69
+ * @returns debt value in USH
70
70
  */
71
71
  public inUsd (): number {
72
72
  return this.denormalizedDebt / LAMPORTS_PER_SOL
@@ -7,10 +7,10 @@ export class VaultHistoryEvent {
7
7
  publicKey: PublicKey
8
8
  actorAccount: PublicKey
9
9
  usdSolPrice: Decimal
10
- usdhDebtBefore: number
11
- usdhDebtAfter: number
12
- solBalanceBefore: number
13
- solBalanceAfter: number
10
+ ushDebtBefore: number
11
+ ushDebtAfter: number
12
+ collateralBalanceBefore: number
13
+ collateralBalanceAfter: number
14
14
  minCollateralRatioBefore: Decimal
15
15
  minCollateralRatioAfter: Decimal
16
16
  vaultStateBefore: PublicKey
@@ -24,10 +24,10 @@ export class VaultHistoryEvent {
24
24
 
25
25
  this.usdSolPrice = DecimalFromU128(account.usdSolPrice.toString())
26
26
 
27
- this.usdhDebtBefore = account.usdhDebtBefore.toNumber()
28
- this.usdhDebtAfter = account.usdhDebtAfter.toNumber()
29
- this.solBalanceBefore = account.solBalanceBefore.toNumber()
30
- this.solBalanceAfter = account.solBalanceAfter.toNumber()
27
+ this.ushDebtBefore = account.ushDebtBefore.toNumber()
28
+ this.ushDebtAfter = account.ushDebtAfter.toNumber()
29
+ this.collateralBalanceBefore = account.collateralBalanceBefore.toNumber()
30
+ this.collateralBalanceAfter = account.collateralBalanceAfter.toNumber()
31
31
  this.minCollateralRatioBefore = DecimalFromU128(account.minCollateralRatioBefore)
32
32
  this.minCollateralRatioAfter = DecimalFromU128(account.minCollateralRatioAfter)
33
33
  this.vaultStateBefore = account.vaultStateBefore