The Router serves as a central entry point for user interactions with the Satoshi Perps protocol. It manages plugins, handles token approvals, and provides functionality for token swapping and position modifications through authorized plugins.
First, a user registers the PositionManager as a plugin.
Copy
// Add the position manager as a pluginawait router.addPlugin(positionManagerAddress);// Approve the position manager pluginawait router.approvePlugin(positionManagerAddress);
2
Approve Tokens
The user approves tokens to be used by the Router.
Now the user can interact with the PositionManager, which uses the Router as an intermediary.
Copy
// Open a long position through the position managerawait positionManager.increasePosition( [wethAddress], // Token path wethAddress, // Index token (ETH) ethers.utils.parseEther("1"), // Amount in 0, // Min output amount (no swap) ethers.utils.parseUnits("5", 30), // Size delta (5x leverage) true, // Is long ethers.utils.parseUnits("2000", 30) // Acceptable price);