hedge-web3 0.1.27 → 0.1.31

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 (80) hide show
  1. package/declarations/Constants.d.ts +1 -1
  2. package/declarations/idl/vault.d.ts +277 -126
  3. package/declarations/index.d.ts +3 -0
  4. package/declarations/instructions/claimLiquidationPoolPosition.d.ts +3 -2
  5. package/declarations/instructions/claimStakingPoolPosition.d.ts +3 -2
  6. package/declarations/instructions/closeLiquidationPoolPosition.d.ts +3 -2
  7. package/declarations/instructions/createStakingPool.d.ts +3 -2
  8. package/declarations/instructions/createVault.d.ts +6 -5
  9. package/declarations/instructions/depositLiquidationPool.d.ts +3 -2
  10. package/declarations/instructions/depositStakingPool.d.ts +3 -2
  11. package/declarations/instructions/depositVault.d.ts +3 -2
  12. package/declarations/instructions/initHedgeFoundation.d.ts +3 -2
  13. package/declarations/instructions/liquidateVault.d.ts +3 -2
  14. package/declarations/instructions/loanVault.d.ts +3 -2
  15. package/declarations/instructions/redeemVault.d.ts +3 -2
  16. package/declarations/instructions/refreshOraclePrice.d.ts +3 -2
  17. package/declarations/instructions/repayVault.d.ts +3 -2
  18. package/declarations/instructions/setHalted.d.ts +3 -2
  19. package/declarations/instructions/setVaultTypeStatus.d.ts +5 -0
  20. package/declarations/instructions/withdrawStakingPool.d.ts +3 -2
  21. package/declarations/instructions/withdrawVault.d.ts +3 -2
  22. package/declarations/state/VaultAccount.d.ts +8 -0
  23. package/declarations/utils/getLinkedListAccounts.d.ts +5 -0
  24. package/lib/Constants.js +1 -1
  25. package/lib/idl/vault.js +277 -126
  26. package/lib/index.js +3 -0
  27. package/lib/instructions/claimLiquidationPoolPosition.js +19 -22
  28. package/lib/instructions/claimStakingPoolPosition.js +19 -19
  29. package/lib/instructions/closeLiquidationPoolPosition.js +22 -22
  30. package/lib/instructions/createStakingPool.js +18 -19
  31. package/lib/instructions/createVault.js +28 -31
  32. package/lib/instructions/depositLiquidationPool.js +17 -18
  33. package/lib/instructions/depositStakingPool.js +16 -18
  34. package/lib/instructions/depositVault.js +31 -26
  35. package/lib/instructions/initHedgeFoundation.js +17 -19
  36. package/lib/instructions/initHedgeFoundationTokens.js +15 -15
  37. package/lib/instructions/liquidateVault.js +36 -32
  38. package/lib/instructions/loanVault.js +27 -22
  39. package/lib/instructions/redeemVault.js +28 -23
  40. package/lib/instructions/refreshOraclePrice.js +17 -17
  41. package/lib/instructions/repayVault.js +27 -22
  42. package/lib/instructions/setHalted.js +8 -9
  43. package/lib/instructions/setVaultTypeStatus.js +37 -0
  44. package/lib/instructions/withdrawStakingPool.js +22 -24
  45. package/lib/instructions/withdrawVault.js +30 -25
  46. package/lib/state/LiquidationPoolEra.js +3 -1
  47. package/lib/state/LiquidationPosition.js +0 -7
  48. package/lib/state/StakingPool.js +3 -4
  49. package/lib/state/VaultAccount.js +51 -1
  50. package/lib/utils/getLinkedListAccounts.js +139 -0
  51. package/package.json +4 -2
  52. package/src/Constants.ts +1 -1
  53. package/src/idl/vault.ts +554 -252
  54. package/src/index.ts +4 -0
  55. package/src/instructions/claimLiquidationPoolPosition.ts +39 -29
  56. package/src/instructions/claimStakingPoolPosition.ts +45 -25
  57. package/src/instructions/closeLiquidationPoolPosition.ts +62 -32
  58. package/src/instructions/createStakingPool.ts +38 -37
  59. package/src/instructions/createVault.ts +81 -125
  60. package/src/instructions/depositLiquidationPool.ts +45 -26
  61. package/src/instructions/depositStakingPool.ts +32 -24
  62. package/src/instructions/depositVault.ts +77 -31
  63. package/src/instructions/initHedgeFoundation.ts +42 -43
  64. package/src/instructions/initHedgeFoundationTokens.ts +38 -39
  65. package/src/instructions/liquidateVault.ts +96 -22
  66. package/src/instructions/loanVault.ts +84 -30
  67. package/src/instructions/redeemVault.ts +91 -32
  68. package/src/instructions/refreshOraclePrice.ts +41 -32
  69. package/src/instructions/repayVault.ts +74 -29
  70. package/src/instructions/setHalted.ts +32 -24
  71. package/src/instructions/setVaultTypeStatus.ts +58 -0
  72. package/src/instructions/withdrawStakingPool.ts +44 -30
  73. package/src/instructions/withdrawVault.ts +87 -33
  74. package/src/state/LiquidationPoolEra.ts +4 -3
  75. package/src/state/LiquidationPosition.ts +0 -27
  76. package/src/state/StakingPool.ts +4 -7
  77. package/src/state/StakingPoolPosition.ts +2 -3
  78. package/src/state/VaultAccount.ts +65 -8
  79. package/src/state/VaultHistoryEvent.ts +1 -2
  80. package/src/utils/getLinkedListAccounts.ts +157 -0
