hedge-web3 0.1.35 → 0.1.38

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.
@@ -1802,18 +1802,6 @@ export declare type Vault = {
1802
1802
  "type": {
1803
1803
  "kind": "struct";
1804
1804
  "fields": [
1805
- {
1806
- "name": "owner";
1807
- "type": "publicKey";
1808
- },
1809
- {
1810
- "name": "pool";
1811
- "type": "publicKey";
1812
- },
1813
- {
1814
- "name": "deposited";
1815
- "type": "u64";
1816
- },
1817
1805
  {
1818
1806
  "name": "startHedgeRewardAccumulator";
1819
1807
  "type": "u128";
@@ -1852,6 +1840,18 @@ export declare type Vault = {
1852
1840
  "name": "closedRewardedTokens";
1853
1841
  "type": "u64";
1854
1842
  },
1843
+ {
1844
+ "name": "deposited";
1845
+ "type": "u64";
1846
+ },
1847
+ {
1848
+ "name": "owner";
1849
+ "type": "publicKey";
1850
+ },
1851
+ {
1852
+ "name": "pool";
1853
+ "type": "publicKey";
1854
+ },
1855
1855
  {
1856
1856
  "name": "state";
1857
1857
  "type": {
package/lib/idl/vault.js CHANGED
@@ -1805,18 +1805,6 @@ exports.IDL = {
1805
1805
  "type": {
1806
1806
  "kind": "struct",
1807
1807
  "fields": [
1808
- {
1809
- "name": "owner",
1810
- "type": "publicKey"
1811
- },
1812
- {
1813
- "name": "pool",
1814
- "type": "publicKey"
1815
- },
1816
- {
1817
- "name": "deposited",
1818
- "type": "u64"
1819
- },
1820
1808
  {
1821
1809
  "name": "startHedgeRewardAccumulator",
1822
1810
  "type": "u128"
@@ -1855,6 +1843,18 @@ exports.IDL = {
1855
1843
  "name": "closedRewardedTokens",
1856
1844
  "type": "u64"
1857
1845
  },
1846
+ {
1847
+ "name": "deposited",
1848
+ "type": "u64"
1849
+ },
1850
+ {
1851
+ "name": "owner",
1852
+ "type": "publicKey"
1853
+ },
1854
+ {
1855
+ "name": "pool",
1856
+ "type": "publicKey"
1857
+ },
1858
1858
  {
1859
1859
  "name": "state",
1860
1860
  "type": {
@@ -28,7 +28,6 @@ function claimLiquidationPoolPosition(program, provider, poolPosition, payer, co
28
28
  exports.claimLiquidationPoolPosition = claimLiquidationPoolPosition;
29
29
  function claimLiquidationPoolPositionInstruction(program, vaultTypeAccount, collateralMint, poolPosition, payer, payerAssociatedTokenAccount, overrideStartTime) {
30
30
  return __awaiter(this, void 0, void 0, function* () {
31
- console.log("inside function");
32
31
  const vaultSystemState = yield (0, Constants_1.getVaultSystemStatePublicKey)();
33
32
  const poolStatePublicKey = yield (0, Constants_1.getLiquidationPoolStatePublicKey)();
34
33
  const poolAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(poolStatePublicKey, collateralMint);
@@ -15,7 +15,6 @@ const spl_token_1 = require("@solana/spl-token");
15
15
  const web3_js_1 = require("@solana/web3.js");
16
16
  const getLinkedListAccounts_1 = require("../utils/getLinkedListAccounts");
17
17
  const Constants_1 = require("../Constants");
18
- const Errors_1 = require("utils/Errors");
19
18
  function loanVault(program, provider, payer, vaultPublicKey, loanAmount, overrideTime) {
20
19
  return __awaiter(this, void 0, void 0, function* () {
21
20
  const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
@@ -28,7 +27,7 @@ function loanVault(program, provider, payer, vaultPublicKey, loanAmount, overrid
28
27
  const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultTypeAccountPublicKey, vaultPublicKey, 0, loanAmount, false, false);
29
28
  const history = web3_js_1.Keypair.generate();
30
29
  const transaction = new web3_js_1.Transaction().add(yield loanVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, loanAmount, overrideTime));
31
- yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history]).catch(Errors_1.parseAnchorErrors);
30
+ yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history]);
32
31
  return vaultPublicKey;
33
32
  });
34
33
  }
@@ -70,10 +70,10 @@ function getLinkedListAccounts(program, provider, vaultTypeAccountPublicKey, vau
70
70
  oldSmallerPublicKey = vaults[indexBefore - 1].publicKey;
71
71
  }
72
72
  // Pretty print all the vaults before the operation
73
- // console.log('Sorted open vaults before')
74
- // vaults.forEach((vault) => {
75
- // console.log(vault.toString(vaultPublicKey))
76
- // })
73
+ console.log('Sorted open vaults before');
74
+ vaults.forEach((vault) => {
75
+ console.log(vault.toString(vaultPublicKey));
76
+ });
77
77
  // If it wasn't in the list, add it now
78
78
  if (indexBefore < 0) {
79
79
  vaults.push(thisVault);
@@ -98,10 +98,10 @@ function getLinkedListAccounts(program, provider, vaultTypeAccountPublicKey, vau
98
98
  // Sort it again since we've changed one vault
99
99
  vaults = vaults.sort(sortVaults);
100
100
  // Pretty print the list again
101
- // console.log('Sorted open vaults with new debt added')
102
- // vaults.forEach((vault) => {
103
- // console.log(vault.toString(vaultPublicKey))
104
- // })
101
+ console.log('Sorted open vaults with new debt added');
102
+ vaults.forEach((vault) => {
103
+ console.log(vault.toString(vaultPublicKey));
104
+ });
105
105
  // Search for the vaults new position
106
106
  let indexAfter = -1;
107
107
  vaults.forEach((vault, index) => {
@@ -110,8 +110,8 @@ function getLinkedListAccounts(program, provider, vaultTypeAccountPublicKey, vau
110
110
  }
111
111
  });
112
112
  // Print where it moved from / to
113
- // console.log('Index Before', indexBefore)
114
- // console.log('Index After', indexAfter)
113
+ console.log('Index Before', indexBefore);
114
+ console.log('Index After', indexAfter);
115
115
  // Save references to the new left and right
116
116
  if (indexAfter > 0) {
117
117
  newSmallerPublicKey = vaults[indexAfter - 1].publicKey;
@@ -120,9 +120,9 @@ function getLinkedListAccounts(program, provider, vaultTypeAccountPublicKey, vau
120
120
  newLargerPublicKey = vaults[indexAfter + 1].publicKey;
121
121
  }
122
122
  // Print out the new left/right
123
- // console.log('oldSmallerPublicKey', oldSmallerPublicKey.toString())
124
- // console.log('newSmallerPublicKey', newSmallerPublicKey.toString())
125
- // console.log('newLargerPublicKey', newLargerPublicKey.toString())
123
+ console.log('oldSmallerPublicKey', oldSmallerPublicKey.toString());
124
+ console.log('newSmallerPublicKey', newSmallerPublicKey.toString());
125
+ console.log('newLargerPublicKey', newLargerPublicKey.toString());
126
126
  return [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, vaults];
127
127
  });
128
128
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedge-web3",
3
- "version": "0.1.35",
3
+ "version": "0.1.38",
4
4
  "description": "Hedge Javascript Web3 API",
5
5
  "main": "lib/index.js",
6
6
  "types": "declarations/index.d.ts",
package/src/idl/vault.ts CHANGED
@@ -1802,18 +1802,6 @@ export type Vault = {
1802
1802
  "type": {
1803
1803
  "kind": "struct",
1804
1804
  "fields": [
1805
- {
1806
- "name": "owner",
1807
- "type": "publicKey"
1808
- },
1809
- {
1810
- "name": "pool",
1811
- "type": "publicKey"
1812
- },
1813
- {
1814
- "name": "deposited",
1815
- "type": "u64"
1816
- },
1817
1805
  {
1818
1806
  "name": "startHedgeRewardAccumulator",
1819
1807
  "type": "u128"
@@ -1852,6 +1840,18 @@ export type Vault = {
1852
1840
  "name": "closedRewardedTokens",
1853
1841
  "type": "u64"
1854
1842
  },
1843
+ {
1844
+ "name": "deposited",
1845
+ "type": "u64"
1846
+ },
1847
+ {
1848
+ "name": "owner",
1849
+ "type": "publicKey"
1850
+ },
1851
+ {
1852
+ "name": "pool",
1853
+ "type": "publicKey"
1854
+ },
1855
1855
  {
1856
1856
  "name": "state",
1857
1857
  "type": {
@@ -4373,18 +4373,6 @@ export const IDL: Vault = {
4373
4373
  "type": {
4374
4374
  "kind": "struct",
4375
4375
  "fields": [
4376
- {
4377
- "name": "owner",
4378
- "type": "publicKey"
4379
- },
4380
- {
4381
- "name": "pool",
4382
- "type": "publicKey"
4383
- },
4384
- {
4385
- "name": "deposited",
4386
- "type": "u64"
4387
- },
4388
4376
  {
4389
4377
  "name": "startHedgeRewardAccumulator",
4390
4378
  "type": "u128"
@@ -4423,6 +4411,18 @@ export const IDL: Vault = {
4423
4411
  "name": "closedRewardedTokens",
4424
4412
  "type": "u64"
4425
4413
  },
4414
+ {
4415
+ "name": "deposited",
4416
+ "type": "u64"
4417
+ },
4418
+ {
4419
+ "name": "owner",
4420
+ "type": "publicKey"
4421
+ },
4422
+ {
4423
+ "name": "pool",
4424
+ "type": "publicKey"
4425
+ },
4426
4426
  {
4427
4427
  "name": "state",
4428
4428
  "type": {
@@ -62,7 +62,6 @@ export async function claimLiquidationPoolPositionInstruction(
62
62
  overrideStartTime?: number
63
63
  ): Promise<TransactionInstruction> {
64
64
 
65
- console.log("inside function")
66
65
  const vaultSystemState = await getVaultSystemStatePublicKey()
67
66
  const poolStatePublicKey = await getLiquidationPoolStatePublicKey()
68
67
  const poolAssociatedTokenAccount = await findAssociatedTokenAddress(poolStatePublicKey, collateralMint)
@@ -19,7 +19,6 @@ import {
19
19
  getVaultSystemStatePublicKey,
20
20
  } from '../Constants'
21
21
  import { Vault } from 'idl/vault'
22
- import { parseAnchorErrors } from 'utils/Errors'
23
22
 
24
23
  export async function loanVault(
25
24
  program: Program<Vault>,
@@ -85,7 +84,7 @@ export async function loanVault(
85
84
  overrideTime
86
85
  )
87
86
  )
88
- await sendAndConfirmTransaction(provider.connection, transaction, [payer, history]).catch(parseAnchorErrors)
87
+ await sendAndConfirmTransaction(provider.connection, transaction, [payer, history])
89
88
  return vaultPublicKey
90
89
  }
91
90
 
@@ -78,10 +78,10 @@ export async function getLinkedListAccounts(
78
78
  }
79
79
 
80
80
  // Pretty print all the vaults before the operation
81
- // console.log('Sorted open vaults before')
82
- // vaults.forEach((vault) => {
83
- // console.log(vault.toString(vaultPublicKey))
84
- // })
81
+ console.log('Sorted open vaults before')
82
+ vaults.forEach((vault) => {
83
+ console.log(vault.toString(vaultPublicKey))
84
+ })
85
85
 
86
86
  // If it wasn't in the list, add it now
87
87
  if (indexBefore < 0) {
@@ -112,10 +112,10 @@ export async function getLinkedListAccounts(
112
112
  vaults = vaults.sort(sortVaults)
113
113
 
114
114
  // Pretty print the list again
115
- // console.log('Sorted open vaults with new debt added')
116
- // vaults.forEach((vault) => {
117
- // console.log(vault.toString(vaultPublicKey))
118
- // })
115
+ console.log('Sorted open vaults with new debt added')
116
+ vaults.forEach((vault) => {
117
+ console.log(vault.toString(vaultPublicKey))
118
+ })
119
119
 
120
120
  // Search for the vaults new position
121
121
  let indexAfter = -1
@@ -126,8 +126,8 @@ export async function getLinkedListAccounts(
126
126
  })
127
127
 
128
128
  // Print where it moved from / to
129
- // console.log('Index Before', indexBefore)
130
- // console.log('Index After', indexAfter)
129
+ console.log('Index Before', indexBefore)
130
+ console.log('Index After', indexAfter)
131
131
 
132
132
  // Save references to the new left and right
133
133
  if (indexAfter > 0) {
@@ -138,9 +138,9 @@ export async function getLinkedListAccounts(
138
138
  }
139
139
 
140
140
  // Print out the new left/right
141
- // console.log('oldSmallerPublicKey', oldSmallerPublicKey.toString())
142
- // console.log('newSmallerPublicKey', newSmallerPublicKey.toString())
143
- // console.log('newLargerPublicKey', newLargerPublicKey.toString())
141
+ console.log('oldSmallerPublicKey', oldSmallerPublicKey.toString())
142
+ console.log('newSmallerPublicKey', newSmallerPublicKey.toString())
143
+ console.log('newLargerPublicKey', newLargerPublicKey.toString())
144
144
 
145
145
  return [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, vaults]
146
146
  }