Inherits: Initializable, OwnableUpgradeable, IHedgeManager
Author: Logarithm Labs
OffChainPositionManager is a smart contract component designed to interact with off-chain perpetual protocols to manage hedge positions. By coordinating with off-chain systems, such as through an oracle or relayer network, the contract adjusts perpetual positions to maintain a target exposure aligned with the strategy’s requirements. This component is ideal for delta-neutral strategies seeking yield from funding payments on off-chain perpetual markets.
OffChainPositionManager is an upgradeable smart contract, deployed through the beacon proxy pattern.
State Variables
OffChainPositionManagerStorageLocation
Copy bytes32 private constant OffChainPositionManagerStorageLocation =
0xc79dcf1ab1ed210e1b815a3e944622845af0e197fa2b370829d3b756c740ef00 ; _getOffChainPositionManagerStorage
Copy function _getOffChainPositionManagerStorage () private pure returns ( OffChainPositionManagerStorage storage $ ); Authorize caller if it is a configured agent.
Copy modifier onlyAgent ( ); Called to adjust the hedge position based on specified parameters.
Parameters
Reports the state of the hedge position.
reportStateAndExecuteRequest
Reports the state of the hedge position while calling the strategy’s callback functions if there is a position adjustment request from the strategy.
Returns the last request that was requested from strategy.
clearIdleCollateral
Transfers idle assets to the vault to process withdraw requests.
forcedTransferToAgent
_transferToAgent
forcedTransferFromAgent
_transferFromAgent
positionNetBalance
Gets the net collateral balance of the position, including pending adjustments.
Returns
The total collateral asset amount in the position.
currentPositionState
Returns the current state of position.
currentLeverage
Retrieves the current leverage of the position.
Returns
The leverage ratio as a uint256.
The address of OffChainConfig smart contract.
The address of agent.
The address of oracle smart contract.
lastRequestRound
The last request round.
The current round which is increased by reporting state.
The position state at a specific round.
pendingCollateralIncrease
The pending collateral amount that is transferred to agent to increase collateral, but not reported by agent.
The request info at a specific round.
positionSizeInTokens
Returns the current size of the position in terms of index tokens.
Returns
The size of the position in index tokens.
Checks whether the keep function needs to be called to maintain the position.
Returns
A boolean indicating if keep should be executed.
Called to maintain or adjust the hedge position as required by strategy logic.
Executes actions needed to align the position with target hedge requirements.
increaseCollateralMinMax
Returns the minimum and maximum collateral limits for increasing the position.
Returns
The minimum allowable collateral increase amount.
The maximum allowable collateral increase amount.
increaseSizeMinMax
Returns the minimum and maximum limits for increasing the position size.
Returns
The minimum allowable increase in position size.
The maximum allowable increase in position size.
decreaseCollateralMinMax
Returns the minimum and maximum collateral limits for decreasing the position.
Returns
The minimum allowable collateral decrease amount.
The maximum allowable collateral decrease amount.
decreaseSizeMinMax
Returns the minimum and maximum limits for decreasing the position size.
Returns
The minimum allowable decrease in position size.
The maximum allowable decrease in position size.
limitDecreaseCollateral
Retrieves the minimum decrease in collateral required for cost-efficient execution.
Helps in optimizing gas usage and cost efficiency.
Returns
The minimum decrease collateral amount that qualifies for cost-effective execution.
collateralToken
Returns the address of the collateral token used in the position.
Returns
The address of the collateral token.
Returns the address of the index token used in the position.
Returns
The address of the index token.
idleCollateralAmount
The balance of collateral asset of this position manager.
Emitted when agent gets updated.
Emitted when a new request from strategy is created.
Emitted when a report is executed after requesting.
RequestIncreasePosition
Emitted when a increase request is created.
RequestDecreasePosition
Emitted when a decrease request is created.
Emitted when asset is transferred to agent to increase collateral.
Emitted when position’s state is reported.
Used to store the state of offchain position.
Used for the request and response infos.
OffChainPositionManagerStorage
Last updated 11 months ago