Migration Guide
Upgrade guide for existing users moving to the latest SDK patterns and APIs.
Table of Contents
Migrating to v0.2.1 (Base_r12 deployment)
v0.2.1 is the first 0.2.x release published to npm. It bundles the Base_r12 deployment cutover with 22 fixes that three adversarial code-review passes found in the staged surface. v0.2.0 was prepared internally but never published — there is no v0.2.0 on npm.
Pin to the deployment you want
@thetanuts-finance/thetanuts-client@^0.1.x— prior Base deployment (immutable on npm; use only if you need to keep talking to the old contracts).@thetanuts-finance/thetanuts-client@^0.2.1— Base_r12 deployment (recommended).
Breaking changes from 0.1.x → 0.2.1
client.events.getCollateralReturnedEventswas renamed togetExcessCollateralReturnedEventswith a new field shape:OptionSplitEventgained two fields. If you were destructuring, addfeePaidandcounterparty:TransferApprovalEventfield order is fixed to match r12:{ target, from, isBuyer, isApproved }. The 0.1.x SDK hadtargetandfromswapped in the typed wrapper forRangerOptionevents specifically.OptionSettlementFailedEventno longer has fields at the contract level. The SDK still populatesoptionAddressfrom the filter context for caller convenience.Butterfly reverse-lookup names reconciled.
getOptionImplementationInfo(addr).namereturns'CALL_FLY'/'PUT_FLY'instead of'CALL_FLYS'/'PUT_FLYS'. TheProductNameunion inclient.utilsfollows.RangerModule.reclaimCollateralparameter renamed fromrecipienttoownedOption. Positional callers unaffected; named callers using a TypeScript object-shape break.LoanRequest.keepOrderOpenis now a no-op. The r12 contract dropped the limit-order conversion field. The SDK still accepts the field for source compatibility but the value is ignored. The internalLoanCoordinator.requestLoanparameter tuple no longer includesconvertToLimitOrdereither; the SDK no longer sends it.LoanIndexerLoan.convertToLimitOrderis optional. The lender-opportunity filter atclient.loan.getLendingOpportunitiesonly skips when the field is explicitlyfalse; missing means eligible. If the r12 indexer drops the field entirely, your lender opportunity list still populates.
What you should also know about 0.2.1
New
client.rangermodule — see the Modules Overview.chainConfig.implementations.RANGER,LINEAR_CALL,INVERSE_CALL_SPREAD,CALL_LOANare new.chainConfig.twapConsumer(string | null) surfaces the HistoricalPriceConsumerV3_TWAP address.Ethereum mainnet (
chainId 1) is now supported as a vault-only chain (onlyclient.wheelVaultworks there).Every RFQ entry point now rejects the seven undeployed
PHYSICAL_*placeholder addresses with a clearINVALID_PARAMSerror.RANGER_OPTION_ABIis exported from the package root.
Breaking Changes
collateralAmount Parameter
The most critical change: collateralAmount must now always be 0 when creating RFQs.
Before (Incorrect Pattern)
After (Correct Pattern)
Why This Changed
Collateral is NOT locked at RFQ creation time. It is pulled from both parties at settlement time. The collateralAmount parameter in RFQ was misleading and should always be 0.
For SELL positions: You still need to calculate collateral, but only for token approval:
New Helper Methods
buildRFQParams()
High-level RFQ builder that:
Enforces
collateralAmount = 0automaticallyResolves addresses from chain config (no hardcoding)
Handles decimal conversions
buildRFQRequest()
Complete RFQ request builder including tracking and reserve price:
strikeToChain() / strikeFromChain()
Precision-safe strike conversion using string-based parsing (avoids floating-point errors):
getFullOptionInfo()
Aggregated option info in a single call (replaces multiple Promise.all patterns):
MM Pricing Filter Utilities
New utilities for filtering and sorting pricing data:
Code Migration Examples
Example 1: RFQ Creation for BUY Position
Example 2: RFQ Creation for SELL Position
Example 3: Option Position Queries
Example 4: Strike Price Conversion
Deprecation Notices
Deprecated Patterns
Hardcoded contract addresses
Deprecated
Use client.chainConfig
Manual collateralAmount calculation
Deprecated
Always use BigInt(0) or buildRFQParams()
Multiple Promise.all for option info
Deprecated
Use getFullOptionInfo()
Manual strike scaling
Deprecated
Use strikeToChain() / strikeFromChain()
API Method Renames
To clarify data sources, some API methods have been renamed:
getUserPositions()
getUserPositionsFromIndexer()
Indexer API
getUserHistory()
getUserHistoryFromIndexer()
Indexer API
getStats()
getStatsFromIndexer()
Indexer API
getUserRFQs()
getUserRFQsFromRfq()
State/RFQ API
getRFQ()
getRFQFromRfq()
State/RFQ API
The old method names are still available as aliases but may be removed in a future version.
Indexer Migration Notes
Tested 2026-04-07 against
indexer.thetanuts.finance(new unified indexer). Compared withoptionbook-indexer.thetanuts.finance(old indexer, to be decommissioned).
Open Issues
Issue 1: Referrer userDailyMetrics not implemented
userDailyMetrics not implementedEndpoint:
GET /api/v1/book/referrer/:addr/stateSeverity: Medium
Description: Old indexer returns per-user, per-day trading stats. New indexer returns
{}.SDK impact:
ReferrerStats.userDailyMetricsinsrc/types/api.tsexpects this data.
Issue 2: Referrer topProfitableTrades not implemented
topProfitableTrades not implementedEndpoint:
GET /api/v1/book/referrer/:addr/stateSeverity: Medium
Description: Old indexer returns top 100 trades ranked by % return. New indexer returns
[].SDK impact:
ReferrerStats.topProfitableTradesinsrc/types/api.tsexpects this data.
Issue 4: Pagination not working on /api/v1/factory/rfqs
/api/v1/factory/rfqsEndpoint:
GET /api/v1/factory/rfqs?limit=2&offset=0Severity: Low
Description: Pagination params are ignored — all RFQs are returned regardless. No pagination metadata in response.
SDK impact: None currently, but will not scale past ~5k RFQs.
Issue 6: Old indexer DNS records still active
Severity: Low
optionbook-indexer.thetanuts.financestill resolves and serves stale data.Cleanup pending once migration is fully verified.
Resolved Issues
SDK ReferrerStats type missing summary field
Fixed — ReferrerStats now includes optional summary?: ReferrerSummary
Daily stats endpoints return empty data
Fixed — getBookDailyStats(), getFactoryDailyStats(), getDailyStats() added
Factory referrals missing / empty
Fixed — StateReferral type corrected to match actual API response shape
Active filter bug — cancelled RFQ appearing in active results
Fixed — SDK now applies client-side re-filtering as a safety net
New Endpoints (not yet in SDK)
The following endpoints are live on the new indexer but do not yet have dedicated SDK methods:
GET /api/v1/book/stats/protocol
Book protocol stats with time windows and implementation-type breakdowns
GET /api/v1/factory/stats/protocol
Factory protocol stats including avgTimeToFill, avgOffersPerRfq
GET /api/v1/stats/protocol
Combined book + factory protocol stats (merged totals + individual breakdowns)
Endpoint Status Summary
/api/v1/book/user/:addr/positions
Working
/api/v1/book/user/:addr/history
Working
/api/v1/book/stats
Working
/api/v1/book/referrer/:addr/state
Partial (positions + summary; userDailyMetrics and topProfitableTrades missing)
/api/v1/book/stats/protocol
Working (new)
/api/v1/book/stats/daily
Working — SDK: getBookDailyStats()
/api/v1/factory/rfqs
Working (no pagination)
/api/v1/factory/rfqs/:id
Working
/api/v1/factory/offers
Working
/api/v1/factory/options
Working
/api/v1/factory/stats
Working
/api/v1/factory/user/:addr/rfqs
Working
/api/v1/factory/user/:addr/offers
Working
/api/v1/factory/user/:addr/positions
Working
/api/v1/factory/option/:addr
Working
/api/v1/factory/stats/protocol
Working (new)
/api/v1/factory/stats/daily
Working — SDK: getFactoryDailyStats()
/api/v1/book/option/:addr
Working
/api/v1/book/state
Working
/api/v1/stats/protocol
Working (new)
/api/v1/stats/daily
Working — SDK: getDailyStats()
/api/state
Working
/health
Working
See Also
Changelog - Version history and release notes
Examples - Runnable code examples covering common patterns
Error Handling — error codes and recovery patterns
Last updated

