@ultratestbro/wdk-swidge-core
v0.2.0
Published
Shared WDK Swidge protocol engine, validation, execution and provider interfaces.
Maintainers
Readme
@ultratestbro/wdk-swidge-core
Shared WDK Swidge protocol engine, validation, execution and provider interfaces.
Installation
npm install @ultratestbro/wdk-swidge-core @tetherto/wdk-walletWhat's inside
Two layers. The engine speaks CrossChainProvider — enabled(), supportsRoute(), getQuote(), buildDeposit(), trackIntent(), plus optional notifyDeposit/registerSignedOrder/preflightDeposit hooks — and knows nothing about keys. On top of it BaseSwidgeProtocol and SingleProviderSwidge implement the WDK SwidgeProtocol contract: they translate SwidgeOptions into engine parameters, bind the account, and execute.
The execution path is chosen by the shape of the unsigned transaction, not by provider name: calldata means an EVM send with approval handling (including the Ethereum-USDT approve-to-zero dance); a bare to+value means a native transfer whose amount is re-checked against the quote; a token id means an SPL / TON jetton / TRC-20 transfer through the account's official transfer() capability; a memo or a base64 cell means TON, the latter only with an injected decoder; typed data means a signed EIP-712 order with no source transaction at all.
CrossChainRouter quotes providers in parallel under a per-provider timeout, validates every candidate before it can be scored, and ranks on price, speed and reliability. Aggregation on top of it lives in wdk-protocol-swidge-router.
remoteProvider moves provider REST/WebSocket calls (and their secrets) behind an HTTP boundary while the whole WDK layer — account binding, approvals, id lifecycle — stays on the client. It ships no quote-integrity binding across that boundary: a deployment that splits quote and build should seal quotes itself, e.g. an HMAC over every execution-relevant field, verified before build.
Durable status ids (wdk1.<venue>.<intent>.<sourceTxHash>) let getSwidgeStatus resolve a swap on a process that never quoted it, and typed errors (WdkSwidgeError and codes) keep the WDK boundary machine-readable.
Extension points: write a CrossChainProvider for a new venue, adapt any SwidgeProtocol or BridgeProtocol module, inject decodeTonBody, or replace the scoring engine outright.
Safety contract
- This is a support package, not a WDK protocol module: it implements no protocol interface and is installed as a dependency of the modules that do.
- Non-EVM token-source deposits use the official WDK account
transfer({ token, recipient, amount })capability. They fail closed when the bound account does not expose it; token metadata is never passed to nativesendTransaction(). - Provider credentials, affiliate settings, endpoints and enablement are explicit constructor options. The package reads no application environment variables.
- Before production use, validate with limited funds and configure fee caps appropriate for the source asset.
Links
- Source: https://github.com/ultratestbro/wdk-swidge-modules
- Upstream discussion: https://github.com/tetherto/wdk/issues/85
Licensed under Apache-2.0.
