Skip to content

Commit 4e8fafa

Browse files
authored
feat(aggregator): update @chainflip/sdk from 2.0.3 to 2.1.1 (#1669)
* feat(aggregator): update @chainflip/sdk from 2.0.3 to 2.1.1 Adds support for new assets (Wbtc, ArbUsdt, SolUsdt) and removes deprecated DCA feature flag which is now enabled by default. * fix(aggregator): replace SDK import in mock with local types to fix ESM issue The mock file imported types from @chainflip/sdk/swap, which triggered loading the real SDK's ESM-only dependency chain (@noble/hashes) in Jest. Define the types locally in the mock instead. * fix(aggregator): address CR feedback on chainflip mock types - Add missing fields to QuoteRequest (brokerCommissionBps, affiliateBrokers, isVaultSwap, ccmParams) and DepositAddressRequestV2 (srcAddress, fillOrKillParams, ccmParams, brokerCommissionBps) - Add new SDK 2.1.1 assets: Wbtc (Ethereum), ArbUsdt (Arbitrum), SolUsdt (Solana) - Remove deprecated enabledFeatures.dca from SwapSDKConfig
1 parent 8a333e9 commit 4e8fafa

File tree

6 files changed

+195
-86
lines changed

6 files changed

+195
-86
lines changed

.changeset/update-chainflip-sdk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@xchainjs/xchain-aggregator': minor
3+
---
4+
5+
Update @chainflip/sdk from 2.0.3 to 2.1.1, adding support for new assets (Wbtc, ArbUsdt, SolUsdt) and removing deprecated DCA feature flag

packages/xchain-aggregator/__mocks__/@chainflip/sdk/swap.ts

Lines changed: 122 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,88 @@
1-
import { AssetData, ChainData, Chains, DepositAddressRequestV2, QuoteRequest } from '@chainflip/sdk/swap'
1+
// Local type definitions to avoid importing from @chainflip/sdk/swap,
2+
// which triggers ESM-only dependency chain (@noble/hashes) in Jest.
3+
4+
interface ChainData {
5+
chain: string
6+
name: string
7+
evmChainId: number | undefined
8+
isMainnet: boolean
9+
requiredBlockConfirmations: number
10+
maxRetryDurationBlocks: number | undefined
11+
}
12+
13+
interface AssetData {
14+
chainflipId: string
15+
asset: string
16+
chain: string
17+
contractAddress: string | undefined
18+
decimals: number
19+
name: string
20+
symbol: string
21+
isMainnet: boolean
22+
minimumSwapAmount: string
23+
maximumSwapAmount: string | null
24+
minimumEgressAmount: string
25+
}
26+
27+
interface ChainAssetRef {
28+
chain: string
29+
asset: string
30+
}
31+
32+
interface QuoteRequest {
33+
srcAsset: string
34+
srcChain: string
35+
destAsset: string
36+
destChain: string
37+
amount: string
38+
brokerCommissionBps?: number
39+
affiliateBrokers?: AffiliateBroker[]
40+
isVaultSwap?: boolean
41+
ccmParams?: {
42+
gasBudget: string
43+
messageLengthBytes: number
44+
}
45+
}
46+
47+
interface AffiliateBroker {
48+
account: string
49+
commissionBps: number
50+
}
51+
52+
interface FillOrKillParams {
53+
retryDurationBlocks: number
54+
refundAddress: string
55+
slippageTolerancePercent?: string | number
56+
minPrice?: string
57+
}
58+
59+
interface DepositAddressRequestV2 {
60+
quote: {
61+
srcAsset: ChainAssetRef
62+
destAsset: ChainAssetRef
63+
depositAmount: string
64+
}
65+
srcAddress?: string
66+
destAddress: string
67+
fillOrKillParams: FillOrKillParams
68+
affiliateBrokers?: AffiliateBroker[]
69+
ccmParams?: {
70+
gasBudget: string
71+
message: string
72+
}
73+
brokerCommissionBps?: number
74+
}
75+
76+
const Chains = {
77+
Ethereum: 'Ethereum',
78+
Arbitrum: 'Arbitrum',
79+
Bitcoin: 'Bitcoin',
80+
Solana: 'Solana',
81+
Assethub: 'Assethub',
82+
} as const
283

384
interface SwapSDKConfig {
485
network?: string
5-
enabledFeatures?: {
6-
dca?: boolean
7-
}
886
broker?: {
987
url: string
1088
commissionBps?: number
@@ -13,10 +91,7 @@ interface SwapSDKConfig {
1391

1492
class SwapSDK {
1593
constructor(_config?: SwapSDKConfig) {
16-
// Mock constructor for Chainflip SwapSDK
17-
// Accepts optional config with network, DCA features, and broker URL
18-
// In a real implementation, this would initialize the SDK with the provided configuration
19-
// Config parameter is prefixed with underscore to indicate it's intentionally unused in the mock
94+
// Mock constructor - config intentionally unused
2095
}
2196

2297
async getChains(): Promise<ChainData[]> {
@@ -107,6 +182,45 @@ class SwapSDK {
107182
maximumSwapAmount: null,
108183
minimumEgressAmount: '600',
109184
},
185+
{
186+
chainflipId: 'Wbtc',
187+
asset: 'WBTC',
188+
chain: 'Ethereum',
189+
contractAddress: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599',
190+
decimals: 8,
191+
name: 'Wrapped BTC',
192+
symbol: 'WBTC',
193+
isMainnet: true,
194+
minimumSwapAmount: '70000',
195+
maximumSwapAmount: null,
196+
minimumEgressAmount: '600',
197+
},
198+
{
199+
chainflipId: 'ArbUsdt',
200+
asset: 'USDT',
201+
chain: 'Arbitrum',
202+
contractAddress: '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9',
203+
decimals: 6,
204+
name: 'USDT',
205+
symbol: 'USDT',
206+
isMainnet: true,
207+
minimumSwapAmount: '20000000',
208+
maximumSwapAmount: null,
209+
minimumEgressAmount: '1',
210+
},
211+
{
212+
chainflipId: 'SolUsdt',
213+
asset: 'USDT',
214+
chain: 'Solana',
215+
contractAddress: 'Es9vMFrzaCERmKcoYhgavJZfoogysRKAeriNU1kU2g3c',
216+
decimals: 6,
217+
name: 'USDT',
218+
symbol: 'USDT',
219+
isMainnet: true,
220+
minimumSwapAmount: '20000000',
221+
maximumSwapAmount: null,
222+
minimumEgressAmount: '1',
223+
},
110224
]
111225
}
112226

packages/xchain-aggregator/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"directory": "release/package"
3030
},
3131
"dependencies": {
32-
"@chainflip/sdk": "2.0.3",
32+
"@chainflip/sdk": "2.1.1",
3333
"@xchainjs/xchain-client": "workspace:*",
3434
"@xchainjs/xchain-mayachain": "workspace:*",
3535
"@xchainjs/xchain-mayachain-amm": "workspace:*",

packages/xchain-aggregator/src/protocols/chainflip/chainflipProtocol.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ export class ChainflipProtocol implements IProtocol {
4949
constructor(configuration?: ProtocolConfig) {
5050
this.sdk = new SwapSDK({
5151
network: networkToChainflip(configuration?.network),
52-
enabledFeatures: {
53-
dca: true,
54-
},
5552
broker: configuration?.brokerUrl ? { url: configuration.brokerUrl } : undefined,
5653
})
5754
this.wallet = configuration?.wallet

tools/xchain-suite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"test:run": "vitest run"
1212
},
1313
"dependencies": {
14-
"@chainflip/sdk": "2.0.3",
14+
"@chainflip/sdk": "2.1.1",
1515
"@xchainjs/xchain-arbitrum": "workspace:*",
1616
"@xchainjs/xchain-avax": "workspace:*",
1717
"@xchainjs/xchain-bitcoin": "workspace:*",

0 commit comments

Comments
 (0)