flash-sdk 12.0.0 → 12.0.1

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 (47) hide show
  1. package/dist/CustodyAccount.d.ts +1 -1
  2. package/dist/MarketAccount.d.ts +2 -2
  3. package/dist/OraclePrice.d.ts +0 -1
  4. package/dist/OrderAccount.d.ts +0 -1
  5. package/dist/PerpetualsClient.d.ts +325 -4360
  6. package/dist/PerpetualsClient.js +1205 -558
  7. package/dist/PoolAccount.d.ts +0 -1
  8. package/dist/PoolConfig.d.ts +3 -1
  9. package/dist/PoolConfig.js +30 -2
  10. package/dist/PoolConfig.json +955 -133
  11. package/dist/PoolDataClient.d.ts +0 -1
  12. package/dist/PositionAccount.d.ts +3 -3
  13. package/dist/TokenStakeAccount.d.ts +0 -1
  14. package/dist/TokenVaultAccount.d.ts +0 -1
  15. package/dist/ViewHelper.d.ts +2 -1
  16. package/dist/ViewHelper.js +11 -8
  17. package/dist/backupOracle.js +27 -6
  18. package/dist/constants/index.d.ts +0 -1
  19. package/dist/idl/perpetuals.d.ts +26433 -13458
  20. package/dist/idl/perpetuals.js +0 -18010
  21. package/dist/idl/perpetuals.json +30985 -0
  22. package/dist/index.d.ts +3 -1
  23. package/dist/index.js +6 -2
  24. package/dist/remoraTokensWithPriceIds.d.ts +13 -0
  25. package/dist/remoraTokensWithPriceIds.js +265 -0
  26. package/dist/testPublkey.d.ts +0 -0
  27. package/dist/testPublkey.js +0 -0
  28. package/dist/tsconfig.tsbuildinfo +1 -1
  29. package/dist/types/generated.d.ts +2275 -0
  30. package/dist/types/generated.js +2 -0
  31. package/dist/types/index.d.ts +47 -160
  32. package/dist/types/index.js +22 -6
  33. package/dist/utils/IdlCoder.d.ts +3 -2
  34. package/dist/utils/IdlCoder.js +21 -9
  35. package/dist/utils/alt.js +5 -6
  36. package/dist/utils/anchorCpiEvents.d.ts +1 -2
  37. package/dist/utils/anchorCpiEvents.js +14 -10
  38. package/dist/utils/index.js +6 -6
  39. package/dist/utils/rpc.js +9 -9
  40. package/package.json +3 -3
  41. package/readme.md +37 -3
  42. package/dist/idl/fbnft_rewards.d.ts +0 -290
  43. package/dist/idl/fbnft_rewards.js +0 -292
  44. package/dist/idl/perp_composability.d.ts +0 -760
  45. package/dist/idl/perp_composability.js +0 -762
  46. package/dist/idl/reward_distribution.d.ts +0 -347
  47. package/dist/idl/reward_distribution.js +0 -349
@@ -1,4 +1,3 @@
1
- /// <reference types="bn.js" />
2
1
  import { BN } from "@coral-xyz/anchor";
3
2
  import { Pool, TokenRatios, StakeStats, CompoundingStats, Permissions } from "./types";
4
3
  import { PublicKey } from "@solana/web3.js";
@@ -87,13 +87,14 @@ export declare class PoolConfig {
87
87
  tokens: Token[];
88
88
  custodies: CustodyConfig[];
89
89
  markets: MarketConfig[];
90
+ marketsDeprecated: MarketConfig[];
90
91
  constructor(programId: PublicKey, perpComposibilityProgramId: PublicKey, fbNftRewardProgramId: PublicKey, cluster: Cluster, poolName: string, poolAddress: PublicKey, stakedLpTokenMint: PublicKey, compoundingTokenMint: PublicKey, stakedLpVault: PublicKey, compoundingLpVault: PublicKey, lpDecimals: number, compoundingLpTokenSymbol: string, stakedLpTokenSymbol: string, perpetuals: PublicKey, transferAuthority: PublicKey, tokenMint: PublicKey, tokenVault: PublicKey, tokenVaultTokenAccount: PublicKey, rebateVault: PublicKey, rebateTokenAccount: PublicKey, revenueTokenAccount: PublicKey, protocolVault: PublicKey, protocolTokenAccount: PublicKey, multisig: PublicKey, addressLookupTableAddresses: PublicKey[], pusherAddressLookupTableAddress: PublicKey, backupOracle: PublicKey, nftCollectionAddress: PublicKey, rewardDistributionProgram: {
91
92
  programId: PublicKey;
92
93
  transferAuthority: PublicKey;
93
94
  rewardVault: PublicKey;
94
95
  rewardMint: PublicKey;
95
96
  rewardTokenAccount: PublicKey;
96
- }, tokens: Token[], custodies: CustodyConfig[], markets: MarketConfig[]);
97
+ }, tokens: Token[], custodies: CustodyConfig[], markets: MarketConfig[], marketsDeprecated: MarketConfig[]);
97
98
  getAllTokenMints(): PublicKey[];
