hedge-web3 0.1.21 → 0.1.23

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.
@@ -1,5 +1,5 @@
1
1
  import { PublicKey } from '@solana/web3.js';
2
- export declare const HEDGE_PROGRAM_ID = "h8i3RfCeswxUSEwXCi5hjnvMfcdY6ZGr44dLKEKL8b3";
2
+ export declare const HEDGE_PROGRAM_ID = "h14ydGHkAt6vpBaxX461fgxGYsZjaf2K8Fqwm7Cn3ik";
3
3
  export declare const HEDGE_PROGRAM_PUBLICKEY: PublicKey;
4
4
  export declare const CHAINLINK_SOL_USD_ID = "FmAmfoyPXiA8Vhhe6MZTr3U6rZfEZ1ctEHay1ysqCqcf";
5
5
  export declare const CHAINLINK_SOL_USD_PUBLICKEY: PublicKey;
@@ -1,6 +1,7 @@
1
1
  export * from './instructions/createStakingPool';
2
2
  export * from './instructions/depositStakingPool';
3
3
  export * from './instructions/withdrawStakingPool';
4
+ export * from './instructions/claimStakingPoolPosition';
4
5
  export * from './instructions/depositLiquidationPool';
5
6
  export * from './instructions/closeLiquidationPoolPosition';
6
7
  export * from './instructions/claimLiquidationPoolPosition';
@@ -0,0 +1,4 @@
1
+ import { Program, Provider } from '@project-serum/anchor';
2
+ import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
3
+ export declare function claimStakingPoolPosition(program: Program, provider: Provider, poolPosition: PublicKey, payer: Signer, collateralType: string): Promise<PublicKey>;
4
+ export declare function claimStakingPoolPositionInstruction(program: Program, feePool: PublicKey, feePoolAssociatedTokenAccount: PublicKey, stakedTokenMint: PublicKey, vaultTypeAccount: PublicKey, collateralMint: PublicKey, poolPosition: PublicKey, payer: PublicKey, payerAssociatedTokenAccount: PublicKey): Promise<TransactionInstruction>;
@@ -10,6 +10,6 @@ export declare class StakingPool {
10
10
  totalHedgeReward: number;
11
11
  hedgeRewardAccumulator: Decimal;
12
12
  usdhFeeAccumulator: Decimal;
13
- solFeeAccumulator: Decimal;
13
+ collateralFeeAccumulator: [Decimal];
14
14
  constructor(poolInfo: any, publicKey: PublicKey);
15
15
  }
