flash-sdk 1.0.61 → 1.0.62

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.
@@ -454,7 +454,7 @@ var PerpetualsClient = (function () {
454
454
  }
455
455
  });
456
456
  }); };
457
- this.addCustody = function (poolName, tokenMint, isStable, oracle, pricing, permissions, fees, borrowRate, ratios) { return __awaiter(_this, void 0, void 0, function () {
457
+ this.addCustody = function (poolName, tokenMint, isStable, isVirtual, oracle, pricing, permissions, fees, borrowRate, ratios) { return __awaiter(_this, void 0, void 0, function () {
458
458
  var trx_id, error_1;
459
459
  return __generator(this, function (_a) {
460
460
  switch (_a.label) {
@@ -463,6 +463,7 @@ var PerpetualsClient = (function () {
463
463
  return [4, this.program.methods
464
464
  .addCustody({
465
465
  isStable: isStable,
466
+ isVirtual: isVirtual,
466
467
  oracle: oracle,
467
468
  pricing: pricing,
468
469
  permissions: permissions,
@@ -566,6 +567,37 @@ var PerpetualsClient = (function () {
566
567
  }
567
568
  });
568
569
  }); };
570
+ this.validateCollectivePnl = function (marketSymbol, collateralSymbol, poolConfig, poolName, side) { return __awaiter(_this, void 0, void 0, function () {
571
+ var marketCustodyConfig, collateralCustodyConfig;
572
+ return __generator(this, function (_a) {
573
+ switch (_a.label) {
574
+ case 0:
575
+ marketCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(marketSymbol).mintKey); });
576
+ collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
577
+ return [4, this.program.methods
578
+ .validateCollectivePnl({ side: side })
579
+ .accounts({
580
+ perpetuals: this.perpetuals.publicKey,
581
+ pool: this.getPoolKey(poolName),
582
+ custody: marketCustodyConfig.custodyAccount,
583
+ custodyOracleAccount: marketCustodyConfig.oracleAddress,
584
+ custodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
585
+ collateralCustody: collateralCustodyConfig.custodyAccount,
586
+ collateralCustodyOracleAccount: collateralCustodyConfig.oracleAddress,
587
+ collateralCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
588
+ })
589
+ .remainingAccounts([])
590
+ .rpc()
591
+ .catch(function (err) {
592
+ console.error(err);
593
+ throw err;
594
+ })];
595
+ case 1:
596
+ _a.sent();
597
+ return [2];
598
+ }
599
+ });
600
+ }); };
569
601
  this.upgradeCustody = function (poolName, tokenMint) { return __awaiter(_this, void 0, void 0, function () {
570
602
  return __generator(this, function (_a) {
571
603
  switch (_a.label) {
@@ -1227,8 +1259,8 @@ var PerpetualsClient = (function () {
1227
1259
  return [4, this.program.methods
1228
1260
  .openPosition(params)
1229
1261
  .accounts({
1262
+ delegate: publicKey,
1230
1263
  owner: publicKey,
1231
- payer: publicKey,
1232
1264
  fundingAccount: collateralSymbol == 'SOL' ? wrappedSolAccount.publicKey : userCollateralTokenAccount,
1233
1265
  transferAuthority: poolConfig.transferAuthority,
1234
1266
  perpetuals: poolConfig.perpetuals,
@@ -1324,8 +1356,8 @@ var PerpetualsClient = (function () {
1324
1356
  return [4, this.program.methods
1325
1357
  .closePosition(params)
1326
1358
  .accounts({
1359
+ delegate: publicKey,
1327
1360
  owner: publicKey,
1328
- payer: publicKey,
1329
1361
  receivingAccount: collateralSymbol == 'SOL' ? wrappedSolAccount.publicKey : userReceivingTokenAccount,
1330
1362
  transferAuthority: poolConfig.transferAuthority,
1331
1363
  perpetuals: poolConfig.perpetuals,
@@ -1535,6 +1567,7 @@ var PerpetualsClient = (function () {
1535
1567
  return [4, this.program.methods
1536
1568
  .swap(params)
1537
1569
  .accounts({
1570
+ delegate: publicKey,
1538
1571
  owner: publicKey,
1539
1572
  fundingAccount: userInputTokenSymbol == 'SOL' ? wrappedSolAccount.publicKey : userInputTokenAccount,
1540
1573
  receivingAccount: userOutputTokenSymbol == 'SOL' ? wrappedSolAccount.publicKey : userOutputTokenAccount,
@@ -1645,6 +1678,7 @@ var PerpetualsClient = (function () {
1645
1678
  case 7: return [4, this.program.methods.addCollateral({
1646
1679
  collateralDelta: collateralWithFee
1647
1680
  }).accounts({
1681
+ delegate: publicKey,
1648
1682
  owner: publicKey,
1649
1683
  position: positionPubKey,
1650
1684
  fundingAccount: collateralSymbol == 'SOL' ? wrappedSolAccount.publicKey : userPayingTokenAccount,
@@ -1741,6 +1775,7 @@ var PerpetualsClient = (function () {
1741
1775
  collateralDelta: collateralWithFee,
1742
1776
  })
1743
1777
  .accounts({
1778
+ delegate: publicKey,
1744
1779
  owner: publicKey,
1745
1780
  receivingAccount: collateralSymbol == 'SOL' ? wrappedSolAccount.publicKey : userReceivingTokenAccount,
1746
1781
  transferAuthority: poolConfig.transferAuthority,
@@ -1779,6 +1814,109 @@ var PerpetualsClient = (function () {
1779
1814
  });
1780
1815
  });
1781
1816
  };
1817
+ this.increaseSize = function (marketSymbol, collateralSymbol, positionPubKey, poolConfig, price, sizeDelta) { return __awaiter(_this, void 0, void 0, function () {
1818
+ var publicKey, collateralCustodyConfig, marketCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, params, instruction;
1819
+ return __generator(this, function (_a) {
1820
+ switch (_a.label) {
1821
+ case 0:
1822
+ publicKey = this.provider.wallet.publicKey;
1823
+ collateralCustodyConfig = poolConfig.custodies.find(function (i) {
1824
+ return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey);
1825
+ });
1826
+ marketCustodyConfig = poolConfig.custodies.find(function (i) {
1827
+ return i.mintKey.equals(poolConfig.getTokenFromSymbol(marketSymbol).mintKey);
1828
+ });
1829
+ if (!collateralCustodyConfig || !marketCustodyConfig) {
1830
+ throw "collateralCustodyConfig/marketCustodyConfig not found";
1831
+ }
1832
+ preInstructions = [];
1833
+ instructions = [];
1834
+ postInstructions = [];
1835
+ additionalSigners = [];
1836
+ params = {
1837
+ price: price,
1838
+ sizeDelta: sizeDelta
1839
+ };
1840
+ return [4, this.program.methods
1841
+ .increaseSize(params)
1842
+ .accounts({
1843
+ delegate: publicKey,
1844
+ owner: publicKey,
1845
+ perpetuals: poolConfig.perpetuals,
1846
+ pool: poolConfig.poolAddress,
1847
+ position: positionPubKey,
1848
+ custody: marketCustodyConfig.custodyAccount,
1849
+ custodyOracleAccount: marketCustodyConfig.oracleAddress,
1850
+ custodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
1851
+ collateralCustody: collateralCustodyConfig.custodyAccount,
1852
+ collateralCustodyOracleAccount: collateralCustodyConfig.oracleAddress,
1853
+ collateralCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
1854
+ eventAuthority: this.eventAuthority.publicKey,
1855
+ program: this.programId,
1856
+ })
1857
+ .instruction()];
1858
+ case 1:
1859
+ instruction = _a.sent();
1860
+ instructions.push(instruction);
1861
+ return [2, {
1862
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
1863
+ additionalSigners: additionalSigners
1864
+ }];
1865
+ }
1866
+ });
1867
+ }); };
1868
+ this.decreaseSize = function (marketSymbol, collateralSymbol, positionPubKey, poolConfig, price, sizeDelta) { return __awaiter(_this, void 0, void 0, function () {
1869
+ var publicKey, collateralCustodyConfig, marketCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, params, instruction;
1870
+ return __generator(this, function (_a) {
1871
+ switch (_a.label) {
1872
+ case 0:
1873
+ publicKey = this.provider.wallet.publicKey;
1874
+ collateralCustodyConfig = poolConfig.custodies.find(function (i) {
1875
+ return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey);
1876
+ });
1877
+ marketCustodyConfig = poolConfig.custodies.find(function (i) {
1878
+ return i.mintKey.equals(poolConfig.getTokenFromSymbol(marketSymbol).mintKey);
1879
+ });
1880
+ if (!collateralCustodyConfig || !marketCustodyConfig) {
1881
+ throw "collateralCustodyConfig/marketCustodyConfig not found";
1882
+ }
1883
+ preInstructions = [];
1884
+ instructions = [];
1885
+ postInstructions = [];
1886
+ additionalSigners = [];
1887
+ params = {
1888
+ price: price,
1889
+ sizeDelta: sizeDelta
1890
+ };
1891
+ return [4, this.program.methods
1892
+ .decreaseSize(params)
1893
+ .accounts({
1894
+ delegate: publicKey,
1895
+ owner: publicKey,
1896
+ perpetuals: poolConfig.perpetuals,
1897
+ pool: poolConfig.poolAddress,
1898
+ position: positionPubKey,
1899
+ custody: marketCustodyConfig.custodyAccount,
1900
+ custodyOracleAccount: marketCustodyConfig.oracleAddress,
1901
+ custodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
1902
+ collateralCustody: collateralCustodyConfig.custodyAccount,
1903
+ collateralCustodyOracleAccount: collateralCustodyConfig.oracleAddress,
1904
+ collateralCustodyCustomOracleAccount: web3_js_1.SystemProgram.programId,
1905
+ collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
1906
+ eventAuthority: this.eventAuthority.publicKey,
1907
+ program: this.programId,
1908
+ })
1909
+ .instruction()];
1910
+ case 1:
1911
+ instruction = _a.sent();
1912
+ instructions.push(instruction);
1913
+ return [2, {
1914
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
1915
+ additionalSigners: additionalSigners
1916
+ }];
1917
+ }
1918
+ });
1919
+ }); };
1782
1920
  this.addLiquidity = function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks) {
1783
1921
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
1784
1922
  return __awaiter(_this, void 0, void 0, function () {
@@ -1880,6 +2018,7 @@ var PerpetualsClient = (function () {
1880
2018
  minLpAmountOut: minLpAmountOut
1881
2019
  })
1882
2020
  .accounts({
2021
+ delegate: publicKey,
1883
2022
  owner: publicKey,
1884
2023
  fundingAccount: payTokenSymbol == 'SOL' ? wrappedSolAccount.publicKey : userPayingTokenAccount,
1885
2024
  lpTokenAccount: lpTokenAccount,
@@ -2001,6 +2140,7 @@ var PerpetualsClient = (function () {
2001
2140
  minAmountOut: minTokenAmountOut
2002
2141
  })
2003
2142
  .accounts({
2143
+ delegate: publicKey,
2004
2144
  owner: publicKey,
2005
2145
  receivingAccount: recieveTokenSymbol == 'SOL' ? wrappedSolAccount.publicKey : userReceivingTokenAccount,
2006
2146
  lpTokenAccount: lpTokenAccount,
@@ -7,16 +7,16 @@
7
7
  },
8
8
  "pools": [
9
9
  {
10
- "programId": "FT9LNjBwCwt4C7A1UiKUHTW7Ds4gJxGBEbqUfJiupSHr",
10
+ "programId": "FT69jb9K5b6uUbvk2BczUoG5bUS9gDPNMRbSk4GRyqw9",
11
11
  "cluster": "devnet",
12
12
  "poolName": "devnet.1",
13
- "poolAddress": "6ScKsHUbEgaidWTBNpo2WzBRwXx4gbvWXitYUNqUFv6p",
14
- "lpTokenMint": "HNnh2dWBt5PKVUCrer85caHqmivPndk6Po5y7XnzcBrg",
13
+ "poolAddress": "9qm6NJrrWejf1SD8jcPsjha5GkK8C6qpqc7Rfm2mnWnS",
14
+ "lpTokenMint": "C5JYa8vWZrkBGexF6rSS1LT1BTGB8gjZmzNPgGke8iyg",
15
15
  "lpDecimals": 6,
16
- "perpetuals": "8iou5Rt7J89uhPwL5kkEcRdwLWwy5AzrWHxRnFqfFkL3",
17
- "transferAuthority": "45McQhLvcCTqKs9ua1c4SauiTWFB4KRfobbwh2h74etc",
18
- "multisig": "3Uj5gn8NA8swzRz6J8LGorhCxPA4eRa6XhnJeeADV3CZ",
19
- "addressLookupTableAddresses": ["2ekzGPUKPzjoesuGrExkMgAEQHVWsaz5FQsyqzJRJGKa"],
16
+ "perpetuals": "ArVyuoPszQtUJ55dLUbfSzgFEd51sGv6e9pa7mY28YSS",
17
+ "transferAuthority": "3SRkyahDfpKu7Z5pBpqqCh3BmNypdqTQTkPihwqJVHch",
18
+ "multisig": "H4qXpG1vtRC6k2FKQ1tCs2Ybu1JrFAAQhR3HpR17pNGk",
19
+ "addressLookupTableAddresses": ["6mft2iEUDTL1SaB5FRWMshF648ELbRZcQm6ZaykCwb81"],
20
20
  "tokens": [
21
21
  {
22
22
  "symbol": "USDC",
@@ -62,8 +62,8 @@
62
62
  "custodies": [
63
63
  {
64
64
  "custodyId": 0,
65
- "custodyAccount": "5Yy4UN3BiG2XGpdnAaZzZiHrLP74v2DPrrR7pseQm34e",
66
- "tokenAccount": "GwBjqN7tuRsJhqZJPXLHRXFadToNf4xHqFAnaJUV3C14",
65
+ "custodyAccount": "FuRBCva68Gv33hw8VEuR54wYhYUYWEu25YoJEvegk9XD",
66
+ "tokenAccount": "FqgWhmYve2bDwMnVJ4sqa7SYCBxZsqNLTvxu67NeYxUc",
67
67
  "symbol": "USDC",
68
68
  "mintKey": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr",
69
69
  "decimals": 6,
@@ -73,8 +73,8 @@
73
73
  },
74
74
  {
75
75
  "custodyId": 1,
76
- "custodyAccount": "EDM5BrduPuHyzTaJS3rSYDR5ZSJGFKfSQ5hcsf5Ybjof",
77
- "tokenAccount": "VdcLYqXk9mCZ4jPknTWijpeofLx7s55S5r5PmwbA8id",
76
+ "custodyAccount": "EFPba9AupUjA2p2m1uwuUNhtcAavmr4Q6CQQXqcjmQLW",
77
+ "tokenAccount": "FLzLLpZ4ddmPrb6d5qmMnVJrR4bqnqT2bjKDLdKyzZgH",
78
78
  "symbol": "SOL",
79
79
  "mintKey": "So11111111111111111111111111111111111111112",
80
80
  "decimals": 9,
@@ -84,8 +84,8 @@
84
84
  },
85
85
  {
86
86
  "custodyId": 2,
87
- "custodyAccount": "ApcBg9AHcuYXW8657V66kLAHDaCVUNKhoNDTTBYhrANL",
88
- "tokenAccount": "CqXFTWCBKne7hYZNXYfRPqLjF4pnys5om9nhgDt8vxfd",
87
+ "custodyAccount": "9N8GUwUXgem1Fb4xx3oFJYMMK92vs52TNGxh34Nvo1vs",
88
+ "tokenAccount": "BT6Yf1dzmkPy5hoXotEz7T32gWj2EuLony175Zefv41N",
89
89
  "symbol": "BTC",
90
90
  "mintKey": "B8DYqbh57aEPRbUq7reyueY6jaYoN75js5YsiM84tFfP",
91
91
  "decimals": 6,
@@ -95,8 +95,8 @@
95
95
  },
96
96
  {
97
97
  "custodyId": 3,
98
- "custodyAccount": "EbaGMJApw6hRu3Hnzm2CbhZjtHJLNJDdP2vn7s5SQH6M",
99
- "tokenAccount": "GEcw5RUT6dA31NwaoMkndXk8hCuUMUZ5yJuXJ5DE6mp3",
98
+ "custodyAccount": "BpTqads4ycN1JKeypKWtkvgymzT482fNKERxNCJSrkrn",
99
+ "tokenAccount": "71gLW8JMtf3AZ1Xb5gJcVyj4kyAAxrCqRGuqCmrJVkhZ",
100
100
  "symbol": "ETH",
101
101
  "mintKey": "BA17bkYW78GvnirtgRHcceQxZdwkhpzbvrwDU6voUXRz",
102
102
  "decimals": 6,