98
99
  getMarketConfigByPk(marketAccountPk: PublicKey): MarketConfig;
99
100
  getMarketConfig(targetCustody: PublicKey, collateralCustody: PublicKey, side: Side): MarketConfig | null;
@@ -101,6 +102,7 @@ export declare class PoolConfig {
101
102
  getPositionFromMarketPk(owner: PublicKey, marketAccount: PublicKey): PublicKey;
102
103
  getOrderFromMarketPk(owner: PublicKey, marketAccount: PublicKey): PublicKey;
103
104
  getPositionFromCustodyPk(owner: PublicKey, targetCustody: PublicKey, collateralCustody: PublicKey, side: Side): PublicKey;
105
+ getOrderFromCustodyPk(owner: PublicKey, targetCustody: PublicKey, collateralCustody: PublicKey, side: Side): PublicKey;
104
106
  doesMarketExist(pubkey: PublicKey): boolean;
105
107
  getAllMarketPks(): PublicKey[];
106
108
  getNonStableTokens(): PublicKey[];
@@ -19,7 +19,7 @@ var web3_js_1 = require("@solana/web3.js");
19
19
  var PoolConfig_json_1 = __importDefault(require("./PoolConfig.json"));
20
20
  var types_1 = require("./types");
21
21
  var PoolConfig = (function () {
22
- function PoolConfig(programId, perpComposibilityProgramId, fbNftRewardProgramId, cluster, poolName, poolAddress, stakedLpTokenMint, compoundingTokenMint, stakedLpVault, compoundingLpVault, lpDecimals, compoundingLpTokenSymbol, stakedLpTokenSymbol, perpetuals, transferAuthority, tokenMint, tokenVault, tokenVaultTokenAccount, rebateVault, rebateTokenAccount, revenueTokenAccount, protocolVault, protocolTokenAccount, multisig, addressLookupTableAddresses, pusherAddressLookupTableAddress, backupOracle, nftCollectionAddress, rewardDistributionProgram, tokens, custodies, markets) {
22
+ function PoolConfig(programId, perpComposibilityProgramId, fbNftRewardProgramId, cluster, poolName, poolAddress, stakedLpTokenMint, compoundingTokenMint, stakedLpVault, compoundingLpVault, lpDecimals, compoundingLpTokenSymbol, stakedLpTokenSymbol, perpetuals, transferAuthority, tokenMint, tokenVault, tokenVaultTokenAccount, rebateVault, rebateTokenAccount, revenueTokenAccount, protocolVault, protocolTokenAccount, multisig, addressLookupTableAddresses, pusherAddressLookupTableAddress, backupOracle, nftCollectionAddress, rewardDistributionProgram, tokens, custodies, markets, marketsDeprecated) {
23
23
  var _this = this;
24
24
  this.programId = programId;
25
25
  this.perpComposibilityProgramId = perpComposibilityProgramId;
@@ -53,6 +53,7 @@ var PoolConfig = (function () {
53
53
  this.tokens = tokens;
54
54
  this.custodies = custodies;
55
55
  this.markets = markets;
56
+ this.marketsDeprecated = marketsDeprecated;
56
57
  this.getTokenFromSymbol = function (symbol) {
57
58
  return _this.tokens.find(function (f) { return f.symbol.toUpperCase() === symbol.toUpperCase(); });
58
59
  };
@@ -68,6 +69,9 @@ var PoolConfig = (function () {
68
69
  };
69
70
  PoolConfig.prototype.getMarketConfigByPk = function (marketAccountPk) {
70
71
  var market = this.markets.find(function (f) { return f.marketAccount.equals(marketAccountPk); });
72
+ if (!market) {
73
+ market = this.marketsDeprecated.find(function (f) { return f.marketAccount.equals(marketAccountPk); });
74
+ }
71
75
  if (!market)
72
76
  throw new Error("No such market ".concat(marketAccountPk.toBase58(), " exists."));
73
77
  return market;
@@ -75,6 +79,9 @@ var PoolConfig = (function () {
75
79
  PoolConfig.prototype.getMarketConfig = function (targetCustody, collateralCustody, side) {
76
80
  var marketAccountPk = this.getMarketPk(targetCustody, collateralCustody, side);
77
81
  var market = this.markets.find(function (f) { return f.marketAccount.equals(marketAccountPk); });
82
+ if (!market) {
83
+ market = this.marketsDeprecated.find(function (f) { return f.marketAccount.equals(marketAccountPk); });
84
+ }
78
85
  if (!market)
79
86
  return null;
80
87
  return market;
@@ -108,6 +115,13 @@ var PoolConfig = (function () {
108
115
  this.getMarketPk(targetCustody, collateralCustody, side).toBuffer(),
109
116
  ], this.programId)[0];
110
117
  };
118
+ PoolConfig.prototype.getOrderFromCustodyPk = function (owner, targetCustody, collateralCustody, side) {
119
+ return web3_js_1.PublicKey.findProgramAddressSync([
120
+ Buffer.from("order"),
121
+ owner.toBuffer(),
122
+ this.getMarketPk(targetCustody, collateralCustody, side).toBuffer(),
123
+ ], this.programId)[0];
124
+ };
111
125
  PoolConfig.prototype.doesMarketExist = function (pubkey) {
112
126
  return;
113
127
  };
@@ -189,13 +203,27 @@ var PoolConfig = (function () {
189
203
  catch (error) {
190
204
  console.log("ERROR: buildPoolconfigFromJson unable to load markets ");
191
205
  }
206
+ var marketsDeprecated;
207
+ try {
208
+ if (!poolConfig['marketsDeprecated']) {
209
+ marketsDeprecated = [];
210
+ }
211
+ else {
212
+ marketsDeprecated = poolConfig['marketsDeprecated'].map(function (i) {
213
+ return __assign(__assign({}, i), { marketAccount: new web3_js_1.PublicKey(i.marketAccount), marketCorrelation: i.marketCorrelation, pool: new web3_js_1.PublicKey(i.pool), targetCustody: new web3_js_1.PublicKey(i.targetCustody), collateralCustody: new web3_js_1.PublicKey(i.collateralCustody), side: i.side === 'long' ? types_1.Side.Long : types_1.Side.Short, maxLev: i.maxLev, degenMinLev: i.degenMinLev, degenMaxLev: i.degenMaxLev, targetMint: new web3_js_1.PublicKey(i.targetMint), collateralMint: new web3_js_1.PublicKey(i.collateralMint) });
214
+ });
215
+ }
216
+ }
217
+ catch (error) {
218
+ console.log("ERROR: buildPoolconfigFromJson unable to load markets ");
219
+ }
192
220
  return new PoolConfig(new web3_js_1.PublicKey(poolConfig.programId), new web3_js_1.PublicKey(poolConfig.perpComposibilityProgramId), new web3_js_1.PublicKey(poolConfig.fbNftRewardProgramId), poolConfig.cluster, poolConfig.poolName, new web3_js_1.PublicKey(poolConfig.poolAddress), new web3_js_1.PublicKey(poolConfig.stakedLpTokenMint), new web3_js_1.PublicKey(poolConfig.compoundingTokenMint), new web3_js_1.PublicKey(poolConfig.stakedLpVault), new web3_js_1.PublicKey(poolConfig.compoundingLpVault), poolConfig.lpDecimals, poolConfig.compoundingLpTokenSymbol, poolConfig.stakedLpTokenSymbol, new web3_js_1.PublicKey(poolConfig.perpetuals), new web3_js_1.PublicKey(poolConfig.transferAuthority), new web3_js_1.PublicKey(poolConfig.tokenMint), new web3_js_1.PublicKey(poolConfig.tokenVault), new web3_js_1.PublicKey(poolConfig.tokenVaultTokenAccount), new web3_js_1.PublicKey(poolConfig.rebateVault), new web3_js_1.PublicKey(poolConfig.rebateTokenAccount), new web3_js_1.PublicKey(poolConfig.revenueTokenAccount), new web3_js_1.PublicKey(poolConfig.protocolVault), new web3_js_1.PublicKey(poolConfig.protocolTokenAccount), new web3_js_1.PublicKey(poolConfig.multisig), addressLookupTableAddresses, pusherAddressLookupTableAddress, new web3_js_1.PublicKey(poolConfig.backupOracle), new web3_js_1.PublicKey(poolConfig.nftCollectionAddress), {
193
221
  programId: new web3_js_1.PublicKey(poolConfig.rewardDistributionProgram.programId),
194
222
  rewardMint: new web3_js_1.PublicKey(poolConfig.rewardDistributionProgram.rewardMint),
195
223
  rewardTokenAccount: new web3_js_1.PublicKey(poolConfig.rewardDistributionProgram.rewardTokenAccount),
196
224
  rewardVault: new web3_js_1.PublicKey(poolConfig.rewardDistributionProgram.rewardVault),
197
225
  transferAuthority: new web3_js_1.PublicKey(poolConfig.rewardDistributionProgram.transferAuthority),
198
- }, tokens, custodies, markets);
226
+ }, tokens, custodies, markets, marketsDeprecated);
199
227
  };
200
228
  PoolConfig.fromIdsByName = function (name, cluster) {
201
229
  var poolConfig = PoolConfig_json_1.default.pools.find(function (pool) { return pool['poolName'] === name && cluster === pool['cluster']; });