package/lib/idl/vault.js CHANGED
@@ -376,10 +376,6 @@ exports.IDL = {
376
376
  "name": "bump1",
377
377
  "type": "u8"
378
378
  },
379
- {
380
- "name": "poolSeedPhraseInput",
381
- "type": "string"
382
- },
383
379
  {
384
380
  "name": "totalRewards",
385
381
  "type": "u64"
@@ -627,11 +623,6 @@ exports.IDL = {
627
623
  "isMut": true,
628
624
  "isSigner": false
629
625
  },
630
- {
631
- "name": "vault",
632
- "isMut": true,
633
- "isSigner": false
634
- },
635
626
  {
636
627
  "name": "vaultAssociatedTokenAccount",
637
628
  "isMut": true,
@@ -672,6 +663,26 @@ exports.IDL = {
672
663
  "isMut": true,
673
664
  "isSigner": false
674
665
  },
666
+ {
667
+ "name": "oldSmallerVaultInfo",
668
+ "isMut": true,
669
+ "isSigner": false
670
+ },
671
+ {
672
+ "name": "newSmallerVaultInfo",
673
+ "isMut": true,
674
+ "isSigner": false
675
+ },
676
+ {
677
+ "name": "newLargerVaultInfo",
678
+ "isMut": false,
679
+ "isSigner": false
680
+ },
681
+ {
682
+ "name": "vault",
683
+ "isMut": true,
684
+ "isSigner": false
685
+ },
675
686
  {
676
687
  "name": "tokenProgram",
677
688
  "isMut": false,
@@ -824,11 +835,6 @@ exports.IDL = {
824
835
  "isMut": true,
825
836
  "isSigner": false
826
837
  },
827
- {
828
- "name": "vaultAccount",
829
- "isMut": true,
830
- "isSigner": false
831
- },
832
838
  {
833
839
  "name": "vaultAssociatedTokenAccount",
834
840
  "isMut": true,
@@ -864,6 +870,26 @@ exports.IDL = {
864
870
  "isMut": true,
865
871
  "isSigner": false
866
872
  },
873
+ {
874
+ "name": "oldSmallerVaultInfo",
875
+ "isMut": true,
876
+ "isSigner": false
877
+ },
878
+ {
879
+ "name": "newSmallerVaultInfo",
880
+ "isMut": true,
881
+ "isSigner": false
882
+ },
883
+ {
884
+ "name": "newLargerVaultInfo",
885
+ "isMut": false,
886
+ "isSigner": false
887
+ },
888
+ {
889
+ "name": "vaultAccount",
890
+ "isMut": true,
891
+ "isSigner": false
892
+ },
867
893
  {
868
894
  "name": "systemProgram",
869
895
  "isMut": false,
@@ -904,11 +930,6 @@ exports.IDL = {
904
930
  "isMut": true,
905
931
  "isSigner": false
906
932
  },
907
- {
908
- "name": "vault",
909
- "isMut": true,
910
- "isSigner": false
911
- },
912
933
  {
913
934
  "name": "vaultAssociatedTokenAccount",
914
935
  "isMut": true,
@@ -949,6 +970,26 @@ exports.IDL = {
949
970
  "isMut": true,
950
971
  "isSigner": false
951
972
  },
973
+ {
974
+ "name": "oldSmallerVaultInfo",
975
+ "isMut": true,
976
+ "isSigner": false
977
+ },
978
+ {
979
+ "name": "newSmallerVaultInfo",
980
+ "isMut": true,
981
+ "isSigner": false
982
+ },
983
+ {
984
+ "name": "newLargerVaultInfo",
985
+ "isMut": false,
986
+ "isSigner": false
987
+ },
988
+ {
989
+ "name": "vault",
990
+ "isMut": true,
991
+ "isSigner": false
992
+ },
952
993
  {
953
994
  "name": "systemProgram",
954
995
  "isMut": false,
@@ -994,11 +1035,6 @@ exports.IDL = {
994
1035
  "isMut": true,
995
1036
  "isSigner": false
996
1037
  },
997
- {
998
- "name": "vaultAccount",
999
- "isMut": true,
1000
- "isSigner": false
1001
- },
1002
1038
  {
1003
1039
  "name": "vaultAssociatedTokenAccount",
1004
1040
  "isMut": true,
@@ -1064,6 +1100,26 @@ exports.IDL = {
1064
1100
  "isMut": true,
1065
1101
  "isSigner": false
1066
1102
  },
1103
+ {
1104
+ "name": "oldSmallerVaultInfo",
1105
+ "isMut": true,
1106
+ "isSigner": false
1107
+ },
1108
+ {
1109
+ "name": "newSmallerVaultInfo",
1110
+ "isMut": true,
1111
+ "isSigner": false
1112
+ },
1113
+ {
1114
+ "name": "newLargerVaultInfo",
1115
+ "isMut": false,
1116
+ "isSigner": false
1117
+ },
1118
+ {
1119
+ "name": "vaultAccount",
1120
+ "isMut": true,
1121
+ "isSigner": false
1122
+ },
1067
1123
  {
1068
1124
  "name": "associatedTokenProgram",
1069
1125
  "isMut": false,
@@ -1155,11 +1211,6 @@ exports.IDL = {
1155
1211
  "isMut": true,
1156
1212
  "isSigner": false
1157
1213
  },
1158
- {
1159
- "name": "vaultAccount",
1160
- "isMut": true,
1161
- "isSigner": false
1162
- },
1163
1214
  {
1164
1215
  "name": "vaultAssociatedTokenAccount",
1165
1216
  "isMut": true,
@@ -1195,6 +1246,26 @@ exports.IDL = {
1195
1246
  "isMut": true,
1196
1247
  "isSigner": false
1197
1248
  },
1249
+ {
1250
+ "name": "oldSmallerVaultInfo",
1251
+ "isMut": true,
1252
+ "isSigner": false
1253
+ },
1254
+ {
1255
+ "name": "newSmallerVaultInfo",
1256
+ "isMut": true,
1257
+ "isSigner": false
1258
+ },
1259
+ {
1260
+ "name": "newLargerVaultInfo",
1261
+ "isMut": false,
1262
+ "isSigner": false
1263
+ },
1264
+ {
1265
+ "name": "vaultAccount",
1266
+ "isMut": true,
1267
+ "isSigner": false
1268
+ },
1198
1269
  {
1199
1270
  "name": "systemProgram",
1200
1271
  "isMut": false,
@@ -1414,11 +1485,6 @@ exports.IDL = {
1414
1485
  "isMut": true,
1415
1486
  "isSigner": false
1416
1487
  },
1417
- {
1418
- "name": "vault",
1419
- "isMut": true,
1420
- "isSigner": false
1421
- },
1422
1488
  {
1423
1489
  "name": "vaultAssociatedTokenAccount",
1424
1490
  "isMut": true,
@@ -1454,6 +1520,26 @@ exports.IDL = {
1454
1520
  "isMut": true,
1455
1521
  "isSigner": false
1456
1522
  },
1523
+ {
1524
+ "name": "oldSmallerVaultInfo",
1525
+ "isMut": true,
1526
+ "isSigner": false
1527
+ },
1528
+ {
1529
+ "name": "newSmallerVaultInfo",
1530
+ "isMut": true,
1531
+ "isSigner": false
1532
+ },
1533
+ {
1534
+ "name": "newLargerVaultInfo",
1535
+ "isMut": false,
1536
+ "isSigner": false
1537
+ },
1538
+ {
1539
+ "name": "vault",
1540
+ "isMut": true,
1541
+ "isSigner": false
1542
+ },
1457
1543
  {
1458
1544
  "name": "systemProgram",
1459
1545
  "isMut": false,
@@ -1475,6 +1561,32 @@ exports.IDL = {
1475
1561
  "type": "i64"
1476
1562
  }
1477
1563
  ]
1564
+ },
1565
+ {
1566
+ "name": "setVaultTypeStatus",
1567
+ "accounts": [
1568
+ {
1569
+ "name": "payer",
1570
+ "isMut": true,
1571
+ "isSigner": true
1572
+ },
1573
+ {
1574
+ "name": "vaultSystemState",
1575
+ "isMut": true,
1576
+ "isSigner": false
1577
+ },
1578
+ {
1579
+ "name": "vaultType",
1580
+ "isMut": true,
1581
+ "isSigner": false
1582
+ }
1583
+ ],
1584
+ "args": [
1585
+ {
1586
+ "name": "deprecated",
1587
+ "type": "bool"
1588
+ }
1589
+ ]
1478
1590
  }
1479
1591
  ],
1480
1592
  "accounts": [
@@ -1688,68 +1800,6 @@ exports.IDL = {
1688
1800
  ]
1689
1801
  }
1690
1802
  },
1691
- {
1692
- "name": "stakingPool",
1693
- "type": {
1694
- "kind": "struct",
1695
- "fields": [
1696
- {
1697
- "name": "halfLifeInDays",
1698
- "type": "u64"
1699
- },
1700
- {
1701
- "name": "deposits",
1702
- "type": "u64"
1703
- },
1704
- {
1705
- "name": "startTime",
1706
- "type": "u64"
1707
- },
1708
- {
1709
- "name": "lastTransactionTime",
1710
- "type": "u64"
1711
- },
1712
- {
1713
- "name": "hedgeRewardAccumulator",
1714
- "type": "u128"
1715
- },
1716
- {
1717
- "name": "ushFeeAccumulator",
1718
- "type": "u128"
1719
- },
1720
- {
1721
- "name": "totalHedgeReward",
1722
- "type": "u64"
1723
- },
1724
- {
1725
- "name": "stakedTokenMint",
1726
- "type": "publicKey"
1727
- },
1728
- {
1729
- "name": "seedPhrase",
1730
- "type": {
1731
- "array": [
1732
- "u8",
1733
- 12
1734
- ]
1735
- }
1736
- },
1737
- {
1738
- "name": "collateralFeeAccumulator",
1739
- "type": {
1740
- "array": [
1741
- "u128",
1742
- 32
1743
- ]
1744
- }
1745
- },
1746
- {
1747
- "name": "bump",
1748
- "type": "u8"
1749
- }
1750
- ]
1751
- }
1752
- },
1753
1803
  {
1754
1804
  "name": "stakingPoolPosition",
1755
1805
  "type": {
@@ -1815,65 +1865,63 @@ exports.IDL = {
1815
1865
  }
1816
1866
  },
1817
1867
  {
1818
- "name": "vault",
1868
+ "name": "stakingPool",
1819
1869
  "type": {
1820
1870
  "kind": "struct",
1821
1871
  "fields": [
1822
1872
  {
1823
- "name": "vaultOwner",
1824
- "type": "publicKey"
1825
- },
1826
- {
1827
- "name": "pdaSalt",
1828
- "type": "string"
1829
- },
1830
- {
1831
- "name": "bump",
1832
- "type": "u8"
1873
+ "name": "halfLifeInDays",
1874
+ "type": "u64"
1833
1875
  },
1834
1876
  {
1835
- "name": "deposited",
1877
+ "name": "deposits",
1836
1878
  "type": "u64"
1837
1879
  },
1838
1880
  {
1839
- "name": "denormalizedDebt",
1881
+ "name": "startTime",
1840
1882
  "type": "u64"
1841
1883
  },
1842
1884
  {
1843
- "name": "vaultVersion",
1885
+ "name": "lastTransactionTime",
1844
1886
  "type": "u64"
1845
1887
  },
1846
1888
  {
1847
- "name": "debtProductSnapshotBytes",
1889
+ "name": "hedgeRewardAccumulator",
1848
1890
  "type": "u128"
1849
1891
  },
1850
1892
  {
1851
- "name": "collateralAccumulatorSnapshotBytes",
1893
+ "name": "ushFeeAccumulator",
1852
1894
  "type": "u128"
1853
1895
  },
1854
1896
  {
1855
- "name": "collateralType",
1856
- "type": "string"
1897
+ "name": "totalHedgeReward",
1898
+ "type": "u64"
1857
1899
  },
1858
1900
  {
1859
- "name": "debtType",
1860
- "type": {
1861
- "defined": "CurrencyType"
1862
- }
1901
+ "name": "stakedTokenMint",
1902
+ "type": "publicKey"
1863
1903
  },
1864
1904
  {
1865
- "name": "vaultStatus",
1905
+ "name": "seedPhrase",
1866
1906
  "type": {
1867
- "defined": "VaultStatus"
1907
+ "array": [
1908
+ "u8",
1909
+ 12
1910
+ ]
1868
1911
  }
1869
1912
  },
1870
1913
  {
1871
- "name": "timeCreated",
1872
- "type": "u64"
1914
+ "name": "collateralFeeAccumulator",
1915
+ "type": {
1916
+ "array": [
1917
+ "u128",
1918
+ 32
1919
+ ]
1920
+ }
1873
1921
  },
1874
1922
  {
1875
- "name": "timeLastInteraction",
1876
- "type": "u64"
1923
+ "name": "bump",
1924
+ "type": "u8"
1877
1925
  }
1878
1926
  ]
1879
1927
  }
@@ -2051,6 +2099,10 @@ exports.IDL = {
2051
2099
  "name": "canBeRedeemed",
2052
2100
  "type": "bool"
2053
2101
  },
2102
+ {
2103
+ "name": "emergencyModeThreshold",
2104
+ "type": "u64"
2105
+ },
2054
2106
  {
2055
2107
  "name": "cumulativeRate",
2056
2108
  "type": "u128"
@@ -2062,6 +2114,90 @@ exports.IDL = {
2062
2114
  {
2063
2115
  "name": "interestRatePerSecond",
2064
2116
  "type": "u128"
2117
+ },
2118
+ {
2119
+ "name": "firstVaultToRedeem",
2120
+ "type": {
2121
+ "option": "publicKey"
2122
+ }
2123
+ },
2124
+ {
2125
+ "name": "deprecated",
2126
+ "type": "bool"
2127
+ }
2128
+ ]
2129
+ }
2130
+ },
2131
+ {
2132
+ "name": "vault",
2133
+ "type": {
2134
+ "kind": "struct",
2135
+ "fields": [
2136
+ {
2137
+ "name": "vaultOwner",
2138
+ "type": "publicKey"
2139
+ },
2140
+ {
2141
+ "name": "vaultNumber",
2142
+ "type": "u64"
2143
+ },
2144
+ {
2145
+ "name": "deposited",
2146
+ "type": "u64"
2147
+ },
2148
+ {
2149
+ "name": "denormalizedDebt",
2150
+ "type": "u64"
2151
+ },
2152
+ {
2153
+ "name": "collateralType",
2154
+ "type": "string"
2155
+ },
2156
+ {
2157
+ "name": "pdaSalt",
2158
+ "type": "string"
2159
+ },
2160
+ {
2161
+ "name": "bump",
2162
+ "type": "u8"
2163
+ },
2164
+ {
2165
+ "name": "vaultVersion",
2166
+ "type": "u64"
2167
+ },
2168
+ {
2169
+ "name": "debtProductSnapshotBytes",
2170
+ "type": "u128"
2171
+ },
2172
+ {
2173
+ "name": "collateralAccumulatorSnapshotBytes",
2174
+ "type": "u128"
2175
+ },
2176
+ {
2177
+ "name": "debtType",
2178
+ "type": {
2179
+ "defined": "CurrencyType"
2180
+ }
2181
+ },
2182
+ {
2183
+ "name": "vaultStatus",
2184
+ "type": {
2185
+ "defined": "VaultStatus"
2186
+ }
2187
+ },
2188
+ {
2189
+ "name": "timeCreated",
2190
+ "type": "u64"
2191
+ },
2192
+ {
2193
+ "name": "timeLastInteraction",
2194
+ "type": "u64"
2195
+ },
2196
+ {
2197
+ "name": "nextVaultToRedeem",
2198
+ "type": {
2199
+ "option": "publicKey"
2200
+ }
2065
2201
  }
2066
2202
  ]
2067
2203
  }
@@ -2351,12 +2487,12 @@ exports.IDL = {
2351
2487
  {
2352
2488
  "code": 6005,
2353
2489
  "name": "VaultClosed",
2354
- "msg": "Vault cannot be liquidated. It is collateralized."
2490
+ "msg": "Vault closed"
2355
2491
  },
2356
2492
  {
2357
2493
  "code": 6006,
2358
2494
  "name": "VaultNotSubjectToLiquidation",
2359
- "msg": "Vault closed"
2495
+ "msg": "Vault cannot be liquidated. It is collateralized."
2360
2496
  },
2361
2497
  {
2362
2498
  "code": 6007,
@@ -2417,6 +2553,21 @@ exports.IDL = {
2417
2553
  "code": 6018,
2418
2554
  "name": "SystemHalted",
2419
2555
  "msg": "System is currently halted. No actions may be taken at this time."
2556
+ },
2557
+ {
2558
+ "code": 6019,
2559
+ "name": "EntireVaultRedeem",
2560
+ "msg": "Entire vault must be redeemed at this time."
2561
+ },
2562
+ {
2563
+ "code": 6020,
2564
+ "name": "RedeemingNonHighestCollateralRatioVault",
2565
+ "msg": "Can only redeem highest collateral ratio vault in system."
2566
+ },
2567
+ {
2568
+ "code": 6021,
2569
+ "name": "VaultTypeDeprecated",
2570
+ "msg": "Vaults of this collateral type are deprecated. No new vaults can be created and no new debt will be issued for this collateral type."
2420
2571
  }
2421
2572
  ]
2422
2573
  };
package/lib/index.js CHANGED
@@ -28,6 +28,7 @@ __exportStar(require("./instructions/refreshOraclePrice"), exports);
28
28
  __exportStar(require("./instructions/initHedgeFoundation"), exports);
29
29
  __exportStar(require("./instructions/initHedgeFoundationTokens"), exports);
30
30
  __exportStar(require("./instructions/setHalted"), exports);
31
+ __exportStar(require("./instructions/setVaultTypeStatus"), exports);
31
32
  __exportStar(require("./HedgeDecimal"), exports);
32
33
  __exportStar(require("./Constants"), exports);
33
34
  __exportStar(require("./state/VaultAccount"), exports);
@@ -37,3 +38,5 @@ __exportStar(require("./state/StakingPoolPosition"), exports);
37
38
  __exportStar(require("./state/LiquidationPoolEra"), exports);
38
39
  __exportStar(require("./state/LiquidationPoolState"), exports);
39
40
  __exportStar(require("./state/LiquidationPosition"), exports);
41
+ __exportStar(require("./utils/getLinkedListAccounts"), exports);
42
+ __exportStar(require("./idl/vault"), exports);
@@ -18,12 +18,12 @@ function claimLiquidationPoolPosition(program, provider, poolPosition, payer, co
18
18
  return __awaiter(this, void 0, void 0, function* () {
19
19
  const vaultTypeAccountPublicKey = yield (0, Constants_1.getVaultTypeAccountPublicKey)(collateralType);
20
20
  const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
21
- const collateralMint = vaultTypeAccountInfo.collateralMint;
21
+ const collateralMintPublicKey = vaultTypeAccountInfo.collateralMint;
22
22
  const poolStatePublicKey = yield (0, Constants_1.getLiquidationPoolStatePublicKey)();
23
- const poolAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(poolStatePublicKey, collateralMint);
24
- const payerAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, payer.publicKey);
25
- const transaction = new web3_js_1.Transaction().add(yield claimLiquidationPoolPositionInstruction(program, poolStatePublicKey, poolAssociatedTokenAccount, vaultTypeAccountPublicKey, collateralMint, poolPosition, payer.publicKey, payerAssociatedTokenAccount.address, overrideStartTime));
26
- yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer], provider.opts).catch(Errors_1.parseAnchorErrors);
23
+ const poolAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(poolStatePublicKey, collateralMintPublicKey);
24
+ const payerAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMintPublicKey, payer.publicKey);
25
+ const transaction = new web3_js_1.Transaction().add(yield claimLiquidationPoolPositionInstruction(program, poolStatePublicKey, poolAssociatedTokenAccount, vaultTypeAccountPublicKey, collateralMintPublicKey, poolPosition, payer.publicKey, payerAssociatedTokenAccount.address, overrideStartTime));
26
+ yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
27
27
  return payerAssociatedTokenAccount.address;
28
28
  });
29
29
  }
@@ -31,23 +31,20 @@ exports.claimLiquidationPoolPosition = claimLiquidationPoolPosition;
31
31
  function claimLiquidationPoolPositionInstruction(program, poolState, poolAssociatedTokenAccount, vaultTypeAccount, collateralMint, poolPosition, payer, payerAssociatedTokenAccount, overrideStartTime) {
32
32
  return __awaiter(this, void 0, void 0, function* () {
33
33
  const vaultSystemState = yield (0, Constants_1.getVaultSystemStatePublicKey)();
34
- return program.instruction.claimLiquidationPoolPosition({
35
- accounts: {
36
- vaultSystemState: vaultSystemState,
37
- poolState: poolState,
38
- poolAssociatedTokenAccount: poolAssociatedTokenAccount,
39
- vaultTypeAccount: vaultTypeAccount,
40
- collateralMint: collateralMint,
41
- poolPosition: poolPosition,
42
- payer: payer,
43
- payerAssociatedTokenAccount: payerAssociatedTokenAccount,
44
- associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
45
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
46
- systemProgram: web3_js_1.SystemProgram.programId,
47
- rent: web3_js_1.SYSVAR_RENT_PUBKEY
48
- },
49
- signers: []
50
- });
34
+ return yield program.methods.claimLiquidationPoolPosition().accounts({
35
+ vaultSystemState: vaultSystemState,
36
+ poolState: poolState,
37
+ poolAssociatedTokenAccount: poolAssociatedTokenAccount,
38
+ vaultTypeAccount: vaultTypeAccount,
39
+ collateralMint: collateralMint,
40
+ poolPosition: poolPosition,
41
+ payer: payer,
42
+ payerAssociatedTokenAccount: payerAssociatedTokenAccount,
43
+ associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
44
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
45
+ systemProgram: web3_js_1.SystemProgram.programId,
46
+ rent: web3_js_1.SYSVAR_RENT_PUBKEY,
47
+ }).instruction();
51
48
  });
52
49
  }
53
50
  exports.claimLiquidationPoolPositionInstruction = claimLiquidationPoolPositionInstruction;