@@ -1819,3 +1819,53 @@ def create_liquidity_pool(self, asset_a, asset_b, share_asset,
18191819 }
18201820 )
18211821 return self .finalizeOp (op , account , "active" , ** kwargs )
1822+
1823+
1824+ def _find_liquidity_pool (self , pool ):
1825+ # Ad-hoc helper for the liquidity pool verbs. It locates a pool id
1826+ # irrespective of whether 'pool' is already a pool id, or perhaps an
1827+ # asset or asset_id of a share asset for a pool. The approach is
1828+ # ad-hoc. Would be better if there was a Pool class to represent pool
1829+ # objects like there is an Asset class to represent asset objects.
1830+ # Then locating a pool could happen in the initialization of the Pool
1831+ # object given either an id or asset/symbol. TBD someday.
1832+ if isinstance (pool , str ) and pool .startswith ("1.19." ):
1833+ pool_id = pool
1834+ else :
1835+ try :
1836+ pool_asset = Asset (pool , blockchain_instance = self )
1837+ except :
1838+ raise ValueError ("'pool' is neither a pool id nor share asset." )
1839+ if "for_liquidity_pool" in pool_asset :
1840+ pool_id = pool_asset ["for_liquidity_pool" ]
1841+ else :
1842+ raise ValueError ("Asset is not a share asset for a pool." )
1843+ return pool_id
1844+
1845+
1846+ def delete_liquidity_pool (self , pool , account = None , ** kwargs ):
1847+ """Delete a liquidity pool
1848+
1849+ :param str,Asset pool: The liquidity pool to delete. Can be the pool id
1850+ as a string, or can be an Asset, asset_id, or symbol of the
1851+ share asset for the pool.
1852+
1853+ """
1854+ if not account :
1855+ if "default_account" in self .config :
1856+ account = self .config ["default_account" ]
1857+ if not account :
1858+ raise ValueError ("You need to provide an account" )
1859+ account = Account (account , blockchain_instance = self )
1860+
1861+ pool_id = self ._find_liquidity_pool (pool )
1862+
1863+ op = operations .Liquidity_pool_delete (
1864+ ** {
1865+ "fee" : {"amount" : 0 , "asset_id" : "1.3.0" },
1866+ "account" : account ["id" ],
1867+ "pool" : pool_id ,
1868+ "extensions" : [],
1869+ }
1870+ )
1871+ return self .finalizeOp (op , account , "active" , ** kwargs )
0 commit comments