@scallop-io/scallop-swap-sdk
v4.1.1
Published
Scallop Swap Meta Aggregator SDK for Sui Blockchain developed by Scallop Labs.
Downloads
645
Readme
Scallop Swap Meta Aggregator SDK
A unified SDK that aggregates existing swap aggregators on Sui, including Aftermath, Cetus, and FlowX and provides a generic SwapSdkBase class for seamless integration and extension with future swap aggregators.
Adding a Custom SDK Integration
Extend SwapSdkBase with your own SDK-specific generic types:
import {
SwapSdkBase,
SwapSdkConstructorParams,
} from '@scallop-io/scallop-swap-sdk';
class MyDexSwap extends SwapSdkBase<
MyPoolType,
MyRawRoute,
MyFetchSettings,
MyClient
> {
constructor(params: SwapSdkConstructorParams<MyFetchSettings>) {
super('mydex', params);
this.client = new MyClient(/* ... */);
}
// Implement abstract methods: fetchRoute, buildSwapTransaction, setFetchRouteSettings, calcSlippage, ensureClient
}To get type-safe access via aggregator.getAggregator('mydex'), extend the SdkRegistry interface using declaration merging:
declare module '@scallop-io/scallop-swap-sdk' {
interface SdkRegistry {
mydex: MyDexSwap;
}
}
// Now fully typed:
const mydex = aggregator.getAggregator('mydex'); // MyDexSwap | undefined
mydex?.client; // MyClient | undefined