@@ -7,8 +7,8 @@ export declare class VaultHistoryEvent {
7
7
  usdSolPrice: Decimal;
8
8
  usdhDebtBefore: number;
9
9
  usdhDebtAfter: number;
10
- solBalanceBefore: number;
11
- solBalanceAfter: number;
10
+ collateralBalanceBefore: number;
11
+ collateralBalanceAfter: number;
12
12
  minCollateralRatioBefore: Decimal;
13
13
  minCollateralRatioAfter: Decimal;
14
14
  vaultStateBefore: PublicKey;
package/lib/Constants.js CHANGED
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.findAssociatedTokenAddress = exports.findVaultAddress = exports.getVaultTypeOracleAccountPublicKey = exports.getVaultTypeAccountPublicKey = exports.getPoolPublicKeyForMint = exports.getHedgeMintPublicKey = exports.getVaultSystemStatePublicKey = exports.getUsdhMintPublicKey = exports.getLiquidationPoolUsdhAccountPublicKey = exports.getLiquidationPoolStatePublicKey = exports.CHAINLINK_SOL_USD_PUBLICKEY = exports.CHAINLINK_SOL_USD_ID = exports.HEDGE_PROGRAM_PUBLICKEY = exports.HEDGE_PROGRAM_ID = void 0;
13
13
  const spl_token_1 = require("@solana/spl-token");
14
14
  const web3_js_1 = require("@solana/web3.js");
15
- exports.HEDGE_PROGRAM_ID = 'h8i3RfCeswxUSEwXCi5hjnvMfcdY6ZGr44dLKEKL8b3';
15
+ exports.HEDGE_PROGRAM_ID = 'h14ydGHkAt6vpBaxX461fgxGYsZjaf2K8Fqwm7Cn3ik';
16
16
  exports.HEDGE_PROGRAM_PUBLICKEY = new web3_js_1.PublicKey(exports.HEDGE_PROGRAM_ID);
17
17
  exports.CHAINLINK_SOL_USD_ID = 'FmAmfoyPXiA8Vhhe6MZTr3U6rZfEZ1ctEHay1ysqCqcf';
18
18
  exports.CHAINLINK_SOL_USD_PUBLICKEY = new web3_js_1.PublicKey(exports.CHAINLINK_SOL_USD_ID);
package/lib/index.js CHANGED
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./instructions/createStakingPool"), exports);
14
14
  __exportStar(require("./instructions/depositStakingPool"), exports);
15
15
  __exportStar(require("./instructions/withdrawStakingPool"), exports);
16
+ __exportStar(require("./instructions/claimStakingPoolPosition"), exports);
16
17
  __exportStar(require("./instructions/depositLiquidationPool"), exports);
17
18
  __exportStar(require("./instructions/closeLiquidationPoolPosition"), exports);
18
19
  __exportStar(require("./instructions/claimLiquidationPoolPosition"), exports);
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.claimStakingPoolPositionInstruction = exports.claimStakingPoolPosition = void 0;
13
+ const spl_token_1 = require("@solana/spl-token");
14
+ const web3_js_1 = require("@solana/web3.js");
15
+ const Errors_1 = require("../utils/Errors");
16
+ const Constants_1 = require("../Constants");
17
+ function claimStakingPoolPosition(program, provider, poolPosition, payer, collateralType) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const vaultTypeAccount = yield (0, Constants_1.getVaultTypeAccountPublicKey)(collateralType);
20
+ const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultTypeAccount);
21
+ const collateralMint = vaultTypeAccountInfo.collateralMint;
22
+ const stakedTokenMint = yield (0, Constants_1.getHedgeMintPublicKey)();
23
+ const [feePool] = yield (0, Constants_1.getPoolPublicKeyForMint)(stakedTokenMint);
24
+ const feePoolAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, feePool, true);
25
+ const payerAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, payer.publicKey);
26
+ const transaction = new web3_js_1.Transaction().add(yield claimStakingPoolPositionInstruction(program, feePool, feePoolAssociatedTokenAccount.address, stakedTokenMint, vaultTypeAccount, collateralMint, poolPosition, payer.publicKey, payerAssociatedTokenAccount.address));
27
+ yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer], provider.opts).catch(Errors_1.parseAnchorErrors);
28
+ return payerAssociatedTokenAccount.address;
29
+ });
30
+ }
31
+ exports.claimStakingPoolPosition = claimStakingPoolPosition;
32
+ function claimStakingPoolPositionInstruction(program, feePool, feePoolAssociatedTokenAccount, stakedTokenMint, vaultTypeAccount, collateralMint, poolPosition, payer, payerAssociatedTokenAccount) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ const vaultSystemState = yield (0, Constants_1.getVaultSystemStatePublicKey)();
35
+ return program.instruction.claimStakingPoolPosition({
36
+ accounts: {
37
+ vaultSystemState: vaultSystemState,
38
+ feePool: feePool,
39
+ stakedTokenMint: stakedTokenMint,
40
+ feePoolAssociatedTokenAccount: feePoolAssociatedTokenAccount,
41
+ vaultTypeAccount: vaultTypeAccount,
42
+ collateralMint: collateralMint,
43
+ poolPosition: poolPosition,
44
+ payer: payer,
45
+ payerAssociatedTokenAccount: payerAssociatedTokenAccount,
46
+ associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
47
+ systemProgram: web3_js_1.SystemProgram.programId,
48
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
49
+ rent: web3_js_1.SYSVAR_RENT_PUBKEY
50
+ },
51
+ signers: []
52
+ });
53
+ });
54
+ }
55
+ exports.claimStakingPoolPositionInstruction = claimStakingPoolPositionInstruction;
@@ -38,7 +38,7 @@ function closeLiquidationPoolPositionInstruction(program, poolEra, poolPosition,
38
38
  const hedgeMint = yield (0, Constants_1.getHedgeMintPublicKey)();
39
39
  const poolUsdhAccount = yield (0, Constants_1.getLiquidationPoolUsdhAccountPublicKey)();
40
40
  const poolState = yield (0, Constants_1.getLiquidationPoolStatePublicKey)();
41
- return program.instruction.closeLiquidationPoolPosition(new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Date.now() / 1000), // override current time
41
+ return program.instruction.closeLiquidationPoolPosition(new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Math.floor(Date.now() / 1000)), // override current time
42
42
  {
43
43
  accounts: {
44
44
  vaultSystemState: vaultSystemStatePublicKey,
@@ -32,7 +32,7 @@ function createStakingPoolInstruction(program, payerPublicKey, mintPublicKey, he
32
32
  const [poolPublickey, poolBump, poolSeedPhrase] = yield (0, Constants_1.getPoolPublicKeyForMint)(mintPublicKey);
33
33
  const poolAssociatedStakedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(poolPublickey, mintPublicKey);
34
34
  const poolAssociatedUsdhTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(poolPublickey, usdhMintPublickey);
35
- return program.instruction.createStakingPool(poolBump, poolSeedPhrase, new anchor_1.BN(hedgeTokensToBeMinted), new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Date.now() / 1000), {
35
+ return program.instruction.createStakingPool(poolBump, poolSeedPhrase, new anchor_1.BN(hedgeTokensToBeMinted), new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Math.floor(Date.now() / 1000)), {
36
36
  accounts: {
37
37
  signer: payerPublicKey,
38
38
  vaultSystemState: vaultSystemStatePublicKey,
@@ -114,8 +114,8 @@ function buildCreateVaultTransaction(program, collateralType, depositAmount, ove
114
114
  destination: payerPublicKey,
115
115
  owner: payerPublicKey,
116
116
  }));
117
+ transaction.partialSign(wrappedSolAccount);
117
118
  }
118
- transaction.partialSign(wrappedSolAccount);
119
119
  transaction.partialSign(history);
120
120
  console.log("transaction", transaction);
121
121
  return [transaction, signers, newVaultPublicKey];
@@ -33,7 +33,7 @@ function depositLiquidationPoolInstruction(program, payerPublicKey, payerUsdhAcc
33
33
  const poolUSDHAccount = yield (0, Constants_1.getLiquidationPoolUsdhAccountPublicKey)();
34
34
  const usdhMint = yield (0, Constants_1.getUsdhMintPublicKey)();
35
35
  const vaultSystemState = yield (0, Constants_1.getVaultSystemStatePublicKey)();
36
- return program.instruction.depositLiquidationPool(new anchor_1.BN(depositAmount), new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Date.now() / 1000), // override current time
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
  {
38
38
  accounts: {
39
39
  vaultSystemState: vaultSystemState,
@@ -30,7 +30,7 @@ function depositStakingPoolInstruction(program, payerPublicKey, poolPositionPubl
30
30
  const poolAssociatedStakedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(poolPublickey, stakedTokenMintPublicKey);
31
31
  const payersArbitraryTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, stakedTokenMintPublicKey);
32
32
  const vaultSystemState = yield (0, Constants_1.getVaultSystemStatePublicKey)();
33
- return program.instruction.depositStakingPool(new anchor_1.BN(depositAmount), new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Date.now() / 1000), // override current time
33
+ return program.instruction.depositStakingPool(new anchor_1.BN(depositAmount), new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Math.floor(Date.now() / 1000)), // override current time
34
34
  {
35
35
  accounts: {
36
36
  payer: payerPublicKey,
@@ -26,7 +26,7 @@ function refreshOraclePriceInstruction(program, collateralType, network, overrid
26
26
  const [oracleInfoAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralType), enc.encode('Oracle')], Constants_1.HEDGE_PROGRAM_PUBLICKEY);
27
27
  const [vaultTypeAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralType), enc.encode('State')], Constants_1.HEDGE_PROGRAM_PUBLICKEY);
28
28
  return program.instruction.refreshOraclePrice(new anchor_1.BN(overridePrice !== null && overridePrice !== void 0 ? overridePrice : web3_js_1.LAMPORTS_PER_SOL * 150), // override usd/sol price
29
- new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)), // override override time
29
+ new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000) - 1), // override override time
30
30
  {
31
31
  accounts: {
32
32
  oracleInfoAccount: oracleInfoAccount,
@@ -36,7 +36,7 @@ function withdrawStakingPoolInstruction(program, payerPublicKey, poolPositionPub
36
36
  const payerAssociatedHedgeAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, hedgeMintPublickey);
37
37
  const payerAssociatedUsdhAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, usdhMintPublickey);
38
38
  const communityHedgeTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(vaultSystemStatePublicKey, hedgeMintPublickey);
39
- return program.instruction.withdrawStakingPool(new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Date.now() / 1000), // override current time
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
  {
41
41
  accounts: {
42
42
  payer: payerPublicKey,
@@ -15,7 +15,7 @@ class StakingPool {
15
15
  this.totalHedgeReward = poolInfo.totalHedgeReward.toNumber();
16
16
  this.hedgeRewardAccumulator = (0, HedgeDecimal_1.DecimalFromU128)(poolInfo.hedgeRewardAccumulator);
17
17
  this.usdhFeeAccumulator = (0, HedgeDecimal_1.DecimalFromU128)(poolInfo.usdhFeeAccumulator);
18
- this.solFeeAccumulator = (0, HedgeDecimal_1.DecimalFromU128)(poolInfo.solFeeAccumulator);
18
+ this.collateralFeeAccumulator = poolInfo.collateralFeeAccumulator.map((sum) => { return (0, HedgeDecimal_1.DecimalFromU128)(sum); });
19
19
  // this.currentRewardsPerDay = DecimalFromU128(poolInfo.currentRewardsPerDay)
20
20
  }
21
21
  }
@@ -10,8 +10,8 @@ class VaultHistoryEvent {
10
10
  this.usdSolPrice = (0, HedgeDecimal_1.DecimalFromU128)(account.usdSolPrice.toString());
11
11
  this.usdhDebtBefore = account.usdhDebtBefore.toNumber();
12
12
  this.usdhDebtAfter = account.usdhDebtAfter.toNumber();
13
- this.solBalanceBefore = account.solBalanceBefore.toNumber();
14
- this.solBalanceAfter = account.solBalanceAfter.toNumber();
13
+ this.collateralBalanceBefore = account.collateralBalanceBefore.toNumber();
14
+ this.collateralBalanceAfter = account.collateralBalanceAfter.toNumber();
15
15
  this.minCollateralRatioBefore = (0, HedgeDecimal_1.DecimalFromU128)(account.minCollateralRatioBefore);
16
16
  this.minCollateralRatioAfter = (0, HedgeDecimal_1.DecimalFromU128)(account.minCollateralRatioAfter);
17
17
  this.vaultStateBefore = account.vaultStateBefore;
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "hedge-web3",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "description": "Hedge Javascript Web3 API",
5
5
  "main": "lib/index.js",
6
+ "types": "declarations/index.d.ts",
6
7
  "scripts": {
7
8
  "build": "tsc",
8
9
  "dev": "tsc --watch",
package/src/Constants.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from '@solana/spl-token'
2
2
  import { PublicKey } from '@solana/web3.js'
3
3
 
4
- export const HEDGE_PROGRAM_ID = 'h8i3RfCeswxUSEwXCi5hjnvMfcdY6ZGr44dLKEKL8b3'
4
+ export const HEDGE_PROGRAM_ID = 'h14ydGHkAt6vpBaxX461fgxGYsZjaf2K8Fqwm7Cn3ik'
5
5
  export const HEDGE_PROGRAM_PUBLICKEY = new PublicKey(HEDGE_PROGRAM_ID)
6
6
 
7
7
  export const CHAINLINK_SOL_USD_ID = 'FmAmfoyPXiA8Vhhe6MZTr3U6rZfEZ1ctEHay1ysqCqcf'
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  export * from './instructions/createStakingPool'
3
3
  export * from './instructions/depositStakingPool'
4
4
  export * from './instructions/withdrawStakingPool'
5
+ export * from './instructions/claimStakingPoolPosition'
5
6
  export * from './instructions/depositLiquidationPool'
6
7
  export * from './instructions/closeLiquidationPoolPosition'
7
8
  export * from './instructions/claimLiquidationPoolPosition'
@@ -0,0 +1,76 @@
1
+ import { Program, Provider } from '@project-serum/anchor'
2
+ import { ASSOCIATED_TOKEN_PROGRAM_ID, getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
+ import { PublicKey, sendAndConfirmTransaction, Signer, SystemProgram, SYSVAR_RENT_PUBKEY, Transaction, TransactionInstruction } from '@solana/web3.js'
4
+ import { parseAnchorErrors } from '../utils/Errors'
5
+ import { getHedgeMintPublicKey, findAssociatedTokenAddress, getVaultTypeAccountPublicKey, getPoolPublicKeyForMint, getVaultSystemStatePublicKey } from '../Constants'
6
+
7
+ export async function claimStakingPoolPosition(
8
+ program: Program,
9
+ provider: Provider,
10
+ poolPosition: PublicKey,
11
+ payer: Signer,
12
+ collateralType: string,
13
+ ): Promise<PublicKey> {
14
+ const vaultTypeAccount = await getVaultTypeAccountPublicKey(collateralType)
15
+ const vaultTypeAccountInfo = await program.account.vaultType.fetch(vaultTypeAccount)
16
+ const collateralMint = vaultTypeAccountInfo.collateralMint
17
+ const stakedTokenMint = await getHedgeMintPublicKey()
18
+ const [feePool] = await getPoolPublicKeyForMint(stakedTokenMint)
19
+ const feePoolAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(provider.connection, payer, collateralMint, feePool, true)
20
+ const payerAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(
21
+ provider.connection,
22
+ payer,
23
+ collateralMint,
24
+ payer.publicKey
25
+ )
26
+
27
+ const transaction = new Transaction().add(
28
+ await claimStakingPoolPositionInstruction(
29
+ program,
30
+ feePool,
31
+ feePoolAssociatedTokenAccount.address,
32
+ stakedTokenMint,
33
+ vaultTypeAccount,
34
+ collateralMint,
35
+ poolPosition,
36
+ payer.publicKey,
37
+ payerAssociatedTokenAccount.address
38
+ )
39
+ )
40
+ await sendAndConfirmTransaction(provider.connection, transaction, [payer], provider.opts).catch(parseAnchorErrors)
41
+ return payerAssociatedTokenAccount.address
42
+ }
43
+
44
+ export async function claimStakingPoolPositionInstruction(
45
+ program: Program,
46
+ feePool: PublicKey,
47
+ feePoolAssociatedTokenAccount: PublicKey,
48
+ stakedTokenMint: PublicKey,
49
+ vaultTypeAccount: PublicKey,
50
+ collateralMint: PublicKey,
51
+ poolPosition: PublicKey,
52
+ payer: PublicKey,
53
+ payerAssociatedTokenAccount: PublicKey
54
+ ): Promise<TransactionInstruction> {
55
+ const vaultSystemState = await getVaultSystemStatePublicKey()
56
+
57
+ return program.instruction.claimStakingPoolPosition(
58
+ {
59
+ accounts: {
60
+ vaultSystemState: vaultSystemState,
61
+ feePool: feePool,
62
+ stakedTokenMint: stakedTokenMint,
63
+ feePoolAssociatedTokenAccount: feePoolAssociatedTokenAccount,
64
+ vaultTypeAccount: vaultTypeAccount,
65
+ collateralMint: collateralMint,
66
+ poolPosition: poolPosition,
67
+ payer: payer,
68
+ payerAssociatedTokenAccount: payerAssociatedTokenAccount,
69
+ associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
70
+ systemProgram: SystemProgram.programId,
71
+ tokenProgram: TOKEN_PROGRAM_ID,
72
+ rent: SYSVAR_RENT_PUBKEY
73
+ },
74
+ signers: []
75
+ })
76
+ }
@@ -55,7 +55,7 @@ export async function closeLiquidationPoolPositionInstruction (
55
55
  const poolState = await getLiquidationPoolStatePublicKey()
56
56
 
57
57
  return program.instruction.closeLiquidationPoolPosition(
58
- new BN(overrideStartTime ?? Date.now() / 1000), // override current time
58
+ new BN(overrideStartTime ?? Math.floor(Date.now() / 1000)), // override current time
59
59
  {
60
60
  accounts: {
61
61
  vaultSystemState: vaultSystemStatePublicKey,
@@ -45,7 +45,7 @@ export async function createStakingPoolInstruction (
45
45
  poolBump,
46
46
  poolSeedPhrase,
47
47
  new BN(hedgeTokensToBeMinted),
48
- new BN(overrideStartTime ?? Date.now() / 1000),
48
+ new BN(overrideStartTime ?? Math.floor(Date.now() / 1000)),
49
49
  {
50
50
  accounts: {
51
51
  signer: payerPublicKey,
@@ -241,8 +241,9 @@ export async function buildCreateVaultTransaction(
241
241
  owner: payerPublicKey,
242
242
  })
243
243
  );
244
+ transaction.partialSign(wrappedSolAccount)
244
245
  }
245
- transaction.partialSign(wrappedSolAccount)
246
+
246
247
  transaction.partialSign(history)
247
248
  console.log("transaction", transaction)
248
249
 
@@ -47,7 +47,7 @@ export async function depositLiquidationPoolInstruction (
47
47
 
48
48
  return program.instruction.depositLiquidationPool(
49
49
  new BN(depositAmount),
50
- new BN(overrideStartTime ?? Date.now() / 1000), // override current time
50
+ new BN(overrideStartTime ?? Math.floor(Date.now() / 1000)), // override current time
51
51
  {
52
52
  accounts: {
53
53
  vaultSystemState: vaultSystemState,
@@ -42,7 +42,7 @@ export async function depositStakingPoolInstruction (
42
42
 
43
43
  return program.instruction.depositStakingPool(
44
44
  new BN(depositAmount),
45
- new BN(overrideStartTime ?? Date.now() / 1000), // override current time
45
+ new BN(overrideStartTime ?? Math.floor(Date.now() / 1000)), // override current time
46
46
  {
47
47
  accounts: {
48
48
  payer: payerPublicKey,
@@ -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,
@@ -45,7 +45,7 @@ export async function withdrawStakingPoolInstruction (
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,
@@ -13,7 +13,7 @@ export class StakingPool {
13
13
 
14
14
  hedgeRewardAccumulator: Decimal
15
15
  usdhFeeAccumulator: Decimal
16
- solFeeAccumulator: Decimal
16
+ collateralFeeAccumulator: [Decimal]
17
17
 
18
18
  constructor (public poolInfo: any, publicKey: PublicKey) {
19
19
  this.publicKey = publicKey
@@ -27,7 +27,7 @@ export class StakingPool {
27
27
 
28
28
  this.hedgeRewardAccumulator = DecimalFromU128(poolInfo.hedgeRewardAccumulator)
29
29
  this.usdhFeeAccumulator = DecimalFromU128(poolInfo.usdhFeeAccumulator)
30
- this.solFeeAccumulator = DecimalFromU128(poolInfo.solFeeAccumulator)
30
+ this.collateralFeeAccumulator = poolInfo.collateralFeeAccumulator.map((sum: any) => { return DecimalFromU128(sum) })
31
31
  // this.currentRewardsPerDay = DecimalFromU128(poolInfo.currentRewardsPerDay)
32
32
  }
33
33
 
@@ -9,8 +9,8 @@ export class VaultHistoryEvent {
9
9
  usdSolPrice: Decimal
10
10
  usdhDebtBefore: number
11
11
  usdhDebtAfter: number
12
- solBalanceBefore: number
13
- solBalanceAfter: number
12
+ collateralBalanceBefore: number
13
+ collateralBalanceAfter: number
14
14
  minCollateralRatioBefore: Decimal
15
15
  minCollateralRatioAfter: Decimal
16
16
  vaultStateBefore: PublicKey
@@ -26,8 +26,8 @@ export class VaultHistoryEvent {
26
26
 
27
27
  this.usdhDebtBefore = account.usdhDebtBefore.toNumber()
28
28
  this.usdhDebtAfter = account.usdhDebtAfter.toNumber()
29
- this.solBalanceBefore = account.solBalanceBefore.toNumber()
30
- this.solBalanceAfter = account.solBalanceAfter.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