def test_setSwapFee_fails(alice_wallet, alice_address, bob_wallet, bob_address): factory = bfactory.BFactory() pool_address = factory.newBPool(alice_wallet) pool = bpool.BPool(pool_address) with pytest.raises(Exception): pool.setSwapFee(toBase18(0.011), from_wallet=bob_wallet) #not ok, bob isn't controller pool.setController(bob_address, from_wallet=alice_wallet) pool.setSwapFee(toBase18(0.011), from_wallet=bob_wallet) #ok now
def _createPool(DT:datatoken.Datatoken, web3_w:web3wallet.Web3Wallet): OCEAN = globaltokens.OCEANtoken() #Create OCEAN-DT pool p_address = bfactory.BFactory().newBPool(from_wallet=web3_w) pool = bpool.BPool(p_address) DT.approve(pool.address, toBase18(_DT_STAKE), from_wallet=web3_w) OCEAN.approve(pool.address, toBase18(_OCEAN_STAKE),from_wallet=web3_w) pool.bind(DT.address, toBase18(_DT_STAKE), toBase18(POOL_WEIGHT_DT), from_wallet=web3_w) pool.bind(OCEAN.address, toBase18(_OCEAN_STAKE), toBase18(POOL_WEIGHT_OCEAN), from_wallet=web3_w) pool.finalize(from_wallet=web3_w) return pool
def _createPoolAgent(self, state) -> PoolAgent: assert self.OCEAN() > 0.0, "should not call if no OCEAN" wallet = self._wallet._web3wallet OCEAN = globaltokens.OCEANtoken() #name pool_i = len(state.agents.filterToPool()) dt_name = f'DT{pool_i}' pool_agent_name = f'pool{pool_i}' #new DT DT = self._createDatatoken(dt_name, mint_amt=1000.0) #magic number #new pool pool_address = bfactory.BFactory().newBPool(from_wallet=wallet) pool = bpool.BPool(pool_address) #bind tokens & add initial liquidity OCEAN_bind_amt = self.OCEAN() #magic number: use all the OCEAN DT_bind_amt = 20.0 #magic number DT.approve(pool.address, toBase18(DT_bind_amt), from_wallet=wallet) OCEAN.approve(pool.address, toBase18(OCEAN_bind_amt), from_wallet=wallet) pool.bind(DT.address, toBase18(DT_bind_amt), toBase18(POOL_WEIGHT_DT), from_wallet=wallet) pool.bind(OCEAN.address, toBase18(OCEAN_bind_amt), toBase18(POOL_WEIGHT_OCEAN), from_wallet=wallet) pool.finalize(from_wallet=wallet) #create agent pool_agent = PoolAgent(pool_agent_name, pool) state.addAgent(pool_agent) self._wallet.resetCachedInfo() return pool_agent
def _deployBPool(from_wallet: web3wallet.Web3Wallet) -> bpool.BPool: f = bfactory.BFactory() p_address = f.newBPool(from_wallet=from_wallet) p = bpool.BPool(p_address) return p
def test1(alice_wallet): f = bfactory.BFactory() p_address = f.newBPool(from_wallet=alice_wallet) p = bpool.BPool(p_address) assert isinstance(p, bpool.BPool)