@@ -1764,3 +1764,58 @@ def update_voting_ticket(self, ticket_id, new_target_type, amount_to_update,
17641764 }
17651765 )
17661766 return self .finalizeOp (op , account , "active" , ** kwargs )
1767+
1768+
1769+ def create_liquidity_pool (self , asset_a , asset_b , share_asset ,
1770+ taker_fee_percent , withdrawal_fee_percent ,
1771+ account = None , ** kwargs ):
1772+ """Create a liquidity pool
1773+
1774+ :param str asset_a: First asset in the pool pair.
1775+ :param str asset_b: Second asset in the pool pair.
1776+ :param str asset_a: The asset which represents shares in the pool.
1777+
1778+ For asset parameters, these can be either symbols or asset_id
1779+ strings. Note that network expects asset_a to have a lower-numbered
1780+ asset_id than asset_b.
1781+
1782+ :param float taker_fee_percent: The pool's taker fee percentage.
1783+ :param float withdrawal_fee_percent: The pool's withdrawal fee percent.
1784+
1785+ For percentages, meaningful range is [0.00, 100.00], where 1% is
1786+ represented as 1.0. Smallest non-zero value recognized by BitShares
1787+ chain is 0.01 for 0.01%.
1788+
1789+ """
1790+ if not account :
1791+ if "default_account" in self .config :
1792+ account = self .config ["default_account" ]
1793+ if not account :
1794+ raise ValueError ("You need to provide an account" )
1795+ account = Account (account , blockchain_instance = self )
1796+
1797+ asset_a = Asset (asset_a )["id" ]
1798+ asset_b = Asset (asset_b )["id" ]
1799+ share_asset = Asset (share_asset )["id" ]
1800+
1801+ if not (taker_fee_percent >= 0 and taker_fee_percent <= 100 ):
1802+ raise ValueError ("Percentages must be in range [0.00, 100.00]." )
1803+ if not (withdrawal_fee_percent >= 0 and withdrawal_fee_percent <= 100 ):
1804+ raise ValueError ("Percentages must be in range [0.00, 100.00]." )
1805+ graphene_1_percent = 100
1806+ taker_fee_percent = int (taker_fee_percent * graphene_1_percent )
1807+ withdrawal_fee_percent = int (withdrawal_fee_percent * graphene_1_percent )
1808+
1809+ op = operations .Liquidity_pool_create (
1810+ ** {
1811+ "fee" : {"amount" : 0 , "asset_id" : "1.3.0" },
1812+ "account" : account ["id" ],
1813+ "asset_a" : asset_a ,
1814+ "asset_b" : asset_b ,
1815+ "share_asset" : share_asset ,
1816+ "taker_fee_percent" : taker_fee_percent ,
1817+ "withdrawal_fee_percent" : withdrawal_fee_percent ,
1818+ "extensions" : [],
1819+ }
1820+ )
1821+ return self .finalizeOp (op , account , "active" , ** kwargs )
0 commit comments