Skip to main content

IMarginManager.sol

Read code on GitHub

Methods

deposit

Deposits funds into the margin of a Primitive Engine

Solidity
function deposit(address recipient, address risky, address stable, uint256 delRisky, uint256 delStable) external payable
Details

Since the PrimitiveManager contract keeps track of the margins, it will deposit the funds into the Primitive Engine using its own address

Parameters

NameTypeDescription
recipientaddressAddress receiving the funds in their margin
riskyaddressAddress of the risky token
stableaddressAddress of the stable token
delRiskyuint256Amount of risky token to deposit
delStableuint256Amount of stable token to deposit

depositCallback

Triggered when depositing tokens to an Engine

Solidity
function depositCallback(uint256 delRisky, uint256 delStable, bytes data) external nonpayable

Parameters

NameTypeDescription
delRiskyuint256Amount of risky tokens required to deposit to risky margin balance
delStableuint256Amount of stable tokens required to deposit to stable margin balance
databytesCalldata passed on deposit function call

margins

Returns the margin of an account for a specific Primitive Engine

Solidity
function margins(address account, address engine) external view returns (uint128 balanceRisky, uint128 balanceStable)

Parameters

NameTypeDescription
accountaddressAddress of the account
engineaddressAddress of the engine

Returns

NameTypeDescription
balanceRiskyuint128Balance of risky in the margin of the user
balanceStableuint128Balance of stable in the margin of the user

withdraw

Withdraws funds from the margin of a Primitive Engine

Solidity
function withdraw(address recipient, address engine, uint256 delRisky, uint256 delStable) external nonpayable

Parameters

NameTypeDescription
recipientaddressAddress receiving the funds in their wallet
engineaddressPrimitive Engine to withdraw from
delRiskyuint256Amount of risky token to withdraw
delStableuint256Amount of stable token to withdraw

Events

Deposit

Emitted when funds are deposited

Solidity
event Deposit(address indexed payer, address indexed recipient, address indexed engine, address risky, address stable, uint256 delRisky, uint256 delStable)

Parameters

NameTypeDescription
payer indexedaddressAddress depositing the funds
recipient indexedaddressAddress receiving the funds in their margin
engine indexedaddressEngine receiving the funds
riskyaddressAddress of the risky token
stableaddressAddress of the stable token
delRiskyuint256Amount of deposited risky
delStableuint256Amount of deposited stable

Withdraw

Emitted when funds are withdrawn

Solidity
event Withdraw(address indexed payer, address indexed recipient, address indexed engine, address risky, address stable, uint256 delRisky, uint256 delStable)

Parameters

NameTypeDescription
payer indexedaddressAddress withdrawing the funds
recipient indexedaddressAddress receiving the funds in their wallet
engine indexedaddressEngine where the funds are withdrawn from
riskyaddressAddress of the risky token
stableaddressAddress of the stable token
delRiskyuint256Amount of withdrawn risky
delStableuint256Amount of withdrawn stable

Errors

ZeroDelError

Thrown when trying to deposit or withdraw 0 risky and stable

Solidity
error ZeroDelError()