Migration notes between consecutive versions of @gearbox-protocol/sdk that
introduce consumer-visible breaking changes. New sections are appended below
as future releases ship.
Despite being a minor bump,
v14.10.0introduced consumer-visible breaking changes. A short-livedv15.0.0-next.{1,2,3}prerelease line carried the same changes but was never released as stable —^14.10.0is the supported upgrade target.
sdk.accountsandsdk.poolsare now built for you.OnchainSDKinstantiates aCreditAccountsServiceV310and aPoolServicein its constructor and exposes them assdk.accounts(ICreditAccountsService) andsdk.pools(IPoolsService). You no longer create these services manually.createCreditAccountServicefactory removed. Usesdk.accountsdirectly.AbstractCreditAccountServiceremoved. Its functionality was merged intoCreditAccountsServiceV310.CreditAccountServiceV310renamed toCreditAccountsServiceV310(note the pluralAccounts).
Before:
import { createCreditAccountService } from "@gearbox-protocol/sdk";
const accounts = createCreditAccountService(sdk, 310);
const data = await accounts.getCreditAccountData(account);After:
const data = await sdk.accounts.getCreditAccountData(account);Before:
import { PoolService } from "@gearbox-protocol/sdk";
const pools = new PoolService(sdk);
pools.getDepositTokensIn(pool);After:
sdk.pools.getDepositTokensIn(pool);- import { CreditAccountServiceV310 } from "@gearbox-protocol/sdk";
+ import { CreditAccountsServiceV310 } from "@gearbox-protocol/sdk";An agent skill ships with this repo at
skills/gearbox-sdk-v14.x-to-v14.10.
npx skills add Gearbox-protocol/sdk --skill gearbox-sdk-v14.x-to-v14.10OnchainSDK— renamed fromGearboxSDK, single-chain entry point- Instantiation is now two steps:
new OnchainSDK(network, clientOptions, options)thenawait sdk.attach()orsdk.hydrate(state) - Network is explicit: you pass a
NetworkTypestring (e.g."Mainnet") to the constructor instead of relying on auto-detection blockNumber,addressProvider,marketConfiguratorsmoved out of constructor options intoAttachOptionsreattach()/rehydrate()— dropped entirely (create a new instance instead)- hooks dropped from OnchainSDK
MultichainSDK— new class wrapping multipleOnchainSDKinstances (one per chain)
- import { GearboxSDK } from "@gearbox-protocol/sdk";
+ import { OnchainSDK } from "@gearbox-protocol/sdk";Before:
const sdk = await GearboxSDK.attach({
rpcURLs: [RPC_URL],
timeout: 480_000,
logger,
blockNumber: 24736900,
plugins: {
adapters: new AdaptersPlugin(),
bots: new BotsPlugin(),
},
});After:
const sdk = new OnchainSDK(
"Mainnet", // explicit network
{ rpcURLs: [RPC_URL], timeout: 480_000 }, // client options
{ // SDK options
logger,
plugins: {
adapters: new AdaptersPlugin(),
bots: new BotsPlugin(),
},
},
);
await sdk.attach({ blockNumber: 24736900 }); // attach optionsKey differences:
- Network type (
"Mainnet","Arbitrum", etc.) is now a required constructor argument - Client connection config and SDK options are separate arguments
blockNumber,addressProvider,marketConfiguratorsmove toattach()- Constructor is sync;
attach()is async
Before:
const sdk = await GearboxSDK.hydrate(savedState, {
rpcURLs: [RPC_URL],
logger,
});After:
const sdk = new OnchainSDK(
"Mainnet",
{ rpcURLs: [RPC_URL] },
{ logger },
);
sdk.hydrate(savedState, { redstone, pyth }); // synchronous| Old | Replacement |
|---|---|
sdk.reattach(...) |
Create a new OnchainSDK instance |
sdk.rehydrate(...) |
Create a new OnchainSDK instance |
Instead of sdk.addHook('syncState', handler) await sync and run your code:
const success = await sdk.syncState()
if (success) {
await myFn(sdk.currentBlock);
}
If you need to subscribe to block changes there's now new async helper that acts as mutex for onBlock callback
const unwatch = watchBlocksAsync(client, {
onBlock: async (block, prevBlock) => {
console.log("new block", block.number);
},
onDrop: (block) => {
console.log("dropped block", block.number);
},
onError: (err) => {
console.error(err);
},
});
An agent skill ships with this repo at
skills/gearbox-sdk-v13-to-v14.
npx skills add Gearbox-protocol/sdk --skill gearbox-sdk-v13-to-v14