Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
2b822f0
fix: logging
prathmeshkhandelwal1 Dec 22, 2025
538bd81
fix: debug signer param
prathmeshkhandelwal1 Dec 22, 2025
9f3ab25
feat: migrate solana rebalancer to threshold-based approach
jintukumardas Dec 23, 2025
38d9c73
fix: add threshold configs
jintukumardas Dec 23, 2025
190f703
fix: lint issues
jintukumardas Dec 23, 2025
5afdbd1
Merge pull request #457 from everclearorg/feat/solana-threshold-rebal…
preethamr Dec 24, 2025
c485b2a
fix: update ccip send instruction discriminator
jintukumardas Dec 25, 2025
e204020
Merge pull request #460 from everclearorg/fix/ccip-instruction
prathmeshkhandelwal1 Jan 5, 2026
f2c096d
fix: target based logic
prathmeshkhandelwal1 Jan 5, 2026
d2427b3
fix: ccip build instruction
jintukumardas Jan 5, 2026
840d435
Merge pull request #461 from everclearorg/fix/ccip-router
prathmeshkhandelwal1 Jan 5, 2026
ca4bf57
fix: use versioned tx to reduce solana tx size below 1232 bytes
jintukumardas Jan 5, 2026
8eb569e
Merge pull request #462 from everclearorg/fix/versioned-tx-solana
prathmeshkhandelwal1 Jan 5, 2026
dc66975
fix: logging
prathmeshkhandelwal1 Jan 5, 2026
9ec21ac
fix: change rate for rebalancing
prathmeshkhandelwal1 Jan 5, 2026
3db3584
fix: custom lut
prathmeshkhandelwal1 Jan 5, 2026
55fbe50
fix: lint issues
prathmeshkhandelwal1 Jan 5, 2026
5644b2a
Merge pull request #463 from everclearorg/lookup-table
prathmeshkhandelwal1 Jan 5, 2026
4e7d641
fix: burn mint address
prathmeshkhandelwal1 Jan 5, 2026
304737a
feat: refactored ccip client
prathmeshkhandelwal1 Jan 6, 2026
066447c
fix: lint
prathmeshkhandelwal1 Jan 6, 2026
67f96b9
Merge pull request #464 from everclearorg/ccip-refactor
prathmeshkhandelwal1 Jan 6, 2026
69cae4e
fix: evm address conversion for ccip client
jintukumardas Jan 6, 2026
7bac5b5
Merge pull request #465 from everclearorg/fix/address-conv
prathmeshkhandelwal1 Jan 6, 2026
bf6bbd8
fix: ata logging
prathmeshkhandelwal1 Jan 6, 2026
1d29aec
fix: added approval
prathmeshkhandelwal1 Jan 6, 2026
beb2184
fix: lint
prathmeshkhandelwal1 Jan 6, 2026
24cdcbe
fix: ccip token pools signer
jintukumardas Jan 6, 2026
b0e040c
Merge pull request #466 from everclearorg/fix/ccip-signer
prathmeshkhandelwal1 Jan 7, 2026
68de31f
fix: update ccip seed
jintukumardas Jan 7, 2026
1827f1a
Merge pull request #467 from everclearorg/fix/ccip-signer
prathmeshkhandelwal1 Jan 7, 2026
70f7593
fix: remove sensitive vars
liu-zhipeng Jan 7, 2026
04bc074
fix: pdas
prathmeshkhandelwal1 Jan 7, 2026
43036a4
fix: build
prathmeshkhandelwal1 Jan 7, 2026
a9dbf41
fix: lint
prathmeshkhandelwal1 Jan 7, 2026
4705fbf
Merge branch 'staging' into fix-solana-ccip
liu-zhipeng Jan 7, 2026
99e381f
fix: remove external approval and use pool signer pda
jintukumardas Jan 7, 2026
b2cc500
Merge pull request #468 from everclearorg/fix/ccip-approval
prathmeshkhandelwal1 Jan 7, 2026
9e9263f
fix: changes reverted
prathmeshkhandelwal1 Jan 7, 2026
e79911c
feat: add "@chainlink/ccip-sdk"
liu-zhipeng Jan 7, 2026
49e344c
fix: remove ccipClient
liu-zhipeng Jan 7, 2026
dc24947
fix: build
liu-zhipeng Jan 7, 2026
7b916b5
fix: ccip send logic
liu-zhipeng Jan 7, 2026
c758d6e
fix: lint
liu-zhipeng Jan 7, 2026
23807e6
fix: lint issues
liu-zhipeng Jan 7, 2026
f9379b2
fix: lint
liu-zhipeng Jan 7, 2026
cb44573
Merge pull request #470 from everclearorg/fix-solana-ccip
liu-zhipeng Jan 7, 2026
9545d97
fix: ccip dynmaic import
jintukumardas Jan 8, 2026
3171d89
fix: lint
jintukumardas Jan 8, 2026
b1f87d4
fix: unit test
jintukumardas Jan 8, 2026
9e926aa
Merge pull request #471 from everclearorg/fix/ccip-import
prathmeshkhandelwal1 Jan 8, 2026
c61e83d
fix: updated mainnet USDC address in cowswap adapter
otsybizov Jan 8, 2026
f52a164
Merge pull request #473 from everclearorg/fix/cowswap-mainnet-usdc
liu-zhipeng Jan 8, 2026
838181b
Merge pull request #475 from everclearorg/staging
preethamr Jan 8, 2026
6b47d3d
fix: use ccip-sdk instead of ccip-js
liu-zhipeng Jan 8, 2026
30d4064
Merge pull request #476 from everclearorg/main
liu-zhipeng Jan 8, 2026
aa49610
fix: pendle api
liu-zhipeng Jan 8, 2026
c52c440
feat: move ccip-sdk to ccip adapter
liu-zhipeng Jan 9, 2026
9e90a08
feat: ccip leg2 works
liu-zhipeng Jan 9, 2026
14c9304
fix: int
liu-zhipeng Jan 9, 2026
d920977
fix: ccip unit tests
liu-zhipeng Jan 9, 2026
7597bec
fix: ccip unit tests
liu-zhipeng Jan 9, 2026
ff94c43
test: ccip coverage
liu-zhipeng Jan 9, 2026
9297560
test: add ccip unit
liu-zhipeng Jan 9, 2026
acecebc
fix: to solana message status
liu-zhipeng Jan 9, 2026
487f767
fix: ccip unit tests coverage
liu-zhipeng Jan 9, 2026
ec7f9c3
Merge pull request #478 from everclearorg/refactor-ccip
liu-zhipeng Jan 9, 2026
c3fdbfd
fix: handle circular references when calling json stringify
jintukumardas Jan 12, 2026
1344b24
Merge pull request #479 from everclearorg/fix/circular-log-ref
liu-zhipeng Jan 12, 2026
0cd38be
fix: max retries to 2 for evm
liu-zhipeng Jan 12, 2026
b5ca9f0
Merge pull request #480 from everclearorg/fix-evm-retries
liu-zhipeng Jan 12, 2026
ccc5cc7
feat: use ccip api to check status
liu-zhipeng Jan 12, 2026
bd09cee
test: fix ccip unit
liu-zhipeng Jan 12, 2026
39b7b15
fix: lint
liu-zhipeng Jan 12, 2026
8a3bf13
Merge pull request #481 from everclearorg/use-ccip-api
liu-zhipeng Jan 12, 2026
02b4947
fix: pendle pricing and move configs
jintukumardas Jan 14, 2026
e26db21
fix: update env and variable namings
jintukumardas Jan 14, 2026
0170fc1
fix: rebalance operation status doesn't have FAILED
liu-zhipeng Jan 14, 2026
a6cb52e
Merge pull request #483 from everclearorg/refactor/solana-rebalance
liu-zhipeng Jan 14, 2026
95112a5
fix: check if solana rebalance enabled
liu-zhipeng Jan 14, 2026
8d36331
Merge pull request #484 from everclearorg/fix-solana-rebalance-enabled
liu-zhipeng Jan 14, 2026
70d6a0f
fix: filter operations by bridge type
liu-zhipeng Jan 14, 2026
e3fa625
fix: ccip unit
liu-zhipeng Jan 14, 2026
cb0c5da
Merge pull request #485 from everclearorg/filter-operations-bridge
liu-zhipeng Jan 15, 2026
83ca310
Merge pull request #486 from everclearorg/staging
liu-zhipeng Jan 15, 2026
e515051
fix: remove unused env
liu-zhipeng Jan 15, 2026
e91e920
Merge pull request #488 from everclearorg/fix-remove-unused-env
preethamr Jan 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions ops/mainnet/mark/config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ locals {
SOLANA_PRIVATE_KEY = local.mark_config.solana.privateKey
SOLANA_RPC_URL = local.mark_config.solana.rpcUrl
SOLANA_SIGNER_ADDRESS = local.mark_config.solanaSignerAddress
# ptUSDe SPL token mint on Solana (from SSM config)
PTUSDE_SOLANA_MINT = local.mark_config.solana.ptUsdeMint
}
)

