clodds 1.1.0 → 1.2.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/README.md +79 -47
- package/dist/agents/handlers/kalshi.d.ts +1 -2
- package/dist/agents/handlers/kalshi.js +369 -616
- package/dist/agents/handlers/kalshi.js.map +1 -1
- package/dist/agents/handlers/types.d.ts +1 -1
- package/dist/agents/index.d.ts +1 -1
- package/dist/agents/index.js +435 -710
- package/dist/agents/index.js.map +1 -1
- package/dist/bittensor/index.d.ts +3 -2
- package/dist/bittensor/index.js +44 -5
- package/dist/bittensor/index.js.map +1 -1
- package/dist/cli/commands/gateway.js +37 -2
- package/dist/cli/commands/gateway.js.map +1 -1
- package/dist/cli/commands/index.js +3 -2
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/index.js +6 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/cron/index.d.ts +1 -1
- package/dist/cron/index.js +26 -34
- package/dist/cron/index.js.map +1 -1
- package/dist/db/index.d.ts +12 -0
- package/dist/db/index.js +51 -23
- package/dist/db/index.js.map +1 -1
- package/dist/db/migrations.js +36 -0
- package/dist/db/migrations.js.map +1 -1
- package/dist/evm/index.d.ts +1 -0
- package/dist/evm/index.js +2 -0
- package/dist/evm/index.js.map +1 -1
- package/dist/evm/pancakeswap.d.ts +55 -0
- package/dist/evm/pancakeswap.js +299 -0
- package/dist/evm/pancakeswap.js.map +1 -0
- package/dist/exchanges/lighter/index.d.ts +95 -0
- package/dist/exchanges/lighter/index.js +154 -0
- package/dist/exchanges/lighter/index.js.map +1 -0
- package/dist/gateway/server.d.ts +9 -0
- package/dist/gateway/server.js +208 -1
- package/dist/gateway/server.js.map +1 -1
- package/dist/gateway/signal-bus.d.ts +2 -43
- package/dist/gateway/signal-bus.js.map +1 -1
- package/dist/index.js +40 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp/security.d.ts +44 -0
- package/dist/mcp/security.js +143 -0
- package/dist/mcp/security.js.map +1 -0
- package/dist/mcp/server.js +27 -2
- package/dist/mcp/server.js.map +1 -1
- package/dist/services/alt-data/index.d.ts +1 -1
- package/dist/sessions/index.js +66 -7
- package/dist/sessions/index.js.map +1 -1
- package/dist/signal-router/router.d.ts +1 -1
- package/dist/signal-router/types.d.ts +1 -1
- package/dist/skills/bundled/arbitrage/index.js +96 -63
- package/dist/skills/bundled/arbitrage/index.js.map +1 -1
- package/dist/skills/bundled/betfair/index.js +121 -83
- package/dist/skills/bundled/betfair/index.js.map +1 -1
- package/dist/skills/bundled/bridge/index.js +42 -13
- package/dist/skills/bundled/bridge/index.js.map +1 -1
- package/dist/skills/bundled/crypto-hft/index.js +267 -226
- package/dist/skills/bundled/crypto-hft/index.js.map +1 -1
- package/dist/skills/bundled/drift/index.js +83 -52
- package/dist/skills/bundled/drift/index.js.map +1 -1
- package/dist/skills/bundled/embeddings/index.js +87 -49
- package/dist/skills/bundled/embeddings/index.js.map +1 -1
- package/dist/skills/bundled/execution/index.js +47 -25
- package/dist/skills/bundled/execution/index.js.map +1 -1
- package/dist/skills/bundled/feeds/index.js +45 -25
- package/dist/skills/bundled/feeds/index.js.map +1 -1
- package/dist/skills/bundled/hyperliquid/index.js +91 -45
- package/dist/skills/bundled/hyperliquid/index.js.map +1 -1
- package/dist/skills/bundled/integrations/index.js +2 -1
- package/dist/skills/bundled/integrations/index.js.map +1 -1
- package/dist/skills/bundled/kamino/index.js +71 -43
- package/dist/skills/bundled/kamino/index.js.map +1 -1
- package/dist/skills/bundled/lighter/index.d.ts +19 -0
- package/dist/skills/bundled/lighter/index.js +385 -0
- package/dist/skills/bundled/lighter/index.js.map +1 -0
- package/dist/skills/bundled/marginfi/index.d.ts +21 -0
- package/dist/skills/bundled/marginfi/index.js +387 -0
- package/dist/skills/bundled/marginfi/index.js.map +1 -0
- package/dist/skills/bundled/opinion/index.js +44 -25
- package/dist/skills/bundled/opinion/index.js.map +1 -1
- package/dist/skills/bundled/pancakeswap/index.d.ts +19 -0
- package/dist/skills/bundled/pancakeswap/index.js +260 -0
- package/dist/skills/bundled/pancakeswap/index.js.map +1 -0
- package/dist/skills/bundled/setup/index.d.ts +16 -0
- package/dist/skills/bundled/setup/index.js +427 -0
- package/dist/skills/bundled/setup/index.js.map +1 -0
- package/dist/skills/bundled/solend/index.d.ts +22 -0
- package/dist/skills/bundled/solend/index.js +401 -0
- package/dist/skills/bundled/solend/index.js.map +1 -0
- package/dist/skills/bundled/trading-evm/index.js +42 -11
- package/dist/skills/bundled/trading-evm/index.js.map +1 -1
- package/dist/skills/errors.d.ts +20 -0
- package/dist/skills/errors.js +84 -0
- package/dist/skills/errors.js.map +1 -0
- package/dist/skills/executor.d.ts +1 -1
- package/dist/skills/executor.js +515 -41
- package/dist/skills/executor.js.map +1 -1
- package/dist/skills/help.d.ts +33 -0
- package/dist/skills/help.js +73 -0
- package/dist/skills/help.js.map +1 -0
- package/dist/solana/marginfi.d.ts +112 -0
- package/dist/solana/marginfi.js +340 -0
- package/dist/solana/marginfi.js.map +1 -0
- package/dist/solana/solend.d.ts +120 -0
- package/dist/solana/solend.js +261 -0
- package/dist/solana/solend.js.map +1 -0
- package/dist/trading/bridge.d.ts +1 -1
- package/dist/trading/position-bridge.d.ts +1 -1
- package/dist/types/signal-bus.d.ts +48 -0
- package/dist/types/signal-bus.js +9 -0
- package/dist/types/signal-bus.js.map +1 -0
- package/dist/types.d.ts +17 -0
- package/dist/utils/json-utils.d.ts +8 -8
- package/package.json +8 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marginfi.js","sourceRoot":"","sources":["../../src/solana/marginfi.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFH,gDA6EC;AAOD,4CA4CC;AASD,0CAyCC;AASD,4CAsCC;AASD,wCAkCC;AASD,sCAsCC;AAQD,8CAKC;AAvZD,qCAAkD;AAClD,kDAAuB;AAoEvB,+CAA+C;AAC/C,YAAY;AAC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AK,UAAU,iBAAiB,CACrC,UAAsB,EACtB,OAAgB;IAEhB,OAAO,kBAAkB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC;AAED,+CAA+C;AAC/C,UAAU;AACV,+CAA+C;AAE/C,SAAS,cAAc,CAAC,MAAW,EAAE,IAAY;IAC/C,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,IAAI,IAAI,GAAG,EAAE,CAAC;IAC1C,KAAK,MAAM,CAAC,EAAE,IAAI,CAAC,IAAI,OAAO,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAI,IAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC;QACxD,IAAI,QAAQ,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;IACrC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solend SDK Integration
|
|
3
|
+
*
|
|
4
|
+
* Lending: deposit, withdraw, borrow, repay
|
|
5
|
+
*/
|
|
6
|
+
import { Connection, Keypair } from '@solana/web3.js';
|
|
7
|
+
export interface SolendReserveInfo {
|
|
8
|
+
address: string;
|
|
9
|
+
symbol: string;
|
|
10
|
+
mint: string;
|
|
11
|
+
decimals: number;
|
|
12
|
+
depositRate: number;
|
|
13
|
+
borrowRate: number;
|
|
14
|
+
totalDeposits: string;
|
|
15
|
+
totalBorrows: string;
|
|
16
|
+
availableLiquidity: string;
|
|
17
|
+
utilizationRate: number;
|
|
18
|
+
ltv: number;
|
|
19
|
+
liquidationThreshold: number;
|
|
20
|
+
}
|
|
21
|
+
export interface SolendObligationInfo {
|
|
22
|
+
address: string;
|
|
23
|
+
owner: string;
|
|
24
|
+
deposits: SolendPositionInfo[];
|
|
25
|
+
borrows: SolendPositionInfo[];
|
|
26
|
+
totalDepositValue: string;
|
|
27
|
+
totalBorrowValue: string;
|
|
28
|
+
borrowLimit: string;
|
|
29
|
+
liquidationThreshold: string;
|
|
30
|
+
healthFactor: number;
|
|
31
|
+
ltv: number;
|
|
32
|
+
}
|
|
33
|
+
export interface SolendPositionInfo {
|
|
34
|
+
reserveAddress: string;
|
|
35
|
+
symbol: string;
|
|
36
|
+
mint: string;
|
|
37
|
+
amount: string;
|
|
38
|
+
amountUsd: string;
|
|
39
|
+
}
|
|
40
|
+
export interface SolendDepositParams {
|
|
41
|
+
reserveMint: string;
|
|
42
|
+
amount: string;
|
|
43
|
+
market?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface SolendWithdrawParams {
|
|
46
|
+
reserveMint: string;
|
|
47
|
+
amount: string;
|
|
48
|
+
withdrawAll?: boolean;
|
|
49
|
+
market?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface SolendBorrowParams {
|
|
52
|
+
reserveMint: string;
|
|
53
|
+
amount: string;
|
|
54
|
+
market?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface SolendRepayParams {
|
|
57
|
+
reserveMint: string;
|
|
58
|
+
amount: string;
|
|
59
|
+
repayAll?: boolean;
|
|
60
|
+
market?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface SolendResult {
|
|
63
|
+
signature: string;
|
|
64
|
+
amount?: string;
|
|
65
|
+
symbol?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get all Solend reserves with rates and utilization
|
|
69
|
+
* @param connection - Solana RPC connection
|
|
70
|
+
* @param market - Market address (defaults to main pool)
|
|
71
|
+
* @returns Array of reserves with APY and utilization
|
|
72
|
+
*/
|
|
73
|
+
export declare function getSolendReserves(connection: Connection, market?: string): Promise<SolendReserveInfo[]>;
|
|
74
|
+
/**
|
|
75
|
+
* Get user's Solend obligation (deposits, borrows, health factor)
|
|
76
|
+
* @param connection - Solana RPC connection
|
|
77
|
+
* @param keypair - User's wallet keypair
|
|
78
|
+
* @param market - Market address (defaults to main pool)
|
|
79
|
+
* @returns Obligation with positions and health metrics, or null if none
|
|
80
|
+
*/
|
|
81
|
+
export declare function getSolendObligation(connection: Connection, keypair: Keypair, market?: string): Promise<SolendObligationInfo | null>;
|
|
82
|
+
/**
|
|
83
|
+
* Deposit collateral to Solend
|
|
84
|
+
* @param connection - Solana RPC connection
|
|
85
|
+
* @param keypair - User's wallet keypair (signs transaction)
|
|
86
|
+
* @param params - Deposit params: reserveMint, amount (in base units)
|
|
87
|
+
* @returns Transaction signature and amount deposited
|
|
88
|
+
*/
|
|
89
|
+
export declare function solendDeposit(connection: Connection, keypair: Keypair, params: SolendDepositParams): Promise<SolendResult>;
|
|
90
|
+
/**
|
|
91
|
+
* Withdraw collateral from Solend
|
|
92
|
+
* @param connection - Solana RPC connection
|
|
93
|
+
* @param keypair - User's wallet keypair (signs transaction)
|
|
94
|
+
* @param params - Withdraw params: reserveMint, amount, withdrawAll flag
|
|
95
|
+
* @returns Transaction signature and amount withdrawn
|
|
96
|
+
*/
|
|
97
|
+
export declare function solendWithdraw(connection: Connection, keypair: Keypair, params: SolendWithdrawParams): Promise<SolendResult>;
|
|
98
|
+
/**
|
|
99
|
+
* Borrow assets from Solend (requires collateral)
|
|
100
|
+
* @param connection - Solana RPC connection
|
|
101
|
+
* @param keypair - User's wallet keypair (signs transaction)
|
|
102
|
+
* @param params - Borrow params: reserveMint, amount (in base units)
|
|
103
|
+
* @returns Transaction signature and amount borrowed
|
|
104
|
+
*/
|
|
105
|
+
export declare function solendBorrow(connection: Connection, keypair: Keypair, params: SolendBorrowParams): Promise<SolendResult>;
|
|
106
|
+
/**
|
|
107
|
+
* Repay borrowed assets to Solend
|
|
108
|
+
* @param connection - Solana RPC connection
|
|
109
|
+
* @param keypair - User's wallet keypair (signs transaction)
|
|
110
|
+
* @param params - Repay params: reserveMint, amount, repayAll flag
|
|
111
|
+
* @returns Transaction signature and amount repaid
|
|
112
|
+
*/
|
|
113
|
+
export declare function solendRepay(connection: Connection, keypair: Keypair, params: SolendRepayParams): Promise<SolendResult>;
|
|
114
|
+
/**
|
|
115
|
+
* Get health factor and risk level for user's Solend position
|
|
116
|
+
* @param connection - Solana RPC connection
|
|
117
|
+
* @param keypair - User's wallet keypair
|
|
118
|
+
* @returns Obligation info with health metrics, or null if no position
|
|
119
|
+
*/
|
|
120
|
+
export declare function getSolendHealth(connection: Connection, keypair: Keypair): Promise<SolendObligationInfo | null>;
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Solend SDK Integration
|
|
4
|
+
*
|
|
5
|
+
* Lending: deposit, withdraw, borrow, repay
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
+
};
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.getSolendReserves = getSolendReserves;
|
|
45
|
+
exports.getSolendObligation = getSolendObligation;
|
|
46
|
+
exports.solendDeposit = solendDeposit;
|
|
47
|
+
exports.solendWithdraw = solendWithdraw;
|
|
48
|
+
exports.solendBorrow = solendBorrow;
|
|
49
|
+
exports.solendRepay = solendRepay;
|
|
50
|
+
exports.getSolendHealth = getSolendHealth;
|
|
51
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
52
|
+
const wallet_1 = require("./wallet");
|
|
53
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
54
|
+
// ============================================
|
|
55
|
+
// DEFAULT MARKET
|
|
56
|
+
// ============================================
|
|
57
|
+
const SOLEND_MAIN_MARKET = 'DdZR6zRFiUt4S5mg7AV1uKB2z1116sp1ObwbKhmYwjGh';
|
|
58
|
+
// ============================================
|
|
59
|
+
// FUNCTIONS
|
|
60
|
+
// ============================================
|
|
61
|
+
/**
|
|
62
|
+
* Get all Solend reserves with rates and utilization
|
|
63
|
+
* @param connection - Solana RPC connection
|
|
64
|
+
* @param market - Market address (defaults to main pool)
|
|
65
|
+
* @returns Array of reserves with APY and utilization
|
|
66
|
+
*/
|
|
67
|
+
async function getSolendReserves(connection, market) {
|
|
68
|
+
try {
|
|
69
|
+
const { SolendMarket } = await Promise.resolve().then(() => __importStar(require('@solendprotocol/solend-sdk')));
|
|
70
|
+
const solendMarket = await SolendMarket.initialize(connection, 'production', new web3_js_1.PublicKey(market || SOLEND_MAIN_MARKET));
|
|
71
|
+
await solendMarket.loadReserves();
|
|
72
|
+
const reserves = [];
|
|
73
|
+
for (const reserve of solendMarket.reserves || []) {
|
|
74
|
+
try {
|
|
75
|
+
const stats = reserve.stats;
|
|
76
|
+
if (!stats)
|
|
77
|
+
continue;
|
|
78
|
+
reserves.push({
|
|
79
|
+
address: reserve.pubkey?.toBase58?.() || '',
|
|
80
|
+
symbol: stats.symbol || 'UNKNOWN',
|
|
81
|
+
mint: stats.mintAddress || '',
|
|
82
|
+
decimals: stats.decimals ?? 6,
|
|
83
|
+
depositRate: (stats.supplyInterestAPY ?? 0) * 100,
|
|
84
|
+
borrowRate: (stats.borrowInterestAPY ?? 0) * 100,
|
|
85
|
+
totalDeposits: (stats.totalDepositsWads?.toString?.() ?? '0'),
|
|
86
|
+
totalBorrows: (stats.totalBorrowsWads?.toString?.() ?? '0'),
|
|
87
|
+
availableLiquidity: (stats.availableAmount?.toString?.() ?? '0'),
|
|
88
|
+
utilizationRate: (stats.utilizationRatio ?? 0) * 100,
|
|
89
|
+
ltv: (stats.loanToValueRatio ?? 0) * 100,
|
|
90
|
+
liquidationThreshold: (stats.liquidationThreshold ?? 0) * 100,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// Skip reserves that fail to parse
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return reserves;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
console.error('Failed to get Solend reserves:', error);
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Get user's Solend obligation (deposits, borrows, health factor)
|
|
106
|
+
* @param connection - Solana RPC connection
|
|
107
|
+
* @param keypair - User's wallet keypair
|
|
108
|
+
* @param market - Market address (defaults to main pool)
|
|
109
|
+
* @returns Obligation with positions and health metrics, or null if none
|
|
110
|
+
*/
|
|
111
|
+
async function getSolendObligation(connection, keypair, market) {
|
|
112
|
+
try {
|
|
113
|
+
const { SolendMarket } = await Promise.resolve().then(() => __importStar(require('@solendprotocol/solend-sdk')));
|
|
114
|
+
const solendMarket = await SolendMarket.initialize(connection, 'production', new web3_js_1.PublicKey(market || SOLEND_MAIN_MARKET));
|
|
115
|
+
await solendMarket.loadReserves();
|
|
116
|
+
await solendMarket.loadObligations();
|
|
117
|
+
const obligations = solendMarket.obligations || [];
|
|
118
|
+
const userObligation = obligations.find((o) => o.owner?.toBase58?.() === keypair.publicKey.toBase58());
|
|
119
|
+
if (!userObligation) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
const deposits = [];
|
|
123
|
+
const borrows = [];
|
|
124
|
+
for (const dep of userObligation.deposits || []) {
|
|
125
|
+
deposits.push({
|
|
126
|
+
reserveAddress: dep.reserveAddress?.toBase58?.() || '',
|
|
127
|
+
symbol: dep.symbol || 'UNKNOWN',
|
|
128
|
+
mint: dep.mintAddress || '',
|
|
129
|
+
amount: dep.amount?.toString?.() || '0',
|
|
130
|
+
amountUsd: dep.marketValue?.toString?.() || '0',
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
for (const bor of userObligation.borrows || []) {
|
|
134
|
+
borrows.push({
|
|
135
|
+
reserveAddress: bor.reserveAddress?.toBase58?.() || '',
|
|
136
|
+
symbol: bor.symbol || 'UNKNOWN',
|
|
137
|
+
mint: bor.mintAddress || '',
|
|
138
|
+
amount: bor.amount?.toString?.() || '0',
|
|
139
|
+
amountUsd: bor.marketValue?.toString?.() || '0',
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
const totalDeposit = parseFloat(userObligation.totalDepositValue?.toString?.() || '0');
|
|
143
|
+
const totalBorrow = parseFloat(userObligation.totalBorrowValue?.toString?.() || '0');
|
|
144
|
+
const ltv = totalDeposit > 0 ? totalBorrow / totalDeposit : 0;
|
|
145
|
+
const healthFactor = ltv > 0 ? 1 / ltv : Infinity;
|
|
146
|
+
return {
|
|
147
|
+
address: userObligation.pubkey?.toBase58?.() || '',
|
|
148
|
+
owner: keypair.publicKey.toBase58(),
|
|
149
|
+
deposits,
|
|
150
|
+
borrows,
|
|
151
|
+
totalDepositValue: totalDeposit.toString(),
|
|
152
|
+
totalBorrowValue: totalBorrow.toString(),
|
|
153
|
+
borrowLimit: userObligation.borrowLimit?.toString?.() || '0',
|
|
154
|
+
liquidationThreshold: userObligation.liquidationThreshold?.toString?.() || '0',
|
|
155
|
+
healthFactor,
|
|
156
|
+
ltv: ltv * 100,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
console.error('Failed to get Solend obligation:', error);
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Deposit collateral to Solend
|
|
166
|
+
* @param connection - Solana RPC connection
|
|
167
|
+
* @param keypair - User's wallet keypair (signs transaction)
|
|
168
|
+
* @param params - Deposit params: reserveMint, amount (in base units)
|
|
169
|
+
* @returns Transaction signature and amount deposited
|
|
170
|
+
*/
|
|
171
|
+
async function solendDeposit(connection, keypair, params) {
|
|
172
|
+
const { SolendAction } = await Promise.resolve().then(() => __importStar(require('@solendprotocol/solend-sdk')));
|
|
173
|
+
const amount = new bn_js_1.default(params.amount);
|
|
174
|
+
const action = await SolendAction.buildDepositTxns(connection, amount.toString(), params.reserveMint, keypair.publicKey, 'production', new web3_js_1.PublicKey(params.market || SOLEND_MAIN_MARKET));
|
|
175
|
+
const txns = await action.getTransactions();
|
|
176
|
+
const allTxs = [txns.preLendingTxn, txns.lendingTxn, txns.postLendingTxn].filter(Boolean);
|
|
177
|
+
let signature = '';
|
|
178
|
+
for (const tx of allTxs) {
|
|
179
|
+
signature = await (0, wallet_1.signAndSendTransaction)(connection, keypair, tx);
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
signature,
|
|
183
|
+
amount: params.amount,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Withdraw collateral from Solend
|
|
188
|
+
* @param connection - Solana RPC connection
|
|
189
|
+
* @param keypair - User's wallet keypair (signs transaction)
|
|
190
|
+
* @param params - Withdraw params: reserveMint, amount, withdrawAll flag
|
|
191
|
+
* @returns Transaction signature and amount withdrawn
|
|
192
|
+
*/
|
|
193
|
+
async function solendWithdraw(connection, keypair, params) {
|
|
194
|
+
const { SolendAction } = await Promise.resolve().then(() => __importStar(require('@solendprotocol/solend-sdk')));
|
|
195
|
+
const amount = params.withdrawAll ? 'max' : new bn_js_1.default(params.amount).toString();
|
|
196
|
+
const action = await SolendAction.buildWithdrawTxns(connection, amount, params.reserveMint, keypair.publicKey, 'production', new web3_js_1.PublicKey(params.market || SOLEND_MAIN_MARKET));
|
|
197
|
+
const txns = await action.getTransactions();
|
|
198
|
+
const allTxs = [txns.preLendingTxn, txns.lendingTxn, txns.postLendingTxn].filter(Boolean);
|
|
199
|
+
let signature = '';
|
|
200
|
+
for (const tx of allTxs) {
|
|
201
|
+
signature = await (0, wallet_1.signAndSendTransaction)(connection, keypair, tx);
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
signature,
|
|
205
|
+
amount: params.amount,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Borrow assets from Solend (requires collateral)
|
|
210
|
+
* @param connection - Solana RPC connection
|
|
211
|
+
* @param keypair - User's wallet keypair (signs transaction)
|
|
212
|
+
* @param params - Borrow params: reserveMint, amount (in base units)
|
|
213
|
+
* @returns Transaction signature and amount borrowed
|
|
214
|
+
*/
|
|
215
|
+
async function solendBorrow(connection, keypair, params) {
|
|
216
|
+
const { SolendAction } = await Promise.resolve().then(() => __importStar(require('@solendprotocol/solend-sdk')));
|
|
217
|
+
const amount = new bn_js_1.default(params.amount).toString();
|
|
218
|
+
const action = await SolendAction.buildBorrowTxns(connection, amount, params.reserveMint, keypair.publicKey, 'production', new web3_js_1.PublicKey(params.market || SOLEND_MAIN_MARKET));
|
|
219
|
+
const txns = await action.getTransactions();
|
|
220
|
+
const allTxs = [txns.preLendingTxn, txns.lendingTxn, txns.postLendingTxn].filter(Boolean);
|
|
221
|
+
let signature = '';
|
|
222
|
+
for (const tx of allTxs) {
|
|
223
|
+
signature = await (0, wallet_1.signAndSendTransaction)(connection, keypair, tx);
|
|
224
|
+
}
|
|
225
|
+
return {
|
|
226
|
+
signature,
|
|
227
|
+
amount: params.amount,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Repay borrowed assets to Solend
|
|
232
|
+
* @param connection - Solana RPC connection
|
|
233
|
+
* @param keypair - User's wallet keypair (signs transaction)
|
|
234
|
+
* @param params - Repay params: reserveMint, amount, repayAll flag
|
|
235
|
+
* @returns Transaction signature and amount repaid
|
|
236
|
+
*/
|
|
237
|
+
async function solendRepay(connection, keypair, params) {
|
|
238
|
+
const { SolendAction } = await Promise.resolve().then(() => __importStar(require('@solendprotocol/solend-sdk')));
|
|
239
|
+
const amount = params.repayAll ? 'max' : new bn_js_1.default(params.amount).toString();
|
|
240
|
+
const action = await SolendAction.buildRepayTxns(connection, amount, params.reserveMint, keypair.publicKey, 'production', new web3_js_1.PublicKey(params.market || SOLEND_MAIN_MARKET));
|
|
241
|
+
const txns = await action.getTransactions();
|
|
242
|
+
const allTxs = [txns.preLendingTxn, txns.lendingTxn, txns.postLendingTxn].filter(Boolean);
|
|
243
|
+
let signature = '';
|
|
244
|
+
for (const tx of allTxs) {
|
|
245
|
+
signature = await (0, wallet_1.signAndSendTransaction)(connection, keypair, tx);
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
signature,
|
|
249
|
+
amount: params.amount,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Get health factor and risk level for user's Solend position
|
|
254
|
+
* @param connection - Solana RPC connection
|
|
255
|
+
* @param keypair - User's wallet keypair
|
|
256
|
+
* @returns Obligation info with health metrics, or null if no position
|
|
257
|
+
*/
|
|
258
|
+
async function getSolendHealth(connection, keypair) {
|
|
259
|
+
return getSolendObligation(connection, keypair);
|
|
260
|
+
}
|
|
261
|
+
//# sourceMappingURL=solend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solend.js","sourceRoot":"","sources":["../../src/solana/solend.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8FH,8CA6CC;AASD,kDAsEC;AASD,sCA8BC;AASD,wCA8BC;AASD,oCA8BC;AASD,kCA8BC;AAQD,0CAKC;AAjYD,6CAA8E;AAC9E,qCAAkD;AAClD,kDAAuB;AA0EvB,+CAA+C;AAC/C,iBAAiB;AACjB,+CAA+C;AAE/C,MAAM,kBAAkB,GAAG,8CAA8C,CAAC;AAE1E,+CAA+C;AAC/C,YAAY;AACZ,+CAA+C;AAE/C;;;;;GAKG;AACI,KAAK,UAAU,iBAAiB,CACrC,UAAsB,EACtB,MAAe;IAEf,IAAI,CAAC;QACH,MAAM,EAAE,YAAY,EAAE,GAAG,wDAAa,4BAA4B,GAAC,CAAC;QAEpE,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC,UAAU,CAChD,UAAiB,EACjB,YAAY,EACZ,IAAI,mBAAS,CAAC,MAAM,IAAI,kBAAkB,CAAC,CAC5C,CAAC;QAEF,MAAM,YAAY,CAAC,YAAY,EAAE,CAAC;QAElC,MAAM,QAAQ,GAAwB,EAAE,CAAC;QACzC,KAAK,MAAM,OAAO,IAAI,YAAY,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC;YAClD,IAAI,CAAC;gBACH,MAAM,KAAK,GAAI,OAAe,CAAC,KAAK,CAAC;gBACrC,IAAI,CAAC,KAAK;oBAAE,SAAS;gBAErB,QAAQ,CAAC,IAAI,CAAC;oBACZ,OAAO,EAAG,OAAe,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE;oBACpD,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI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BAAsB,EAAC,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,OAAO;QACL,SAAS;QACT,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,eAAe,CACnC,UAAsB,EACtB,OAAgB;IAEhB,OAAO,mBAAmB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC"}
|
package/dist/trading/bridge.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* 2. Routes TradingSignal events to trigger immediate strategy evaluations
|
|
9
9
|
* 3. Re-emits BotManager trade/signal events through the signal bus
|
|
10
10
|
*/
|
|
11
|
-
import type { SignalBus } from '../
|
|
11
|
+
import type { SignalBus } from '../types/signal-bus.js';
|
|
12
12
|
import type { BotManager } from './bots/index.js';
|
|
13
13
|
export interface TradingBridge {
|
|
14
14
|
/** Start forwarding events between signal bus and bot manager. */
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Also connects to the orchestrator's guarded execution so that all
|
|
10
10
|
* exit orders go through safety checks.
|
|
11
11
|
*/
|
|
12
|
-
import type { SignalBus } from '../
|
|
12
|
+
import type { SignalBus } from '../types/signal-bus.js';
|
|
13
13
|
import type { ExecutionService } from '../execution/index.js';
|
|
14
14
|
import type { PositionManager, Position } from '../execution/position-manager.js';
|
|
15
15
|
import type { SignalRouter } from '../signal-router/index.js';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signal Bus — Shared type definitions for feed → consumer event system.
|
|
3
|
+
*
|
|
4
|
+
* These types are public (tracked in git). The implementation lives in
|
|
5
|
+
* src/gateway/signal-bus.ts (private, gitignored).
|
|
6
|
+
*/
|
|
7
|
+
import { EventEmitter } from 'events';
|
|
8
|
+
import type { Platform } from '../types.js';
|
|
9
|
+
export interface TickUpdate {
|
|
10
|
+
platform: Platform;
|
|
11
|
+
marketId: string;
|
|
12
|
+
outcomeId: string;
|
|
13
|
+
price: number;
|
|
14
|
+
prevPrice: number | null;
|
|
15
|
+
timestamp: number;
|
|
16
|
+
}
|
|
17
|
+
export interface OrderbookUpdate {
|
|
18
|
+
platform: Platform;
|
|
19
|
+
marketId: string;
|
|
20
|
+
outcomeId: string;
|
|
21
|
+
bids: Array<[number, number]>;
|
|
22
|
+
asks: Array<[number, number]>;
|
|
23
|
+
spread?: number | null;
|
|
24
|
+
midPrice?: number | null;
|
|
25
|
+
timestamp: number;
|
|
26
|
+
}
|
|
27
|
+
export interface TradingSignal {
|
|
28
|
+
type: 'momentum' | 'reversal' | 'volatility_spike' | 'spread_widening' | 'opportunity' | 'sentiment_shift';
|
|
29
|
+
platform: string;
|
|
30
|
+
marketId: string;
|
|
31
|
+
outcomeId: string;
|
|
32
|
+
strength: number;
|
|
33
|
+
direction: 'buy' | 'sell' | 'neutral';
|
|
34
|
+
features: Record<string, number>;
|
|
35
|
+
timestamp: number;
|
|
36
|
+
}
|
|
37
|
+
export interface SignalBus extends EventEmitter {
|
|
38
|
+
/** Subscribe to FeedManager events (call once, or again after rebuildRuntime). */
|
|
39
|
+
connectFeeds(feeds: unknown): void;
|
|
40
|
+
/** Remove listeners from the current FeedManager. */
|
|
41
|
+
disconnectFeeds(): void;
|
|
42
|
+
/** Register a tick consumer. */
|
|
43
|
+
onTick(handler: (update: TickUpdate) => void): void;
|
|
44
|
+
/** Register an orderbook consumer. */
|
|
45
|
+
onOrderbook(handler: (update: OrderbookUpdate) => void): void;
|
|
46
|
+
/** Register a trading-signal consumer. */
|
|
47
|
+
onSignal(handler: (signal: TradingSignal) => void): void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Signal Bus — Shared type definitions for feed → consumer event system.
|
|
4
|
+
*
|
|
5
|
+
* These types are public (tracked in git). The implementation lives in
|
|
6
|
+
* src/gateway/signal-bus.ts (private, gitignored).
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
//# sourceMappingURL=signal-bus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signal-bus.js","sourceRoot":"","sources":["../../src/types/signal-bus.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
|
package/dist/types.d.ts
CHANGED
|
@@ -455,6 +455,8 @@ export interface SessionContext {
|
|
|
455
455
|
preferences: Record<string, unknown>;
|
|
456
456
|
/** Conversation history for multi-turn context (last N messages) */
|
|
457
457
|
conversationHistory: ConversationMessage[];
|
|
458
|
+
/** Compressed summary of older conversation that was evicted from the window */
|
|
459
|
+
contextSummary?: string;
|
|
458
460
|
/** Checkpoint for conversation resumption */
|
|
459
461
|
checkpoint?: {
|
|
460
462
|
createdAt: number;
|
|
@@ -482,6 +484,21 @@ export interface ConversationMessage {
|
|
|
482
484
|
content: string;
|
|
483
485
|
timestamp: number;
|
|
484
486
|
}
|
|
487
|
+
/**
|
|
488
|
+
* Credentials Manager interface — manages encrypted per-user trading credentials.
|
|
489
|
+
* Implementation lives in src/credentials/ (private, gitignored).
|
|
490
|
+
*/
|
|
491
|
+
export interface CredentialsManager {
|
|
492
|
+
setCredentials: (userId: string, platform: Platform, credentials: PolymarketCredentials | KalshiCredentials | ManifoldCredentials) => Promise<void>;
|
|
493
|
+
getCredentials: <T>(userId: string, platform: Platform) => Promise<T | null>;
|
|
494
|
+
hasCredentials: (userId: string, platform: Platform) => Promise<boolean>;
|
|
495
|
+
deleteCredentials: (userId: string, platform: Platform) => Promise<void>;
|
|
496
|
+
markSuccess: (userId: string, platform: Platform) => Promise<void>;
|
|
497
|
+
markFailure: (userId: string, platform: Platform) => Promise<void>;
|
|
498
|
+
isInCooldown: (userId: string, platform: Platform) => Promise<boolean>;
|
|
499
|
+
buildTradingContext: (userId: string, sessionKey: string) => Promise<TradingContext>;
|
|
500
|
+
listUserPlatforms: (userId: string) => Promise<Platform[]>;
|
|
501
|
+
}
|
|
485
502
|
/** File attachment in a message */
|
|
486
503
|
export interface MessageAttachment {
|
|
487
504
|
/** Attachment type */
|
|
@@ -81,8 +81,8 @@ export declare const SessionStorageSchema: z.ZodObject<{
|
|
|
81
81
|
name?: string | undefined;
|
|
82
82
|
role?: string | undefined;
|
|
83
83
|
}[];
|
|
84
|
-
expiresAt?: string | undefined;
|
|
85
84
|
metadata?: Record<string, unknown> | undefined;
|
|
85
|
+
expiresAt?: string | undefined;
|
|
86
86
|
}, {
|
|
87
87
|
id: string;
|
|
88
88
|
createdAt: string;
|
|
@@ -95,8 +95,8 @@ export declare const SessionStorageSchema: z.ZodObject<{
|
|
|
95
95
|
name?: string | undefined;
|
|
96
96
|
role?: string | undefined;
|
|
97
97
|
}[];
|
|
98
|
-
expiresAt?: string | undefined;
|
|
99
98
|
metadata?: Record<string, unknown> | undefined;
|
|
99
|
+
expiresAt?: string | undefined;
|
|
100
100
|
}>, "many">>>;
|
|
101
101
|
}, "strip", z.ZodTypeAny, {
|
|
102
102
|
sessions: {
|
|
@@ -111,8 +111,8 @@ export declare const SessionStorageSchema: z.ZodObject<{
|
|
|
111
111
|
name?: string | undefined;
|
|
112
112
|
role?: string | undefined;
|
|
113
113
|
}[];
|
|
114
|
-
expiresAt?: string | undefined;
|
|
115
114
|
metadata?: Record<string, unknown> | undefined;
|
|
115
|
+
expiresAt?: string | undefined;
|
|
116
116
|
}[];
|
|
117
117
|
}, {
|
|
118
118
|
sessions?: {
|
|
@@ -127,8 +127,8 @@ export declare const SessionStorageSchema: z.ZodObject<{
|
|
|
127
127
|
name?: string | undefined;
|
|
128
128
|
role?: string | undefined;
|
|
129
129
|
}[];
|
|
130
|
-
expiresAt?: string | undefined;
|
|
131
130
|
metadata?: Record<string, unknown> | undefined;
|
|
131
|
+
expiresAt?: string | undefined;
|
|
132
132
|
}[] | undefined;
|
|
133
133
|
}>;
|
|
134
134
|
/** Schema for Google token storage */
|
|
@@ -139,13 +139,13 @@ export declare const GoogleTokenSchema: z.ZodObject<{
|
|
|
139
139
|
token_type: z.ZodOptional<z.ZodString>;
|
|
140
140
|
}, "strip", z.ZodTypeAny, {
|
|
141
141
|
access_token: string;
|
|
142
|
-
expires_at?: number | undefined;
|
|
143
142
|
refresh_token?: string | undefined;
|
|
143
|
+
expires_at?: number | undefined;
|
|
144
144
|
token_type?: string | undefined;
|
|
145
145
|
}, {
|
|
146
146
|
access_token: string;
|
|
147
|
-
expires_at?: number | undefined;
|
|
148
147
|
refresh_token?: string | undefined;
|
|
148
|
+
expires_at?: number | undefined;
|
|
149
149
|
token_type?: string | undefined;
|
|
150
150
|
}>;
|
|
151
151
|
/** Schema for MCP tool response */
|
|
@@ -182,13 +182,13 @@ export declare const ApiResponseSchema: z.ZodObject<{
|
|
|
182
182
|
message: z.ZodOptional<z.ZodString>;
|
|
183
183
|
}, "strip", z.ZodTypeAny, {
|
|
184
184
|
error?: string | undefined;
|
|
185
|
-
message?: string | undefined;
|
|
186
185
|
data?: unknown;
|
|
186
|
+
message?: string | undefined;
|
|
187
187
|
success?: boolean | undefined;
|
|
188
188
|
}, {
|
|
189
189
|
error?: string | undefined;
|
|
190
|
-
message?: string | undefined;
|
|
191
190
|
data?: unknown;
|
|
191
|
+
message?: string | undefined;
|
|
192
192
|
success?: boolean | undefined;
|
|
193
193
|
}>;
|
|
194
194
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clodds",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "AI trading terminal
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Open-source AI trading terminal. Trade Polymarket, Kalshi, Betfair, Binance, Bybit, Hyperliquid, Solana DEXs from Telegram, Discord, Slack or web. Arbitrage detection, whale tracking, copy trading, perpetual futures up to 200x, DeFi swaps, MEV protection. Self-hosted, 118 skills, powered by Claude.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"clodds": "./dist/cli/index.js"
|
|
@@ -17,9 +17,7 @@
|
|
|
17
17
|
"test": "node --test --import tsx --import ./tests/helpers/test-setup.ts tests/**/*.test.ts",
|
|
18
18
|
"ci": "npm run typecheck && npm run test && npm run build",
|
|
19
19
|
"prepublishOnly": "npm run build",
|
|
20
|
-
"publish:npm": "npm publish --registry https://registry.npmjs.org"
|
|
21
|
-
"publish:github": "npm publish --registry https://npm.pkg.github.com",
|
|
22
|
-
"publish:all": "npm run publish:npm && npm run publish:github"
|
|
20
|
+
"publish:npm": "npm publish --registry https://registry.npmjs.org"
|
|
23
21
|
},
|
|
24
22
|
"keywords": [
|
|
25
23
|
"trading",
|
|
@@ -42,7 +40,11 @@
|
|
|
42
40
|
"claude",
|
|
43
41
|
"telegram-bot",
|
|
44
42
|
"discord-bot",
|
|
45
|
-
"trading-bot"
|
|
43
|
+
"trading-bot",
|
|
44
|
+
"lending",
|
|
45
|
+
"marginfi",
|
|
46
|
+
"solend",
|
|
47
|
+
"kamino"
|
|
46
48
|
],
|
|
47
49
|
"author": "alsk1992",
|
|
48
50
|
"homepage": "https://cloddsbot.com",
|