SpotManager
Inherits: Initializable, OwnableUpgradeable, ISpotManager
Author: Logarithm Labs
SpotManager is a dedicated smart contract that manages spot positions for a trading strategy, enabling it to buy or sell assets on a decentralized exchange (DEX) or other spot market. This manager operates in tandem with a basis strategy, allowing it to adjust the spot position dynamically based on the strategy’s target exposure. The primary objective is to provide liquidity for the basis trade, maintaining optimal spot exposure relative to the short hedge position.
SpotManager is an upgradeable smart contract, deployed through the beacon proxy pattern.
State Variables
SpotManagerStorageLocation
bytes32 private constant SpotManagerStorageLocation = 0x95ef178669169c185a874b31b21c7794e00401fe355c9bd013bddba6545f1000;
Functions
_getSpotManagerStorage
function _getSpotManagerStorage() private pure returns (SpotManagerStorage storage $);
authCaller
Authorizes a caller if it is the specified account.
modifier authCaller(address authorized);
initialize
function initialize(address _owner, address _strategy, address[] calldata _assetToProductSwapPath)
external
initializer;
_setManualSwapPath
function _setManualSwapPath(address[] calldata _assetToProductSwapPath, address _asset, address _product) private;
buy
Buys product in the spot market.
function buy(uint256 amount, SwapType swapType, bytes calldata swapData) external authCaller(strategy());
Parameters
amount
uint256
The asset amount to be swapped to product.
swapType
SwapType
The swap type.
swapData
bytes
The data used in swapping if necessary.
sell
Sells product in the spot market.
function sell(uint256 amount, SwapType swapType, bytes calldata swapData) external authCaller(strategy());
Parameters
amount
uint256
The product amount to be swapped to asset.
swapType
SwapType
The swap type.
swapData
bytes
The data used in swapping if necessary.
exposure
The spot exposure that is needed to be hedged by the perpetual positions.
function exposure() external view returns (uint256);
uniswapV3SwapCallback
function uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external;
_verifyCallback
function _verifyCallback() internal view;
strategy
The strategy address.
function strategy() public view returns (address);
asset
The asset address.
function asset() public view returns (address);
product
The product address.
function product() public view returns (address);
Events
SpotBuy
Emitted when product is bought in spot markets.
event SpotBuy(uint256 assetDelta, uint256 productDelta);
SpotSell
Emitted when product is sold in spot markets.
event SpotSell(uint256 assetDelta, uint256 productDelta);
Structs
SpotManagerStorage
struct SpotManagerStorage {
address strategy;
address asset;
address product;
mapping(address => bool) isSwapPool;
address[] productToAssetSwapPath;
address[] assetToProductSwapPath;
}
Last updated