Expand Down
2 changes: 0 additions & 2 deletions ops/mainnet/mason/config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ locals {
SOLANA_PRIVATE_KEY = local.mark_config.solana.privateKey
SOLANA_RPC_URL = local.mark_config.solana.rpcUrl
SOLANA_SIGNER_ADDRESS = local.mark_config.solanaSignerAddress
# ptUSDe SPL token mint on Solana (from SSM config)
PTUSDE_SOLANA_MINT = local.mark_config.solana.ptUsdeMint
}
)

Expand Down
2 changes: 1 addition & 1 deletion ops/mainnet/mason/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ module "mark_solana_usdc_poller" {
subnet_ids = module.network.private_subnets
security_group_id = module.sgs.lambda_sg_id
container_env_vars = local.solana_usdc_poller_env_vars
schedule_expression = "rate(30 minutes)"
schedule_expression = "rate(5 minutes)"
}

# TAC-only Lambda - runs TAC USDT rebalancing every 1 minute
Expand Down
104 changes: 92 additions & 12 deletions packages/adapters/chainservice/src/solana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {
TransactionInstruction,
sendAndConfirmTransaction,
ComputeBudgetProgram,
MessageV0,
AddressLookupTableAccount,
} from '@solana/web3.js';
import bs58 from 'bs58';

