flash-sdk 1.0.134 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/CustodyAccount.d.ts +6 -8
- package/dist/CustodyAccount.js +0 -21
- package/dist/MarketAccount.d.ts +23 -0
- package/dist/MarketAccount.js +42 -0
- package/dist/OraclePrice.d.ts +2 -0
- package/dist/OraclePrice.js +12 -4
- package/dist/PerpetualsClient.d.ts +1500 -976
- package/dist/PerpetualsClient.js +1410 -825
- package/dist/PoolAccount.d.ts +13 -3
- package/dist/PoolConfig.d.ts +25 -1
- package/dist/PoolConfig.js +61 -18
- package/dist/PoolConfig.json +582 -142
- package/dist/PoolDataClient.d.ts +2 -9
- package/dist/PoolDataClient.js +1 -43
- package/dist/PositionAccount.d.ts +14 -12
- package/dist/TradingAccount.d.ts +20 -0
- package/dist/TradingAccount.js +17 -0
- package/dist/backupOracle.js +16 -3
- package/dist/constants/index.d.ts +2 -2
- package/dist/constants/index.js +3 -2
- package/dist/idl/perp_composability.d.ts +132 -86
- package/dist/idl/perp_composability.js +132 -86
- package/dist/idl/perpetuals.d.ts +2276 -1102
- package/dist/idl/perpetuals.js +2250 -1076
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +24 -2
- package/dist/types/index.js +23 -12
- package/dist/utils/getNftAccounts.d.ts +7 -0
- package/dist/utils/getNftAccounts.js +28 -0
- package/package.json +1 -1
package/dist/PoolAccount.d.ts
CHANGED
@@ -1,16 +1,26 @@
|
|
1
1
|
/// <reference types="bn.js" />
|
2
2
|
import { BN } from "@coral-xyz/anchor";
|
3
|
-
import { Pool, TokenRatios } from "./types";
|
3
|
+
import { Pool, TokenRatios, StakeStats, Permissions } from "./types";
|
4
4
|
import { PublicKey } from "@solana/web3.js";
|
5
5
|
export declare class PoolAccount implements Pool {
|
6
6
|
publicKey: PublicKey;
|
7
7
|
name: string;
|
8
|
+
permissions: Permissions;
|
9
|
+
inceptionTime: BN;
|
10
|
+
flpMint: PublicKey;
|
11
|
+
oracleAuthority: PublicKey;
|
12
|
+
flpTokenAccount: PublicKey;
|
13
|
+
rewardCustody: PublicKey;
|
8
14
|
custodies: PublicKey[];
|
9
15
|
ratios: TokenRatios[];
|
16
|
+
markets: PublicKey[];
|
17
|
+
maxAumUsd: BN;
|
10
18
|
aumUsd: BN;
|
19
|
+
totalStaked: StakeStats;
|
20
|
+
stakingFeeShareBps: BN;
|
11
21
|
bump: number;
|
12
|
-
|
13
|
-
|
22
|
+
flpMintBump: number;
|
23
|
+
flpTokenAccountBump: number;
|
14
24
|
constructor(publicKey: PublicKey, parseData: Pool);
|
15
25
|
static from(publicKey: PublicKey, parseData: Pool): PoolAccount;
|
16
26
|
updatePoolData(parseData: Pool): void;
|
package/dist/PoolConfig.d.ts
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import { Address } from '@coral-xyz/anchor';
|
2
2
|
import { Cluster, PublicKey } from '@solana/web3.js';
|
3
|
+
import poolConfigs from './PoolConfig.json';
|
4
|
+
import { Side } from './types';
|
3
5
|
export interface CustodyConfig {
|
4
6
|
custodyId: number;
|
5
7
|
custodyAccount: PublicKey;
|
@@ -11,6 +13,18 @@ export interface CustodyConfig {
|
|
11
13
|
isVirtual: boolean;
|
12
14
|
oracleAddress: PublicKey;
|
13
15
|
}
|
16
|
+
export interface MarketConfig {
|
17
|
+
marketId: number;
|
18
|
+
marketAccount: PublicKey;
|
19
|
+
pool: PublicKey;
|
20
|
+
targetCustody: PublicKey;
|
21
|
+
collateralCustody: PublicKey;
|
22
|
+
side: Side;
|
23
|
+
targetCustodyId: number;
|
24
|
+
collateralCustodyId: number;
|
25
|
+
targetMint: PublicKey;
|
26
|
+
collateralMint: PublicKey;
|
27
|
+
}
|
14
28
|
export type Token = {
|
15
29
|
symbol: string;
|
16
30
|
mintKey: PublicKey;
|
@@ -34,10 +48,19 @@ export declare class PoolConfig {
|
|
34
48
|
multisig: PublicKey;
|
35
49
|
addressLookupTableAddresses: PublicKey[];
|
36
50
|
backupOracle: PublicKey;
|
51
|
+
nftCollectionAddress: PublicKey;
|
37
52
|
tokens: Token[];
|
38
53
|
custodies: CustodyConfig[];
|
39
|
-
|
54
|
+
markets: MarketConfig[];
|
55
|
+
constructor(programId: PublicKey, perpComposibilityProgramId: PublicKey, cluster: Cluster, poolName: string, poolAddress: PublicKey, lpTokenMint: PublicKey, lpDecimals: number, lpTokenSymbol: string, perpetuals: PublicKey, transferAuthority: PublicKey, multisig: PublicKey, addressLookupTableAddresses: PublicKey[], backupOracle: PublicKey, nftCollectionAddress: PublicKey, tokens: Token[], custodies: CustodyConfig[], markets: MarketConfig[]);
|
40
56
|
getAllTokenMints(): PublicKey[];
|
57
|
+
getMarketConfigByPk(marketAccountPk: PublicKey): MarketConfig;
|
58
|
+
getMarketConfig(targetCustody: PublicKey, collateralCustody: PublicKey, side: Side): MarketConfig | null;
|
59
|
+
getMarketPk(targetCustody: PublicKey, collateralCustody: PublicKey, side: Side): PublicKey;
|
60
|
+
getPositionFromMarketPk(owner: PublicKey, marketAccount: PublicKey): PublicKey;
|
61
|
+
getPositionFromCustodyPk(owner: PublicKey, targetCustody: PublicKey, collateralCustody: PublicKey, side: Side): PublicKey;
|
62
|
+
doesMarketExist(pubkey: PublicKey): boolean;
|
63
|
+
getAllMarketPks(): PublicKey[];
|
41
64
|
getNonStableTokens(): PublicKey[];
|
42
65
|
getAllCustodies(): PublicKey[];
|
43
66
|
getNonStableCustodies(): PublicKey[];
|
@@ -48,6 +71,7 @@ export declare class PoolConfig {
|
|
48
71
|
getCustodyIdFromCustodyAccount(custodyAccountPk: Address): number;
|
49
72
|
getCustodyAccountFromCustodyId(custodyId: number): PublicKey;
|
50
73
|
static getTokensInPool(name: string, cluster: Cluster): Token[];
|
74
|
+
static buildPoolconfigFromJson(poolConfig: typeof poolConfigs['pools'][0]): PoolConfig;
|
51
75
|
static fromIdsByName(name: string, cluster: Cluster): PoolConfig;
|
52
76
|
static fromIdsByPk(poolPk: PublicKey, cluster: Cluster): PoolConfig;
|
53
77
|
}
|
package/dist/PoolConfig.js
CHANGED
@@ -17,8 +17,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.PoolConfig = void 0;
|
18
18
|
var web3_js_1 = require("@solana/web3.js");
|
19
19
|
var PoolConfig_json_1 = __importDefault(require("./PoolConfig.json"));
|
20
|
+
var types_1 = require("./types");
|
20
21
|
var PoolConfig = (function () {
|
21
|
-
function PoolConfig(programId, perpComposibilityProgramId, cluster, poolName, poolAddress, lpTokenMint, lpDecimals, lpTokenSymbol, perpetuals, transferAuthority, multisig, addressLookupTableAddresses, backupOracle, tokens, custodies) {
|
22
|
+
function PoolConfig(programId, perpComposibilityProgramId, cluster, poolName, poolAddress, lpTokenMint, lpDecimals, lpTokenSymbol, perpetuals, transferAuthority, multisig, addressLookupTableAddresses, backupOracle, nftCollectionAddress, tokens, custodies, markets) {
|
22
23
|
var _this = this;
|
23
24
|
this.programId = programId;
|
24
25
|
this.perpComposibilityProgramId = perpComposibilityProgramId;
|
@@ -33,8 +34,10 @@ var PoolConfig = (function () {
|
|
33
34
|
this.multisig = multisig;
|
34
35
|
this.addressLookupTableAddresses = addressLookupTableAddresses;
|
35
36
|
this.backupOracle = backupOracle;
|
37
|
+
this.nftCollectionAddress = nftCollectionAddress;
|
36
38
|
this.tokens = tokens;
|
37
39
|
this.custodies = custodies;
|
40
|
+
this.markets = markets;
|
38
41
|
this.getTokenFromSymbol = function (symbol) {
|
39
42
|
return _this.tokens.find(function (f) { return f.symbol.toUpperCase() === symbol.toUpperCase(); });
|
40
43
|
};
|
@@ -48,6 +51,47 @@ var PoolConfig = (function () {
|
|
48
51
|
PoolConfig.prototype.getAllTokenMints = function () {
|
49
52
|
return Array.from(this.tokens.map(function (token) { return new web3_js_1.PublicKey(token.mintKey); }));
|
50
53
|
};
|
54
|
+
PoolConfig.prototype.getMarketConfigByPk = function (marketAccountPk) {
|
55
|
+
var market = this.markets.find(function (f) { return f.marketAccount.equals(marketAccountPk); });
|
56
|
+
if (!market)
|
57
|
+
throw new Error("No such market ".concat(marketAccountPk.toBase58(), " exists."));
|
58
|
+
return market;
|
59
|
+
};
|
60
|
+
PoolConfig.prototype.getMarketConfig = function (targetCustody, collateralCustody, side) {
|
61
|
+
var marketAccountPk = this.getMarketPk(targetCustody, collateralCustody, side);
|
62
|
+
var market = this.markets.find(function (f) { return f.marketAccount.equals(marketAccountPk); });
|
63
|
+
if (!market)
|
64
|
+
return null;
|
65
|
+
return market;
|
66
|
+
};
|
67
|
+
PoolConfig.prototype.getMarketPk = function (targetCustody, collateralCustody, side) {
|
68
|
+
return web3_js_1.PublicKey.findProgramAddressSync([
|
69
|
+
Buffer.from('market'),
|
70
|
+
targetCustody.toBuffer(),
|
71
|
+
collateralCustody.toBuffer(),
|
72
|
+
Buffer.from([(0, types_1.isVariant)(side, 'long') ? 1 : 2])
|
73
|
+
], this.programId)[0];
|
74
|
+
};
|
75
|
+
PoolConfig.prototype.getPositionFromMarketPk = function (owner, marketAccount) {
|
76
|
+
return web3_js_1.PublicKey.findProgramAddressSync([
|
77
|
+
Buffer.from("position"),
|
78
|
+
owner.toBuffer(),
|
79
|
+
marketAccount.toBuffer(),
|
80
|
+
], this.programId)[0];
|
81
|
+
};
|
82
|
+
PoolConfig.prototype.getPositionFromCustodyPk = function (owner, targetCustody, collateralCustody, side) {
|
83
|
+
return web3_js_1.PublicKey.findProgramAddressSync([
|
84
|
+
Buffer.from("position"),
|
85
|
+
owner.toBuffer(),
|
86
|
+
this.getMarketPk(targetCustody, collateralCustody, side).toBuffer(),
|
87
|
+
], this.programId)[0];
|
88
|
+
};
|
89
|
+
PoolConfig.prototype.doesMarketExist = function (pubkey) {
|
90
|
+
return;
|
91
|
+
};
|
92
|
+
PoolConfig.prototype.getAllMarketPks = function () {
|
93
|
+
return this.markets.map(function (m) { return m.marketAccount; });
|
94
|
+
};
|
51
95
|
PoolConfig.prototype.getNonStableTokens = function () {
|
52
96
|
return Array.from(this.tokens
|
53
97
|
.filter(function (token) { return !token.isStable; })
|
@@ -79,10 +123,7 @@ var PoolConfig = (function () {
|
|
79
123
|
});
|
80
124
|
return tokens;
|
81
125
|
};
|
82
|
-
PoolConfig.
|
83
|
-
var poolConfig = PoolConfig_json_1.default.pools.find(function (pool) { return pool['poolName'] === name && cluster === pool['cluster']; });
|
84
|
-
if (!poolConfig)
|
85
|
-
throw new Error("No pool config ".concat(name, " found in Ids!"));
|
126
|
+
PoolConfig.buildPoolconfigFromJson = function (poolConfig) {
|
86
127
|
var tokens = poolConfig['tokens'].map(function (i) {
|
87
128
|
return __assign(__assign({}, i), { mintKey: new web3_js_1.PublicKey(i.mintKey) });
|
88
129
|
});
|
@@ -93,22 +134,24 @@ var PoolConfig = (function () {
|
|
93
134
|
var addressLookupTableAddresses = poolConfig['addressLookupTableAddresses'].map(function (i) {
|
94
135
|
return new web3_js_1.PublicKey(i);
|
95
136
|
});
|
96
|
-
|
137
|
+
var markets = poolConfig['markets'].map(function (i) {
|
138
|
+
return __assign(__assign({}, i), { marketAccount: new web3_js_1.PublicKey(i.marketAccount), 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, targetMint: new web3_js_1.PublicKey(i.targetMint), collateralMint: new web3_js_1.PublicKey(i.collateralMint) });
|
139
|
+
});
|
140
|
+
return new PoolConfig(new web3_js_1.PublicKey(poolConfig.programId), new web3_js_1.PublicKey(poolConfig.perpComposibilityProgramId), poolConfig.cluster, poolConfig.poolName, new web3_js_1.PublicKey(poolConfig.poolAddress), new web3_js_1.PublicKey(poolConfig.lpTokenMint), poolConfig.lpDecimals, poolConfig.lpTokenSymbol, new web3_js_1.PublicKey(poolConfig.perpetuals), new web3_js_1.PublicKey(poolConfig.transferAuthority), new web3_js_1.PublicKey(poolConfig.multisig), addressLookupTableAddresses, new web3_js_1.PublicKey(poolConfig.backupOracle), new web3_js_1.PublicKey(poolConfig.nftCollectionAddress), tokens, custodies, markets);
|
141
|
+
};
|
142
|
+
PoolConfig.fromIdsByName = function (name, cluster) {
|
143
|
+
var poolConfig = PoolConfig_json_1.default.pools.find(function (pool) { return pool['poolName'] === name && cluster === pool['cluster']; });
|
144
|
+
if (!poolConfig) {
|
145
|
+
throw new Error("No pool with ".concat(name, " found!"));
|
146
|
+
}
|
147
|
+
return PoolConfig.buildPoolconfigFromJson(poolConfig);
|
97
148
|
};
|
98
149
|
PoolConfig.fromIdsByPk = function (poolPk, cluster) {
|
99
150
|
var poolConfig = PoolConfig_json_1.default.pools.find(function (pool) { return pool['poolAddress'] === poolPk.toString() && cluster === pool['cluster']; });
|
100
|
-
if (!poolConfig)
|
101
|
-
throw new Error("No pool
|
102
|
-
|
103
|
-
|
104
|
-
});
|
105
|
-
var custodies = poolConfig['custodies'].map(function (i) {
|
106
|
-
return __assign(__assign({}, i), { custodyAccount: new web3_js_1.PublicKey(i.custodyAccount), tokenAccount: new web3_js_1.PublicKey(i.tokenAccount), mintKey: new web3_js_1.PublicKey(i.mintKey), oracleAddress: new web3_js_1.PublicKey(i.oracleAddress) });
|
107
|
-
});
|
108
|
-
var addressLookupTableAddresses = poolConfig['addressLookupTableAddresses'].map(function (i) {
|
109
|
-
return new web3_js_1.PublicKey(i);
|
110
|
-
});
|
111
|
-
return new PoolConfig(new web3_js_1.PublicKey(poolConfig.programId), new web3_js_1.PublicKey(poolConfig.perpComposibilityProgramId), poolConfig.cluster, poolConfig.poolName, new web3_js_1.PublicKey(poolConfig.poolAddress), new web3_js_1.PublicKey(poolConfig.lpTokenMint), poolConfig.lpDecimals, poolConfig.lpTokenSymbol, new web3_js_1.PublicKey(poolConfig.perpetuals), new web3_js_1.PublicKey(poolConfig.transferAuthority), new web3_js_1.PublicKey(poolConfig.multisig), addressLookupTableAddresses, new web3_js_1.PublicKey(poolConfig.backupOracle), tokens, custodies);
|
151
|
+
if (!poolConfig) {
|
152
|
+
throw new Error("No pool with ".concat(poolPk.toString(), " found!"));
|
153
|
+
}
|
154
|
+
return PoolConfig.buildPoolconfigFromJson(poolConfig);
|
112
155
|
};
|
113
156
|
return PoolConfig;
|
114
157
|
}());
|