@strkfarm/sdk 2.0.0-dev.35 → 2.0.0-dev.36
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 +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/index.browser.global.js +19244 -28574
- package/dist/index.browser.mjs +8439 -17951
- package/dist/index.d.ts +578 -2746
- package/dist/index.js +8528 -18078
- package/dist/index.mjs +8456 -17968
- package/package.json +3 -3
- package/src/data/universal-vault.abi.json +8 -7
- package/src/dataTypes/bignumber.browser.ts +5 -1
- package/src/dataTypes/bignumber.node.ts +5 -0
- package/src/global.ts +21 -1
- package/src/interfaces/common.tsx +39 -4
- package/src/modules/avnu.ts +19 -10
- package/src/modules/index.ts +1 -1
- package/src/strategies/base-strategy.ts +92 -8
- package/src/strategies/constants.ts +8 -3
- package/src/strategies/ekubo-cl-vault.tsx +150 -16
- package/src/strategies/factory.ts +21 -1
- package/src/strategies/index.ts +2 -7
- package/src/strategies/registry.ts +28 -5
- package/src/strategies/sensei.ts +29 -13
- package/src/strategies/svk-strategy.ts +26 -2
- package/src/strategies/token-boosted-xstrk-carry-strategy.tsx +1057 -0
- package/src/strategies/universal-adapters/avnu-adapter.ts +16 -8
- package/src/strategies/universal-adapters/index.ts +1 -2
- package/src/strategies/universal-adapters/svk-troves-adapter.ts +19 -6
- package/src/strategies/universal-adapters/vesu-modify-position-adapter.ts +22 -3
- package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +75 -52
- package/src/strategies/universal-adapters/vesu-position-common.ts +38 -31
- package/src/strategies/universal-lst-muliplier-strategy.tsx +222 -269
- package/src/strategies/universal-strategy.tsx +166 -105
- package/src/strategies/vesu-rebalance.tsx +3 -6
- package/src/strategies/yoloVault.ts +1084 -0
- package/src/utils/health-factor-math.ts +29 -0
- package/src/modules/ExtendedWrapperSDk/index.ts +0 -62
- package/src/modules/ExtendedWrapperSDk/types.ts +0 -334
- package/src/modules/ExtendedWrapperSDk/wrapper.ts +0 -611
- package/src/strategies/universal-adapters/extended-adapter.ts +0 -860
- package/src/strategies/universal-adapters/usdc<>usdce-adapter.ts +0 -200
- package/src/strategies/usdc-boosted-strategy.tsx +0 -693
- package/src/strategies/vesu-extended-strategy/services/executionService.ts +0 -2234
- package/src/strategies/vesu-extended-strategy/services/extended-vesu-state-manager.ts +0 -4254
- package/src/strategies/vesu-extended-strategy/services/ltv-imbalance-rebalance-math.ts +0 -783
- package/src/strategies/vesu-extended-strategy/services/operationService.ts +0 -56
- package/src/strategies/vesu-extended-strategy/types/transaction-metadata.ts +0 -88
- package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +0 -78
- package/src/strategies/vesu-extended-strategy/utils/constants.ts +0 -48
- package/src/strategies/vesu-extended-strategy/utils/helper.ts +0 -528
- package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +0 -1014
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Web3Number } from "@/dataTypes";
|
|
2
|
-
import { ExtendedAdapter } from "@/strategies/universal-adapters/extended-adapter";
|
|
3
|
-
import { VesuMultiplyAdapter } from "../../universal-adapters/vesu-multiply-adapter";
|
|
4
|
-
import { CycleType, TransactionResult } from "../types/transaction-metadata";
|
|
5
|
-
|
|
6
|
-
/** Planned asset routing between protocols (concrete `Operations` subclasses define shape). */
|
|
7
|
-
export interface AssetMovementPlan {}
|
|
8
|
-
|
|
9
|
-
export abstract class Operations {
|
|
10
|
-
|
|
11
|
-
abstract computeAssetMovements(
|
|
12
|
-
extendedAmount: Web3Number,
|
|
13
|
-
vesuAmount: Web3Number
|
|
14
|
-
): Promise<AssetMovementPlan | null>;
|
|
15
|
-
|
|
16
|
-
abstract executeAssetMovements(
|
|
17
|
-
plan: AssetMovementPlan
|
|
18
|
-
): Promise<TransactionResult[]>;
|
|
19
|
-
|
|
20
|
-
abstract shouldMoveAssets(
|
|
21
|
-
extendedAmount: Web3Number,
|
|
22
|
-
vesuAmount: Web3Number
|
|
23
|
-
): Promise<TransactionResult[]>;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
abstract shouldInvest(): Promise<{
|
|
27
|
-
shouldInvest: boolean;
|
|
28
|
-
vesuAmount: Web3Number;
|
|
29
|
-
extendedAmount: Web3Number;
|
|
30
|
-
extendedLeverage: number;
|
|
31
|
-
vesuLeverage: number;
|
|
32
|
-
debtAmountToBeRepaid: Web3Number;
|
|
33
|
-
}>;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Move assets between protocols.
|
|
37
|
-
* Returns transaction calls and metadata for DB tracking.
|
|
38
|
-
*/
|
|
39
|
-
abstract moveAssets(
|
|
40
|
-
params: { from: string; to: string; amount: Web3Number, cycleType: CycleType },
|
|
41
|
-
extendedAdapter: ExtendedAdapter,
|
|
42
|
-
vesuAdapter: VesuMultiplyAdapter,
|
|
43
|
-
): Promise<TransactionResult>;
|
|
44
|
-
/**
|
|
45
|
-
* Handle deposit operation.
|
|
46
|
-
* Returns transaction calls and metadata for DB tracking.
|
|
47
|
-
*/
|
|
48
|
-
abstract handleDeposit(): Promise<TransactionResult<{
|
|
49
|
-
extendedAmountInBTC: Web3Number;
|
|
50
|
-
}>>;
|
|
51
|
-
/**
|
|
52
|
-
* Handle withdrawal operation.
|
|
53
|
-
* Returns transaction calls and metadata for DB tracking.
|
|
54
|
-
*/
|
|
55
|
-
abstract handleWithdraw(amount: Web3Number): Promise<TransactionResult[]>;
|
|
56
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { Call } from "starknet";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transaction metadata that SDK generates and risk engine stores in DB.
|
|
5
|
-
* This metadata is used to track transaction lifecycle without coupling SDK to DB.
|
|
6
|
-
*/
|
|
7
|
-
export interface TransactionMetadata {
|
|
8
|
-
protocolFrom: string;
|
|
9
|
-
protocolTo: string;
|
|
10
|
-
transactionType: 'DEPOSIT' | 'WITHDRAWAL' | 'NONE';
|
|
11
|
-
usdAmount: string;
|
|
12
|
-
status: 'COMPLETED' | 'FAILED' | 'PENDING';
|
|
13
|
-
cycleType: CycleType;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export enum CycleType {
|
|
18
|
-
INVESTMENT = 'INVESTMENT',
|
|
19
|
-
REBALANCE_PRICE_DROP = 'REBALANCE_PRICE_DROP',
|
|
20
|
-
REBALANCE_PRICE_RISE = 'REBALANCE_PRICE_RISE',
|
|
21
|
-
WITHDRAWAL = 'WITHDRAWAL',
|
|
22
|
-
DELTA_NEUTRAL_ADJUSTMENT = 'DELTA_NEUTRAL_ADJUSTMENT',
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Enhanced return type for operations that generate transactions.
|
|
27
|
-
* Includes both the calls (for execution) and metadata (for DB storage).
|
|
28
|
-
*/
|
|
29
|
-
export interface TransactionResult<T = any> {
|
|
30
|
-
calls: Call[];
|
|
31
|
-
status: boolean;
|
|
32
|
-
transactionMetadata: TransactionMetadata;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// ─── Execution Lifecycle Events ─────────────────────────────────────────────
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Key lifecycle event types emitted during execution.
|
|
39
|
-
* Used by callers (e.g. risk engine) to hook into the execution pipeline
|
|
40
|
-
* and persist state to DB, send alerts, etc.
|
|
41
|
-
*/
|
|
42
|
-
export enum ExecutionEventType {
|
|
43
|
-
/** Execution started — tx sent on-chain or order placed on exchange */
|
|
44
|
-
INITIATED = 'INITIATED',
|
|
45
|
-
/** Execution completed successfully — tx confirmed / order filled */
|
|
46
|
-
SUCCESS = 'SUCCESS',
|
|
47
|
-
/** Execution failed — tx reverted / order rejected / timeout */
|
|
48
|
-
FAILURE = 'FAILURE',
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Metadata payload accompanying each execution lifecycle event.
|
|
53
|
-
* Contains relevant identifiers, prices, and contextual information.
|
|
54
|
-
*/
|
|
55
|
-
export interface ExecutionEventMetadata {
|
|
56
|
-
/** Route type string (e.g. RouteType value) */
|
|
57
|
-
routeType?: string;
|
|
58
|
-
/** Human-readable route summary */
|
|
59
|
-
routeSummary?: string;
|
|
60
|
-
/** On-chain transaction hash (when available) */
|
|
61
|
-
txHash?: string;
|
|
62
|
-
/** Exchange order ID (for off-chain orders) */
|
|
63
|
-
orderId?: string;
|
|
64
|
-
/** Amount involved in the operation */
|
|
65
|
-
amount?: string;
|
|
66
|
-
/** Protocol name */
|
|
67
|
-
protocol?: string;
|
|
68
|
-
/** Actual execution price (for exchange orders) */
|
|
69
|
-
executionPrice?: number;
|
|
70
|
-
/** Limit price that was set */
|
|
71
|
-
limitPrice?: number;
|
|
72
|
-
/** Error message on failure */
|
|
73
|
-
error?: string;
|
|
74
|
-
/** On-chain calls that were built */
|
|
75
|
-
calls?: Call[];
|
|
76
|
-
/** Extensible: any extra metadata */
|
|
77
|
-
[key: string]: any;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Callback invoked on key execution lifecycle events.
|
|
82
|
-
* Callers can use this to save to DB, send notifications, log, etc.
|
|
83
|
-
*/
|
|
84
|
-
export type ExecutionCallback = (
|
|
85
|
-
eventType: ExecutionEventType,
|
|
86
|
-
metadata: ExecutionEventMetadata,
|
|
87
|
-
) => void | Promise<void>;
|
|
88
|
-
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AVNU_API,
|
|
3
|
-
USDC_TOKEN_ADDRESS,
|
|
4
|
-
USDC_TOKEN_DECIMALS,
|
|
5
|
-
WBTC_TOKEN_ADDRESS,
|
|
6
|
-
WBTC_TOKEN_DECIMALS,
|
|
7
|
-
WALLET_ADDRESS,
|
|
8
|
-
EXTEND_CONTRACT_ADDRESS,
|
|
9
|
-
MULTIPLY_CONTRACT_ADDRESS,
|
|
10
|
-
EXTENDED_BASE_URL,
|
|
11
|
-
EXTEND_MARKET_NAME,
|
|
12
|
-
EXTENDED_QTY_PRECISION,
|
|
13
|
-
EXTENDED_FEES,
|
|
14
|
-
MAINTENANCE_MARGIN,
|
|
15
|
-
VESU_POOL_ID,
|
|
16
|
-
MAX_LTV_BTC_USDC,
|
|
17
|
-
MAX_LIQUIDATION_RATIO,
|
|
18
|
-
TARGET_HF,
|
|
19
|
-
EKUBO_ENDPOINT,
|
|
20
|
-
PRICE_MAX_SLIPPAGE_EKUBO,
|
|
21
|
-
MINIMUM_DEBT_AMOUNT_VESU_FOR_REBALANCING,
|
|
22
|
-
MINIMUM_EXTENDED_POSITION_SIZE
|
|
23
|
-
} from "./constants"
|
|
24
|
-
import VesuPoolV2Abi from '@/data/vesu-pool-v2.abi.json';
|
|
25
|
-
import ExtendedDepositAbi from '@/data/extended-deposit.abi.json';
|
|
26
|
-
import VesuMultiplyAbi from '@/data/vesu-multiple.abi.json';
|
|
27
|
-
|
|
28
|
-
// Grouped, readable configuration (no behavior change). Consumers can migrate gradually.
|
|
29
|
-
|
|
30
|
-
export const AddressesConfig = {
|
|
31
|
-
tokens: {
|
|
32
|
-
USDC: { address: USDC_TOKEN_ADDRESS, decimals: USDC_TOKEN_DECIMALS },
|
|
33
|
-
WBTC: { address: WBTC_TOKEN_ADDRESS, decimals: WBTC_TOKEN_DECIMALS },
|
|
34
|
-
},
|
|
35
|
-
contracts: {
|
|
36
|
-
EXTENDED: EXTEND_CONTRACT_ADDRESS,
|
|
37
|
-
MULTIPLY: MULTIPLY_CONTRACT_ADDRESS,
|
|
38
|
-
},
|
|
39
|
-
wallet: {
|
|
40
|
-
address: WALLET_ADDRESS,
|
|
41
|
-
},
|
|
42
|
-
} as const;
|
|
43
|
-
|
|
44
|
-
export const ExtendedConfig = {
|
|
45
|
-
baseUrl: EXTENDED_BASE_URL,
|
|
46
|
-
marketName: EXTEND_MARKET_NAME,
|
|
47
|
-
maintenanceMargin: MAINTENANCE_MARGIN,
|
|
48
|
-
precision: EXTENDED_QTY_PRECISION,
|
|
49
|
-
fees: EXTENDED_FEES,
|
|
50
|
-
minPositionSize: MINIMUM_EXTENDED_POSITION_SIZE,
|
|
51
|
-
} as const;
|
|
52
|
-
|
|
53
|
-
export const VesuConfig = {
|
|
54
|
-
poolId: VESU_POOL_ID,
|
|
55
|
-
maxLtv: MAX_LTV_BTC_USDC,
|
|
56
|
-
maxLiquidationRatio: MAX_LIQUIDATION_RATIO,
|
|
57
|
-
targetHealthFactor: TARGET_HF,
|
|
58
|
-
ekubo: {
|
|
59
|
-
endpoint: EKUBO_ENDPOINT,
|
|
60
|
-
priceMaxSlippage: PRICE_MAX_SLIPPAGE_EKUBO,
|
|
61
|
-
},
|
|
62
|
-
avnu: {
|
|
63
|
-
api: AVNU_API,
|
|
64
|
-
},
|
|
65
|
-
targetLtv : 0.61,
|
|
66
|
-
minDebtForVesuRebalacing:MINIMUM_DEBT_AMOUNT_VESU_FOR_REBALANCING
|
|
67
|
-
} as const;
|
|
68
|
-
|
|
69
|
-
export const AbisConfig = {
|
|
70
|
-
vesu: {
|
|
71
|
-
multiply: VesuMultiplyAbi,
|
|
72
|
-
pool: VesuPoolV2Abi,
|
|
73
|
-
},
|
|
74
|
-
extended: {
|
|
75
|
-
contract: ExtendedDepositAbi,
|
|
76
|
-
},
|
|
77
|
-
} as const;
|
|
78
|
-
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export const AVNU_API = "https://starknet.api.avnu.fi/swap/v2/quotes";
|
|
2
|
-
export const SLIPPAGE = 0.01;
|
|
3
|
-
export const USDC_TOKEN_DECIMALS = 6;
|
|
4
|
-
export const USDC_TOKEN_ADDRESS =
|
|
5
|
-
"0x053C91253BC9682c04929cA02ED00b3E423f6710D2ee7e0D5EBB06F3eCF368A8";
|
|
6
|
-
export const BUFFER_USDC_IN_WITHDRAWAL=5;
|
|
7
|
-
export const WBTC_TOKEN_ADDRESS = "0x3fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac";
|
|
8
|
-
export const WBTC_TOKEN_DECIMALS = 8;
|
|
9
|
-
export const MAINTENANCE_MARGIN = 0.01;
|
|
10
|
-
export const MAX_PRICE_DROP_PERCENTAGE = Number(process.env.MAX_PRICE_DROP_PERCENTAGE ?? 0.25);
|
|
11
|
-
export const MAX_LTV_BTC_USDC = 0.8428;
|
|
12
|
-
export const MAX_LIQUIDATION_RATIO = 0.86;
|
|
13
|
-
export const VAULT_ID_EXTENDED= process.env.VAULT_ID_EXTENDED ?? 220774;
|
|
14
|
-
export const WALLET_ADDRESS =
|
|
15
|
-
process.env.WALLET_ADDRESS ?? "0x007E24592287427aaE9d291770B17d582E8A45f3aE54228F998793Ec769B7D13";
|
|
16
|
-
export const STRK_API_TEST_RPC = process.env.STRK_API_TEST_RPC ?? "https://sepolia.starknet.a5a.ch";
|
|
17
|
-
export const STRK_API_RPC = process.env.STRK_API_RPC ?? "https://mainnet.starknet.a5a.ch";
|
|
18
|
-
export const MAX_RETRIES = Number(process.env.MAX_RETRIES ?? 3);
|
|
19
|
-
export const MAX_DELAY = Number(process.env.MAX_DELAY ?? 100);
|
|
20
|
-
export const EXTEND_MARKET_NAME = "BTC-USD";
|
|
21
|
-
|
|
22
|
-
// factor of balance to keep as buffer (0.05 = 5%)
|
|
23
|
-
export const LIMIT_BALANCE = Number(process.env.LIMIT_BALANCE ?? 0.05);
|
|
24
|
-
export const LIMIT_BALANCE_VALUE=20;
|
|
25
|
-
export const REBALANCER_INTERVAL = Number(process.env.REBALANCER_INTERVAL ?? 180000); //3 mins
|
|
26
|
-
export const WITHDRAWAL_INTERVAL = Number(process.env.WITHDRAWAL_INTERVAL ?? 18000000); //5 hours
|
|
27
|
-
export const INVESTING_INTERVAL = Number(process.env.INVESTING_INTERVAL ?? 180000); //3 mins
|
|
28
|
-
export const MAXIMUM_DELTA = Number(process.env.MAXIMUM_DELTA ?? 5);
|
|
29
|
-
export const EXTENDED_BASE_URL = process.env.EXTENDED_BASE_URL ?? "https://api.starknet.extended.exchange";
|
|
30
|
-
export const VESU_POOL_ID = "0x02eef0c13b10b487ea5916b54c0a7f98ec43fb3048f60fdeedaf5b08f6f88aaf";
|
|
31
|
-
export const EKUBO_ENDPOINT = "https://quoter-mainnet-api.ekubo.org/{{AMOUNT}}/{{TOKEN_FROM_ADDRESS}}/{{TOKEN_TO_ADDRESS}}"; // e.g. ETH/USDC'
|
|
32
|
-
export const TARGET_HF = Number(process.env.TARGET_HF ?? 1.4);
|
|
33
|
-
export const MULTIPLY_CONTRACT_ADDRESS = "0x07964760e90baa28841ec94714151e03fbc13321797e68a874e88f27c9d58513";
|
|
34
|
-
export const EXTEND_CONTRACT_ADDRESS = "0x062da0780fae50d68cecaa5a051606dc21217ba290969b302db4dd99d2e9b470";
|
|
35
|
-
export const EXTENDED_QTY_PRECISION = 5;
|
|
36
|
-
export const EXTENDED_FEES= Number(process.env.EXTENDED_FEES ?? 0.006);
|
|
37
|
-
export const REBALANCE_PRICE_DROP_PERCENTAGE = Number(process.env.REBALANCE_PRICE_DROP_PERCENTAGE ?? 3);
|
|
38
|
-
export const PRICE_MAX_SLIPPAGE_EKUBO = Number(process.env.PRICE_MAX_SLIPPAGE_EKUBO ?? 0.005);
|
|
39
|
-
export const MINIMUM_DEBT_AMOUNT_VESU_FOR_REBALANCING = Number(process.env.MINIMUM_DEBT_AMOUNT_VESU_FOR_REBALANCING ?? 1);
|
|
40
|
-
export const MINIMUM_EXTENDED_POSITION_SIZE = 0.0001;
|
|
41
|
-
export const MINIMUM_WBTC_DIFFERENCE_FOR_AVNU_SWAP = 0.00001;
|
|
42
|
-
export const MAX_PRICE_DIFFERENCE_BETWEEN_AVNU_AND_EXTENDED = 700;
|
|
43
|
-
export const MIN_PRICE_DIFFERENCE_BETWEEN_AVNU_AND_EXTENDED = -100;
|
|
44
|
-
|
|
45
|
-
//STATUS CODES
|
|
46
|
-
export const SUCCESS_STATUS_CODE = 200;
|
|
47
|
-
export const ERROR_STATUS_CODE = 500;
|
|
48
|
-
export const BAD_REQUEST_STATUS_CODE = 400;
|