@sonarwatch/portfolio-plugins 0.11.151 → 0.11.153
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1331 -1323
- package/README.md +3 -3
- package/package.json +2 -2
- package/src/index.js +4 -0
- package/src/index.js.map +1 -1
- package/src/orphanPlatorms.js +9 -1
- package/src/orphanPlatorms.js.map +1 -1
- package/src/plugins/aptin/constants.js +1 -1
- package/src/plugins/aptin/constants.js.map +1 -1
- package/src/plugins/armada-staking/constants.d.ts +1 -2
- package/src/plugins/armada-staking/constants.js +2 -7
- package/src/plugins/armada-staking/constants.js.map +1 -1
- package/src/plugins/armada-staking/index.js +0 -1
- package/src/plugins/armada-staking/index.js.map +1 -1
- package/src/plugins/armada-staking/stakingFetcher.js +3 -1
- package/src/plugins/armada-staking/stakingFetcher.js.map +1 -1
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/benqi/constants.js +3 -3
- package/src/plugins/benqi/constants.js.map +1 -1
- package/src/plugins/flash/constants.js +1 -1
- package/src/plugins/flash/constants.js.map +1 -1
- package/src/plugins/flexlend/constants.js +1 -0
- package/src/plugins/flexlend/constants.js.map +1 -1
- package/src/plugins/jupiter/constants.js +2 -1
- package/src/plugins/jupiter/constants.js.map +1 -1
- package/src/plugins/kamino/lendsFetcher.js +10 -7
- package/src/plugins/kamino/lendsFetcher.js.map +1 -1
- package/src/plugins/navi/constants.js +2 -1
- package/src/plugins/navi/constants.js.map +1 -1
- package/src/plugins/phoenix/constants.d.ts +8 -0
- package/src/plugins/phoenix/constants.js +18 -0
- package/src/plugins/phoenix/constants.js.map +1 -0
- package/src/plugins/phoenix/helpers/deserializeMarketData.d.ts +5 -0
- package/src/plugins/phoenix/helpers/deserializeMarketData.js +213 -0
- package/src/plugins/phoenix/helpers/deserializeMarketData.js.map +1 -0
- package/src/plugins/phoenix/helpers/misc.d.ts +6 -0
- package/src/plugins/phoenix/helpers/misc.js +46 -0
- package/src/plugins/phoenix/helpers/misc.js.map +1 -0
- package/src/plugins/phoenix/index.d.ts +6 -0
- package/src/plugins/phoenix/index.js +12 -0
- package/src/plugins/phoenix/index.js.map +1 -0
- package/src/plugins/phoenix/positionsFetcher.d.ts +3 -0
- package/src/plugins/phoenix/positionsFetcher.js +118 -0
- package/src/plugins/phoenix/positionsFetcher.js.map +1 -0
- package/src/plugins/phoenix/structs/marketHeader.d.ts +40 -0
- package/src/plugins/phoenix/structs/marketHeader.js +39 -0
- package/src/plugins/phoenix/structs/marketHeader.js.map +1 -0
- package/src/plugins/phoenix/structs/misc.d.ts +47 -0
- package/src/plugins/phoenix/structs/misc.js +44 -0
- package/src/plugins/phoenix/structs/misc.js.map +1 -0
- package/src/plugins/phoenix/structs/seat.d.ts +11 -0
- package/src/plugins/phoenix/structs/seat.js +14 -0
- package/src/plugins/phoenix/structs/seat.js.map +1 -0
- package/src/plugins/phoenix/types.d.ts +45 -0
- package/src/plugins/phoenix/types.js +3 -0
- package/src/plugins/phoenix/types.js.map +1 -0
- package/src/plugins/pyth/constants.js +1 -1
- package/src/plugins/pyth/constants.js.map +1 -1
- package/src/plugins/sushiswap/helpers.js +24 -24
- package/src/plugins/uniswap-v2/helpers.js +22 -22
- package/src/utils/sei/constants.js +8 -8
- package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
- package/src/utils/solana/getParsedProgramAccounts.js +2 -2
- package/src/utils/solana/getParsedProgramAccounts.js.map +1 -1
- package/src/utils/solana/getProgramAccounts.d.ts +2 -0
- package/src/utils/solana/{getProgramAccountsSafe.js → getProgramAccounts.js} +5 -5
- package/src/utils/solana/getProgramAccounts.js.map +1 -0
- package/src/utils/solana/index.d.ts +1 -1
- package/src/utils/solana/index.js +1 -1
- package/src/utils/solana/index.js.map +1 -1
- package/src/utils/solana/getProgramAccountsSafe.d.ts +0 -2
- package/src/utils/solana/getProgramAccountsSafe.js.map +0 -1
@@ -0,0 +1,213 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.getTraderState = exports.deserializeMarketData = void 0;
|
7
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
8
|
+
const web3_js_1 = require("@solana/web3.js");
|
9
|
+
const misc_1 = require("../structs/misc");
|
10
|
+
const marketHeader_1 = require("../structs/marketHeader");
|
11
|
+
function getNodeIndices(data, keyDeserializer, valueDeserializer) {
|
12
|
+
const indexMap = new Map();
|
13
|
+
const treeNodes = deserializeRedBlackTreeNodes(data, keyDeserializer, valueDeserializer);
|
14
|
+
const nodes = treeNodes[0];
|
15
|
+
const freeNodes = treeNodes[1];
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
17
|
+
for (const [index, [key]] of nodes.entries()) {
|
18
|
+
if (!freeNodes.has(index)) {
|
19
|
+
indexMap.set(key, index + 1);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
return indexMap;
|
23
|
+
}
|
24
|
+
function getUiOrderSequenceNumber(orderId) {
|
25
|
+
const twosComplement = toBN(orderId.orderSequenceNumber).fromTwos(64);
|
26
|
+
return twosComplement.isNeg()
|
27
|
+
? twosComplement.neg().sub(new bn_js_1.default(1))
|
28
|
+
: twosComplement;
|
29
|
+
}
|
30
|
+
function toBN(n) {
|
31
|
+
if (typeof n === 'number') {
|
32
|
+
return new bn_js_1.default(n);
|
33
|
+
}
|
34
|
+
return new bn_js_1.default(n.toString());
|
35
|
+
}
|
36
|
+
function sign(n) {
|
37
|
+
if (n.lt(new bn_js_1.default(0))) {
|
38
|
+
return -1;
|
39
|
+
}
|
40
|
+
if (n.gt(new bn_js_1.default(0))) {
|
41
|
+
return 1;
|
42
|
+
}
|
43
|
+
return 0;
|
44
|
+
}
|
45
|
+
function deserializeRedBlackTree(data, keyDeserializer, valueDeserializer) {
|
46
|
+
const tree = new Map();
|
47
|
+
const treeNodes = deserializeRedBlackTreeNodes(data, keyDeserializer, valueDeserializer);
|
48
|
+
const nodes = treeNodes[0];
|
49
|
+
const freeNodes = treeNodes[1];
|
50
|
+
for (const [index, [key, value]] of nodes.entries()) {
|
51
|
+
if (!freeNodes.has(index)) {
|
52
|
+
tree.set(key, value);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
return tree;
|
56
|
+
}
|
57
|
+
function deserializeRedBlackTreeNodes(data, keyDeserializer, valueDeserializer) {
|
58
|
+
let offset = 0;
|
59
|
+
const keySize = keyDeserializer.byteSize;
|
60
|
+
const valueSize = valueDeserializer.byteSize;
|
61
|
+
const nodes = new Array();
|
62
|
+
// Skip RBTree header
|
63
|
+
offset += 16;
|
64
|
+
// Skip node allocator size
|
65
|
+
offset += 8;
|
66
|
+
const bumpIndex = data.readInt32LE(offset);
|
67
|
+
offset += 4;
|
68
|
+
let freeListHead = data.readInt32LE(offset);
|
69
|
+
offset += 4;
|
70
|
+
const freeListPointers = new Array();
|
71
|
+
for (let index = 0; offset < data.length && index < bumpIndex - 1; index++) {
|
72
|
+
const registers = new Array();
|
73
|
+
for (let i = 0; i < 4; i++) {
|
74
|
+
registers.push(data.readInt32LE(offset)); // skip padding
|
75
|
+
offset += 4;
|
76
|
+
}
|
77
|
+
const [key] = keyDeserializer.deserialize(data.subarray(offset, offset + keySize));
|
78
|
+
offset += keySize;
|
79
|
+
const [value] = valueDeserializer.deserialize(data.subarray(offset, offset + valueSize));
|
80
|
+
offset += valueSize;
|
81
|
+
nodes.push([key, value]);
|
82
|
+
freeListPointers.push([index, registers[0]]);
|
83
|
+
}
|
84
|
+
const freeNodes = new Set();
|
85
|
+
let indexToRemove = freeListHead - 1;
|
86
|
+
let counter = 0;
|
87
|
+
// If there's an infinite loop here, that means that the state is corrupted
|
88
|
+
while (freeListHead < bumpIndex) {
|
89
|
+
// We need to subtract 1 because the node allocator is 1-indexed
|
90
|
+
const next = freeListPointers[freeListHead - 1];
|
91
|
+
[indexToRemove, freeListHead] = next;
|
92
|
+
freeNodes.add(indexToRemove);
|
93
|
+
counter += 1;
|
94
|
+
if (counter > bumpIndex) {
|
95
|
+
throw new Error('Infinite loop detected');
|
96
|
+
}
|
97
|
+
}
|
98
|
+
return [nodes, freeNodes];
|
99
|
+
}
|
100
|
+
function getValueFromRedBlackTreeNodes(data, key, valueDeserializer) {
|
101
|
+
const keySize = key.byteLength;
|
102
|
+
const valueSize = valueDeserializer.byteSize;
|
103
|
+
let offset = 24;
|
104
|
+
const bumpIndex = data.readInt32LE(offset);
|
105
|
+
offset += 8;
|
106
|
+
for (let index = 0; offset < data.length && index < bumpIndex - 1; index++) {
|
107
|
+
const registers = new Array();
|
108
|
+
for (let i = 0; i < 4; i++) {
|
109
|
+
registers.push(data.readInt32LE(offset)); // skip padding
|
110
|
+
offset += 4;
|
111
|
+
}
|
112
|
+
const cKey = data.subarray(offset, offset + keySize);
|
113
|
+
offset += keySize;
|
114
|
+
if (cKey.equals(key)) {
|
115
|
+
return valueDeserializer.deserialize(data.subarray(offset, offset + valueSize))[0];
|
116
|
+
}
|
117
|
+
offset += valueSize;
|
118
|
+
}
|
119
|
+
return null;
|
120
|
+
}
|
121
|
+
function deserializeMarketData(data) {
|
122
|
+
// Deserialize the market header
|
123
|
+
let offset = marketHeader_1.marketHeaderStruct.byteSize;
|
124
|
+
const [header] = marketHeader_1.marketHeaderStruct.deserialize(data.subarray(0, offset));
|
125
|
+
// Parse market data
|
126
|
+
const paddingLen = 8 * 32;
|
127
|
+
let remaining = data.subarray(offset + paddingLen);
|
128
|
+
offset = 0;
|
129
|
+
const baseLotsPerBaseUnit = Number(remaining.readBigUInt64LE(offset));
|
130
|
+
offset += 8;
|
131
|
+
const quoteLotsPerBaseUnitPerTick = Number(remaining.readBigUInt64LE(offset));
|
132
|
+
offset += 8;
|
133
|
+
const sequenceNumber = Number(remaining.readBigUInt64LE(offset));
|
134
|
+
offset += 8;
|
135
|
+
const takerFeeBps = Number(remaining.readBigUInt64LE(offset));
|
136
|
+
offset += 8;
|
137
|
+
const collectedQuoteLotFees = Number(remaining.readBigUInt64LE(offset));
|
138
|
+
offset += 8;
|
139
|
+
const unclaimedQuoteLotFees = Number(remaining.readBigUInt64LE(offset));
|
140
|
+
offset += 8;
|
141
|
+
remaining = remaining.subarray(offset);
|
142
|
+
// Parse bids, asks and traders
|
143
|
+
const numBids = header.marketSizeParams.bidsSize.toNumber();
|
144
|
+
const numAsks = header.marketSizeParams.asksSize.toNumber();
|
145
|
+
const numTraders = header.marketSizeParams.numSeats.toNumber();
|
146
|
+
const bidsSize = 16 + 16 + (16 + misc_1.orderIdBeet.byteSize + misc_1.restingOrderBeet.byteSize) * numBids;
|
147
|
+
const asksSize = 16 + 16 + (16 + misc_1.orderIdBeet.byteSize + misc_1.restingOrderBeet.byteSize) * numAsks;
|
148
|
+
const tradersSize = 16 + 16 + (16 + 32 + misc_1.traderStateBeet.byteSize) * numTraders;
|
149
|
+
offset = 0;
|
150
|
+
const bidBuffer = remaining.subarray(offset, offset + bidsSize);
|
151
|
+
offset += bidsSize;
|
152
|
+
const askBuffer = remaining.subarray(offset, offset + asksSize);
|
153
|
+
offset += asksSize;
|
154
|
+
const traderBuffer = remaining.subarray(offset, offset + tradersSize);
|
155
|
+
const bidsUnsorted = deserializeRedBlackTree(bidBuffer, misc_1.orderIdBeet, misc_1.restingOrderBeet);
|
156
|
+
const asksUnsorted = deserializeRedBlackTree(askBuffer, misc_1.orderIdBeet, misc_1.restingOrderBeet);
|
157
|
+
// Sort bids in descending order of price, and ascending order of sequence number
|
158
|
+
const bids = [...bidsUnsorted].sort((a, b) => {
|
159
|
+
const priceComparison = sign(toBN(b[0].priceInTicks).sub(toBN(a[0].priceInTicks)));
|
160
|
+
if (priceComparison !== 0) {
|
161
|
+
return priceComparison;
|
162
|
+
}
|
163
|
+
return sign(getUiOrderSequenceNumber(a[0]).sub(getUiOrderSequenceNumber(b[0])));
|
164
|
+
});
|
165
|
+
// Sort asks in ascending order of price, and ascending order of sequence number
|
166
|
+
const asks = [...asksUnsorted].sort((a, b) => {
|
167
|
+
const priceComparison = sign(toBN(a[0].priceInTicks).sub(toBN(b[0].priceInTicks)));
|
168
|
+
if (priceComparison !== 0) {
|
169
|
+
return priceComparison;
|
170
|
+
}
|
171
|
+
return sign(getUiOrderSequenceNumber(a[0]).sub(getUiOrderSequenceNumber(b[0])));
|
172
|
+
});
|
173
|
+
const traders = new Map();
|
174
|
+
for (const [k, traderState] of deserializeRedBlackTree(traderBuffer, misc_1.publicKeyBeet, misc_1.traderStateBeet)) {
|
175
|
+
traders.set(k.publicKey.toString(), traderState);
|
176
|
+
}
|
177
|
+
const traderPubkeyToTraderIndex = new Map();
|
178
|
+
const traderIndexToTraderPubkey = new Map();
|
179
|
+
for (const [k, index] of getNodeIndices(traderBuffer, misc_1.publicKeyBeet, misc_1.traderStateBeet)) {
|
180
|
+
traderPubkeyToTraderIndex.set(k.publicKey.toString(), index);
|
181
|
+
traderIndexToTraderPubkey.set(index, k.publicKey.toString());
|
182
|
+
}
|
183
|
+
return {
|
184
|
+
header,
|
185
|
+
baseLotsPerBaseUnit,
|
186
|
+
quoteLotsPerBaseUnitPerTick,
|
187
|
+
orderSequenceNumber: sequenceNumber,
|
188
|
+
takerFeeBps,
|
189
|
+
collectedQuoteLotFees,
|
190
|
+
unclaimedQuoteLotFees,
|
191
|
+
bids,
|
192
|
+
asks,
|
193
|
+
traders,
|
194
|
+
traderPubkeyToTraderIndex,
|
195
|
+
traderIndexToTraderPubkey,
|
196
|
+
};
|
197
|
+
}
|
198
|
+
exports.deserializeMarketData = deserializeMarketData;
|
199
|
+
function getTraderState(data, trader) {
|
200
|
+
// Deserialize the market header
|
201
|
+
const [partialHeader] = marketHeader_1.partialMarketHeaderStruct.deserialize(data);
|
202
|
+
const numBids = partialHeader.marketSizeParams.bidsSize.toNumber();
|
203
|
+
const numAsks = partialHeader.marketSizeParams.asksSize.toNumber();
|
204
|
+
const numTraders = partialHeader.marketSizeParams.numSeats.toNumber();
|
205
|
+
const bidsSize = 32 + (16 + misc_1.orderIdBeet.byteSize + misc_1.restingOrderBeet.byteSize) * numBids;
|
206
|
+
const asksSize = 32 + (16 + misc_1.orderIdBeet.byteSize + misc_1.restingOrderBeet.byteSize) * numAsks;
|
207
|
+
const tradersSize = 32 + (48 + misc_1.traderStateBeet.byteSize) * numTraders;
|
208
|
+
const offset = marketHeader_1.marketHeaderStruct.byteSize + 304 + bidsSize + asksSize;
|
209
|
+
const traderBuffer = data.subarray(offset, offset + tradersSize);
|
210
|
+
return getValueFromRedBlackTreeNodes(traderBuffer, new web3_js_1.PublicKey(trader).toBuffer(), misc_1.traderStateBeet);
|
211
|
+
}
|
212
|
+
exports.getTraderState = getTraderState;
|
213
|
+
//# sourceMappingURL=deserializeMarketData.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"deserializeMarketData.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/phoenix/helpers/deserializeMarketData.ts"],"names":[],"mappings":";;;;;;AACA,kDAAuB;AAEvB,6CAA4C;AAC5C,0CAOyB;AACzB,0DAGiC;AAGjC,SAAS,cAAc,CACrB,IAAY,EACZ,eAAoC,EACpC,iBAAwC;IAExC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAe,CAAC;IACxC,MAAM,SAAS,GAAG,4BAA4B,CAC5C,IAAI,EACJ,eAAe,EACf,iBAAiB,CAClB,CAAC;IAEF,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAE/B,6DAA6D;IAC7D,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;QAC7C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IA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CAAC;IACvE,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC;IAEjE,OAAO,6BAA6B,CAClC,YAAY,EACZ,IAAI,mBAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAChC,sBAAe,CAChB,CAAC;AACJ,CAAC;AAtBD,wCAsBC"}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
2
|
+
import { MarketHeader } from '../types';
|
3
|
+
import { MarketHeaderAccount } from '../structs/marketHeader';
|
4
|
+
export declare function marketHeaderAccountToMarketHeader(marketHeaderAccount: MarketHeaderAccount): MarketHeader;
|
5
|
+
export declare function getSeatManagerAddress(market: PublicKey): PublicKey;
|
6
|
+
export declare function getSeatAddress(market: PublicKey, trader: PublicKey): PublicKey;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getSeatAddress = exports.getSeatManagerAddress = exports.marketHeaderAccountToMarketHeader = void 0;
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
5
|
+
const constants_1 = require("../constants");
|
6
|
+
function marketHeaderAccountToMarketHeader(marketHeaderAccount) {
|
7
|
+
return {
|
8
|
+
discriminant: marketHeaderAccount.discriminant.toString(),
|
9
|
+
status: marketHeaderAccount.status.toString(),
|
10
|
+
marketSizeParams: {
|
11
|
+
bidsSize: marketHeaderAccount.marketSizeParams.bidsSize.toString(),
|
12
|
+
asksSize: marketHeaderAccount.marketSizeParams.asksSize.toString(),
|
13
|
+
numSeats: marketHeaderAccount.marketSizeParams.numSeats.toString(),
|
14
|
+
},
|
15
|
+
baseParams: {
|
16
|
+
decimals: marketHeaderAccount.baseParams.decimals,
|
17
|
+
vaultBump: marketHeaderAccount.baseParams.vaultBump,
|
18
|
+
mintKey: marketHeaderAccount.baseParams.mintKey.toString(),
|
19
|
+
vaultKey: marketHeaderAccount.baseParams.vaultKey.toString(),
|
20
|
+
},
|
21
|
+
baseLotSize: marketHeaderAccount.baseLotSize.toString(),
|
22
|
+
quoteParams: {
|
23
|
+
decimals: marketHeaderAccount.quoteParams.decimals,
|
24
|
+
vaultBump: marketHeaderAccount.quoteParams.vaultBump,
|
25
|
+
mintKey: marketHeaderAccount.quoteParams.mintKey.toString(),
|
26
|
+
vaultKey: marketHeaderAccount.quoteParams.vaultKey.toString(),
|
27
|
+
},
|
28
|
+
quoteLotSize: marketHeaderAccount.quoteLotSize.toString(),
|
29
|
+
tickSizeInQuoteAtomsPerBaseUnit: marketHeaderAccount.tickSizeInQuoteAtomsPerBaseUnit.toString(),
|
30
|
+
authority: marketHeaderAccount.authority.toString(),
|
31
|
+
feeRecipient: marketHeaderAccount.feeRecipient.toString(),
|
32
|
+
marketSequenceNumber: marketHeaderAccount.marketSequenceNumber.toString(),
|
33
|
+
successor: marketHeaderAccount.successor.toString(),
|
34
|
+
rawBaseUnitsPerBaseUnit: marketHeaderAccount.rawBaseUnitsPerBaseUnit,
|
35
|
+
};
|
36
|
+
}
|
37
|
+
exports.marketHeaderAccountToMarketHeader = marketHeaderAccountToMarketHeader;
|
38
|
+
function getSeatManagerAddress(market) {
|
39
|
+
return web3_js_1.PublicKey.findProgramAddressSync([market.toBuffer()], constants_1.phoenixSeatManagerPid)[0];
|
40
|
+
}
|
41
|
+
exports.getSeatManagerAddress = getSeatManagerAddress;
|
42
|
+
function getSeatAddress(market, trader) {
|
43
|
+
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('seat'), market.toBuffer(), trader.toBuffer()], constants_1.phoenixPid)[0];
|
44
|
+
}
|
45
|
+
exports.getSeatAddress = getSeatAddress;
|
46
|
+
//# sourceMappingURL=misc.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"misc.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/phoenix/helpers/misc.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;A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CAAC,YAAY,CAAC,QAAQ,EAAE;QACzD,oBAAoB,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,QAAQ,EAAE;QACzE,SAAS,EAAE,mBAAmB,CAAC,SAAS,CAAC,QAAQ,EAAE;QACnD,uBAAuB,EAAE,mBAAmB,CAAC,uBAAuB;KACrE,CAAC;AACJ,CAAC;AAjCD,8EAiCC;AAED,SAAgB,qBAAqB,CAAC,MAAiB;IACrD,OAAO,mBAAS,CAAC,sBAAsB,CACrC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EACnB,iCAAqB,CACtB,CAAC,CAAC,CAAC,CAAC;AACP,CAAC;AALD,sDAKC;AAED,SAAgB,cAAc,CAC5B,MAAiB,EACjB,MAAiB;IAEjB,OAAO,mBAAS,CAAC,sBAAsB,CACrC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,EAC3D,sBAAU,CACX,CAAC,CAAC,CAAC,CAAC;AACP,CAAC;AARD,wCAQC"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.fetchers = exports.jobs = exports.platforms = void 0;
|
7
|
+
const constants_1 = require("./constants");
|
8
|
+
const positionsFetcher_1 = __importDefault(require("./positionsFetcher"));
|
9
|
+
exports.platforms = [constants_1.platform];
|
10
|
+
exports.jobs = [];
|
11
|
+
exports.fetchers = [positionsFetcher_1.default];
|
12
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/phoenix/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,0EAAkD;AAErC,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,EAAE,CAAC;AACjB,QAAA,QAAQ,GAAc,CAAC,0BAAgB,CAAC,CAAC"}
|
@@ -0,0 +1,118 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
17
|
+
const constants_1 = require("./constants");
|
18
|
+
const clients_1 = require("../../utils/clients");
|
19
|
+
const solana_1 = require("../../utils/solana");
|
20
|
+
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
21
|
+
const seat_1 = require("./structs/seat");
|
22
|
+
const marketHeader_1 = require("./structs/marketHeader");
|
23
|
+
const getMultipleAccountsInfoSafe_1 = require("../../utils/solana/getMultipleAccountsInfoSafe");
|
24
|
+
const deserializeMarketData_1 = require("./helpers/deserializeMarketData");
|
25
|
+
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
26
|
+
const connection = (0, clients_1.getClientSolana)();
|
27
|
+
const accounts = yield (0, solana_1.getParsedProgramAccounts)(connection, seat_1.seatStruct, constants_1.phoenixPid, [
|
28
|
+
{
|
29
|
+
dataSize: seat_1.seatStruct.byteSize,
|
30
|
+
},
|
31
|
+
{
|
32
|
+
memcmp: {
|
33
|
+
bytes: owner,
|
34
|
+
offset: 40,
|
35
|
+
},
|
36
|
+
},
|
37
|
+
]);
|
38
|
+
if (accounts.length === 0)
|
39
|
+
return [];
|
40
|
+
const marketAddresses = accounts.map((acc) => acc.market);
|
41
|
+
const marketsAccounts = yield (0, getMultipleAccountsInfoSafe_1.getMultipleAccountsInfoSafe)(connection, marketAddresses);
|
42
|
+
const marketHeaders = marketsAccounts.map((acc) => acc ? marketHeader_1.marketHeaderStruct.deserialize(acc.data)[0] : null);
|
43
|
+
const mints = [];
|
44
|
+
const decimals = new Map();
|
45
|
+
marketHeaders.forEach((mh) => {
|
46
|
+
if (!mh)
|
47
|
+
return;
|
48
|
+
const quoteMint = mh.quoteParams.mintKey.toString();
|
49
|
+
const baseMint = mh.baseParams.mintKey.toString();
|
50
|
+
mints.push(quoteMint, baseMint);
|
51
|
+
decimals.set(quoteMint, mh.quoteParams.decimals);
|
52
|
+
decimals.set(baseMint, mh.baseParams.decimals);
|
53
|
+
});
|
54
|
+
if (mints.length === 0)
|
55
|
+
return [];
|
56
|
+
const tokenPrices = yield cache.getTokenPricesAsMap(mints, portfolio_core_1.NetworkId.solana);
|
57
|
+
const liquidities = [];
|
58
|
+
for (let i = 0; i < accounts.length; i++) {
|
59
|
+
const marketAcc = marketsAccounts.at(i);
|
60
|
+
const marketHeader = marketHeaders.at(i);
|
61
|
+
if (!marketAcc || !marketHeader)
|
62
|
+
continue;
|
63
|
+
const traderState = (0, deserializeMarketData_1.getTraderState)(marketAcc.data, owner);
|
64
|
+
if (!traderState)
|
65
|
+
continue;
|
66
|
+
const baseMint = marketHeader.baseParams.mintKey.toString();
|
67
|
+
const baseDecimals = decimals.get(baseMint);
|
68
|
+
const quoteMint = marketHeader.quoteParams.mintKey.toString();
|
69
|
+
const quoteDecimals = decimals.get(quoteMint);
|
70
|
+
if (baseDecimals === undefined || quoteDecimals === undefined)
|
71
|
+
continue;
|
72
|
+
const baseAmount = new bignumber_js_1.default(traderState.baseLotsFree.toString())
|
73
|
+
.plus(traderState.baseLotsLocked.toString())
|
74
|
+
.div(Math.pow(10, baseDecimals))
|
75
|
+
.times(marketHeader.baseLotSize)
|
76
|
+
.toNumber();
|
77
|
+
const quoteAmount = new bignumber_js_1.default(traderState.quoteLotsFree.toString())
|
78
|
+
.plus(traderState.quoteLotsLocked.toString())
|
79
|
+
.div(Math.pow(10, quoteDecimals))
|
80
|
+
.times(marketHeader.quoteLotSize)
|
81
|
+
.toNumber();
|
82
|
+
if (baseAmount === 0 && quoteAmount === 0)
|
83
|
+
continue;
|
84
|
+
const baseAsset = (0, tokenPriceToAssetToken_1.default)(baseMint, baseAmount, portfolio_core_1.NetworkId.solana, tokenPrices.get(baseMint));
|
85
|
+
const quoteAsset = (0, tokenPriceToAssetToken_1.default)(quoteMint, quoteAmount, portfolio_core_1.NetworkId.solana, tokenPrices.get(quoteMint));
|
86
|
+
const value = (0, portfolio_core_1.getUsdValueSum)([baseAsset.value, quoteAsset.value]);
|
87
|
+
const liquidity = {
|
88
|
+
assets: [baseAsset, quoteAsset],
|
89
|
+
assetsValue: value,
|
90
|
+
rewardAssets: [],
|
91
|
+
rewardAssetsValue: 0,
|
92
|
+
value,
|
93
|
+
yields: [],
|
94
|
+
};
|
95
|
+
liquidities.push(liquidity);
|
96
|
+
}
|
97
|
+
if (liquidities.length === 0)
|
98
|
+
return [];
|
99
|
+
return [
|
100
|
+
{
|
101
|
+
type: portfolio_core_1.PortfolioElementType.liquidity,
|
102
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
103
|
+
platformId: constants_1.platformId,
|
104
|
+
label: 'Deposit',
|
105
|
+
value: (0, portfolio_core_1.getUsdValueSum)(liquidities.map((l) => l.value)),
|
106
|
+
data: {
|
107
|
+
liquidities,
|
108
|
+
},
|
109
|
+
},
|
110
|
+
];
|
111
|
+
});
|
112
|
+
const fetcher = {
|
113
|
+
id: `${constants_1.platformId}-positions`,
|
114
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
115
|
+
executor,
|
116
|
+
};
|
117
|
+
exports.default = fetcher;
|
118
|
+
//# sourceMappingURL=positionsFetcher.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"positionsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/phoenix/positionsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAKoC;AACpC,gEAAqC;AAErC,2CAAqD;AAErD,iDAAsD;AACtD,+CAA8D;AAC9D,qGAA6E;AAC7E,yCAA4C;AAC5C,yDAA4D;AAC5D,gGAA6F;AAC7F,2EAAiE;AAEjE,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,UAAU,GAAG,IAAA,yBAAe,GAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,MAAM,IAAA,iCAAwB,EAC7C,UAAU,EACV,iBAAU,EACV,sBAAU,EACV;QACE;YACE,QAAQ,EAAE,iBAAU,CAAC,QAAQ;SAC9B;QACD;YACE,MAAM,EAAE;gBACN,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,EAAE;aACX;SACF;KACF,CACF,CAAC;IACF,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAErC,MAAM,eAAe,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1D,MAAM,eAAe,GAAG,MAAM,IAAA,yDAA2B,EACvD,UAAU,EACV,eAAe,CAChB,CAAC;IAEF,MAAM,aAAa,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAChD,GAAG,CAAC,CAAC,CAAC,iCAAkB,CAA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,EACvC,SAAS,EACT,WAAW,EACX,0BAAS,CAAC,MAAM,EAChB,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAC3B,CAAC;QACF,MAAM,KAAK,GAAG,IAAA,+BAAc,EAAC,CAAC,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;QAElE,MAAM,SAAS,GAAuB;YACpC,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC;YAC/B,WAAW,EAAE,KAAK;YAClB,YAAY,EAAE,EAAE;YAChB,iBAAiB,EAAE,CAAC;YACpB,KAAK;YACL,MAAM,EAAE,EAAE;SACX,CAAC;QACF,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACxC,OAAO;QACL;YACE,IAAI,EAAE,qCAAoB,CAAC,SAAS;YACpC,SAAS,EAAE,0BAAS,CAAC,MAAM;YAC3B,UAAU,EAAV,sBAAU;YACV,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,IAAA,+BAAc,EAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YACtD,IAAI,EAAE;gBACJ,WAAW;aACZ;SACF;KACF,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,YAAY;IAC7B,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import { BeetStruct } from '@metaplex-foundation/beet';
|
3
|
+
import BigNumber from 'bignumber.js';
|
4
|
+
import { PublicKey } from '@solana/web3.js';
|
5
|
+
export type TokenParams = {
|
6
|
+
decimals: number;
|
7
|
+
vaultBump: number;
|
8
|
+
mintKey: PublicKey;
|
9
|
+
vaultKey: PublicKey;
|
10
|
+
};
|
11
|
+
export declare const tokenParamsStruct: BeetStruct<TokenParams, Partial<TokenParams>>;
|
12
|
+
export type MarketSizeParams = {
|
13
|
+
bidsSize: BigNumber;
|
14
|
+
asksSize: BigNumber;
|
15
|
+
numSeats: BigNumber;
|
16
|
+
};
|
17
|
+
export declare const marketSizeParamsBeet: BeetStruct<MarketSizeParams, Partial<MarketSizeParams>>;
|
18
|
+
export type MarketHeaderAccount = {
|
19
|
+
discriminant: BigNumber;
|
20
|
+
status: BigNumber;
|
21
|
+
marketSizeParams: MarketSizeParams;
|
22
|
+
baseParams: TokenParams;
|
23
|
+
baseLotSize: BigNumber;
|
24
|
+
quoteParams: TokenParams;
|
25
|
+
quoteLotSize: BigNumber;
|
26
|
+
tickSizeInQuoteAtomsPerBaseUnit: BigNumber;
|
27
|
+
authority: PublicKey;
|
28
|
+
feeRecipient: PublicKey;
|
29
|
+
marketSequenceNumber: BigNumber;
|
30
|
+
successor: PublicKey;
|
31
|
+
rawBaseUnitsPerBaseUnit: number;
|
32
|
+
padding1: number;
|
33
|
+
padding2: BigNumber[];
|
34
|
+
};
|
35
|
+
export declare const marketHeaderStruct: BeetStruct<MarketHeaderAccount, Partial<MarketHeaderAccount>>;
|
36
|
+
export type PartialMarketHeaderAccount = {
|
37
|
+
buffer: Buffer;
|
38
|
+
marketSizeParams: MarketSizeParams;
|
39
|
+
};
|
40
|
+
export declare const partialMarketHeaderStruct: BeetStruct<PartialMarketHeaderAccount, Partial<PartialMarketHeaderAccount>>;
|
@@ -0,0 +1,39 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.partialMarketHeaderStruct = exports.marketHeaderStruct = exports.marketSizeParamsBeet = exports.tokenParamsStruct = void 0;
|
4
|
+
const beet_1 = require("@metaplex-foundation/beet");
|
5
|
+
const beet_solana_1 = require("@metaplex-foundation/beet-solana");
|
6
|
+
const solana_1 = require("../../../utils/solana");
|
7
|
+
exports.tokenParamsStruct = new beet_1.BeetStruct([
|
8
|
+
['decimals', beet_1.u32],
|
9
|
+
['vaultBump', beet_1.u32],
|
10
|
+
['mintKey', beet_solana_1.publicKey],
|
11
|
+
['vaultKey', beet_solana_1.publicKey],
|
12
|
+
], (args) => args);
|
13
|
+
exports.marketSizeParamsBeet = new beet_1.BeetStruct([
|
14
|
+
['bidsSize', solana_1.u64],
|
15
|
+
['asksSize', solana_1.u64],
|
16
|
+
['numSeats', solana_1.u64],
|
17
|
+
], (args) => args);
|
18
|
+
exports.marketHeaderStruct = new beet_1.BeetStruct([
|
19
|
+
['discriminant', solana_1.u64],
|
20
|
+
['status', solana_1.u64],
|
21
|
+
['marketSizeParams', exports.marketSizeParamsBeet],
|
22
|
+
['baseParams', exports.tokenParamsStruct],
|
23
|
+
['baseLotSize', solana_1.u64],
|
24
|
+
['quoteParams', exports.tokenParamsStruct],
|
25
|
+
['quoteLotSize', solana_1.u64],
|
26
|
+
['tickSizeInQuoteAtomsPerBaseUnit', solana_1.u64],
|
27
|
+
['authority', beet_solana_1.publicKey],
|
28
|
+
['feeRecipient', beet_solana_1.publicKey],
|
29
|
+
['marketSequenceNumber', solana_1.u64],
|
30
|
+
['successor', beet_solana_1.publicKey],
|
31
|
+
['rawBaseUnitsPerBaseUnit', beet_1.u32],
|
32
|
+
['padding1', beet_1.u32],
|
33
|
+
['padding2', (0, beet_1.uniformFixedSizeArray)(solana_1.u64, 32)],
|
34
|
+
], (args) => args);
|
35
|
+
exports.partialMarketHeaderStruct = new beet_1.BeetStruct([
|
36
|
+
['buffer', (0, solana_1.blob)(16)],
|
37
|
+
['marketSizeParams', exports.marketSizeParamsBeet],
|
38
|
+
], (args) => args);
|
39
|
+
//# sourceMappingURL=marketHeader.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"marketHeader.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/phoenix/struct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,IAA2B,CACtC,CAAC;AAOW,QAAA,yBAAyB,GACpC,IAAI,iBAAU,CACZ;IACE,CAAC,QAAQ,EAAE,IAAA,aAAI,EAAC,EAAE,CAAC,CAAC;IACpB,CAAC,kBAAkB,EAAE,4BAAoB,CAAC;CAC3C,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAkC,CAC7C,CAAC"}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import { BeetArgsStruct, BeetStruct, COption, FixableBeetStruct, bignum } from '@metaplex-foundation/beet';
|
2
|
+
import { PublicKey } from '@solana/web3.js';
|
3
|
+
import BigNumber from 'bignumber.js';
|
4
|
+
export type PubkeyWrapper = {
|
5
|
+
publicKey: PublicKey;
|
6
|
+
};
|
7
|
+
export declare const publicKeyBeet: BeetArgsStruct<PubkeyWrapper>;
|
8
|
+
export type TraderState = {
|
9
|
+
quoteLotsLocked: bignum;
|
10
|
+
quoteLotsFree: bignum;
|
11
|
+
baseLotsLocked: bignum;
|
12
|
+
baseLotsFree: bignum;
|
13
|
+
padding: bignum[];
|
14
|
+
};
|
15
|
+
export declare const traderStateBeet: BeetArgsStruct<TraderState>;
|
16
|
+
export type CondensedOrder = {
|
17
|
+
priceInTicks: BigNumber;
|
18
|
+
sizeInBaseLots: BigNumber;
|
19
|
+
lastValidSlot: COption<BigNumber>;
|
20
|
+
lastValidUnixTimestampInSeconds: COption<BigNumber>;
|
21
|
+
};
|
22
|
+
export declare const condensedOrderBeet: FixableBeetStruct<CondensedOrder, Partial<CondensedOrder>>;
|
23
|
+
export declare enum FailedMultipleLimitOrderBehavior {
|
24
|
+
FailOnInsufficientFundsAndAmendOnCross = 0,
|
25
|
+
FailOnInsufficientFundsAndFailOnCross = 1,
|
26
|
+
SkipOnInsufficientFundsAndAmendOnCross = 2,
|
27
|
+
SkipOnInsufficientFundsAndFailOnCross = 3
|
28
|
+
}
|
29
|
+
export type MultipleOrderPacket = {
|
30
|
+
bids: CondensedOrder[];
|
31
|
+
asks: CondensedOrder[];
|
32
|
+
clientOrderId: COption<BigNumber>;
|
33
|
+
failedMultipleLimitOrderBehavior: FailedMultipleLimitOrderBehavior;
|
34
|
+
};
|
35
|
+
export declare const multipleOrderPacketStruct: FixableBeetStruct<MultipleOrderPacket, Partial<MultipleOrderPacket>>;
|
36
|
+
export type OrderId = {
|
37
|
+
priceInTicks: BigNumber;
|
38
|
+
orderSequenceNumber: BigNumber;
|
39
|
+
};
|
40
|
+
export declare const orderIdBeet: BeetArgsStruct<OrderId>;
|
41
|
+
export type RestingOrder = {
|
42
|
+
traderIndex: BigNumber;
|
43
|
+
numBaseLots: BigNumber;
|
44
|
+
lastValidSlot: BigNumber;
|
45
|
+
lastValidUnixTimestampInSeconds: BigNumber;
|
46
|
+
};
|
47
|
+
export declare const restingOrderBeet: BeetStruct<RestingOrder, Partial<RestingOrder>>;
|
@@ -0,0 +1,44 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.restingOrderBeet = exports.orderIdBeet = exports.multipleOrderPacketStruct = exports.FailedMultipleLimitOrderBehavior = exports.condensedOrderBeet = exports.traderStateBeet = exports.publicKeyBeet = void 0;
|
4
|
+
const beet_1 = require("@metaplex-foundation/beet");
|
5
|
+
const beet_solana_1 = require("@metaplex-foundation/beet-solana");
|
6
|
+
const solana_1 = require("../../../utils/solana");
|
7
|
+
exports.publicKeyBeet = new beet_1.BeetArgsStruct([['publicKey', beet_solana_1.publicKey]], 'PubkeyWrapper');
|
8
|
+
exports.traderStateBeet = new beet_1.BeetArgsStruct([
|
9
|
+
['quoteLotsLocked', beet_1.u64],
|
10
|
+
['quoteLotsFree', beet_1.u64],
|
11
|
+
['baseLotsLocked', beet_1.u64],
|
12
|
+
['baseLotsFree', beet_1.u64],
|
13
|
+
['padding', (0, beet_1.uniformFixedSizeArray)(beet_1.u64, 8)],
|
14
|
+
], 'TraderState');
|
15
|
+
exports.condensedOrderBeet = new beet_1.FixableBeetStruct([
|
16
|
+
['priceInTicks', solana_1.u64],
|
17
|
+
['sizeInBaseLots', solana_1.u64],
|
18
|
+
['lastValidSlot', (0, beet_1.coption)(solana_1.u64)],
|
19
|
+
['lastValidUnixTimestampInSeconds', (0, beet_1.coption)(solana_1.u64)],
|
20
|
+
], (args) => args);
|
21
|
+
var FailedMultipleLimitOrderBehavior;
|
22
|
+
(function (FailedMultipleLimitOrderBehavior) {
|
23
|
+
FailedMultipleLimitOrderBehavior[FailedMultipleLimitOrderBehavior["FailOnInsufficientFundsAndAmendOnCross"] = 0] = "FailOnInsufficientFundsAndAmendOnCross";
|
24
|
+
FailedMultipleLimitOrderBehavior[FailedMultipleLimitOrderBehavior["FailOnInsufficientFundsAndFailOnCross"] = 1] = "FailOnInsufficientFundsAndFailOnCross";
|
25
|
+
FailedMultipleLimitOrderBehavior[FailedMultipleLimitOrderBehavior["SkipOnInsufficientFundsAndAmendOnCross"] = 2] = "SkipOnInsufficientFundsAndAmendOnCross";
|
26
|
+
FailedMultipleLimitOrderBehavior[FailedMultipleLimitOrderBehavior["SkipOnInsufficientFundsAndFailOnCross"] = 3] = "SkipOnInsufficientFundsAndFailOnCross";
|
27
|
+
})(FailedMultipleLimitOrderBehavior || (exports.FailedMultipleLimitOrderBehavior = FailedMultipleLimitOrderBehavior = {}));
|
28
|
+
exports.multipleOrderPacketStruct = new beet_1.FixableBeetStruct([
|
29
|
+
['bids', (0, beet_1.array)(exports.condensedOrderBeet)],
|
30
|
+
['asks', (0, beet_1.array)(exports.condensedOrderBeet)],
|
31
|
+
['clientOrderId', (0, beet_1.coption)(solana_1.u128)],
|
32
|
+
['failedMultipleLimitOrderBehavior', beet_1.u8],
|
33
|
+
], (args) => args);
|
34
|
+
exports.orderIdBeet = new beet_1.BeetArgsStruct([
|
35
|
+
['priceInTicks', solana_1.u64],
|
36
|
+
['orderSequenceNumber', solana_1.u64],
|
37
|
+
], 'fIFOOrderId');
|
38
|
+
exports.restingOrderBeet = new beet_1.BeetStruct([
|
39
|
+
['traderIndex', solana_1.u64],
|
40
|
+
['numBaseLots', solana_1.u64],
|
41
|
+
['lastValidSlot', solana_1.u64],
|
42
|
+
['lastValidUnixTimestampInSeconds', solana_1.u64],
|
43
|
+
], (args) => args);
|
44
|
+
//# sourceMappingURL=misc.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"misc.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/phoenix/structs/misc.ts"],"names":[],"mappings":";;;AAAA,oDAWmC;AACnC,kEAA6D;AAG7D,kDAAkD;AAMrC,QAAA,aAAa,GAAG,IAAI,qBAAc,CAC7C,CAAC,CAAC,WAAW,EAAE,uBAAS,CAAC,CAAC,EAC1B,eAAe,CAChB,CAAC;AAUW,QAAA,eAAe,GAAG,IAAI,qBAAc,CAC/C;IACE,CAAC,iBAAiB,EAAE,UAAO,CAAC;IAC5B,CAAC,eAAe,EAAE,UAAO,CAAC;IAC1B,CAAC,gBAAgB,EAAE,UAAO,CAAC;IAC3B,CAAC,cAAc,EAAE,UAAO,CAAC;IACzB,CAAC,SAAS,EAAE,IAAA,4BAAqB,EAAC,UAAO,EAAE,CAAC,CAAC,CAAC;CAC/C,EACD,aAAa,CACd,CAAC;AASW,QAAA,kBAAkB,GAAG,IAAI,wBAAiB,CACrD;IACE,CAAC,cAAc,EAAE,YAAG,CAAC;IACrB,CAAC,gBAAgB,EAAE,YAAG,CAAC;IACvB,CAAC,eAAe,EAAE,IAAA,cAAO,EAAC,YAAG,CAAC,CAAC;IAC/B,CAAC,iCAAiC,EAAE,IAAA,cAAO,EAAC,YAAG,CAAC,CAAC;CAClD,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAsB,CACjC,CAAC;AAEF,IAAY,gCAKX;AALD,WAAY,gCAAgC;IAC1C,2JAAsC,CAAA;IACtC,yJAAqC,CAAA;IACrC,2JAAsC,CAAA;IACtC,yJAAqC,CAAA;AACvC,CAAC,EALW,gCAAgC,gDAAhC,gCAAgC,QAK3C;AASY,QAAA,yBAAyB,GACpC,IAAI,wBAAiB,CACnB;IACE,CAAC,MAAM,EAAE,IAAA,YAAK,EAAC,0BAAkB,CAAC,CAAC;IACnC,CAAC,MAAM,EAAE,IAAA,YAAK,EAAC,0BAAkB,CAAC,CAAC;IACnC,CAAC,eAAe,EAAE,IAAA,cAAO,EAAC,aAAI,CAAC,CAAC;IAChC,CAAC,kCAAkC,EAAE,SAAE,CAAC;CACzC,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAA2B,CACtC,CAAC;AAOS,QAAA,WAAW,GAAG,IAAI,qBAAc,CAC3C;IACE,CAAC,cAAc,EAAE,YAAG,CAAC;IACrB,CAAC,qBAAqB,EAAE,YAAG,CAAC;CAC7B,EACD,aAAa,CACd,CAAC;AASW,QAAA,gBAAgB,GAAG,IAAI,iBAAU,CAC5C;IACE,CAAC,aAAa,EAAE,YAAG,CAAC;IACpB,CAAC,aAAa,EAAE,YAAG,CAAC;IACpB,CAAC,eAAe,EAAE,YAAG,CAAC;IACtB,CAAC,iCAAiC,EAAE,YAAG,CAAC;CACzC,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAoB,CAC/B,CAAC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { BeetStruct } from '@metaplex-foundation/beet';
|
2
|
+
import BigNumber from 'bignumber.js';
|
3
|
+
import { PublicKey } from '@solana/web3.js';
|
4
|
+
export type Seat = {
|
5
|
+
discriminant: BigNumber;
|
6
|
+
market: PublicKey;
|
7
|
+
trader: PublicKey;
|
8
|
+
approvalStatus: BigNumber;
|
9
|
+
padding: BigNumber[];
|
10
|
+
};
|
11
|
+
export declare const seatStruct: BeetStruct<Seat, Partial<Seat>>;
|