@zeroexcore/trader 1.1.4 → 3.0.0
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.
- package/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/dca/cancel.d.ts +3 -0
- package/dist/commands/dca/cancel.d.ts.map +1 -0
- package/dist/commands/dca/cancel.js +44 -0
- package/dist/commands/dca/cancel.js.map +1 -0
- package/dist/commands/dca/create.d.ts +3 -0
- package/dist/commands/dca/create.d.ts.map +1 -0
- package/dist/commands/dca/create.js +88 -0
- package/dist/commands/dca/create.js.map +1 -0
- package/dist/commands/dca/index.d.ts +3 -0
- package/dist/commands/dca/index.d.ts.map +1 -0
- package/dist/commands/dca/index.js +10 -0
- package/dist/commands/dca/index.js.map +1 -0
- package/dist/commands/dca/list.d.ts +3 -0
- package/dist/commands/dca/list.d.ts.map +1 -0
- package/dist/commands/dca/list.js +48 -0
- package/dist/commands/dca/list.js.map +1 -0
- package/dist/commands/limit/cancel.d.ts +3 -0
- package/dist/commands/limit/cancel.d.ts.map +1 -0
- package/dist/commands/limit/cancel.js +45 -0
- package/dist/commands/limit/cancel.js.map +1 -0
- package/dist/commands/limit/create.d.ts +3 -0
- package/dist/commands/limit/create.d.ts.map +1 -0
- package/dist/commands/limit/create.js +68 -0
- package/dist/commands/limit/create.js.map +1 -0
- package/dist/commands/limit/index.d.ts +3 -0
- package/dist/commands/limit/index.d.ts.map +1 -0
- package/dist/commands/limit/index.js +10 -0
- package/dist/commands/limit/index.js.map +1 -0
- package/dist/commands/limit/list.d.ts +3 -0
- package/dist/commands/limit/list.d.ts.map +1 -0
- package/dist/commands/limit/list.js +40 -0
- package/dist/commands/limit/list.js.map +1 -0
- package/dist/commands/perps/close.d.ts +3 -0
- package/dist/commands/perps/close.d.ts.map +1 -0
- package/dist/commands/perps/close.js +48 -0
- package/dist/commands/perps/close.js.map +1 -0
- package/dist/commands/perps/decrease.d.ts +3 -0
- package/dist/commands/perps/decrease.d.ts.map +1 -0
- package/dist/commands/perps/decrease.js +55 -0
- package/dist/commands/perps/decrease.js.map +1 -0
- package/dist/commands/perps/increase.d.ts +3 -0
- package/dist/commands/perps/increase.d.ts.map +1 -0
- package/dist/commands/perps/increase.js +60 -0
- package/dist/commands/perps/increase.js.map +1 -0
- package/dist/commands/perps/index.d.ts.map +1 -1
- package/dist/commands/perps/index.js +8 -0
- package/dist/commands/perps/index.js.map +1 -1
- package/dist/commands/perps/open.d.ts +3 -0
- package/dist/commands/perps/open.d.ts.map +1 -0
- package/dist/commands/perps/open.js +60 -0
- package/dist/commands/perps/open.js.map +1 -0
- package/dist/commands/perps/pool.d.ts.map +1 -1
- package/dist/commands/perps/pool.js +37 -29
- package/dist/commands/perps/pool.js.map +1 -1
- package/dist/commands/perps/positions.d.ts.map +1 -1
- package/dist/commands/perps/positions.js +56 -61
- package/dist/commands/perps/positions.js.map +1 -1
- package/dist/commands/perps/show.d.ts.map +1 -1
- package/dist/commands/perps/show.js +45 -25
- package/dist/commands/perps/show.js.map +1 -1
- package/dist/commands/portfolio.d.ts.map +1 -1
- package/dist/commands/portfolio.js +65 -18
- package/dist/commands/portfolio.js.map +1 -1
- package/dist/commands/predict/buy.d.ts.map +1 -1
- package/dist/commands/predict/buy.js +3 -0
- package/dist/commands/predict/buy.js.map +1 -1
- package/dist/commands/predict/sell.d.ts.map +1 -1
- package/dist/commands/predict/sell.js +3 -0
- package/dist/commands/predict/sell.js.map +1 -1
- package/dist/commands/tokens/quote.d.ts.map +1 -1
- package/dist/commands/tokens/quote.js +4 -1
- package/dist/commands/tokens/quote.js.map +1 -1
- package/dist/commands/tokens/swap.d.ts.map +1 -1
- package/dist/commands/tokens/swap.js +6 -3
- package/dist/commands/tokens/swap.js.map +1 -1
- package/dist/config.d.ts +4 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -1
- package/dist/config.js.map +1 -1
- package/dist/utils/amounts.d.ts +0 -16
- package/dist/utils/amounts.d.ts.map +1 -1
- package/dist/utils/amounts.js +4 -36
- package/dist/utils/amounts.js.map +1 -1
- package/dist/utils/helius.d.ts +3 -23
- package/dist/utils/helius.d.ts.map +1 -1
- package/dist/utils/helius.js +0 -123
- package/dist/utils/helius.js.map +1 -1
- package/dist/utils/jupiter.d.ts +4 -8
- package/dist/utils/jupiter.d.ts.map +1 -1
- package/dist/utils/jupiter.js +1 -7
- package/dist/utils/jupiter.js.map +1 -1
- package/dist/utils/nft.d.ts +3 -37
- package/dist/utils/nft.d.ts.map +1 -1
- package/dist/utils/nft.js +0 -71
- package/dist/utils/nft.js.map +1 -1
- package/dist/utils/perps/index.d.ts +51 -10
- package/dist/utils/perps/index.d.ts.map +1 -1
- package/dist/utils/perps/index.js +249 -34
- package/dist/utils/perps/index.js.map +1 -1
- package/dist/utils/perps-api.d.ts +110 -0
- package/dist/utils/perps-api.d.ts.map +1 -0
- package/dist/utils/perps-api.js +260 -0
- package/dist/utils/perps-api.js.map +1 -0
- package/dist/utils/positions.d.ts +3 -77
- package/dist/utils/positions.d.ts.map +1 -1
- package/dist/utils/positions.js +3 -330
- package/dist/utils/positions.js.map +1 -1
- package/dist/utils/prediction.d.ts +6 -28
- package/dist/utils/prediction.d.ts.map +1 -1
- package/dist/utils/prediction.js +0 -37
- package/dist/utils/prediction.js.map +1 -1
- package/dist/utils/recurring.d.ts +79 -0
- package/dist/utils/recurring.d.ts.map +1 -0
- package/dist/utils/recurring.js +73 -0
- package/dist/utils/recurring.js.map +1 -0
- package/dist/utils/token-book.d.ts.map +1 -1
- package/dist/utils/token-book.js +10 -1
- package/dist/utils/token-book.js.map +1 -1
- package/dist/utils/token-info.d.ts +2 -1
- package/dist/utils/token-info.d.ts.map +1 -1
- package/dist/utils/token-info.js +5 -2
- package/dist/utils/token-info.js.map +1 -1
- package/dist/utils/trigger.d.ts +88 -0
- package/dist/utils/trigger.d.ts.map +1 -0
- package/dist/utils/trigger.js +114 -0
- package/dist/utils/trigger.js.map +1 -0
- package/dist/utils/wallet.d.ts +0 -9
- package/dist/utils/wallet.d.ts.map +1 -1
- package/dist/utils/wallet.js +14 -4
- package/dist/utils/wallet.js.map +1 -1
- package/package.json +8 -2
- package/dist/utils/perps/doves-idl.d.ts +0 -380
- package/dist/utils/perps/doves-idl.d.ts.map +0 -1
- package/dist/utils/perps/doves-idl.js +0 -379
- package/dist/utils/perps/doves-idl.js.map +0 -1
- package/dist/utils/perps/jupiter-perpetuals-idl.d.ts +0 -7243
- package/dist/utils/perps/jupiter-perpetuals-idl.d.ts.map +0 -1
- package/dist/utils/perps/jupiter-perpetuals-idl.js +0 -7242
- package/dist/utils/perps/jupiter-perpetuals-idl.js.map +0 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Connection } from '@solana/web3.js';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { toSmallestUnit } from '../../utils/amounts.js';
|
|
4
|
+
import { getPerpsPositions, buildDecreasePositionTransaction, signAndSendPerps, formatUsd, assetToMint, DEFAULT_SLIPPAGE_BPS, } from '../../utils/perps-api.js';
|
|
5
|
+
import { loadKeypairForSigning, getWalletAddress } from '../../utils/wallet.js';
|
|
6
|
+
import { output, action, requirePassword, getRpcUrl } from '../shared.js';
|
|
7
|
+
export const decreaseCommand = new Command('decrease')
|
|
8
|
+
.argument('<market>', 'Market: SOL, ETH, BTC')
|
|
9
|
+
.argument('<side>', 'Side: long, short')
|
|
10
|
+
.argument('<amount-usd>', 'Size to reduce in USD')
|
|
11
|
+
.option('--receive <token>', 'Token to receive (default: asset for longs, USDC for shorts)')
|
|
12
|
+
.option('--slippage <bps>', `Price slippage in bps (default: ${DEFAULT_SLIPPAGE_BPS})`)
|
|
13
|
+
.option('-n, --note <note>', 'Trading journal note')
|
|
14
|
+
.description('Decrease a perps position (e.g. perps decrease BTC short 5)')
|
|
15
|
+
.action(action(async (market, side, amountUsd, options) => {
|
|
16
|
+
const password = requirePassword();
|
|
17
|
+
const asset = market.toUpperCase();
|
|
18
|
+
const sideNorm = side.toLowerCase();
|
|
19
|
+
const usdAmount = parseFloat(amountUsd);
|
|
20
|
+
const slippageBps = options.slippage ? parseInt(options.slippage, 10) : DEFAULT_SLIPPAGE_BPS;
|
|
21
|
+
if (!['long', 'short'].includes(sideNorm))
|
|
22
|
+
throw new Error('Side must be "long" or "short"');
|
|
23
|
+
if (isNaN(usdAmount) || usdAmount <= 0)
|
|
24
|
+
throw new Error(`Invalid amount: "${amountUsd}"`);
|
|
25
|
+
assetToMint(asset);
|
|
26
|
+
const rpcUrl = getRpcUrl();
|
|
27
|
+
const connection = new Connection(rpcUrl, 'confirmed');
|
|
28
|
+
const walletAddress = getWalletAddress(password);
|
|
29
|
+
const { dataList } = await getPerpsPositions(walletAddress, connection);
|
|
30
|
+
const pos = dataList.find(p => p.asset.toUpperCase() === asset && p.side === sideNorm);
|
|
31
|
+
if (!pos)
|
|
32
|
+
throw new Error(`No open ${asset} ${sideNorm} position found`);
|
|
33
|
+
const defaultReceive = sideNorm === 'long' ? asset : 'USDC';
|
|
34
|
+
const receiveToken = (options.receive || defaultReceive).toUpperCase();
|
|
35
|
+
const sizeUsdDelta = toSmallestUnit(usdAmount, 6);
|
|
36
|
+
console.log(`\nDecreasing ${asset} ${sideNorm} by $${usdAmount} — current size ${formatUsd(pos.sizeUsd)}`);
|
|
37
|
+
console.log(` Receive: ${receiveToken}, slippage: ${slippageBps} bps`);
|
|
38
|
+
const { tx } = await buildDecreasePositionTransaction(connection, { positionPubkey: pos.positionPubkey, receiveToken, sizeUsdDelta, slippageBps }, { side: sideNorm, asset });
|
|
39
|
+
console.log('Signing and submitting...');
|
|
40
|
+
const keypair = loadKeypairForSigning(password);
|
|
41
|
+
const txid = await signAndSendPerps(connection, keypair, tx);
|
|
42
|
+
console.log(`\nDecrease request submitted — keeper will execute shortly.`);
|
|
43
|
+
console.log(`https://solscan.io/tx/${txid}`);
|
|
44
|
+
output({
|
|
45
|
+
txid,
|
|
46
|
+
positionPubkey: pos.positionPubkey,
|
|
47
|
+
asset,
|
|
48
|
+
side: sideNorm,
|
|
49
|
+
sizeUsdDelta: usdAmount,
|
|
50
|
+
receive: receiveToken,
|
|
51
|
+
slippageBps,
|
|
52
|
+
note: options.note,
|
|
53
|
+
});
|
|
54
|
+
}));
|
|
55
|
+
//# sourceMappingURL=decrease.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decrease.js","sourceRoot":"","sources":["../../../src/commands/perps/decrease.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EACL,iBAAiB,EACjB,gCAAgC,EAChC,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,oBAAoB,GAIrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1E,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;KACnD,QAAQ,CAAC,UAAU,EAAE,uBAAuB,CAAC;KAC7C,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;KACvC,QAAQ,CAAC,cAAc,EAAE,uBAAuB,CAAC;KACjD,MAAM,CAAC,mBAAmB,EAAE,8DAA8D,CAAC;KAC3F,MAAM,CAAC,kBAAkB,EAAE,mCAAmC,oBAAoB,GAAG,CAAC;KACtF,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC;KACnD,WAAW,CAAC,6DAA6D,CAAC;KAC1E,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;IACxD,MAAM,QAA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ources":["../../../src/commands/perps/increase.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAepC,eAAO,MAAM,eAAe,SAyDvB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Connection } from '@solana/web3.js';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { toSmallestUnit } from '../../utils/amounts.js';
|
|
4
|
+
import { buildIncreasePositionTransaction, signAndSendPerps, assetToMint, perpsTokenDecimals, DEFAULT_SLIPPAGE_BPS, } from '../../utils/perps-api.js';
|
|
5
|
+
import { loadKeypairForSigning, getWalletAddress } from '../../utils/wallet.js';
|
|
6
|
+
import { output, action, requirePassword, getRpcUrl } from '../shared.js';
|
|
7
|
+
export const increaseCommand = new Command('increase')
|
|
8
|
+
.argument('<market>', 'Market: SOL, ETH, BTC')
|
|
9
|
+
.argument('<side>', 'Side: long, short')
|
|
10
|
+
.argument('<token>', 'Payment token: SOL, ETH, BTC, USDC')
|
|
11
|
+
.argument('<amount>', 'Amount of payment token to add')
|
|
12
|
+
.option('--leverage <leverage>', 'Leverage multiplier (e.g. 5 for 5x)')
|
|
13
|
+
.option('--slippage <bps>', `Price slippage in bps (default: ${DEFAULT_SLIPPAGE_BPS})`)
|
|
14
|
+
.option('-n, --note <note>', 'Trading journal note')
|
|
15
|
+
.description('Increase a perps position (e.g. perps increase BTC short USDC 5 --leverage 2)')
|
|
16
|
+
.action(action(async (market, side, token, amount, options) => {
|
|
17
|
+
const password = requirePassword();
|
|
18
|
+
const asset = market.toUpperCase();
|
|
19
|
+
const sideNorm = side.toLowerCase();
|
|
20
|
+
const inputToken = token.toUpperCase();
|
|
21
|
+
const amountNum = parseFloat(amount);
|
|
22
|
+
const slippageBps = options.slippage ? parseInt(options.slippage, 10) : DEFAULT_SLIPPAGE_BPS;
|
|
23
|
+
if (!['long', 'short'].includes(sideNorm))
|
|
24
|
+
throw new Error('Side must be "long" or "short"');
|
|
25
|
+
if (isNaN(amountNum) || amountNum <= 0)
|
|
26
|
+
throw new Error(`Invalid amount: "${amount}"`);
|
|
27
|
+
assetToMint(asset);
|
|
28
|
+
const rpcUrl = getRpcUrl();
|
|
29
|
+
const connection = new Connection(rpcUrl, 'confirmed');
|
|
30
|
+
const walletAddress = getWalletAddress(password);
|
|
31
|
+
const decimals = perpsTokenDecimals(inputToken);
|
|
32
|
+
const inputTokenAmount = toSmallestUnit(amountNum, decimals);
|
|
33
|
+
console.log(`\nIncrease ${asset} ${sideNorm} — adding ${amountNum} ${inputToken}, ${options.leverage || 'auto'}x leverage`);
|
|
34
|
+
const { tx, positionPubkey } = await buildIncreasePositionTransaction(connection, {
|
|
35
|
+
asset,
|
|
36
|
+
inputToken,
|
|
37
|
+
inputTokenAmount,
|
|
38
|
+
leverage: options.leverage,
|
|
39
|
+
side: sideNorm,
|
|
40
|
+
slippageBps,
|
|
41
|
+
walletAddress,
|
|
42
|
+
});
|
|
43
|
+
console.log('Signing and submitting...');
|
|
44
|
+
const keypair = loadKeypairForSigning(password);
|
|
45
|
+
const txid = await signAndSendPerps(connection, keypair, tx);
|
|
46
|
+
console.log(`\nIncrease request submitted — keeper will execute shortly.`);
|
|
47
|
+
console.log(`https://solscan.io/tx/${txid}`);
|
|
48
|
+
output({
|
|
49
|
+
txid,
|
|
50
|
+
positionPubkey,
|
|
51
|
+
asset,
|
|
52
|
+
side: sideNorm,
|
|
53
|
+
inputToken,
|
|
54
|
+
amount: amountNum,
|
|
55
|
+
leverage: options.leverage || 'auto',
|
|
56
|
+
slippageBps,
|
|
57
|
+
note: options.note,
|
|
58
|
+
});
|
|
59
|
+
}));
|
|
60
|
+
//# sourceMappingURL=increase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"increase.js","sourceRoot":"","sources":["../../../src/commands/perps/increase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE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,6DAA6D,CAAC,CAAC;IAC3E,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC;IAE7C,MAAM,CAAC;QACL,IAAI;QACJ,cAAc;QACd,KAAK;QACL,IAAI,EAAE,QAAQ;QACd,UAAU;QACV,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,MAAM;QACpC,WAAW;QACX,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CAAC,CAAC;AACL,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/perps/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/perps/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,eAAO,MAAM,YAAY,SACyB,CAAC"}
|
|
@@ -2,9 +2,17 @@ import { Command } from 'commander';
|
|
|
2
2
|
import { showCommand } from './show.js';
|
|
3
3
|
import { positionsCommand } from './positions.js';
|
|
4
4
|
import { poolCommand } from './pool.js';
|
|
5
|
+
import { openCommand } from './open.js';
|
|
6
|
+
import { closeCommand } from './close.js';
|
|
7
|
+
import { increaseCommand } from './increase.js';
|
|
8
|
+
import { decreaseCommand } from './decrease.js';
|
|
5
9
|
export const perpsCommand = new Command('perps')
|
|
6
10
|
.description('Perpetual futures on SOL/ETH/BTC');
|
|
7
11
|
perpsCommand.addCommand(showCommand);
|
|
8
12
|
perpsCommand.addCommand(positionsCommand);
|
|
9
13
|
perpsCommand.addCommand(poolCommand);
|
|
14
|
+
perpsCommand.addCommand(openCommand);
|
|
15
|
+
perpsCommand.addCommand(closeCommand);
|
|
16
|
+
perpsCommand.addCommand(increaseCommand);
|
|
17
|
+
perpsCommand.addCommand(decreaseCommand);
|
|
10
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/perps/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/perps/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;KAC7C,WAAW,CAAC,kCAAkC,CAAC,CAAC;AAEnD,YAAY,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AACrC,YAAY,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;AAC1C,YAAY,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AACrC,YAAY,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AACrC,YAAY,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;AACtC,YAAY,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;AACzC,YAAY,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../../src/commands/perps/open.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAepC,eAAO,MAAM,WAAW,SAyDnB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Connection } from '@solana/web3.js';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { toSmallestUnit } from '../../utils/amounts.js';
|
|
4
|
+
import { buildIncreasePositionTransaction, signAndSendPerps, assetToMint, perpsTokenDecimals, DEFAULT_SLIPPAGE_BPS, } from '../../utils/perps-api.js';
|
|
5
|
+
import { loadKeypairForSigning, getWalletAddress } from '../../utils/wallet.js';
|
|
6
|
+
import { output, action, requirePassword, getRpcUrl } from '../shared.js';
|
|
7
|
+
export const openCommand = new Command('open')
|
|
8
|
+
.argument('<market>', 'Market: SOL, ETH, BTC')
|
|
9
|
+
.argument('<side>', 'Side: long, short')
|
|
10
|
+
.argument('<token>', 'Payment token: SOL, ETH, BTC, USDC')
|
|
11
|
+
.argument('<amount>', 'Amount of payment token')
|
|
12
|
+
.option('--leverage <leverage>', 'Leverage multiplier (e.g. 5 for 5x)')
|
|
13
|
+
.option('--slippage <bps>', `Price slippage tolerance in bps (default: ${DEFAULT_SLIPPAGE_BPS})`)
|
|
14
|
+
.option('-n, --note <note>', 'Trading journal note')
|
|
15
|
+
.description('Open a new perps position (e.g. perps open SOL long SOL 0.06 --leverage 2)')
|
|
16
|
+
.action(action(async (market, side, token, amount, options) => {
|
|
17
|
+
const password = requirePassword();
|
|
18
|
+
const asset = market.toUpperCase();
|
|
19
|
+
const sideNorm = side.toLowerCase();
|
|
20
|
+
const inputToken = token.toUpperCase();
|
|
21
|
+
const amountNum = parseFloat(amount);
|
|
22
|
+
const slippageBps = options.slippage ? parseInt(options.slippage, 10) : DEFAULT_SLIPPAGE_BPS;
|
|
23
|
+
if (!['long', 'short'].includes(sideNorm))
|
|
24
|
+
throw new Error('Side must be "long" or "short"');
|
|
25
|
+
if (isNaN(amountNum) || amountNum <= 0)
|
|
26
|
+
throw new Error(`Invalid amount: "${amount}"`);
|
|
27
|
+
assetToMint(asset);
|
|
28
|
+
const rpcUrl = getRpcUrl();
|
|
29
|
+
const connection = new Connection(rpcUrl, 'confirmed');
|
|
30
|
+
const walletAddress = getWalletAddress(password);
|
|
31
|
+
const decimals = perpsTokenDecimals(inputToken);
|
|
32
|
+
const inputTokenAmount = toSmallestUnit(amountNum, decimals);
|
|
33
|
+
console.log(`\n${asset} ${sideNorm} — ${amountNum} ${inputToken}, ${options.leverage || 'auto'}x leverage, ${slippageBps} bps slippage`);
|
|
34
|
+
const { tx, positionPubkey } = await buildIncreasePositionTransaction(connection, {
|
|
35
|
+
asset,
|
|
36
|
+
inputToken,
|
|
37
|
+
inputTokenAmount,
|
|
38
|
+
leverage: options.leverage,
|
|
39
|
+
side: sideNorm,
|
|
40
|
+
slippageBps,
|
|
41
|
+
walletAddress,
|
|
42
|
+
});
|
|
43
|
+
console.log('Signing and submitting...');
|
|
44
|
+
const keypair = loadKeypairForSigning(password);
|
|
45
|
+
const txid = await signAndSendPerps(connection, keypair, tx);
|
|
46
|
+
console.log(`\nPosition request submitted — keeper will execute shortly.`);
|
|
47
|
+
console.log(`https://solscan.io/tx/${txid}`);
|
|
48
|
+
output({
|
|
49
|
+
txid,
|
|
50
|
+
positionPubkey,
|
|
51
|
+
asset,
|
|
52
|
+
side: sideNorm,
|
|
53
|
+
inputToken,
|
|
54
|
+
amount: amountNum,
|
|
55
|
+
leverage: options.leverage || 'auto',
|
|
56
|
+
slippageBps,
|
|
57
|
+
note: options.note,
|
|
58
|
+
});
|
|
59
|
+
}));
|
|
60
|
+
//# sourceMappingURL=open.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open.js","sourceRoot":"","sources":["../../../src/commands/perps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AChD,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;IAE7D,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;IAC3E,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC;IAE7C,MAAM,CAAC;QACL,IAAI;QACJ,cAAc;QACd,KAAK;QACL,IAAI,EAAE,QAAQ;QACd,UAAU;QACV,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,MAAM;QACpC,WAAW;QACX,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CAAC,CAAC;AACL,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../../src/commands/perps/pool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../../src/commands/perps/pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,eAAO,MAAM,WAAW,SA0CnB,CAAC"}
|
|
@@ -1,33 +1,41 @@
|
|
|
1
|
-
import { Connection } from '@solana/web3.js';
|
|
2
1
|
import { Command } from 'commander';
|
|
3
|
-
import {
|
|
4
|
-
import { output,
|
|
5
|
-
import { getRpcUrl } from '../../config.js';
|
|
2
|
+
import { getPoolInfo, assetToMint, PERPS_ASSETS, } from '../../utils/perps-api.js';
|
|
3
|
+
import { output, action } from '../shared.js';
|
|
6
4
|
export const poolCommand = new Command('pool')
|
|
7
|
-
.description('View JLP pool stats and
|
|
8
|
-
.action(async () => {
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
.description('View JLP pool stats and liquidity')
|
|
6
|
+
.action(action(async () => {
|
|
7
|
+
const results = await Promise.all(PERPS_ASSETS.map(async (asset) => {
|
|
8
|
+
const pool = await getPoolInfo(assetToMint(asset));
|
|
9
|
+
return { asset, pool };
|
|
10
|
+
}));
|
|
11
|
+
const poolData = results.map(({ asset, pool }) => ({
|
|
12
|
+
market: asset,
|
|
13
|
+
longAvailableLiquidity: pool.longAvailableLiquidity,
|
|
14
|
+
longBorrowRatePercent: pool.longBorrowRatePercent,
|
|
15
|
+
longUtilizationPercent: pool.longUtilizationPercent,
|
|
16
|
+
shortAvailableLiquidity: pool.shortAvailableLiquidity,
|
|
17
|
+
shortBorrowRatePercent: pool.shortBorrowRatePercent,
|
|
18
|
+
shortUtilizationPercent: pool.shortUtilizationPercent,
|
|
19
|
+
openFeePercent: pool.openFeePercent,
|
|
20
|
+
}));
|
|
21
|
+
output({ pool: poolData }, () => {
|
|
22
|
+
const lines = [
|
|
23
|
+
'Jupiter Perpetuals Pool',
|
|
21
24
|
'',
|
|
22
|
-
|
|
23
|
-
'',
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
25
|
+
'Market Long Liq Borrow Util Short Liq Borrow Util Open Fee',
|
|
26
|
+
'------- ------------------ -------- ------- ------------------ -------- ------- --------',
|
|
27
|
+
];
|
|
28
|
+
for (const { asset, pool } of results) {
|
|
29
|
+
lines.push(`${asset.padEnd(7)} ` +
|
|
30
|
+
`${pool.longAvailableLiquidity.padEnd(18)} ` +
|
|
31
|
+
`${(pool.longBorrowRatePercent + '%').padEnd(8)} ` +
|
|
32
|
+
`${(pool.longUtilizationPercent + '%').padEnd(7)} ` +
|
|
33
|
+
`${pool.shortAvailableLiquidity.padEnd(18)} ` +
|
|
34
|
+
`${(pool.shortBorrowRatePercent + '%').padEnd(8)} ` +
|
|
35
|
+
`${(pool.shortUtilizationPercent + '%').padEnd(7)} ` +
|
|
36
|
+
`${pool.openFeePercent}%`);
|
|
37
|
+
}
|
|
38
|
+
return lines.join('\n');
|
|
39
|
+
});
|
|
40
|
+
}));
|
|
33
41
|
//# sourceMappingURL=pool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../../src/commands/perps/pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../../src/commands/perps/pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,WAAW,EACX,WAAW,EACX,YAAY,GAEb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,mCAAmC,CAAC;KAChD,MAAM,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;IACxB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,KAAiB,EAAE,EAAE;QAC3C,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;QACnD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACzB,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QACjD,MAAM,EAAE,KAAK;QACb,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;QACnD,qBAAqB,EAAE,IAAI,CAAC,qBAAqB;QACjD,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;QACnD,uBAAuB,EAAE,IAAI,CA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ands/perps/positions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"positions.d.ts","sourceRoot":"","sources":["../../../src/commands/perps/positions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,eAAO,MAAM,gBAAgB,SAkExB,CAAC"}
|
|
@@ -1,68 +1,63 @@
|
|
|
1
|
-
import { Connection
|
|
1
|
+
import { Connection } from '@solana/web3.js';
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
-
import {
|
|
4
|
-
import { output, error, requirePassword, getRpcUrl } from '../shared.js';
|
|
3
|
+
import { getPerpsPositions, rawToUsd, formatUsd, } from '../../utils/perps-api.js';
|
|
5
4
|
import { getWalletAddress } from '../../utils/wallet.js';
|
|
5
|
+
import { output, action, requirePassword, getRpcUrl } from '../shared.js';
|
|
6
6
|
export const positionsCommand = new Command('positions')
|
|
7
|
-
.description('View your open perps positions')
|
|
7
|
+
.description('View your open perps positions with PnL')
|
|
8
8
|
.option('-w, --wallet <address>', 'Wallet address (defaults to configured wallet)')
|
|
9
|
-
.action(async (options) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
if (!walletAddress) {
|
|
15
|
-
const password = requirePassword();
|
|
16
|
-
walletAddress = getWalletAddress(password);
|
|
17
|
-
}
|
|
18
|
-
const positions = await getOpenPositions(connection, new PublicKey(walletAddress));
|
|
19
|
-
if (positions.length === 0) {
|
|
20
|
-
output({
|
|
21
|
-
wallet: walletAddress,
|
|
22
|
-
positions: [],
|
|
23
|
-
message: 'No open perps positions found',
|
|
24
|
-
tradeUrl: 'https://jup.ag/perps',
|
|
25
|
-
}, () => [
|
|
26
|
-
`Perps Positions for ${walletAddress.slice(0, 8)}...`,
|
|
27
|
-
'',
|
|
28
|
-
'No open perps positions found',
|
|
29
|
-
'',
|
|
30
|
-
'Open a position at: https://jup.ag/perps',
|
|
31
|
-
].join('\n'));
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const positionsData = positions.map((pos) => ({
|
|
35
|
-
market: pos.custody,
|
|
36
|
-
side: pos.side,
|
|
37
|
-
sizeUsd: pos.sizeUsd.toFixed(2),
|
|
38
|
-
collateralUsd: pos.collateralUsd.toFixed(2),
|
|
39
|
-
leverage: pos.leverage.toFixed(1),
|
|
40
|
-
entryPrice: pos.entryPrice.toFixed(2),
|
|
41
|
-
publicKey: pos.publicKey,
|
|
42
|
-
}));
|
|
43
|
-
output({
|
|
44
|
-
wallet: walletAddress,
|
|
45
|
-
positions: positionsData,
|
|
46
|
-
}, () => {
|
|
47
|
-
const lines = [
|
|
48
|
-
`Perps Positions for ${walletAddress.slice(0, 8)}...`,
|
|
49
|
-
'',
|
|
50
|
-
'Market Side Size Collateral Leverage Entry',
|
|
51
|
-
'------- ------ ------------ ------------ --------- ----------',
|
|
52
|
-
];
|
|
53
|
-
for (const pos of positions) {
|
|
54
|
-
const side = pos.side.toUpperCase().padEnd(6);
|
|
55
|
-
const size = `$${pos.sizeUsd.toFixed(2)}`.padEnd(12);
|
|
56
|
-
const collateral = `$${pos.collateralUsd.toFixed(2)}`.padEnd(12);
|
|
57
|
-
const leverage = `${pos.leverage.toFixed(1)}x`.padEnd(9);
|
|
58
|
-
const entry = `$${pos.entryPrice.toFixed(2)}`;
|
|
59
|
-
lines.push(`${pos.custody.padEnd(7)} ${side} ${size} ${collateral} ${leverage} ${entry}`);
|
|
60
|
-
}
|
|
61
|
-
return lines.join('\n');
|
|
62
|
-
});
|
|
9
|
+
.action(action(async (options) => {
|
|
10
|
+
let walletAddress = options.wallet;
|
|
11
|
+
if (!walletAddress) {
|
|
12
|
+
const password = requirePassword();
|
|
13
|
+
walletAddress = getWalletAddress(password);
|
|
63
14
|
}
|
|
64
|
-
|
|
65
|
-
|
|
15
|
+
const rpcUrl = getRpcUrl();
|
|
16
|
+
const connection = new Connection(rpcUrl, 'confirmed');
|
|
17
|
+
const { dataList: positions, count } = await getPerpsPositions(walletAddress, connection);
|
|
18
|
+
if (positions.length === 0) {
|
|
19
|
+
output({ wallet: walletAddress, positions: [], message: 'No open perps positions found' }, () => [
|
|
20
|
+
`Perps Positions for ${walletAddress.slice(0, 8)}...`,
|
|
21
|
+
'',
|
|
22
|
+
'No open perps positions found',
|
|
23
|
+
'',
|
|
24
|
+
'Open a position: trader perps open SOL long 100 --leverage 5',
|
|
25
|
+
].join('\n'));
|
|
26
|
+
return;
|
|
66
27
|
}
|
|
67
|
-
|
|
28
|
+
const positionsData = positions.map(p => ({
|
|
29
|
+
asset: p.asset,
|
|
30
|
+
side: p.side,
|
|
31
|
+
sizeUsd: rawToUsd(p.sizeUsd),
|
|
32
|
+
collateralUsd: rawToUsd(p.collateralUsd),
|
|
33
|
+
leverage: p.leverage,
|
|
34
|
+
entryPriceUsd: rawToUsd(p.entryPriceUsd),
|
|
35
|
+
markPriceUsd: rawToUsd(p.markPriceUsd),
|
|
36
|
+
liquidationPriceUsd: rawToUsd(p.liquidationPriceUsd),
|
|
37
|
+
pnlAfterFeesUsd: rawToUsd(p.pnlAfterFeesUsd),
|
|
38
|
+
pnlAfterFeesPct: p.pnlAfterFeesPct,
|
|
39
|
+
positionPubkey: p.positionPubkey,
|
|
40
|
+
}));
|
|
41
|
+
output({ wallet: walletAddress, positions: positionsData, count }, () => {
|
|
42
|
+
const lines = [
|
|
43
|
+
`Perps Positions for ${walletAddress.slice(0, 8)}...`,
|
|
44
|
+
'',
|
|
45
|
+
'Market Side Size Entry Mark Liq PnL Lev',
|
|
46
|
+
'------- ------ ------------ ------------ ------------ ------------ ---------------- ------',
|
|
47
|
+
];
|
|
48
|
+
for (const p of positions) {
|
|
49
|
+
const pnl = rawToUsd(p.pnlAfterFeesUsd);
|
|
50
|
+
const pnlStr = `${pnl >= 0 ? '+' : ''}${formatUsd(p.pnlAfterFeesUsd)} (${p.pnlAfterFeesPct}%)`;
|
|
51
|
+
lines.push(`${p.asset.padEnd(7)} ` +
|
|
52
|
+
`${p.side.toUpperCase().padEnd(6)} ` +
|
|
53
|
+
`${formatUsd(p.sizeUsd).padEnd(12)} ` +
|
|
54
|
+
`${formatUsd(p.entryPriceUsd).padEnd(12)} ` +
|
|
55
|
+
`${formatUsd(p.markPriceUsd).padEnd(12)} ` +
|
|
56
|
+
`${formatUsd(p.liquidationPriceUsd).padEnd(12)} ` +
|
|
57
|
+
`${pnlStr.padEnd(16)} ` +
|
|
58
|
+
`${p.leverage}x`);
|
|
59
|
+
}
|
|
60
|
+
return lines.join('\n');
|
|
61
|
+
});
|
|
62
|
+
}));
|
|
68
63
|
//# sourceMappingURL=positions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"positions.js","sourceRoot":"","sources":["../../../src/commands/perps/positions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"positions.js","sourceRoot":"","sources":["../../../src/commands/perps/positions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,SAAS,GACV,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1E,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC;KACrD,WAAW,CAAC,yCAAyC,CAAC;KACtD,MAAM,CAAC,wBAAwB,EAAE,gDAAgD,CAAC;KAClF,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IAC/B,IAAI,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IACnC,IAAI,CAAC,aAAa,E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AG,CAAC,CAAC,QAAQ,GAAG,CACjB,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../../src/commands/perps/show.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../../src/commands/perps/show.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,eAAO,MAAM,WAAW,SAyDnB,CAAC"}
|
|
@@ -1,36 +1,56 @@
|
|
|
1
|
-
import { Connection } from '@solana/web3.js';
|
|
2
1
|
import { Command } from 'commander';
|
|
3
|
-
import {
|
|
2
|
+
import { getMarketStats, getPoolInfo, assetToMint, PERPS_ASSETS, } from '../../utils/perps-api.js';
|
|
4
3
|
import { output, action } from '../shared.js';
|
|
5
|
-
import { getRpcUrl } from '../../config.js';
|
|
6
4
|
export const showCommand = new Command('show')
|
|
7
5
|
.argument('[market]', 'Market symbol (SOL, ETH, BTC) — omit for all')
|
|
8
|
-
.description('View market
|
|
6
|
+
.description('View market prices, stats, and pool info')
|
|
9
7
|
.action(action(async (market) => {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
const assets = market
|
|
9
|
+
? [market.toUpperCase()]
|
|
10
|
+
: [...PERPS_ASSETS];
|
|
11
|
+
// Validate
|
|
12
|
+
for (const a of assets)
|
|
13
|
+
assetToMint(a);
|
|
14
|
+
// Fetch market stats and pool info in parallel
|
|
15
|
+
const results = await Promise.all(assets.map(async (asset) => {
|
|
16
|
+
const mint = assetToMint(asset);
|
|
17
|
+
const [stats, pool] = await Promise.all([
|
|
18
|
+
getMarketStats(mint),
|
|
19
|
+
getPoolInfo(mint),
|
|
20
|
+
]);
|
|
21
|
+
return { asset, stats, pool };
|
|
22
|
+
}));
|
|
23
|
+
const marketsData = results.map(({ asset, stats, pool }) => ({
|
|
24
|
+
market: asset,
|
|
25
|
+
price: stats.price,
|
|
26
|
+
priceChange24H: stats.priceChange24H,
|
|
27
|
+
priceHigh24H: stats.priceHigh24H,
|
|
28
|
+
priceLow24H: stats.priceLow24H,
|
|
29
|
+
volume: stats.volume,
|
|
30
|
+
longLiquidity: pool.longAvailableLiquidity,
|
|
31
|
+
longBorrowRate: pool.longBorrowRatePercent,
|
|
32
|
+
longUtilization: pool.longUtilizationPercent,
|
|
33
|
+
shortLiquidity: pool.shortAvailableLiquidity,
|
|
34
|
+
shortBorrowRate: pool.shortBorrowRatePercent,
|
|
35
|
+
shortUtilization: pool.shortUtilizationPercent,
|
|
36
|
+
openFee: pool.openFeePercent,
|
|
22
37
|
}));
|
|
23
38
|
output({ markets: marketsData, tradeUrl: 'https://jup.ag/perps' }, () => {
|
|
24
|
-
const lines = [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
lines.push(`${
|
|
39
|
+
const lines = ['Jupiter Perpetuals', ''];
|
|
40
|
+
for (const { asset, stats, pool } of results) {
|
|
41
|
+
const price = parseFloat(String(stats.price));
|
|
42
|
+
const change = parseFloat(String(stats.priceChange24H));
|
|
43
|
+
const high = parseFloat(String(stats.priceHigh24H));
|
|
44
|
+
const low = parseFloat(String(stats.priceLow24H));
|
|
45
|
+
const chg = change >= 0 ? `+${change.toFixed(2)}%` : `${change.toFixed(2)}%`;
|
|
46
|
+
lines.push(`${asset}-PERP`);
|
|
47
|
+
lines.push(` Price: $${price.toLocaleString()} 24h: ${chg} H: $${high.toLocaleString()} L: $${low.toLocaleString()}`);
|
|
48
|
+
lines.push(` Long: Liquidity ${pool.longAvailableLiquidity} Borrow ${pool.longBorrowRatePercent}% Util ${pool.longUtilizationPercent}%`);
|
|
49
|
+
lines.push(` Short: Liquidity ${pool.shortAvailableLiquidity} Borrow ${pool.shortBorrowRatePercent}% Util ${pool.shortUtilizationPercent}%`);
|
|
50
|
+
lines.push(` Open Fee: ${pool.openFeePercent}%`);
|
|
51
|
+
lines.push('');
|
|
32
52
|
}
|
|
33
|
-
lines.push('
|
|
53
|
+
lines.push('Trade at: https://jup.ag/perps');
|
|
34
54
|
return lines.join('\n');
|
|
35
55
|
});
|
|
36
56
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"show.js","sourceRoot":"","sources":["../../../src/commands/perps/show.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"show.js","sourceRoot":"","sources":["../../../src/commands/perps/show.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,cAAc,EACd,WAAW,EACX,WAAW,EACX,YAAY,GAEb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,QAAQ,CAAC,UAAU,EAAE,8CAA8C,CAAC;KACpE,WAAW,CAAC,0CAA0C,CAAC;KACvD,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;IAC9B,MAAM,MAAM,GAAiB,MAAM;QACjC,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,EAAgB,CAAC;QACtC,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC;IAEtB,WAAW;IACX,KAAK,MAAM,CAAC,IAAI,MAAM;QAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAEvC,+CAA+C;IAC/C,MAAM,OAAO,GAAG,MAAM,O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AI,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portfolio.d.ts","sourceRoot":"","sources":["../../src/commands/portfolio.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"portfolio.d.ts","sourceRoot":"","sources":["../../src/commands/portfolio.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC,eAAO,MAAM,gBAAgB,SA6IxB,CAAC"}
|