BasisOS
  • INTRODUCTION
    • What is BasisOS
    • Key Concepts in Basis Trading
    • Vision and Value Proposition
  • Basis Vaults
    • Architecture Overview
    • Components and Interactions
    • Managed Approach
    • Execution Flow
  • BASISOS AGENT
    • Overview
    • Core Components
    • System Design and Interactions
    • Agentic Roadmap
      • Stage 0: Assistant
      • Stage 1: Maintainer
      • Stage 2: Curator
      • Stage 3: Sovereign
  • TOKENOMICS
    • Token Distribution
    • Liquidity Mining
      • Distribution Mechanics
      • Rewards Schedule
    • Mindshare Mining
      • Distribution Mechanics
      • Rewards Schedule
  • CORE PROTOCOL
    • LogarithmVault
    • BasisStrategy
    • SpotManager
    • OffchainPositionManager
    • GmxV2PositionManager
    • LogarithmOracle
      • Oracle Provider
    • Contract Addresses
  • RISK MANAGEMENT
    • Funding Risk
    • Liquidity Risk
    • Risk Framework
      • Margin Treasury
      • Maximum Leverage
      • Asset Clustering
      • Strategy Capacity
    • Backtests
Powered by GitBook
On this page
  • State Variables
  • Functions
  • Events
  • Structs
  1. CORE PROTOCOL

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

Name
Type
Description

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

Name
Type
Description

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;
}
PreviousBasisStrategyNextOffchainPositionManager

Last updated 3 months ago