Sifi Documentation
website·Indexed 30 days ago
https://docs.sifi.org/Sifi is a router for DEXs and bridges that enables token swapping across chains. It provides a TypeScript SDK, a REST API for quotes and swaps, and a series of gas-optimized contract facets for protocols including Uniswap V2, Curve, and Stargate. Key features include the Warp Link for streaming swap instruction processing and the Stateless facet for swaps with untrusted contracts.
What's inside Sifi
- The Sifi contract is implemented using the ERC-2535: Diamonds, Multi-Facet Proxy standard. This allows the system to be deployed as a single contract where functions are organized into separate diamond facets.
Understand Sifi contract facet categories
Sifi contract functions are organized into facets based on their purpose and gas efficiency.
- Flexible Facets: Designed for high flexibility, allowing users to compose custom swaps, bridges, or interact with untrusted contracts. These consume more gas but offer broader utility (e.g.,
warpLinkEngage). - Protocol Specific Facets: Optimized for common tasks with minimal gas usage. These are laser-focused functions tailored to specific protocols (e.g.,
uniswapV2ExactInputSingleorstargateJumpToken).
- Flexible Facets: Designed for high flexibility, allowing users to compose custom swaps, bridges, or interact with untrusted contracts. These consume more gas but offer broader utility (e.g.,
Execute complex cross-chain swaps using Sifi Warp Link
Sifi provides a 'Warp Link' feature that allows users to perform a combination of token splits, swaps, and cross-chain jumps within a single transaction. Instead of manually executing multiple approvals and swaps across different protocols and chains, the Warp Link smart contract processes a list of instructions sequentially, acting as an assembly line for the trade.Integrate Sifi swaps into applications
The Sifi REST API enables developers to integrate cryptocurrency swap functionality and quote requests into external platforms. Common use-cases include adding Sifi swaps to a website or integrating them directly into a mobile wallet.Use Sifi as a router for DEXs and bridges
Sifi acts as a unified router for various decentralized exchanges (DEXs) and bridges (e.g., Uniswap DEX, Stargate bridge), providing a familiar interface for callers. Developers can use Sifi to integrate swaps or bridging directly into smart contracts or to compose custom swaps within a decentralized application (dapp).Manage partner fee sharing in Sifi swaps
When apartneraddress is specified in a swap or bridge function, any fees charged (feeBps) and any positive slippage not delivered to the user are split between the Sifi protocol and the specified partner. IffeeBpsis provided without apartner, the entire fee goes to the protocol. Partners can claim their accumulated fees via the StarVault facet.Use Flexible Facets for custom compositions and untrusted contracts
Flexible facets provide the ability to perform complex operations in a single transaction or interact with external, untrusted contracts.
- Warp Link: Allows a combination of splits, swaps, and chain jumps within one transaction.
- Stateless: Specifically used for interacting with untrusted contracts.
Optimize gas for DEX swaps and bridging using protocol-specific facets
Sifi provides specialized diamond facets for popular protocols to minimize gas consumption. While general-purpose tools like Warp Link or Stateless can perform swaps and bridges, using a protocol-specific facet is more gas-efficient. For example, swapping WETH for DAI on Curve is cheaper via the Curve facet than via Warp Link, and bridging USDC from Ethereum to Arbitrum is cheaper via the Stargate facet than via Warp Link.Install the Sifi SDK via npm
The Sifi SDK is a TypeScript package available on npm that allows you to integrate Sifi functionality into Node.js or browser-based applications. It is used for requesting quotes and building swap transactions.npm install @sifi/sdkUse Permit2 signatures instead of ERC-20 approvals
Sifi provides two versions of many methods to handle token approvals:
FooMethodandFooMethodPermit.FooMethod: Uses standard ERC-20approve. The user must approve the Sifi contract to spendamountInoftokenInbefore calling.FooMethodPermit: Uses the Permit2 standard. The user approves the Permit2 contract once and then passes a permit signature allowing Sifi to spend the tokens.
Constraint: Permits cannot be used when
tokenInis the native token (zero address).Use Protocol Specific Facets for gas-efficient operations
For standard operations on supported protocols, use protocol-specific facets to minimize gas costs. Supported categories include:
- Exchanges: Optimized functions for Uniswap (and its forks like Sushiswap) and Curve Finance.
- Bridges: Optimized functions for Stargate.
Common parameters for Sifi swap and bridge functions
Many Sifi functions, including Warp Link and Stateless, use a consistent set of parameters for token transfers and slippage control. Note that the native token (e.g., ETH, AVAX) is always represented by the zero address (0x00...).// Common Field Definitions tokenIn: // The input token address (zero address for native) tokenOut: // The output/settlement token address (zero address for native) recipient: // Address where tokenOut will be sent amountIn: // Amount of input tokens. For native tokens, msg.value must equal amountIn amountOut: // Amount of tokens the user was quoted or expects slippageBps: // Acceptable slippage in Basis Points (1 BP = 0.01%, 10 BP = 0.10%) partner: // Address of the partner (zero address for no partner) feeBps: // Fee to charge for the swap in Basis Points (1 BP = 0.01%) deadline: // Unix timestamp; transaction reverts if deadline is in the past