@pendle/sdk-boros 1.0.11-strategies → 1.0.12-cross-deposit-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addresses.d.ts +11 -1
- package/dist/addresses.js +23 -1
- package/dist/addresses.js.map +1 -1
- package/dist/backend/secrettune/BorosCoreSDK.d.ts +165 -21
- package/dist/backend/secrettune/BorosCoreSDK.js +72 -6
- package/dist/backend/secrettune/BorosCoreSDK.js.map +1 -1
- package/dist/backend/secrettune/BorosSendTxsBotSDK.d.ts +4 -3
- package/dist/backend/secrettune/BorosSendTxsBotSDK.js.map +1 -1
- package/dist/backend/secrettune/PendleV2SDK.d.ts +2281 -0
- package/dist/backend/secrettune/PendleV2SDK.js +970 -0
- package/dist/backend/secrettune/PendleV2SDK.js.map +1 -0
- package/dist/backend/secrettune/module.d.ts +6 -0
- package/dist/backend/secrettune/module.js +25 -0
- package/dist/backend/secrettune/module.js.map +1 -1
- package/dist/common/chainId.d.ts +12 -0
- package/dist/common/chainId.js +17 -0
- package/dist/common/chainId.js.map +1 -0
- package/dist/contracts/abis/viemAbiDepositBoxFactory.d.ts +75 -0
- package/dist/contracts/abis/viemAbiDepositBoxFactory.js +103 -0
- package/dist/contracts/abis/viemAbiDepositBoxFactory.js.map +1 -0
- package/dist/contracts/abis/viemAbiRouter.d.ts +1983 -0
- package/dist/contracts/abis/viemAbiRouter.js +2549 -0
- package/dist/contracts/abis/viemAbiRouter.js.map +1 -0
- package/dist/contracts/contracts.factory.d.ts +8 -2
- package/dist/contracts/contracts.factory.js +16 -4
- package/dist/contracts/contracts.factory.js.map +1 -1
- package/dist/contracts/deposit-box-factory.d.ts +86 -0
- package/dist/contracts/deposit-box-factory.js +16 -0
- package/dist/contracts/deposit-box-factory.js.map +1 -0
- package/dist/contracts/erc20.d.ts +158 -0
- package/dist/contracts/erc20.js +52 -0
- package/dist/contracts/erc20.js.map +1 -0
- package/dist/contracts/router.d.ts +1987 -0
- package/dist/contracts/router.js +12 -0
- package/dist/contracts/router.js.map +1 -0
- package/dist/entities/crossChainDeposit/AggregatorHelper.d.ts +109 -0
- package/dist/entities/crossChainDeposit/AggregatorHelper.js +26 -0
- package/dist/entities/crossChainDeposit/AggregatorHelper.js.map +1 -0
- package/dist/entities/crossChainDeposit/AggregatorHelperErrors.d.ts +80 -0
- package/dist/entities/crossChainDeposit/AggregatorHelperErrors.js +116 -0
- package/dist/entities/crossChainDeposit/AggregatorHelperErrors.js.map +1 -0
- package/dist/entities/crossChainDeposit/Depositor.d.ts +31 -0
- package/dist/entities/crossChainDeposit/Depositor.js +64 -0
- package/dist/entities/crossChainDeposit/Depositor.js.map +1 -0
- package/dist/entities/crossChainDeposit/aggregators/Boros/index.d.ts +36 -0
- package/dist/entities/crossChainDeposit/aggregators/Boros/index.js +191 -0
- package/dist/entities/crossChainDeposit/aggregators/Boros/index.js.map +1 -0
- package/dist/entities/crossChainDeposit/aggregators/Boros/types.d.ts +10 -0
- package/dist/entities/crossChainDeposit/aggregators/Boros/types.js.map +1 -0
- package/dist/entities/crossChainDeposit/aggregators/Lifi/index.d.ts +39 -0
- package/dist/entities/crossChainDeposit/aggregators/Lifi/index.js +159 -0
- package/dist/entities/crossChainDeposit/aggregators/Lifi/index.js.map +1 -0
- package/dist/entities/crossChainDeposit/aggregators/Lifi/types.d.ts +186 -0
- package/dist/entities/crossChainDeposit/aggregators/Lifi/types.js +28 -0
- package/dist/entities/crossChainDeposit/aggregators/Lifi/types.js.map +1 -0
- package/dist/entities/crossChainDeposit/aggregators/Pendle/index.d.ts +38 -0
- package/dist/entities/crossChainDeposit/aggregators/Pendle/index.js +171 -0
- package/dist/entities/crossChainDeposit/aggregators/Pendle/index.js.map +1 -0
- package/dist/entities/crossChainDeposit/helpers/TokenHelper.d.ts +23 -0
- package/dist/entities/crossChainDeposit/helpers/TokenHelper.js +67 -0
- package/dist/entities/crossChainDeposit/helpers/TokenHelper.js.map +1 -0
- package/dist/entities/crossChainDeposit/helpers/utils.d.ts +4 -0
- package/dist/entities/crossChainDeposit/helpers/utils.js +25 -0
- package/dist/entities/crossChainDeposit/helpers/utils.js.map +1 -0
- package/dist/entities/crossChainDeposit/index.d.ts +2 -0
- package/dist/entities/{Calculator → crossChainDeposit}/index.js +2 -6
- package/dist/entities/crossChainDeposit/index.js.map +1 -0
- package/dist/entities/index.d.ts +2 -1
- package/dist/entities/index.js +2 -1
- package/dist/entities/index.js.map +1 -1
- package/dist/entities/token/Token.d.ts +31 -0
- package/dist/entities/token/Token.js +61 -0
- package/dist/entities/token/Token.js.map +1 -0
- package/dist/entities/token/index.d.ts +1 -0
- package/dist/entities/token/index.js +18 -0
- package/dist/entities/token/index.js.map +1 -0
- package/dist/errors/PendleSdkError.d.ts +7 -0
- package/dist/errors/PendleSdkError.js +15 -0
- package/dist/errors/PendleSdkError.js.map +1 -0
- package/dist/types/common.d.ts +16 -0
- package/dist/utils/signing/index.d.ts +1 -1
- package/dist/utils/signing/index.js +2 -1
- package/dist/utils/signing/index.js.map +1 -1
- package/dist/utils/signing/sensitive.d.ts +2 -1
- package/dist/utils/signing/sensitive.js +29 -0
- package/dist/utils/signing/sensitive.js.map +1 -1
- package/package.json +1 -1
- package/dist/entities/Calculator/exchangeFees.d.ts +0 -47
- package/dist/entities/Calculator/exchangeFees.js +0 -93
- package/dist/entities/Calculator/exchangeFees.js.map +0 -1
- package/dist/entities/Calculator/index.d.ts +0 -6
- package/dist/entities/Calculator/index.js.map +0 -1
- package/dist/entities/Calculator/marginCalculator.d.ts +0 -10
- package/dist/entities/Calculator/marginCalculator.js +0 -67
- package/dist/entities/Calculator/marginCalculator.js.map +0 -1
- package/dist/entities/Calculator/strategyApr.d.ts +0 -30
- package/dist/entities/Calculator/strategyApr.js +0 -94
- package/dist/entities/Calculator/strategyApr.js.map +0 -1
- package/dist/entities/Calculator/strategyExecution.d.ts +0 -28
- package/dist/entities/Calculator/strategyExecution.js +0 -130
- package/dist/entities/Calculator/strategyExecution.js.map +0 -1
- package/dist/entities/Calculator/strategyFinder.d.ts +0 -11
- package/dist/entities/Calculator/strategyFinder.js +0 -162
- package/dist/entities/Calculator/strategyFinder.js.map +0 -1
- package/dist/entities/Calculator/types.d.ts +0 -84
- package/dist/entities/Calculator/types.js.map +0 -1
- /package/dist/entities/{Calculator → crossChainDeposit/aggregators/Boros}/types.js +0 -0
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.signSetAccManagerMessage = signSetAccManagerMessage;
|
|
4
4
|
exports.signApproveAgentMessage = signApproveAgentMessage;
|
|
5
|
+
exports.signDepositFromBoxMessage = signDepositFromBoxMessage;
|
|
5
6
|
const __1 = require("..");
|
|
6
7
|
const common_1 = require("./common");
|
|
7
8
|
async function signSetAccManagerMessage(wallet, message) {
|
|
@@ -41,4 +42,32 @@ async function signApproveAgentMessage(wallet, message) {
|
|
|
41
42
|
message,
|
|
42
43
|
});
|
|
43
44
|
}
|
|
45
|
+
async function signDepositFromBoxMessage(wallet, message) {
|
|
46
|
+
const account = await (0, __1.getUserAddressFromWalletClient)(wallet);
|
|
47
|
+
return wallet.signTypedData({
|
|
48
|
+
account: wallet.account ?? account,
|
|
49
|
+
domain: (0, common_1.PENDLE_BOROS_ROUTER_DOMAIN)(),
|
|
50
|
+
types: {
|
|
51
|
+
EIP712Domain: common_1.EIP712_DOMAIN_TYPES,
|
|
52
|
+
DepositFromBoxMessage: [
|
|
53
|
+
{ name: 'root', type: 'address' },
|
|
54
|
+
{ name: 'boxId', type: 'uint32' },
|
|
55
|
+
{ name: 'tokenSpent', type: 'address' },
|
|
56
|
+
{ name: 'maxAmountSpent', type: 'uint256' },
|
|
57
|
+
{ name: 'accountId', type: 'uint8' },
|
|
58
|
+
{ name: 'tokenId', type: 'uint16' },
|
|
59
|
+
{ name: 'marketId', type: 'uint24' },
|
|
60
|
+
{ name: 'minDepositAmount', type: 'uint256' },
|
|
61
|
+
{ name: 'payTreasuryAmount', type: 'uint256' },
|
|
62
|
+
{ name: 'swapExtRouter', type: 'address' },
|
|
63
|
+
{ name: 'swapApprove', type: 'address' },
|
|
64
|
+
{ name: 'swapCalldata', type: 'bytes' },
|
|
65
|
+
{ name: 'expiry', type: 'uint64' },
|
|
66
|
+
{ name: 'salt', type: 'uint256' },
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
primaryType: 'DepositFromBoxMessage',
|
|
70
|
+
message,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
44
73
|
//# sourceMappingURL=sensitive.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sensitive.js","sourceRoot":"","sources":["../../../src/utils/signing/sensitive.ts"],"names":[],"mappings":";;AAKA,4DAiBC;AAED,0DAkBC;
|
|
1
|
+
{"version":3,"file":"sensitive.js","sourceRoot":"","sources":["../../../src/utils/signing/sensitive.ts"],"names":[],"mappings":";;AAKA,4DAiBC;AAED,0DAkBC;AAED,8DA2BC;AAtED,0BAAoD;AAEpD,qCAA2E;AAEpE,KAAK,UAAU,wBAAwB,CAAC,MAAoB,EAAE,OAA4B;IAC/F,MAAM,OAAO,GAAG,MAAM,IAAA,kCAA8B,EAAC,MAAM,CAAC,CAAC;IAC7D,OAAO,MAAM,CAAC,aAAa,CAAC;QAC1B,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,OAAO;QAClC,MAAM,EAAE,IAAA,mCAA0B,GAAE;QACpC,KAAK,EAAE;YACL,YAAY,EAAE,4BAAmB;YACjC,oBAAoB,EAAE;gBACpB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;gBACjC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE;gBACpC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE;gBACvC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE;aAClC;SACF;QACD,WAAW,EAAE,sBAA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AAE;gBACvC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE;gBAC3C,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE;gBACpC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACnC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACpC,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,SAAS,EAAE;gBAC7C,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,SAAS,EAAE;gBAC9C,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,EAAE;gBAC1C,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;gBACxC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE;gBACvC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAClC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;aAClC;SACF;QACD,WAAW,EAAE,uBAAuB;QACpC,OAAO;KACR,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { MarketResponse } from '../../backend/secrettune/BorosCoreSDK';
|
|
2
|
-
export declare const EXCHANGE_PERP_FEES: Record<string, {
|
|
3
|
-
maker: number;
|
|
4
|
-
taker: number;
|
|
5
|
-
}>;
|
|
6
|
-
export declare const DEFAULT_PERP_FEE: {
|
|
7
|
-
maker: number;
|
|
8
|
-
taker: number;
|
|
9
|
-
};
|
|
10
|
-
export type FeeType = 'maker' | 'taker';
|
|
11
|
-
export declare function getExchangePerpFee(exchange: string, feeType?: FeeType): number;
|
|
12
|
-
export declare function getBorosFeesFromMarket(market: MarketResponse): {
|
|
13
|
-
tradeFee: number;
|
|
14
|
-
settlementFee: number;
|
|
15
|
-
};
|
|
16
|
-
export declare function getStrategyFees(longMarket: MarketResponse, shortMarket: MarketResponse): {
|
|
17
|
-
exchangeFee1: number;
|
|
18
|
-
exchangeFee2: number;
|
|
19
|
-
borosTradeFee: number;
|
|
20
|
-
borosSettlementFee: number;
|
|
21
|
-
};
|
|
22
|
-
export type VipTier = 'base' | 'vip1' | 'vip2' | 'vip3' | 'vip4' | 'vip5';
|
|
23
|
-
export declare const BINANCE_VIP_FEES: Record<VipTier, {
|
|
24
|
-
maker: number;
|
|
25
|
-
taker: number;
|
|
26
|
-
}>;
|
|
27
|
-
export declare const HYPERLIQUID_TIER_FEES: Record<string, {
|
|
28
|
-
maker: number;
|
|
29
|
-
taker: number;
|
|
30
|
-
}>;
|
|
31
|
-
export declare const OKX_VIP_FEES: Record<VipTier, {
|
|
32
|
-
maker: number;
|
|
33
|
-
taker: number;
|
|
34
|
-
}>;
|
|
35
|
-
export declare function getExchangePerpFeeWithTier(exchange: string, tier?: VipTier, feeType?: FeeType): number;
|
|
36
|
-
export declare function formatFeeSummary(fees: {
|
|
37
|
-
exchangeFee1: number;
|
|
38
|
-
exchangeFee2: number;
|
|
39
|
-
borosTradeFee: number;
|
|
40
|
-
borosSettlementFee: number;
|
|
41
|
-
}): {
|
|
42
|
-
exchangeFee1Pct: string;
|
|
43
|
-
exchangeFee2Pct: string;
|
|
44
|
-
borosTradeFeePct: string;
|
|
45
|
-
borosSettlementFeePct: string;
|
|
46
|
-
totalFeePct: string;
|
|
47
|
-
};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OKX_VIP_FEES = exports.HYPERLIQUID_TIER_FEES = exports.BINANCE_VIP_FEES = exports.DEFAULT_PERP_FEE = exports.EXCHANGE_PERP_FEES = void 0;
|
|
4
|
-
exports.getExchangePerpFee = getExchangePerpFee;
|
|
5
|
-
exports.getBorosFeesFromMarket = getBorosFeesFromMarket;
|
|
6
|
-
exports.getStrategyFees = getStrategyFees;
|
|
7
|
-
exports.getExchangePerpFeeWithTier = getExchangePerpFeeWithTier;
|
|
8
|
-
exports.formatFeeSummary = formatFeeSummary;
|
|
9
|
-
exports.EXCHANGE_PERP_FEES = {
|
|
10
|
-
Binance: {
|
|
11
|
-
maker: 0.0002,
|
|
12
|
-
taker: 0.0005,
|
|
13
|
-
},
|
|
14
|
-
Hyperliquid: {
|
|
15
|
-
maker: 0.0001,
|
|
16
|
-
taker: 0.00035,
|
|
17
|
-
},
|
|
18
|
-
OKX: {
|
|
19
|
-
maker: 0.0002,
|
|
20
|
-
taker: 0.0005,
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
exports.DEFAULT_PERP_FEE = {
|
|
24
|
-
maker: 0.0002,
|
|
25
|
-
taker: 0.0005,
|
|
26
|
-
};
|
|
27
|
-
function getExchangePerpFee(exchange, feeType = 'taker') {
|
|
28
|
-
const fees = exports.EXCHANGE_PERP_FEES[exchange] ?? exports.DEFAULT_PERP_FEE;
|
|
29
|
-
return fees[feeType];
|
|
30
|
-
}
|
|
31
|
-
function getBorosFeesFromMarket(market) {
|
|
32
|
-
const tradeFee = market.config.takerFee ? Number(market.config.takerFee) / 1e18 : 0.0015;
|
|
33
|
-
const settlementFee = market.extConfig.settleFeeRate ? Number(market.extConfig.settleFeeRate) / 1e18 : 0.0015;
|
|
34
|
-
return {
|
|
35
|
-
tradeFee,
|
|
36
|
-
settlementFee,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function getStrategyFees(longMarket, shortMarket) {
|
|
40
|
-
const exchange1 = longMarket.metadata?.platformName ?? 'Unknown';
|
|
41
|
-
const exchange2 = shortMarket.metadata?.platformName ?? 'Unknown';
|
|
42
|
-
const borosFees = getBorosFeesFromMarket(longMarket);
|
|
43
|
-
return {
|
|
44
|
-
exchangeFee1: getExchangePerpFee(exchange1, 'taker'),
|
|
45
|
-
exchangeFee2: getExchangePerpFee(exchange2, 'taker'),
|
|
46
|
-
borosTradeFee: borosFees.tradeFee,
|
|
47
|
-
borosSettlementFee: borosFees.settlementFee,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
exports.BINANCE_VIP_FEES = {
|
|
51
|
-
base: { maker: 0.0002, taker: 0.0005 },
|
|
52
|
-
vip1: { maker: 0.00016, taker: 0.0004 },
|
|
53
|
-
vip2: { maker: 0.00014, taker: 0.00035 },
|
|
54
|
-
vip3: { maker: 0.00012, taker: 0.00032 },
|
|
55
|
-
vip4: { maker: 0.0001, taker: 0.0003 },
|
|
56
|
-
vip5: { maker: 0.00008, taker: 0.00027 },
|
|
57
|
-
};
|
|
58
|
-
exports.HYPERLIQUID_TIER_FEES = {
|
|
59
|
-
base: { maker: 0.0001, taker: 0.00035 },
|
|
60
|
-
referral: { maker: 0.0001, taker: 0.00035 },
|
|
61
|
-
vip: { maker: 0.00005, taker: 0.00025 },
|
|
62
|
-
};
|
|
63
|
-
exports.OKX_VIP_FEES = {
|
|
64
|
-
base: { maker: 0.0002, taker: 0.0005 },
|
|
65
|
-
vip1: { maker: 0.00018, taker: 0.00045 },
|
|
66
|
-
vip2: { maker: 0.00015, taker: 0.0004 },
|
|
67
|
-
vip3: { maker: 0.00012, taker: 0.00035 },
|
|
68
|
-
vip4: { maker: 0.0001, taker: 0.0003 },
|
|
69
|
-
vip5: { maker: 0.00008, taker: 0.00025 },
|
|
70
|
-
};
|
|
71
|
-
function getExchangePerpFeeWithTier(exchange, tier = 'base', feeType = 'taker') {
|
|
72
|
-
switch (exchange) {
|
|
73
|
-
case 'Binance':
|
|
74
|
-
return exports.BINANCE_VIP_FEES[tier]?.[feeType] ?? exports.BINANCE_VIP_FEES.base[feeType];
|
|
75
|
-
case 'OKX':
|
|
76
|
-
return exports.OKX_VIP_FEES[tier]?.[feeType] ?? exports.OKX_VIP_FEES.base[feeType];
|
|
77
|
-
case 'Hyperliquid':
|
|
78
|
-
return exports.HYPERLIQUID_TIER_FEES.base[feeType];
|
|
79
|
-
default:
|
|
80
|
-
return exports.DEFAULT_PERP_FEE[feeType];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
function formatFeeSummary(fees) {
|
|
84
|
-
const totalFee = 2 * (fees.exchangeFee1 + fees.exchangeFee2 + fees.borosTradeFee + fees.borosSettlementFee);
|
|
85
|
-
return {
|
|
86
|
-
exchangeFee1Pct: `${(fees.exchangeFee1 * 100).toFixed(3)}%`,
|
|
87
|
-
exchangeFee2Pct: `${(fees.exchangeFee2 * 100).toFixed(3)}%`,
|
|
88
|
-
borosTradeFeePct: `${(fees.borosTradeFee * 100).toFixed(3)}%`,
|
|
89
|
-
borosSettlementFeePct: `${(fees.borosSettlementFee * 100).toFixed(3)}%`,
|
|
90
|
-
totalFeePct: `${(totalFee * 100).toFixed(3)}%`,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=exchangeFees.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exchangeFees.js","sourceRoot":"","sources":["../../../src/entities/Calculator/exchangeFees.ts"],"names":[],"mappings":";;;AA+CA,gDAGC;AAQD,wDAcC;AAWD,0CAkBC;AA8CD,gEAgBC;AAKD,4CAqBC;AAtLY,QAAA,kBAAkB,GAAqD;IAGlF,OAAO,EAAE;QACP,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,MAAM;KACd;IAID,WAAW,EAAE;QACX,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,OAAO;KACf;IAID,GAAG,EAAE;QACH,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,MAAM;KACd;CACF,CAAC;AAKW,QAAA,gBAAgB,GAAG;IAC9B,KAAK,EAAE,MAAM;IACb,KAAK,EAAE,MAAM;CACd,CAAC;AAWF,SAAgB,kBAAkB,CAAC,QAAgB,EAAE,UAAmB,OAAO;IAC7E,MAAM,IAAI,GAAG,0BAAkB,CAAC,QAAQ,CAAC,IAAI,wBAAgB,CAAC;IAC9D,OA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AC,IAAI,oBAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrE,KAAK,aAAa;YAEhB,OAAO,6BAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7C;YACE,OAAO,wBAAgB,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;AACH,CAAC;AAKD,SAAgB,gBAAgB,CAAC,IAKhC;IAOC,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAE5G,OAAO;QACL,eAAe,EAAE,GAAG,CAAC,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;QAC3D,eAAe,EAAE,GAAG,CAAC,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;QAC3D,gBAAgB,EAAE,GAAG,CAAC,IAAI,CAAC,aAAa,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;QAC7D,qBAAqB,EAAE,GAAG,CAAC,IAAI,CAAC,kBAAkB,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;QACvE,WAAW,EAAE,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;KAC/C,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/entities/Calculator/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,mDAAiC;AACjC,sDAAoC;AACpC,gDAA8B;AAC9B,iDAA+B;AAC/B,qDAAmC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { FixedX18 } from '@pendle/boros-offchain-math';
|
|
2
|
-
import type { MarketResponse } from '../../backend/secrettune/BorosCoreSDK';
|
|
3
|
-
export declare function getMarginRequiredFor1YU(market: MarketResponse, leverage?: number): number;
|
|
4
|
-
export declare function getMarginRequiredFor1YUFixedX18(market: MarketResponse, leverage?: number): FixedX18;
|
|
5
|
-
export declare function getStrategyBorosMargin(longMarket: MarketResponse, shortMarket: MarketResponse, leverage?: number): number;
|
|
6
|
-
export declare function getStrategyMarginRequirements(longMarket: MarketResponse, shortMarket: MarketResponse, leverage?: number): {
|
|
7
|
-
marginRequired1: number;
|
|
8
|
-
marginRequired2: number;
|
|
9
|
-
totalBorosMargin: number;
|
|
10
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMarginRequiredFor1YU = getMarginRequiredFor1YU;
|
|
4
|
-
exports.getMarginRequiredFor1YUFixedX18 = getMarginRequiredFor1YUFixedX18;
|
|
5
|
-
exports.getStrategyBorosMargin = getStrategyBorosMargin;
|
|
6
|
-
exports.getStrategyMarginRequirements = getStrategyMarginRequirements;
|
|
7
|
-
const boros_offchain_math_1 = require("@pendle/boros-offchain-math");
|
|
8
|
-
const SECONDS_PER_YEAR = 3600 * 24 * 365;
|
|
9
|
-
const DEFAULT_MIN_MARGIN_INDEX_RATE = boros_offchain_math_1.FixedX18.fromNumber(0.1);
|
|
10
|
-
function getMarginRequiredFor1YU(market, leverage) {
|
|
11
|
-
const effectiveLeverage = leverage ?? market.metadata?.maxLeverage ?? 1;
|
|
12
|
-
const marginFactor = market.config.kIM
|
|
13
|
-
? boros_offchain_math_1.FixedX18.fromRawValue(BigInt(market.config.kIM))
|
|
14
|
-
: boros_offchain_math_1.FixedX18.fromNumber(0.5);
|
|
15
|
-
const tThresh_s = market.config.tThresh ?? 604800;
|
|
16
|
-
const tThresh_y = tThresh_s / SECONDS_PER_YEAR;
|
|
17
|
-
const timeToMaturity_s = market.data?.timeToMaturity ??
|
|
18
|
-
(market.imData.maturity - Math.floor(Date.now() / 1000));
|
|
19
|
-
const timeToMaturity_y = Math.max(0, timeToMaturity_s / SECONDS_PER_YEAR);
|
|
20
|
-
const time_y = Math.max(timeToMaturity_y, tThresh_y);
|
|
21
|
-
const time = boros_offchain_math_1.FixedX18.fromNumber(time_y);
|
|
22
|
-
const impliedApr = market.data?.ammImpliedApr ?? market.data?.midApr ?? 0;
|
|
23
|
-
const absImpliedApr = boros_offchain_math_1.FixedX18.fromNumber(Math.abs(impliedApr));
|
|
24
|
-
const rate = absImpliedApr.gt(DEFAULT_MIN_MARGIN_INDEX_RATE)
|
|
25
|
-
? absImpliedApr
|
|
26
|
-
: DEFAULT_MIN_MARGIN_INDEX_RATE;
|
|
27
|
-
const contractSuf = rate.mulDown(time).mulDown(marginFactor);
|
|
28
|
-
const offchainSuf = rate.mulDown(time).divDown(boros_offchain_math_1.FixedX18.fromNumber(effectiveLeverage));
|
|
29
|
-
const imSuf = contractSuf.gt(offchainSuf) ? contractSuf : offchainSuf;
|
|
30
|
-
return imSuf.toNumber();
|
|
31
|
-
}
|
|
32
|
-
function getMarginRequiredFor1YUFixedX18(market, leverage) {
|
|
33
|
-
const effectiveLeverage = leverage ?? market.metadata?.maxLeverage ?? 1;
|
|
34
|
-
const marginFactor = market.config.kIM
|
|
35
|
-
? boros_offchain_math_1.FixedX18.fromRawValue(BigInt(market.config.kIM))
|
|
36
|
-
: boros_offchain_math_1.FixedX18.fromNumber(0.5);
|
|
37
|
-
const tThresh_s = market.config.tThresh ?? 604800;
|
|
38
|
-
const tThresh_y = tThresh_s / SECONDS_PER_YEAR;
|
|
39
|
-
const timeToMaturity_s = market.data?.timeToMaturity ??
|
|
40
|
-
(market.imData.maturity - Math.floor(Date.now() / 1000));
|
|
41
|
-
const timeToMaturity_y = Math.max(0, timeToMaturity_s / SECONDS_PER_YEAR);
|
|
42
|
-
const time_y = Math.max(timeToMaturity_y, tThresh_y);
|
|
43
|
-
const time = boros_offchain_math_1.FixedX18.fromNumber(time_y);
|
|
44
|
-
const impliedApr = market.data?.ammImpliedApr ?? market.data?.midApr ?? 0;
|
|
45
|
-
const absImpliedApr = boros_offchain_math_1.FixedX18.fromNumber(Math.abs(impliedApr));
|
|
46
|
-
const rate = absImpliedApr.gt(DEFAULT_MIN_MARGIN_INDEX_RATE)
|
|
47
|
-
? absImpliedApr
|
|
48
|
-
: DEFAULT_MIN_MARGIN_INDEX_RATE;
|
|
49
|
-
const contractSuf = rate.mulDown(time).mulDown(marginFactor);
|
|
50
|
-
const offchainSuf = rate.mulDown(time).divDown(boros_offchain_math_1.FixedX18.fromNumber(effectiveLeverage));
|
|
51
|
-
return contractSuf.gt(offchainSuf) ? contractSuf : offchainSuf;
|
|
52
|
-
}
|
|
53
|
-
function getStrategyBorosMargin(longMarket, shortMarket, leverage) {
|
|
54
|
-
const marginRequired1 = getMarginRequiredFor1YU(longMarket, leverage);
|
|
55
|
-
const marginRequired2 = getMarginRequiredFor1YU(shortMarket, leverage);
|
|
56
|
-
return marginRequired1 + marginRequired2;
|
|
57
|
-
}
|
|
58
|
-
function getStrategyMarginRequirements(longMarket, shortMarket, leverage) {
|
|
59
|
-
const marginRequired1 = getMarginRequiredFor1YU(longMarket, leverage);
|
|
60
|
-
const marginRequired2 = getMarginRequiredFor1YU(shortMarket, leverage);
|
|
61
|
-
return {
|
|
62
|
-
marginRequired1,
|
|
63
|
-
marginRequired2,
|
|
64
|
-
totalBorosMargin: marginRequired1 + marginRequired2,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=marginCalculator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"marginCalculator.js","sourceRoot":"","sources":["../../../src/entities/Calculator/marginCalculator.ts"],"names":[],"mappings":";;AA0BA,0DAyCC;AAKD,0EA+BC;AAUD,wDAQC;AAKD,sEAgBC;AA9ID,qEAAuD;AAGvD,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAE,GAAG,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,CAAC,CAAC;IACtE,MAAM,eAAe,GAAG,uBAAuB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACvE,OAAO;QACL,eAAe;QACf,eAAe;QACf,gBAAgB,EAAE,eAAe,GAAG,eAAe;KACpD,CAAC;AACJ,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { FixedX18 } from '@pendle/boros-offchain-math';
|
|
2
|
-
import type { Strategy, StrategyCalculatorInput, StrategyCalculatorResult, StrategyFixedAprParams } from './types';
|
|
3
|
-
export declare function calculateStrategyFixedApr(params: StrategyFixedAprParams): number;
|
|
4
|
-
export declare function calculateStrategyFixedAprFixedX18(params: {
|
|
5
|
-
perpLeverage: number;
|
|
6
|
-
daysToMaturity: number;
|
|
7
|
-
borosMargin: FixedX18;
|
|
8
|
-
impliedApr1: FixedX18;
|
|
9
|
-
impliedApr2: FixedX18;
|
|
10
|
-
exchangeFee1: FixedX18;
|
|
11
|
-
exchangeFee2: FixedX18;
|
|
12
|
-
borosTradeFee: FixedX18;
|
|
13
|
-
borosSettlementFee: FixedX18;
|
|
14
|
-
}): FixedX18;
|
|
15
|
-
export declare function calculateStrategy(input: StrategyCalculatorInput): StrategyCalculatorResult;
|
|
16
|
-
export declare function calculateStrategyAprFromStrategy(params: {
|
|
17
|
-
strategy: Strategy;
|
|
18
|
-
perpLeverage: number;
|
|
19
|
-
borosMargin: number;
|
|
20
|
-
exchangeFee1?: number;
|
|
21
|
-
exchangeFee2?: number;
|
|
22
|
-
borosTradeFee?: number;
|
|
23
|
-
borosSettlementFee?: number;
|
|
24
|
-
}): number;
|
|
25
|
-
export declare function calculateAprTimesMaxLeverage(strategy: Strategy, borosMargin: number, fees?: {
|
|
26
|
-
exchangeFee1?: number;
|
|
27
|
-
exchangeFee2?: number;
|
|
28
|
-
borosTradeFee?: number;
|
|
29
|
-
borosSettlementFee?: number;
|
|
30
|
-
}): number;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateStrategyFixedApr = calculateStrategyFixedApr;
|
|
4
|
-
exports.calculateStrategyFixedAprFixedX18 = calculateStrategyFixedAprFixedX18;
|
|
5
|
-
exports.calculateStrategy = calculateStrategy;
|
|
6
|
-
exports.calculateStrategyAprFromStrategy = calculateStrategyAprFromStrategy;
|
|
7
|
-
exports.calculateAprTimesMaxLeverage = calculateAprTimesMaxLeverage;
|
|
8
|
-
const boros_offchain_math_1 = require("@pendle/boros-offchain-math");
|
|
9
|
-
function calculateStrategyFixedApr(params) {
|
|
10
|
-
const { perpLeverage, daysToMaturity, borosMargin, impliedApr1, impliedApr2, exchangeFee1, exchangeFee2, borosTradeFee, borosSettlementFee, } = params;
|
|
11
|
-
if (daysToMaturity <= 0) {
|
|
12
|
-
return 0;
|
|
13
|
-
}
|
|
14
|
-
const impliedAprDiff = Math.abs(impliedApr1 - impliedApr2);
|
|
15
|
-
const annualizationFactor = 365 / daysToMaturity;
|
|
16
|
-
const totalExchangeFees = 2 * (exchangeFee1 + exchangeFee2);
|
|
17
|
-
const totalBorosFees = 2 * (borosSettlementFee + borosTradeFee);
|
|
18
|
-
const totalFees = totalExchangeFees + totalBorosFees;
|
|
19
|
-
const leverageFactor = 1 / (2 / perpLeverage + borosMargin);
|
|
20
|
-
const fixedApr = leverageFactor * (impliedAprDiff - annualizationFactor * totalFees);
|
|
21
|
-
return fixedApr;
|
|
22
|
-
}
|
|
23
|
-
function calculateStrategyFixedAprFixedX18(params) {
|
|
24
|
-
const { perpLeverage, daysToMaturity, borosMargin, impliedApr1, impliedApr2, exchangeFee1, exchangeFee2, borosTradeFee, borosSettlementFee, } = params;
|
|
25
|
-
if (daysToMaturity <= 0) {
|
|
26
|
-
return boros_offchain_math_1.FixedX18.ZERO;
|
|
27
|
-
}
|
|
28
|
-
const impliedAprDiff = impliedApr1.sub(impliedApr2).abs();
|
|
29
|
-
const annualizationFactor = boros_offchain_math_1.FixedX18.fromNumber(365 / daysToMaturity);
|
|
30
|
-
const two = boros_offchain_math_1.FixedX18.fromNumber(2);
|
|
31
|
-
const totalExchangeFees = exchangeFee1.add(exchangeFee2).mulDown(two);
|
|
32
|
-
const totalBorosFees = borosSettlementFee.add(borosTradeFee).mulDown(two);
|
|
33
|
-
const totalFees = totalExchangeFees.add(totalBorosFees);
|
|
34
|
-
const annualizedFees = annualizationFactor.mulDown(totalFees);
|
|
35
|
-
const netReturn = impliedAprDiff.sub(annualizedFees);
|
|
36
|
-
const twoOverPerpLev = boros_offchain_math_1.FixedX18.fromNumber(2 / perpLeverage);
|
|
37
|
-
const denominator = twoOverPerpLev.add(borosMargin);
|
|
38
|
-
const leverageFactor = boros_offchain_math_1.FixedX18.ONE.divDown(denominator);
|
|
39
|
-
const fixedApr = leverageFactor.mulDown(netReturn);
|
|
40
|
-
return fixedApr;
|
|
41
|
-
}
|
|
42
|
-
function calculateStrategy(input) {
|
|
43
|
-
const { totalCapital, daysToMaturity, perpLeverage, borosMargin, impliedApr1, impliedApr2, exchangeFee1, exchangeFee2, borosTradeFee, borosSettlementFee, } = input;
|
|
44
|
-
const params = {
|
|
45
|
-
perpLeverage,
|
|
46
|
-
daysToMaturity,
|
|
47
|
-
borosMargin: borosMargin / 100,
|
|
48
|
-
impliedApr1: impliedApr1 / 100,
|
|
49
|
-
impliedApr2: impliedApr2 / 100,
|
|
50
|
-
exchangeFee1: exchangeFee1 / 100,
|
|
51
|
-
exchangeFee2: exchangeFee2 / 100,
|
|
52
|
-
borosTradeFee: borosTradeFee / 100,
|
|
53
|
-
borosSettlementFee: borosSettlementFee / 100,
|
|
54
|
-
};
|
|
55
|
-
const fixedApr = calculateStrategyFixedApr(params);
|
|
56
|
-
const roi = fixedApr * (daysToMaturity / 365);
|
|
57
|
-
const estimatedEarnings = totalCapital * roi;
|
|
58
|
-
const estimatedEarningsPerYear = totalCapital * fixedApr;
|
|
59
|
-
return {
|
|
60
|
-
fixedApr,
|
|
61
|
-
fixedAprPercentage: fixedApr * 100,
|
|
62
|
-
estimatedEarnings,
|
|
63
|
-
estimatedEarningsPerYear,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
function calculateStrategyAprFromStrategy(params) {
|
|
67
|
-
const { strategy, perpLeverage, borosMargin, exchangeFee1 = 0.0005, exchangeFee2 = 0.0005, borosTradeFee = 0.0005, borosSettlementFee = 0.002, } = params;
|
|
68
|
-
return calculateStrategyFixedApr({
|
|
69
|
-
perpLeverage,
|
|
70
|
-
daysToMaturity: strategy.daysToMaturity,
|
|
71
|
-
borosMargin,
|
|
72
|
-
impliedApr1: strategy.longMarket.impliedApr,
|
|
73
|
-
impliedApr2: strategy.shortMarket.impliedApr,
|
|
74
|
-
exchangeFee1,
|
|
75
|
-
exchangeFee2,
|
|
76
|
-
borosTradeFee,
|
|
77
|
-
borosSettlementFee,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
function calculateAprTimesMaxLeverage(strategy, borosMargin, fees) {
|
|
81
|
-
const { exchangeFee1 = 0.0005, exchangeFee2 = 0.0005, borosTradeFee = 0.0005, borosSettlementFee = 0.002, } = fees ?? {};
|
|
82
|
-
return calculateStrategyFixedApr({
|
|
83
|
-
perpLeverage: strategy.maxPerpLeverage,
|
|
84
|
-
daysToMaturity: strategy.daysToMaturity,
|
|
85
|
-
borosMargin,
|
|
86
|
-
impliedApr1: strategy.longMarket.impliedApr,
|
|
87
|
-
impliedApr2: strategy.shortMarket.impliedApr,
|
|
88
|
-
exchangeFee1,
|
|
89
|
-
exchangeFee2,
|
|
90
|
-
borosTradeFee,
|
|
91
|
-
borosSettlementFee,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=strategyApr.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strategyApr.js","sourceRoot":"","sources":["../../../src/entities/Calculator/strategyApr.ts"],"names":[],"mappings":";;AAYA,8DA6BC;AAKD,8EAoDC;AAWD,8CAwC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e;QACtC,cAAc,EAAE,QAAQ,CAAC,cAAc;QACvC,WAAW;QACX,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;QAC3C,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC,UAAU;QAC5C,YAAY;QACZ,YAAY;QACZ,aAAa;QACb,kBAAkB;KACnB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Strategy, StrategyExecutionPlan } from './types';
|
|
2
|
-
export type GenerateExecutionPlanParams = {
|
|
3
|
-
strategy: Strategy;
|
|
4
|
-
totalCapital: number;
|
|
5
|
-
perpLeverage: number;
|
|
6
|
-
borosMargin: number;
|
|
7
|
-
};
|
|
8
|
-
export declare function generateExecutionPlan(params: GenerateExecutionPlanParams): StrategyExecutionPlan;
|
|
9
|
-
export declare function getExecutionStepsSummary(plan: StrategyExecutionPlan): string[];
|
|
10
|
-
export declare function formatExecutionStepsForUI(plan: StrategyExecutionPlan): Array<{
|
|
11
|
-
action: 'Long' | 'Short';
|
|
12
|
-
size: string;
|
|
13
|
-
description: string;
|
|
14
|
-
platform: 'perp' | 'boros';
|
|
15
|
-
exchange: string;
|
|
16
|
-
clickable: boolean;
|
|
17
|
-
}>;
|
|
18
|
-
export declare function calculateCapitalAllocation(params: {
|
|
19
|
-
totalCapital: number;
|
|
20
|
-
perpLeverage: number;
|
|
21
|
-
liquidationThreshold: number;
|
|
22
|
-
}): {
|
|
23
|
-
capitalPerPerpLeg: number;
|
|
24
|
-
capitalPerBorosLeg: number;
|
|
25
|
-
totalPerpCapital: number;
|
|
26
|
-
totalBorosCapital: number;
|
|
27
|
-
notionalExposurePerLeg: number;
|
|
28
|
-
};
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateExecutionPlan = generateExecutionPlan;
|
|
4
|
-
exports.getExecutionStepsSummary = getExecutionStepsSummary;
|
|
5
|
-
exports.formatExecutionStepsForUI = formatExecutionStepsForUI;
|
|
6
|
-
exports.calculateCapitalAllocation = calculateCapitalAllocation;
|
|
7
|
-
function generateExecutionPlan(params) {
|
|
8
|
-
const { strategy, totalCapital, perpLeverage, borosMargin } = params;
|
|
9
|
-
const positionSizePerLeg = totalCapital / (2 / perpLeverage + borosMargin);
|
|
10
|
-
const yuSize = positionSizePerLeg;
|
|
11
|
-
const steps = [
|
|
12
|
-
{
|
|
13
|
-
stepNumber: 1,
|
|
14
|
-
action: 'long',
|
|
15
|
-
platform: 'perp',
|
|
16
|
-
exchange: strategy.longMarket.exchange,
|
|
17
|
-
description: `Long ${strategy.asset} on ${strategy.longMarket.exchange} perpetual`,
|
|
18
|
-
details: {
|
|
19
|
-
asset: strategy.asset,
|
|
20
|
-
size: `${positionSizePerLeg} ${strategy.asset}`,
|
|
21
|
-
marketType: 'perpetual',
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
stepNumber: 2,
|
|
26
|
-
action: 'short',
|
|
27
|
-
platform: 'perp',
|
|
28
|
-
exchange: strategy.shortMarket.exchange,
|
|
29
|
-
description: `Short ${strategy.asset} on ${strategy.shortMarket.exchange} perpetual`,
|
|
30
|
-
details: {
|
|
31
|
-
asset: strategy.asset,
|
|
32
|
-
size: `${positionSizePerLeg} ${strategy.asset}`,
|
|
33
|
-
marketType: 'perpetual',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
stepNumber: 3,
|
|
38
|
-
action: 'long',
|
|
39
|
-
platform: 'boros',
|
|
40
|
-
exchange: strategy.longMarket.exchange,
|
|
41
|
-
description: `Long ${strategy.asset} YU on Boros ${strategy.longMarket.exchange} market`,
|
|
42
|
-
marketId: strategy.longMarket.marketId,
|
|
43
|
-
ammId: strategy.longMarket.ammId,
|
|
44
|
-
details: {
|
|
45
|
-
asset: strategy.asset,
|
|
46
|
-
size: `${yuSize} YU ${strategy.asset}`,
|
|
47
|
-
marketType: `Boros ${strategy.longMarket.exchange} market`,
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
stepNumber: 4,
|
|
52
|
-
action: 'short',
|
|
53
|
-
platform: 'boros',
|
|
54
|
-
exchange: strategy.shortMarket.exchange,
|
|
55
|
-
description: `Short ${strategy.asset} YU on Boros ${strategy.shortMarket.exchange} market`,
|
|
56
|
-
marketId: strategy.shortMarket.marketId,
|
|
57
|
-
ammId: strategy.shortMarket.ammId,
|
|
58
|
-
details: {
|
|
59
|
-
asset: strategy.asset,
|
|
60
|
-
size: `${yuSize} YU ${strategy.asset}`,
|
|
61
|
-
marketType: `Boros ${strategy.shortMarket.exchange} market`,
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
];
|
|
65
|
-
return {
|
|
66
|
-
strategy,
|
|
67
|
-
steps,
|
|
68
|
-
totalCapitalRequired: totalCapital,
|
|
69
|
-
perpLeverage,
|
|
70
|
-
borosMargin,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function getExecutionStepsSummary(plan) {
|
|
74
|
-
return plan.steps.map((step) => {
|
|
75
|
-
const actionText = step.action === 'long' ? 'Long' : 'Short';
|
|
76
|
-
return `${actionText} ${step.details.size} on ${step.details.marketType}`;
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
function formatExecutionStepsForUI(plan) {
|
|
80
|
-
const { strategy, totalCapitalRequired, perpLeverage, borosMargin } = plan;
|
|
81
|
-
const positionSize = totalCapitalRequired / (2 / perpLeverage + borosMargin);
|
|
82
|
-
return [
|
|
83
|
-
{
|
|
84
|
-
action: 'Long',
|
|
85
|
-
size: `${positionSize} ${strategy.asset}`,
|
|
86
|
-
description: `on ${strategy.longMarket.exchange} ${strategy.asset} perpetual`,
|
|
87
|
-
platform: 'perp',
|
|
88
|
-
exchange: strategy.longMarket.exchange,
|
|
89
|
-
clickable: true,
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
action: 'Short',
|
|
93
|
-
size: `${positionSize} ${strategy.asset}`,
|
|
94
|
-
description: `on ${strategy.shortMarket.exchange} ${strategy.asset} perpetual`,
|
|
95
|
-
platform: 'perp',
|
|
96
|
-
exchange: strategy.shortMarket.exchange,
|
|
97
|
-
clickable: true,
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
action: 'Long',
|
|
101
|
-
size: `${positionSize} YU ${strategy.asset}`,
|
|
102
|
-
description: `on Boros ${strategy.longMarket.exchange} ${strategy.asset} market`,
|
|
103
|
-
platform: 'boros',
|
|
104
|
-
exchange: strategy.longMarket.exchange,
|
|
105
|
-
clickable: true,
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
action: 'Short',
|
|
109
|
-
size: `${positionSize} YU ${strategy.asset}`,
|
|
110
|
-
description: `on Boros ${strategy.shortMarket.exchange} ${strategy.asset} market`,
|
|
111
|
-
platform: 'boros',
|
|
112
|
-
exchange: strategy.shortMarket.exchange,
|
|
113
|
-
clickable: true,
|
|
114
|
-
},
|
|
115
|
-
];
|
|
116
|
-
}
|
|
117
|
-
function calculateCapitalAllocation(params) {
|
|
118
|
-
const { totalCapital, perpLeverage, liquidationThreshold } = params;
|
|
119
|
-
const capitalPerPerpLeg = totalCapital / 2;
|
|
120
|
-
const notionalExposurePerLeg = capitalPerPerpLeg * perpLeverage;
|
|
121
|
-
const capitalPerBorosLeg = 0;
|
|
122
|
-
return {
|
|
123
|
-
capitalPerPerpLeg,
|
|
124
|
-
capitalPerBorosLeg,
|
|
125
|
-
totalPerpCapital: totalCapital,
|
|
126
|
-
totalBorosCapital: 0,
|
|
127
|
-
notionalExposurePerLeg,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
//# sourceMappingURL=strategyExecution.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strategyExecution.js","sourceRoot":"","sources":["../../../src/entities/Calculator/strategyExecution.ts"],"names":[],"mappings":";;AAoBA,sDA6EC;AAKD,4DAK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,QAAQ,CAAC,KAAK,EAAE;YAC5C,WAAW,EAAE,YAAY,QAAQ,CAAC,WAAW,CAAC,QAAQ,IAAI,QAAQ,CAAC,KAAK,SAAS;YACjF,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAAC,QAAQ;YACvC,SAAS,EAAE,IAAI;SAChB;KACF,CAAC;AACJ,CAAC;AAKD,SAAgB,0BAA0B,CAAC,MAI1C;IAOC,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAC;IAKpE,MAAM,iBAAiB,GAAG,YAAY,GAAG,CAAC,CAAC;IAC3C,MAAM,sBAAsB,GAAG,iBAAiB,GAAG,YAAY,CAAC;IAGhE,MAAM,kBAAkB,GAAG,CAAC,CAAC;IAE7B,OAAO;QACL,iBAAiB;QACjB,kBAAkB;QAClB,gBAAgB,EAAE,YAAY;QAC9B,iBAAiB,EAAE,CAAC;QACpB,sBAAsB;KACvB,CAAC;AACJ,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { GetStrategiesParams, GetStrategiesResult } from './types';
|
|
2
|
-
export declare function findStrategies(params?: GetStrategiesParams): Promise<GetStrategiesResult>;
|
|
3
|
-
export declare function findStrategiesByAsset(params: GetStrategiesParams & {
|
|
4
|
-
asset: string;
|
|
5
|
-
}): Promise<GetStrategiesResult>;
|
|
6
|
-
export declare function findStrategiesByMaturity(params: GetStrategiesParams & {
|
|
7
|
-
maturity: number;
|
|
8
|
-
}): Promise<GetStrategiesResult>;
|
|
9
|
-
export declare function findStrategiesByExchanges(params: GetStrategiesParams & {
|
|
10
|
-
exchanges: [string, string];
|
|
11
|
-
}): Promise<GetStrategiesResult>;
|