@rallycash/sendy
v0.0.0
Published
Inject-on-init swap SDK
Readme
@rallycash/sendy
Class-based swap client. Inject quote, chain, and wallet transports. The library never reads process.env.
import {
MockQuoteTransport,
Sendy,
createEvmChainTransport,
createEvmWalletTransport,
} from '@rallycash/sendy'
const sendy = new Sendy({
quoters: [new MockQuoteTransport()],
chains: [createEvmChainTransport({ chainId: 8453, publicClient })],
hooks: {
onSubmitted: ({ hash }) => persistSubmitted(hash),
onFilled: (result) => persistFilled(result),
},
})
const quote = await sendy.quote({
tokenIn: { chainId: 8453, address: usdc, decimals: 6 },
tokenOut: { chainId: 8453, address: weth, decimals: 18 },
amountIn: 1_000_000n,
})
const swap = await sendy.send({
quote,
wallet: createEvmWalletTransport({ chainId: 8453, walletClient }),
})
await swap.waitForResult()createEvmChainTransport / createEvmWalletTransport wrap viem-like clients. Real aggregators (0x, Relay, Jupiter) are follow-up transports that implement QuoteTransport.
