Skip to content

Commit

Permalink
chore: chain 0.19.0 compatibility (#214)
Browse files Browse the repository at this point in the history
* chore: compatibility with chain 0.19.0rc1

* fix: auth unit test

* chore: chain v0.19.0 liquidation adjustments

* chore: cleanup
  • Loading branch information
onikonychev authored Feb 14, 2023
1 parent 3d2f013 commit a936e4d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 25 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.

## Unreleased

## v0.19.0

Compatible with NibiruChain/nibiru v0.19

- [[#214]](https://github.com/NibiruChain/py-sdk/pull/214) chore: update protos to v0.19.0


## v0.17.0

Compatible with NibiruChain/nibiru v0.17
Expand Down
41 changes: 28 additions & 13 deletions nibiru/msg/perp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
from nibiru.utils import to_sdk_dec, to_sdk_int


@dataclasses.dataclass
class Liquidation:
"""
Keeper of the pair/trader pairs for liquidations
"""

pair: str
trader: str


class MsgsPerp:
"""
Messages for the Nibiru Chain x/perp module
Expand Down Expand Up @@ -106,7 +116,7 @@ def liquidate(
sender: str,
pair: str,
trader: str,
) -> 'MsgLiquidate':
) -> 'MsgMultiLiquidate':
"""
Liquidates unhealthy position (pair + trader)
Expand All @@ -115,7 +125,22 @@ def liquidate(
pair (str): The token pair
trader (str): The trader address
"""
return MsgLiquidate(sender=sender, pair=pair, trader=trader)
return MsgMultiLiquidate(
sender=sender, liquidations=[Liquidation(pair=pair, trader=trader)]
)

@staticmethod
def liquidate_multiple(
sender: str, liquidations: List[Liquidation]
) -> 'MsgMultiLiquidate':
"""
Liquidates multiple unhealthy positions (pair + trader)
Attributes:
sender (str): The liquidator address
liquidations (List[Liquidation]): list of pair/traders to liquidate
"""
return MsgMultiLiquidate(sender=sender, liquidations=liquidations)


@dataclasses.dataclass
Expand Down Expand Up @@ -251,16 +276,6 @@ def to_pb(self) -> pb.MsgClosePosition:
)


@dataclasses.dataclass
class Liquidation:
"""
Keeper of the pair/trader pairs for liquidations
"""

pair: str
trader: str


@dataclasses.dataclass
class MsgMultiLiquidate(PythonMsg):
"""
Expand All @@ -285,7 +300,7 @@ def to_pb(self) -> pb.MsgMultiLiquidate:
return pb.MsgMultiLiquidate(
sender=self.sender,
liquidations=[
pb.MsgMultiLiquidate.MultiLiquidation(
pb.MsgMultiLiquidate.Liquidation(
pair=liquidation.pair,
trader=liquidation.trader,
)
Expand Down
20 changes: 10 additions & 10 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nibiru"
version = "0.18.0rc2"
version = "0.19.0"
description = "Python SDK for interacting with Nibiru."
authors = ["Nibiru Chain <[email protected]>"]
license = "MIT"
Expand Down Expand Up @@ -34,7 +34,7 @@ pre-commit = "^2.20.0"
shutup = "^0.2.0"
websocket-client = "^1.4.1"
packaging = "^21.3"
nibiru-proto = {version = "0.19.0rc1", allow-prereleases = true}
nibiru-proto = "==0.19.0"
bip32 = "^3.3"
importlib-metadata = "^5.0.0"

Expand Down

0 comments on commit a936e4d

Please sign in to comment.