Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog,
and this project adheres to Semantic Versioning.
[unreleased]
[2.4.0] - 2022-12-02
Added
- Add
CollateralManager.getDebtThresholdByTrader() - Add
CollateralManager.getTotalWhitelistedDebtThreshold()
[2.3.0] - 2022-12-02
Added
- Add
Insurance.distributeFee() - Add
Insurance.getThreshold() - Add
Insurance.getSurplusBeneficiary() - Add new event
ThresholdChanged,SurplusBeneficiaryChanged,FeeDistributedtoInsuranceFund
[2.2.4] - 2022-12-02
- Support remove all liquidity in
quitMarket()if user has orders in closed market
[2.2.3] - 2022-10-24
Changed
- Fix rounding issue (expect amount is not equal to response) when open position with
isBaseToQuote: falseandisExactInput: true
[2.2.2] - 2022-10-13
Changed
- Change
_MAX_PRICE_SPREAD_RATIOfrom 20% to 10%
[2.2.1] - 2022-10-11
- Add
InsuranceFund.getInsuranceFundCapacity()
[2.2.0] - 2022-09-30
Added
- Add
Vault.settleBadDebt() - Add
InsuranceFund.repay() - Add new event
Repaid,BadDebtSettled
Removed
- Remove
InsuranceFund.borrow()
[2.1.1] - 2022-09-21
Changed
AccountBalance.getLiquidatablePositionSize()returns entire position size if the position value is less than _MIN_PARTIAL_LIQUIDATE_POSITION_VALUE.
[2.1.0] - 2022-08-16
Added
- Add
Vault.withdrawAll()to withdraw all free collateral(specified) from vault - Add
Vault.withdrawAllEther()to withdraw all ETH from vault
Changed
- Update return parameter names in NatSpec
Fixed
- Fix rounding issue when liquidating collaterals in full
- Fix collateral value precision and underlying rounding issues
[2.0.1] - 2022-08-10
Added
- Add
DelegateApproval.canAddLiquidityForto check if can add liquidity for another maker. - Add
DelegateApproval.canRemoveLiquidityForto check if can remove liquidity belonging to another maker.
[2.0.0] - 2022-08-10
Changed
-
liquidate()becomes position transfer instead of market selling. So liquidators now require collaterals to do liquidation.-
liquidate()has new interfaces:function liquidate( address trader, address baseToken, int256 positionSize ) external; // liquidate as much as possible function liquidate( address trader, address baseToken, ) external;
-
Added
- Add
AccountBalance.getLiquidatablePositionSize()to calculate the liquidatable position size for trader.
Deprecated
function liquidate(address trader, address baseToken, uint256 oppositeAmountBound)
[1.4.0] - 2022-07-05
Added
- Add
DelegateApproval- Currently only allow delegating
ClearingHouseOpenPosition
- Currently only allow delegating
- Add
ClearingHouse.openPositionFor() - Add
ClearingHouse.getDelegateApproval()
[1.3.0] - 2022-06-20
Added
- Add
BaseToken.cacheTwapto offer the flexibility of updating index prices by either users or ourselves.
[1.2.0] - 2022-04-28
Changed
ClearingHouse.getAccountValue()function now callsVault.getAccountValue()Vault.deposit(),Vault.withdraw(),Vault.depositFor()can be used for non-settlement token
Added
Vaultnow supports depositing non-settlement token as collateral- Add
CollateralManagercontract for non-settlement collateral related params management - Add
Vault.depositEther(),Vault.depositEtherFor()Vault.withdrawEther()for ETH deposit/withdraw - Add
Vault.getAccountValue()to get the account value in settlement token's decimals - Add
Vault.getBalanceByToken()to query collateral balance by token address - Add
Vault.getCollateralTokens()to query all non-settlement collateral token addresses of a trader - Add
Vault.getFreeCollateralByToken()to query free collateral by given collateral token addresses - Add
Vault.getSettlementTokenValue()to query trader's settlement token value - Add
Vault.isLiquidatable()to check if a trader's non-settlement collateral can be liquidated - Add
Vault.getMarginRequirementForCollateralLiquidation()to get the margin requirement that a trader's
non-settlement collateral is eligible to be liquidated - Add
Vault.getCollateralMmRatio()to get the mmRatio for collateral liquidation - Add
Vault.getLiquidatableCollateralBySettlement()to get the liquidatable collateral amount by given
repaid settlement amount - Add
Vault.getRepaidSettlementByCollateralto get the repaid settlement amount by given collateral amount
for liquidation - Add
Vault.getMaxRepaidSettlementAndLiquidatableCollateral()to query the max repaid settlement amount and
max collateral amount for liquidation - Add
Vault.liquidateCollateralto liquidate trader's non-settlement collateral
[1.1.0] - 2022-04-12
- Add
BaseToken.pause()(only owner) - Add
BaseToken.close(uint256)(only owner) - Add
IBaseToken.close() - Add
IBaseToken.getPausedTimestamp() - Add
IBaseToken.getPausedIndexPrice() - Add
IBaseToken.getClosedPrice() - Add
IBaseToken.isOpen() - Add
IBaseToken.isPaused() - Add
IBaseToken.isClosed() - Add
IVault.depositFor(address, address, uint256) - Add
IClearingHouse.quitMarket(address, address) - Add new event
PositionClosedtoClearingHouse, will emit inquitMarket(address, address)
[1.0.15] - 2022-02-09
Changed
- emit
PositionChangedevent incancelExcessOrdersandcancelAllExcessOrders
[1.0.14] - 2022-01-28
Added
- Add
IClearingHouse.liquidate(address, address, uint)to liquidate with slippage protection.
[1.0.13] - 2022-01-21
Deploy
- Deploy
SOLmarket to optimism
[1.0.12] - 2022-01-20
Deploy
- Deploy
LUNAmarket to optimism
[1.0.11] - 2022-01-18
Deploy
- Deploy
AVAXmarket to optimism
[1.0.10] - 2022-01-17
Changed
- Add _backstopLiquidityProviderMap in ClearingHouseConfigStorageV2. It's for only configured backstopLiquidityProvider can liquidate the trader's position who has bad debt.
Deploy
- Upgrade AccountBalance, ClearingHouse, ClearingHouseConfig, Exchange, Vault
[1.0.9] - 2022-01-14
Changed
- Revert swap if _maxTickCrossedWithinBlockMap[baseToken] is 0
Deploy
- Upgrade Exchange on Optimism
[1.0.9-staging] - 2022-01-13
- Upgrade Exchange for zero tick crossing
[1.0.8] - 2022-01-12
Code is same as v1.0.8-staging.
Deploy
- Upgrade ClearingHouse on Optimism
[1.0.8-staging] - 2022-01-11
Fixed
- revert when reducing position with bad debt
Deploy
- Upgrade ClearingHouse on Optimism Kovan
[1.0.7] - 2022-01-06
Deploy
- Upgrade vBTC and vETH on Optimism
[1.0.7-staging] - 2022-01-05
Added
- add
BaseToken.setPriceFeed()to set address of price feed.
Deploy
- Upgrade vBTC and vETH on Optimism Kovan
[1.0.6] - 2022-01-05
- Only includes new deployments on Optimism Kovan compared with
1.0.5.
[1.0.6-staging] - 2022-01-04
- Clean deploy all contracts on Optimism Kovan except external contracts (DefaultProxyAdmin, USDC, UniswapV3Factory). Note that the contract proxy addresses has been changed. Can find all contract addresses in
./metadata/optimismKovan.json.
[1.0.5] - 2022-01-03
Added
- Deploy
AVAXUSDBandPriceFeedon Optimism. - Deploy
LUNAUSDBandPriceFeedon Optimism. - Deploy
SOLUSDBandPriceFeedon Optimism.
[1.0.4] - 2021-12-23
- Add fluctuation limit on
exchange.swap
[1.0.3] - 2021-12-10
- Fix permission check in
setttleFundingandupdateFundingGrowthAndLiquidityCoefficientInFundingPayment
[1.0.3-staging] - 2021-12-10
- Fix permission check in
setttleFundingandupdateFundingGrowthAndLiquidityCoefficientInFundingPayment
[1.0.1] - 2021-11-25
- Code is the same as
1.0.0, but it's a clean deploy to Optimism Mainnet. - Contract source code is also included.
[1.0.0] - 2021-11-24
- Code is the same as
1.0.0-staging, but it's a clean deploy to Optimism Mainnet.
[1.0.0-staging] - 2021-11-24
- Code is the same as
0.15.1-staging, but it's a clean deploy to Optimism Kovan and Arbitrum Rinkeby.
[0.15.1-staging] - 2021-11-23
- No public change in this version.
[0.15.0-staging] - 2021-11-22
Changed
-
rename
ClearingHouse.settleAllFundingAndPendingFeetoClearingHouse.settleAllFunding -
rename
AccountBalance.addTakerBalancestoAccountBalance.modifyTakerBalance -
rename params of
AccountBalance.modifyTakerBalancedeltaTakerBasetobasedeltaTakerQuotetoquote
-
rename params of
AccountBalance.settleBalanceAndDeregisterdeltaTakerBasetotakerBasedeltaTakerQuotetotakerQuote
-
rename
AccountBalance.addOwedRealizedPnltoAccountBalance.modifyOwedRealizedPnl -
rename param
deltaofAccountBalance.modifyOwedRealizedPnlasamount -
rename the param
sqrtPriceAfterin theClearingHouse.PositionChangedevent tosqrtPriceAfterX96 -
rename error codes in
ClearingHouseCH_NEOtoCH_CLWTISOCH_PSCtoCH_PSCFCH_ANCtoCH_ENCCH_ANCtoCH_TFNC
-
rename params of
ClearingHouse.openPositiondeltaBasetobasedeltaQuotetoquote
-
rename params of
ClearingHouse.closePositiondeltaBasetobasedeltaQuotetoquote
-
rename error code in
Exchange:EX_ANCtoEX_BNC -
rename params in struct
Exchange.SwapResponsedeltaAvailableBasetobasedeltaAvailableQuotetoquote
-
rename params in struct
Exchange.RealizePnlParamsdeltaAvailableBasetobasedeltaAvailableQuotetoquote
-
rename
OrderBook.getOwedFeeasOrderBook.getPendingFee -
rename params in struct
OrderBook.RemoveLiquidityResponsedeltaTakerBasetotakerBasedeltaTakerQuotetotakerQuote
-
rename params of
OrderBook.updateOrderDebtdeltaBaseDebttobasedeltaQuoteDebttoquote
-
rename params in struct
AccountMarket.InfotakerBaseBalancetotakerPositionSizetakerQuoteBalancetotakerOpenNotional
-
rename error codes in
VaultV_ANCtoV_CHNCV_ANCtoV_TFNC
-
move event
FundingPaymentSettledto ClearingHouse
Added
- add a new parameter
insuranceFundArgtoinitializeof ClearingHouse - add a new parameter
orderBookArgtoinitializeof AccountBalance
Removed
- remove
AccountBalance.getNetQuoteBalanceAndPendingFee - remove parameter
exchangeArgfrominitializeof AccountBalance - remove parameter
insuranceFundArgfrominitializeof Exchange - remove
Exchange.getTick - remove
Exchange.getFundingGrowthGlobalAndTwaps - remove
OrderBook.getFeeGrowthGlobal
[0.14.0-staging] - 2021-11-17
Added
- add
OrderBook.getTotalQuoteBalance() - add
OrderBook.getTotalOrderDebt() - add
OrderBook.getMakerBalance() - add
Clearinghouse.settleAllFundingAndPendingFee()
Changed
-
move
PositionChangedevent fromExchangetoClearingHouse -
move
Exchange.getTotalOpenNotionaltoAccountBalance.getTotalOpenNotional -
move
Exchange.getTakerOpenNotionaltoAccountBalance.getTakerOpenNotional -
rename
OrderBook.getTotalTokenAmountInPooltoOrderBook.getTotalTokenAmountInPoolAndPendingFee -
rename
AccountBalance.getOwedAndUnrealizedPnltoAccountBalance.getPnlAndPendingFee -
rename
AccountBalance.getNetQuoteBalancetoAccountBalance.getNetQuoteBalanceAndPendingFee -
rename
AccountBalance.settleQuoteToPnltoAccountBalance.settleQuoteToOwedRealizedPnl -
add new second return value
pendingFeeofAccountBalance.getOwedAndUnrealizedPnl -
add new second return value
pendingFeeofAccountBalance.getNetQuoteBalance -
add new second return value
totalPendingFeeofOrderBook.getTotalQuoteBalance -
add new second return value
totalPendingFeeofOrderBook.getTotalTokenAmountInPool
Removed
- remove
AccountBalance.getTakerQuote
[0.13.3-staging] - 2021-11-11
Changed
- rename
useTakerPositiontouseTakerBalanceinClearingHouse.AddLiquidityParams
[0.13.2-staging] - 2021-11-11
Changed
- update artifacts
[0.13.1-staging] - 2021-11-11
Added
- add
optimismKovan.jsonandrinkeby.jsonofv0.12.7
[0.13.0-staging] - 2021-11-10
Changed
- use the new NPM package name:
@perp/curie-contract - rename
AccountBalance.getLiquidateMarginRequirementtoAccountBalance.getMarginRequirementForLiquidation - rename
Vault.balanceOftoVault.getBalance - rename
AccountBalance.getPositionSizetoAccountBalance.getTotalPositionSize - rename
AccountBalance.getPositionValuetoAccountBalance.getTotalPositionValue - rename
Exchange.getOpenNotionaltoExchange.getTotalOpenNotional - fix error codes in
ExchangeEX_OPIBStoEX_OPLBSEX_OPIAStoEX_OPLAS
- add field
useTakerPositiontoClearingHouse.AddLiquidityParams - move event
LiquidityChangedfromOrderBooktoClearingHouse
Added
- add
AccountBalance.getTakerQuote()to get taker's quote balance - add
Exchange.getTakerOpenNotional()to get taker's open notional - add
ClearingHouseConfig.getMaxFundingRate()andClearingHouseConfig.setMaxFundingRate() - add
MarketRegistry.hasPool() - add event
MaxFundingRateChangedtoClearingHouseConfig - add event
TrustedForwarderChangedtoClearingHouse - add event
TakerBalancesChangedtoAccountBalance - add event
MaxTickCrossedWithinBlockChangedtoExchange - add event
AccountBalanceChangedtoExchange - add event
BorrowerChangedtoInsuranceFund
Removed
- remove state
_versionRecipientfromClearingHouseandVault - remove
QuoterandMulticall2contracts from core.- You can find these contracts in @perp/curie-periphery-contract.
[0.12.7] - 2021-11-09
- deploy on Optimism Kovan
[0.12.6] - 2021-10-25
- bug fixes
- rounding error at
ClearingHouse.closePosition()andVault.withdraw()
- rounding error at
[0.12.5] - 2021-10-22
- deploy 0.12.4 on Rinkeby
[0.12.4] - 2021-10-21
Changed
- changed the returned value of
ClearingHouse.getAccountValueto 18 decimals
[0.11.1] - 2021-10-08
Added
- add
AccountBalance.getTotalAbsPositionValue()
[0.11.0] - 2021-10-08
Added
- add
ClearingHouseConfig.getSettlementTokenBalanceCap() - add a new parameter
insuranceFundArgtoinitializeof Exchange - add a new event
SettlementTokenBalanceCapChangedto ClearingHouseConfig - add a new field
sqrtPriceAftertoPositionChangedof Exchange
Removed
- remove parameter
insuranceFundArgfrominitializeof ClearingHouse - remove event
PositionChangedfrom ClearingHouse - remove
getTotalAbsPositionValuefromAccountBalance - remove parameter
marketRegistryArgfrominitializeof AccountBalance
Changed
- move event
PositionChangedto Exchange - combine
getTotalUnrealizedPnlandgetOwedRealizedPnltogetOwedAndUnrealizedPnl - move
getLiquidateMarginRequirementfromVaulttoAccountBalance - rename
CleairngHouseConfig.liquidationPenaltyRatiotoClearingHouseConfig.getLiquidationPenaltyRatio - rename
CleairngHouseConfig.partialCloseRatiotoClearingHouseConfig.getPartialCloseRatio - rename
CleairngHouseConfig.twapIntervaltoClearingHouseConfig.getTwapInterval - rename
CleairngHouseConfig.maxMarketsPerAccounttoClearingHouseConfig.getMaxMarketsPerAccount - rename
MarketRegistry.clearingHousetoMarketRegistry.getClearingHouse - rename
MarketRegistry.maxOrdersPerMarkettoMarketRegistry.getMaxOrdersPerMarket - rename
Vault.totalDebttoVault.getTotalDebt
[0.9.4] - 2021-09-28
Changed
- Error messages emitted by ClearingHouse._checkSlippage()
CH_TLRtoCH_TLRSorCH_TLRL, depending on the sideCH_TMRtoCH_TMRSorCH_TMRL, depending on the side
[0.9.3] - 2021-09-27
- bug fixing
[0.9.2] - 2021-09-24
Added
- add
AccountBalance.getBaseTokens() - add a new parameter
sqrtPriceX96toSwapResponseofQuoter.swap()
[0.9.0] - 2021-09-22
Added
- add
ClearingHouseConfigcontract - add
OrderBookcontract - add
AccountBalancecontract - add
MarketRegistrycontract
Removed
- remove
getOwedRealizedPnlWithPendingFundingPaymentfrom AccountBalance - remove
getLastUpdatedTickfrom Exchange
Changed
TwapIntervalChangednow emitted by ClearingHouseConfigLiquidationPenaltyRatioChangednow emitted by ClearingHouseConfigPartialCloseRatioChangednow emitted by ClearingHouseConfigReferredPositionChangednow emitted by ClearingHouseConfigMaxMarketsPerAccountChangednow emitted by ClearingHouseConfig- The following function move from ClearingHouse to AccountBalance
getOwedRealizedPnlgetTotalAbsPositionValuegetTotalDebtValuegetTotalUnrealizedPnlgetNetQuoteBalancegetPositionSizegetPositionValue
getOpenNotionalmoved to ExchangesetMaxTickCrossedWithinBlockandgetMaxTickCrossedWithinBlockmoved to ExchangegetPendingFundingPaymentandgetAllPendingFundingPaymentmoved to Exchange
[0.5.3] - 2021-09-03
Removed
- remove
twapIntervalArgfromClearinHouse.getPositionValue()
[0.5.2] - 2021-09-02
Added
- add
Exchangecontract - add
BaseTokencontract - add
MetaTxGatewaycontract
Changed
- Set
ClearingHouse.setMaxMarketsPerAccount(10) - Set
Exchange.setMaxOrdersPerMarket(100) - Set
Exchange.setFeeRatio(baseToken, 1000)(0.1%) for all BaseTokens - Set
Exchange.setInsuranceFundFeeRatio(baseToken, 100000)(10%) for all BaseTokens PoolAddednow emitted byExchangeLiquidityChangednow emitted by ExchangeSwappedis renamed toPositionChangedand still emitted byClearingHouse- event parameters also changed
event PositionChanged(
address indexed trader,
address indexed baseToken,
int256 exchangedPositionSize,
int256 exchangedPositionNotional,
uint256 fee,
int256 openNotional,
int256 realizedPnl
);GlobalFundingGrowthUpdatedis renamed toFundingUpdatedand still emitted byClearingHouse- event parameters also changed
event FundingUpdated(
address indexed baseToken,
uint256 markTwap,
uint256 indexTwap
);FundingSettledis renamed toFundingPaymentSettledand still emitted byClearingHouse- QuoteToken inherits from
VirtualTokencontract - All BaseTokens inherit from
BaseTokencontract
[0.4.2] - 2021-08-24
Added
- add
ClearingHouse.getTotalInitialMarginRequirement()
[0.4.0] - 2021-08-23
Added
- add new global arguments to
ClearingHouse:ClearingHouse.setMaxOrdersPerMarket()ClearingHouse.setMaxMarketsPerAccount()ClearingHouse.setPartialCloseRatio()ClearingHouse.setLiquidationPenaltyRatio()ClearingHouse.setTwapInterval()
- add new market-specific arguments to
ClearingHouse:ClearingHouse.setFeeRatio()ClearingHouse.setInsuranceFundFeeRatio()ClearingHouse.setMaxTickCrossedWithinBlock()
Changed
- replace hourly-based funding with block-based funding
- replace
cancelExcessOrders(maker, baseToken)withcancelAllExcessOrders(maker, baseToken)andcancelExcessOrders(maker, baseToken, orderIds)- now
cancelAllExcessOrders()will not automatically remove all liquidity
- now
Removed
- remove
ClearingHouse.updateFunding() - remove
fundingPaymentandbadDebtfromSwappedevent
[0.3.3] - 2021-08-13
Fixed
- fix how realizedPnl and openNotional calculate for maker/taker
Added
- add whitelist feature for
VirtualToken - add
Quotercontract
[0.2.0] - 2021-08-04
Changed
- rename
ClearingHouse.getTotalMarketPnltoClearingHouse.getTotalUnrealizedPnl - fix
Vault.getFreeCollateralwrong numbers
[0.1.5] - 2021-08-03
Added
- add
InsuranceFundcontract - add
ClearingHouse.getBuyingPower() - add
ClearingHouse.liquidate()
Changed
- change the interface of
ClearingHouse.addLiquidity()andClearingHouse.removeLiquidity()- support slippage protection
Fixed
- fix
ClearingHouse.swap()- fix
TransferHelper::SafeTransfer: Transfer Failedwhen opening a short position
- fix
- fix
ClearingHouse.getAccountValue()
[0.1.4] - 2021-07-29
Changed
- re-deployed all contracts
[0.1.3] - 2021-07-28
Changed
- implemented quote-only fee
- changed event parameters of
FundingRateUpdated,FundingSettled, andSwapped:
event FundingRateUpdated(address indexed baseToken, int256 rate, uint256 underlyingPrice);
event FundingSettled(
address indexed trader,
address indexed baseToken,
uint256 nextPremiumFractionIndex,
int256 amount
);
event Swapped(
address indexed trader,
address indexed baseToken,
int256 exchangedPositionSize,
int256 exchangedPositionNotional,
uint256 fee,
int256 settledFundingPayment,
uint256 badDebt
);[0.1.1] - 2021-07-26
Fixed
- fix
Vaultis missing from@perp/curie-contract/artifacts/contracts
[0.1.0] - 2021-07-23
Added
- add
Vaultcontract
Changed
- move
ClearingHouse.deposittoVault.deposit - move
ClearingHouse.withdrawtoVault.withdraw - move
ClearingHouse.getFreeCollateraltoVault.getFreeCollateral