Expand Down Expand Up @@ -77,6 +79,8 @@ export interface SolanaTransactionRequest {
computeUnitPrice?: number;
/** Optional compute unit limit */
computeUnitLimit?: number;
/** Optional address lookup table addresses for versioned transactions */
addressLookupTableAddresses?: PublicKey[];
}

/**
Expand Down Expand Up @@ -151,6 +155,13 @@ export class SolanaSigner {
return this.keypair.publicKey.toBase58();
}

/**
* Get the underlying keypair for direct access
*/
getKeypair(): Keypair {
return this.keypair;
}

/**
* Get the underlying connection for read operations
*/
Expand Down Expand Up @@ -213,23 +224,97 @@ export class SolanaSigner {
return transaction;
}

/**
* Build a versioned transaction with address lookup tables for reduced transaction size.
*/
async buildVersionedTransaction(request: SolanaTransactionRequest): Promise<VersionedTransaction> {
const { instructions, feePayer, computeUnitPrice, computeUnitLimit, addressLookupTableAddresses } = request;

const allInstructions: TransactionInstruction[] = [];

// Add compute budget instructions if specified (for priority fees)
if (computeUnitLimit) {
allInstructions.push(
ComputeBudgetProgram.setComputeUnitLimit({
units: computeUnitLimit,
}),
);
}

if (computeUnitPrice) {
allInstructions.push(
ComputeBudgetProgram.setComputeUnitPrice({
microLamports: computeUnitPrice,
}),
);
}

// Add user instructions
allInstructions.push(...instructions);

// Get recent blockhash
const { blockhash } = await this.connection.getLatestBlockhash(this.config.commitment);

// Fetch address lookup table accounts if provided
const lookupTableAccounts: AddressLookupTableAccount[] = [];
if (addressLookupTableAddresses && addressLookupTableAddresses.length > 0) {
for (const address of addressLookupTableAddresses) {
const lookupTableAccount = await this.connection.getAddressLookupTable(address);
if (lookupTableAccount.value) {
lookupTableAccounts.push(lookupTableAccount.value);
}
}
}

// Create versioned transaction message using MessageV0
const messageV0 = MessageV0.compile({
payerKey: feePayer || this.keypair.publicKey,
recentBlockhash: blockhash,
instructions: allInstructions,
addressLookupTableAccounts: lookupTableAccounts,
});

return new VersionedTransaction(messageV0);
}

