def createSealedBidAuctionInstance(self, asset_id, asset_name): sp.verify(sp.sender == self.data.master_auction_contract) contract_address = sp.some(sp.create_contract( storage = sp.record(owner = sp.source, master_auction_contract = sp.to_address(sp.self), asset_id = asset_id, # deposit will get seized if participant tries to cheat deposit = 0, sealed_bids = sp.map(tkey = sp.TAddress, tvalue = sp.TBytes), # TODO: maintain revealed_participants list and only refund those # possibly split the money b/w highest bidder and owner # enforcing all participants to reveal their bids # Then there'll be no need to maintain revealed_count & first_revealed revealed_count = 0, highest_bid = sp.mutez(0), highest_bidder = sp.sender, started = sp.bool(False), first_revealed = sp.bool(False), ended = sp.bool(False), start_time = sp.now, round_time = 0), contract = self.sealed_bid)) # registerInstance c = sp.contract(sp.TRecord(asset_id = sp.TNat, contract_address = sp.TAddress), self.data.master_auction_contract, entry_point = "registerInstance").open_some() sp.transfer(sp.record(asset_id = asset_id, contract_address = contract_address.open_some()), sp.mutez(0), c)
def createDutchAuctionInstance(self, asset_id): sp.verify(sp.sender == self.data.master_auction_contract) contract_address = sp.some( sp.create_contract(storage=sp.record( owner=sp.source, master_auction_contract=self.data.master_auction_contract, asset_id=asset_id, current_price=0, reserve_price=0, started=sp.bool(False), ended=sp.bool(False), start_time=sp.now, round_time=0), contract=self.dutch)) # registerInstance c = sp.contract(sp.TRecord(asset_id=sp.TNat, contract_address=sp.TAddress), self.data.master_auction_contract, entry_point="registerInstance").open_some() sp.transfer( sp.record(asset_id=asset_id, contract_address=contract_address.open_some()), sp.mutez(0), c)
def OpenVault(self,params): self.data.contract = sp.create_contract(storage=sp.record(token=sp.nat(0),xtz=sp.nat(0), owner = sp.sender, oracle = self.data.oracle , Closed = True,stablecoin = self.data.token, Insurance = sp.now, securityDelegator = sp.sender ), contract = self.Vault ) c = sp.contract(sp.TRecord( address = sp.TAddress, owner = sp.TAddress), self.data.token, entry_point = "AddVault").open_some() mydata = sp.record(address = self.data.contract , owner = sp.sender) sp.transfer(mydata, sp.mutez(0), c)
def createMarket(self, params): sp.set_type(params, sp.TRecord(end=sp.TInt, ipfsString=sp.TString)) contractAddress = sp.create_contract(storage=sp.record( admin=sp.pair(self.data.admin, sp.sender), infoIPFS=params.ipfsString, uuid=0, endTime=sp.timestamp(0).add_seconds(params.end), result=sp.none, orders={}, buyLongOrders={}, buyShortOrders={}, sellLongOrders={}, sellShortOrders={}, sharesLong={}, sharesShort={}), contract=self.market) self.data.markets[contractAddress] = sp.sender
def createDutchAuctionInstance(self, asset_id, asset_name): contract_address = sp.create_contract( storage = sp.record(owner = sp.sender, master_auction_contract = sp.to_address(sp.self), asset_id = asset_id, current_price = 0, reserve_price = 0, started = sp.bool(False), ended = sp.bool(False), start_time = sp.now, wait_time = 0), contract = self.dutch) self.data.instances_map[asset_id] = sp.record( asset_name = asset_name, auction_type = "dutch", owner = sp.sender, contract_address = contract_address, is_available = sp.bool(True))
def createEnglishAuctionInstance(self, asset_id, asset_name): contract_address = sp.some(sp.create_contract( storage = sp.record(owner = sp.sender, master_auction_contract = sp.to_address(sp.self), asset_id = asset_id, current_bid = sp.mutez(0), min_increase = 0, highest_bidder = sp.sender, started = sp.bool(False), ended = sp.bool(False), start_time = sp.now, wait_time = 0), contract = self.english)) self.data.instances_map[asset_id] = sp.record( asset_name = asset_name, auction_type = "english", owner = sp.sender, contract_address = contract_address.open_some(), is_available = sp.bool(True))
def createEnglishAuctionInstance(self, asset_id): sp.verify((sp.sender == self.data.master_auction_contract), "only master auction contract can create instance") contract_address = sp.some(sp.create_contract( storage = sp.record(owner = sp.source, master_auction_contract = self.data.master_auction_contract, asset_id = asset_id, current_bid = sp.mutez(0), min_increase = 0, highest_bidder = self.data.master_auction_contract, started = sp.bool(False), first_bid_placed = sp.bool(False), ended = sp.bool(False), start_time = sp.now, round_time = 0), contract = self.english)) # registerInstance c = sp.contract(sp.TRecord(asset_id = sp.TNat, contract_address = sp.TAddress), self.data.master_auction_contract, entry_point = "registerInstance").open_some() sp.transfer(sp.record(asset_id = asset_id, contract_address = contract_address.open_some()), sp.mutez(0), c)