Optyn
Search…
Market Maker Guide
Optyn has been designed so that anyone can create custom selling strategies that liquidity providers can provide liquidity to and options can be purchased for.
Some sample scenarios for why to you might want to become a market maker can be found in the advanced option selling section: price optimization, new or custom oracles.
As a market maker you can create an option selling strategy that you or anyone can provide liquidity for. You may take on some responsibilities to manage some of the pool risks and you will be rewarded with a market maker fee.
Market making currently doesn't have a ux frontend so varying degrees of experience with Solidity is required.
The "market making" discord group is the best place to ask questions and request assistance with how to implement a custom strategy.
The main market maker functions are:
    Create a liquidity pool
    Link any oracles to the pool
    Modify the pricing function
    Modify other parameters
    Lock the pool
    Delta hedge the pool
    Set the market maker fee

Create a liquidity pool

1
function createPool(IOracle _oracle, IERC20 _collateralToken, IERC20 _hedgeToken, IUniswapV2Factory _swapFactory, IUniswapV2Router02 _swapRouter) public {
Copied!
Any contract that implements the IOracle interface can be enabled/disabled in the pool.
1
interface IOracle {
2
3
function decimals()
4
external
5
view
6
returns (
7
uint8
8
);
9
10
function description()
11
external
12
view
13
returns (
14
string memory
15
);
16
17
function latestAnswer()
18
external
19
view
20
returns (
21
uint256
22
);
23
}
24
25
function setOracleEnabled(uint poolId, IOracle _oracle, bool value) external {
Copied!

Modify the pricing function

When a pool is created the default pricing function is used. Any contract that implements the IFeeCalcs can be used to implement a custom pricing function.
Each getter function returns a number between 0(0%) & 10000(100%) this these are multiplied by the option size to determine the option premium.
Changing the pricing function is only possible if the pool is not readonly.
1
interface IFeeCalcs {
2
function getStrikeFee(uint256 period, uint256 optionSize, uint256 strike, uint256 currentPrice, IOptions.OptionType optionType, uint poolId, IOracle oracle) external pure returns (uint256);
3
function getPeriodFee(uint256 period, uint256 optionSize, uint256 strike, uint256 currentPrice, IOptions.OptionType optionType, uint poolId, IOracle oracle) external view returns (uint256);
4
function getBalanceUtilisationFee(uint256 period, uint256 optionSize, uint256 strike, uint256 currentPrice, IOptions.OptionType optionType, uint poolId, IOracle oracle) external view returns (uint256);
5
function getPoolFee(uint256 period, uint256 optionSize, uint256 strike, uint256 currentPrice, IOptions.OptionType optionType, uint poolId, IOracle oracle) external view returns (uint256);
6
struct Fees {
7
uint256 total;
8
uint256 protocolFee;
9
uint256 strikeFee;
10
uint256 periodFee;
11
uint256 balanceUtilisationFee;
12
uint256 poolFee;
13
}
14
}
15
16
/* Change the pricing calculation function */
17
function setPoolFeeCalc(uint poolId, IFeeCalcs value);
18
Copied!

Modify other parameters

Either the pool owner or operator can modify these parameters unless the pool has been set as readonly. Only the pool owner can change the pool owner.
1
/* Change the account that owns the pool */
2
function setPoolOwner(uint poolId, address value);
3
4
/* Change the account that can operate the pool */
5
function setPoolOperator(uint poolId, address value);
6
7
/* Change the pool fee charged; 0=0%, 10000=100% */
8
function setPoolFee(uint poolId, uint256 value);
9
10
/* Change where to load information about the pool from */
11
function setIpfsHash(uint poolId, string memory value)
12
13
/* Sets the maximum investment limit that can be made */
14
function setMaxInvest(uint poolId, uint256 value)
15
16
/* Sets the minimum option period that can be purchased */
17
function setPeriodMin(uint poolId, uint256 value)
18
19
/* Sets the maxium option period that can be purchased */
20
function setPeriodMax(uint poolId, uint256 value)
21
22
/* Sets the period that funds cannot be withdrawn once deposited */
23
function setLockupPeriod(uint poolId, uint256 value)
24
25
/* Sets the option collateralization ratio; 0=0%, 10000=100% */
26
function setCollaterizationRatio(uint poolId, uint256 value)
Copied!

Lock the pool

The market maker can set the pool to be readonly. Once set no more changes can be made to the pricing function, oracles or parameters.
1
/* Sets the pool to be permenently readonly */
2
function setReadOnly(uint poolId, bool value)
Copied!

Delta hedge the pool

The market maker or operator can use these functions to perform delta hedging. Liquidity is stored in UniswapV2 compatible pools so when first created the initial state of the pool is balanced 50% to each collateral & hedge token.
The market maker can use "setDeltaHedge" function which sells a percentage of the balance of the swap pool and buys more of the collateral or hedge token.
Calling the resetDeltaReserves function returns it back to a balanced state with 50% value in each.
This function can be called even after the pool has been set to read only and nobody has direct access to the funds.
1
/* deposits any collateral or hedge reserves back into the pool */
2
function resetDeltaReserves(uint _poolId, bool resetCollateral)
3
4
/* withdraws the % of the pool(10000=100%) and uses swaps to the collateral token or hedge token */
5
function setDeltaHedge(uint _poolId, uint percent, bool _toCollateral) public returns (uint collateralAmount, uint hedgeAmount, uint[] memory swapAmounts) {
6
Copied!

Set the market maker fee

The pool fee is distributed to the poolOwner address. The pricing function reads this property so this property will be used by default but could also be overridden in the pricing function.
1
/* Change the pool fee charged; 0=0%, 10000=100% */
2
function setPoolFee(uint poolId, uint256 value);
Copied!
Last modified 1mo ago