/**
* Sign and send a transaction with automatic retry and confirmation
*/
async signAndSendTransaction(request: SolanaTransactionRequest): Promise<SolanaTransactionResult> {
// Build the transaction
const transaction = await this.buildTransaction(request);
const useVersionedTransaction =
request.addressLookupTableAddresses && request.addressLookupTableAddresses.length > 0;

// Sign and send with retries
let lastError: Error | null = null;

for (let attempt = 1; attempt <= this.config.maxRetries; attempt++) {
try {
const signature = await sendAndConfirmTransaction(this.connection, transaction, [this.keypair], {
commitment: this.config.commitment,
skipPreflight: this.config.skipPreflight,
maxRetries: 0, // We handle retries ourselves
});
let signature: string;

if (useVersionedTransaction) {
// Build and send versioned transaction with lookup tables
const versionedTx = await this.buildVersionedTransaction(request);
versionedTx.sign([this.keypair]);

signature = await this.connection.sendTransaction(versionedTx, {
skipPreflight: this.config.skipPreflight,
maxRetries: 0,
});

// Wait for confirmation
const confirmation = await this.connection.confirmTransaction(signature, this.config.commitment);
if (confirmation.value.err) {
throw new Error(`Transaction failed: ${JSON.stringify(confirmation.value.err)}`);
}
} else {
// Build and send legacy transaction
const transaction = await this.buildTransaction(request);
signature = await sendAndConfirmTransaction(this.connection, transaction, [this.keypair], {
commitment: this.config.commitment,
skipPreflight: this.config.skipPreflight,
maxRetries: 0, // We handle retries ourselves
});
}

// Get transaction details
const txDetails = await this.connection.getTransaction(signature, {
Expand Down Expand Up @@ -259,11 +344,6 @@ export class SolanaSigner {
// Exponential backoff
const backoffMs = Math.min(1000 * Math.pow(2, attempt - 1), 10000);
await this.delay(backoffMs);

// Get fresh blockhash for retry
const { blockhash, lastValidBlockHeight } = await this.connection.getLatestBlockhash(this.config.commitment);
transaction.recentBlockhash = blockhash;
transaction.lastValidBlockHeight = lastValidBlockHeight;
}
}

Expand Down
12 changes: 12 additions & 0 deletions packages/adapters/database/src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ export async function getRebalanceOperations(
offset?: number,
filter?: {
status?: RebalanceOperationStatus | RebalanceOperationStatus[];
bridge?: string | string[];
chainId?: number;
earmarkId?: string | null;
invoiceId?: string;
Expand All @@ -737,6 +738,17 @@ export async function getRebalanceOperations(
paramCount++;
}

if (filter.bridge) {
if (Array.isArray(filter.bridge)) {
conditions.push(`ro.bridge = ANY($${paramCount})`);
values.push(filter.bridge);
} else {
conditions.push(`ro.bridge = $${paramCount}`);
values.push(filter.bridge);
}
paramCount++;
}

if (filter.chainId !== undefined) {
conditions.push(`ro."origin_chain_id" = $${paramCount}`);
values.push(filter.chainId);
Expand Down
3 changes: 2 additions & 1 deletion packages/adapters/rebalance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
"test:unit": "jest --coverage --testPathIgnorePatterns='.*\\.integration\\.spec\\.ts$'"
},
"dependencies": {
"@chainlink/ccip-js": "^0.2.6",
"@chainlink/ccip-sdk": "^0.93.0",
"@cowprotocol/cow-sdk": "^7.1.2-beta.0",
"@defuse-protocol/one-click-sdk-typescript": "^0.1.5",
"@mark/core": "workspace:*",
"@mark/database": "workspace:*",
"@mark/logger": "workspace:*",
"@solana/web3.js": "^1.98.0",
"@tonappchain/sdk": "0.7.1",
"axios": "1.9.0",
"bs58": "^6.0.0",
Expand Down
Loading