Skip to content

Commit

Permalink
frank/0.7.40 (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
soundsonacid committed Mar 15, 2024
1 parent 89dd25c commit 541ca84
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.7.39
current_version = 0.7.40
commit = True
tag = True
tag_name = {new_version}
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Expand Up @@ -202,4 +202,10 @@ Add max confidence interval multiplier to oracle validity calculations

## [0.7.39] - 2024-3-13

Fix events archiver bug with logs less than 8 bytes
Fix events archiver bug with logs less than 8 bytes

## [0.7.40] - 2024-3-14

Update `drift.json` IDL

Fix enum interpretaton bug in `get_max_confidence_interval_multiplier`
2 changes: 1 addition & 1 deletion pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "driftpy"
version = "0.7.39"
version = "0.7.40"
description = "A Python client for the Drift DEX"
authors = ["x19 <https://twitter.com/0xNineteen@gmail.com>", "bigz <https://twitter.com/bigz_pubkey>", "frank <https://twitter.com/soundsonacid>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src/driftpy/__init__.py
@@ -1 +1 @@
__version__ = "0.7.39"
__version__ = "0.7.40"
67 changes: 66 additions & 1 deletion src/driftpy/idl/drift.json
@@ -1,5 +1,5 @@
{
"version": "2.70.0",
"version": "2.72.0",
"name": "drift",
"instructions": [
{
Expand Down Expand Up @@ -3336,6 +3336,32 @@
}
]
},
{
"name": "updatePerpMarketFundingPeriod",
"accounts": [
{
"name": "admin",
"isMut": false,
"isSigner": true
},
{
"name": "state",
"isMut": false,
"isSigner": false
},
{
"name": "perpMarket",
"isMut": true,
"isSigner": false
}
],
"args": [
{
"name": "fundingPeriod",
"type": "i64"
}
]
},
{
"name": "updatePerpMarketMaxImbalances",
"accounts": [
Expand Down Expand Up @@ -4967,6 +4993,11 @@
"isMut": true,
"isSigner": false
},
{
"name": "perpMarket",
"isMut": true,
"isSigner": false
},
{
"name": "state",
"isMut": false,
Expand All @@ -4981,6 +5012,37 @@
}
}
]
},
{
"name": "deletePrelaunchOracle",
"accounts": [
{
"name": "admin",
"isMut": true,
"isSigner": true
},
{
"name": "prelaunchOracle",
"isMut": true,
"isSigner": false
},
{
"name": "perpMarket",
"isMut": false,
"isSigner": false
},
{
"name": "state",
"isMut": false,
"isSigner": false
}
],
"args": [
{
"name": "perpMarketIndex",
"type": "u16"
}
]
}
],
"accounts": [
Expand Down Expand Up @@ -8560,6 +8622,9 @@
},
{
"name": "UpdateAMMCurve"
},
{
"name": "OracleOrderPrice"
}
]
}
Expand Down
25 changes: 14 additions & 11 deletions src/driftpy/math/oracles.py
Expand Up @@ -104,8 +104,12 @@ def is_oracle_valid(

is_oracle_price_too_volatile = lhs or rhs

print(market.contract_tier)
max_confidence_multiplier = get_max_confidence_interval_multiplier(market)

print(oracle_guard_rails.validity.confidence_interval_max_size)
print(max_confidence_multiplier)

is_confidence_too_large = (
(max(1, oracle_price_data.confidence) * BID_ASK_SPREAD_PRECISION)
// oracle_price_data.price
Expand All @@ -128,14 +132,13 @@ def is_oracle_valid(


def get_max_confidence_interval_multiplier(market: PerpMarketAccount) -> int:
match market.contract_tier:
case ContractTier.A():
return 1
case ContractTier.B():
return 1
case ContractTier.C():
return 2
case ContractTier.Speculative():
return 10
case ContractTier.Isolated():
return 50
if str(market.contract_tier) == "ContractTier.A()":
return 1
elif str(market.contract_tier) == "ContractTier.B()":
return 1
elif str(market.contract_tier) == "ContractTier.C()":
return 2
elif str(market.contract_tier) == "ContractTier.Speculative()":
return 10
elif str(market.contract_tier) == "ContractTier.Isolated()":
return 50

0 comments on commit 541ca84

Please sign in to comment.