Skip to content

Commit 8055905

Browse files
christophersanbornxeroc
authored andcommitted
Add operation objects for liquidity pool operations
1 parent afb0b43 commit 8055905

3 files changed

Lines changed: 116 additions & 1 deletion

File tree

bitsharesbase/objecttypes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@
2020
object_type["htlc"] = 16
2121
object_type["custom_authority"] = 17
2222
object_type["ticket"] = 18
23-
object_type["OBJECT_TYPE_COUNT"] = 18
23+
object_type["liquidity_pool"] = 19
24+
object_type["OBJECT_TYPE_COUNT"] = 19

bitsharesbase/operationids.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@
6060
"custom_authority_delete_operation",
6161
"ticket_create_operation",
6262
"ticket_update_operation",
63+
"liquidity_pool_create",
64+
"liquidity_pool_delete",
65+
"liquidity_pool_deposit",
66+
"liquidity_pool_withdraw",
67+
"liquidity_pool_exchange",
6368
]
6469
operations = {o: ops.index(o) for o in ops}
6570

bitsharesbase/operations.py

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,4 +1102,113 @@ def __init__(self, *args, **kwargs):
11021102
)
11031103

11041104

1105+
class Liquidity_pool_create(GrapheneObject):
1106+
def __init__(self, *args, **kwargs):
1107+
if isArgsThisClass(self, args):
1108+
self.data = args[0].data
1109+
else:
1110+
if len(args) == 1 and len(kwargs) == 0:
1111+
kwargs = args[0]
1112+
1113+
super().__init__(
1114+
OrderedDict(
1115+
[
1116+
("fee", Asset(kwargs["fee"])),
1117+
("account", ObjectId(kwargs["account"], "account")),
1118+
("asset_a", ObjectId(kwargs["asset_a"], "asset")),
1119+
("asset_b", ObjectId(kwargs["asset_b"], "asset")),
1120+
("share_asset", ObjectId(kwargs["share_asset"], "asset")),
1121+
("taker_fee_percent", Uint16(kwargs["taker_fee_percent"])),
1122+
("withdrawal_fee_percent", Uint16(kwargs["withdrawal_fee_percent"])),
1123+
("extensions", Set([])),
1124+
]
1125+
)
1126+
)
1127+
1128+
1129+
class Liquidity_pool_delete(GrapheneObject):
1130+
def __init__(self, *args, **kwargs):
1131+
if isArgsThisClass(self, args):
1132+
self.data = args[0].data
1133+
else:
1134+
if len(args) == 1 and len(kwargs) == 0:
1135+
kwargs = args[0]
1136+
1137+
super().__init__(
1138+
OrderedDict(
1139+
[
1140+
("fee", Asset(kwargs["fee"])),
1141+
("account", ObjectId(kwargs["account"], "account")),
1142+
("pool", ObjectId(kwargs["pool"], "liquidity_pool")),
1143+
("extensions", Set([])),
1144+
]
1145+
)
1146+
)
1147+
1148+
1149+
class Liquidity_pool_deposit(GrapheneObject):
1150+
def __init__(self, *args, **kwargs):
1151+
if isArgsThisClass(self, args):
1152+
self.data = args[0].data
1153+
else:
1154+
if len(args) == 1 and len(kwargs) == 0:
1155+
kwargs = args[0]
1156+
1157+
super().__init__(
1158+
OrderedDict(
1159+
[
1160+
("fee", Asset(kwargs["fee"])),
1161+
("account", ObjectId(kwargs["account"], "account")),
1162+
("pool", ObjectId(kwargs["pool"], "liquidity_pool")),
1163+
("amount_a", Asset(kwargs["amount_a"])),
1164+
("amount_b", Asset(kwargs["amount_b"])),
1165+
("extensions", Set([])),
1166+
]
1167+
)
1168+
)
1169+
1170+
1171+
class Liquidity_pool_withdraw(GrapheneObject):
1172+
def __init__(self, *args, **kwargs):
1173+
if isArgsThisClass(self, args):
1174+
self.data = args[0].data
1175+
else:
1176+
if len(args) == 1 and len(kwargs) == 0:
1177+
kwargs = args[0]
1178+
1179+
super().__init__(
1180+
OrderedDict(
1181+
[
1182+
("fee", Asset(kwargs["fee"])),
1183+
("account", ObjectId(kwargs["account"], "account")),
1184+
("pool", ObjectId(kwargs["pool"], "liquidity_pool")),
1185+
("share_amount", Asset(kwargs["share_amount"])),
1186+
("extensions", Set([])),
1187+
]
1188+
)
1189+
)
1190+
1191+
1192+
class Liquidity_pool_exchange(GrapheneObject):
1193+
def __init__(self, *args, **kwargs):
1194+
if isArgsThisClass(self, args):
1195+
self.data = args[0].data
1196+
else:
1197+
if len(args) == 1 and len(kwargs) == 0:
1198+
kwargs = args[0]
1199+
1200+
super().__init__(
1201+
OrderedDict(
1202+
[
1203+
("fee", Asset(kwargs["fee"])),
1204+
("account", ObjectId(kwargs["account"], "account")),
1205+
("pool", ObjectId(kwargs["pool"], "liquidity_pool")),
1206+
("amount_to_sell", Asset(kwargs["amount_to_sell"])),
1207+
("min_to_receive", Asset(kwargs["min_to_receive"])),
1208+
("extensions", Set([])),
1209+
]
1210+
)
1211+
)
1212+
1213+
11051214
fill_classmaps()

0 commit comments

Comments
 (0)