Esempio n. 1
0
 def regaintez(self,daoid):
     mem_address=sp.sender
     sp.verify(self.data.addDAOdata[daoid].disputestatus==0)
     sp.verify(self.data.addmemberdata[mem_address].DAO== daoid)
     sendfunds=self.data.addmemberdata[mem_address].contribution
     sp.send(mem_address,sendfunds)
     del self.data.addmemberdata[mem_address]
Esempio n. 2
0
 def withdrawBuyOrder(self, params):
     sp.verify(self.data.orders[params.id].creator == sp.sender)
     sp.verify(self.data.buyLongOrders.contains(params.id) | self.data.buyShortOrders.contains(params.id))
     order = self.data.orders[params.id]
     sp.if self.data.buyLongOrders.contains(params.id):
         del self.data.buyLongOrders[params.id]
         sp.send(order.creator, sp.mutez((order.quantity * order.price) // 10))
Esempio n. 3
0
 def selectWinner(self):
     #random id
     randomId = (sp.timestamp_from_utc_now() - sp.timestamp(0)) % 5
     
     #pay out
     sp.send(self.data.ticketToAddress[randomId], sp.tez(5))
     self.data.previousWinners.push(self.data.ticketToAddress[randomId])
Esempio n. 4
0
 def custClaim(self, params):
     sp.verify(self.data.custAddr == sp.sender)
     sp.verify(self.data.status == CUST_CLOSE)
     sp.verify(self.data.delayExpiry < sp.now)
     sp.send(self.data.custAddr, self.data.custBal)
     self.data.custBal = sp.tez(0)
     self.data.status = CLOSED
 def collect_royalties(self, to_):
     sp.set_type(to_, sp.TAddress)
     accumulated_royalties = self.data.accumulated_royalties[sp.sender]
     
     sp.send(to_, accumulated_royalties)
     
     del self.data.accumulated_royalties[sp.sender]
Esempio n. 6
0
 def mutualClose(self, params):
     sp.verify(self.data.status == OPEN)
     # Check customer signature
     sp.verify(sp.check_signature(self.data.custPk,
                                  params.custSig,
                                  sp.pack(sp.record(
                                          chanID = self.data.chanID,
                                          custAddr = self.data.custAddr,
                                          merchAddr = self.data.merchAddr,
                                          custBal = params.custBal,
                                          merchBal = params.merchBal)
                                         )
                                 ))
     # Check merchant signature
     sp.verify(sp.check_signature(self.data.merchPk,
                                  params.merchSig,
                                  sp.pack(sp.record(
                                          chanID = self.data.chanID,
                                          custAddr = self.data.custAddr,
                                          merchAddr = self.data.merchAddr,
                                          custBal = params.custBal,
                                          merchBal = params.merchBal)
                                         )
                                 ))
     self.data.custBal = params.custBal
     self.data.merchBal = params.merchBal
     sp.send(self.data.custAddr, self.data.custBal)
     sp.send(self.data.merchAddr, self.data.merchBal)
     self.data.custBal = sp.tez(0)
     self.data.merchBal = sp.tez(0)
     self.data.status = CLOSED
Esempio n. 7
0
 def merchDispute(self, params):
     sp.verify(self.data.merchAddr == sp.sender)
     sp.verify(self.data.status == CUST_CLOSE)
     sp.verify(self.data.revLock == sp.sha256(params.secret))
     sp.send(self.data.merchAddr, self.data.custBal)
     self.data.custBal = sp.tez(0)
     self.data.status = CLOSED
 def Cancellation_Guest(self):
     sp.verify(self.data.guest == sp.sender)
     sp.verify(self.data.active == True)
     sp.verify(self.data.in_house == False)
     sp.if (self.data.host == sp.test_account("VOID").address): 
         sp.send(self.data.guest, self.data.g_deposit)
         sp.send(self.data.guest, self.data.rent)
Esempio n. 9
0
 def withdrawToken(self,params):
     sp.verify(params.amount > 0)
     sp.verify(self.data.ledger.contains(sp.sender))
     sp.verify(self.data.ledger[sp.sender].balance >= params.amount)
     self.data.ledger[sp.sender].balance = sp.as_nat(self.data.ledger[sp.sender].balance - params.amount)
     self.data.totalSupply = sp.as_nat(self.data.totalSupply - params.amount)
     sp.send(sp.sender,sp.mutez(params.amount*100))
Esempio n. 10
0
 def submit(self, _job_id, _candidate):
     sp.verify(self.data.jobs.contains(_job_id))
     sp.verify(self.data.jobs[_job_id].owner == sp.source)
     sp.verify(self.data.jobs[_job_id].selected.contains(_candidate))
     sp.send(_candidate, self.data.jobs[_job_id].stipend)
     del self.data.jobs[_job_id].selected[_candidate]
     sp.if sp.len(self.data.jobs[_job_id].selected) == 0:
         del self.data.jobs[_job_id]
Esempio n. 11
0
 def merchClaim(self, params):
     sp.verify(self.data.merchAddr == sp.sender)
     sp.verify(self.data.status == MERCH_CLOSE)
     sp.verify(self.data.delayExpiry < sp.now)
     sp.send(self.data.merchAddr, self.data.custBal + self.data.merchBal)
     self.data.custBal = sp.tez(0)
     self.data.merchBal = sp.tez(0)
     self.data.status = CLOSED
Esempio n. 12
0
 def cancelAuction(self, params):
     sp.verify(sp.sender == self.data.owner)
     sp.verify(self.data.is_active)
     # verify less than wait_time end_time 
     
     # send current_bid to highest_bidder
     sp.if ~(self.data.owner == self.data.highest_bidder) :
         sp.send(self.data.highest_bidder, self.data.current_bid)
Esempio n. 13
0
 def dispatchRoyalties(self, params):
     sp.verify(sp.sender == self.data.administrator)
     rounded = sp.as_nat(10**10)
     muCVRtez = sp.as_nat(self.data.circulatingSupply)*rounded // params.amount + 1
     sp.for address in params.addresses:
         sp.if (self.data.balances.contains(address) & (sp.as_nat(self.data.balances[address].balance)*rounded > muCVRtez)):
             sendMuTez = sp.as_nat(self.data.balances[address].balance)*rounded // muCVRtez
             sp.send(address, sp.mutez(sendMuTez))
 def channelRenounce(self, params):
     sp.verify(self.data.active)
     self.data.active = False
     sp.if params.party == 1:
         if 1 not in self.no_checks:
             sig = params.sig.open_some() if self.no_checks else params.sig
             sp.verify(sp.check_signature(self.data.party1.pk, sig, sp.pack(sp.record(id = self.data.id, name = "renounce"))))
         sp.send(self.data.party2.address, self.data.party1.bond + self.data.party2.bond - self.data.party1.looserClaim)
         sp.send(self.data.party1.address, self.data.party1.looserClaim)
Esempio n. 15
0
 def bid(self, params):
     sp.verify(self.data.is_active)
     sp.verify(sp.amount - self.data.current_bid >= sp.mutez(self.data.min_increase))
     sp.verify(~(self.data.highest_bidder == sp.sender))
     # verify less than wait_time end_time 
     
     # if owner != highest_bidder then send current_bid to highest_bidder
     sp.if ~(self.data.owner == self.data.highest_bidder) :
         sp.send(self.data.highest_bidder, self.data.current_bid)
Esempio n. 16
0
    def cancelAuction(self, params):
        sp.verify(self.data.started)
        sp.verify(~self.data.first_revealed)
        sp.verify(~self.data.ended)
        sp.verify(sp.sender == self.data.owner)

        sp.for bidder in self.data.sealed_bids.keys():
            # refund participation fee to bidder
            sp.send(bidder, sp.mutez(self.data.deposit))
Esempio n. 17
0
    def refund(self, params):
        sp.verify(sp.now > self.data.maxTime)
        sp.verify(self.data.minAmount > sp.balance)

        parties_list = sp.local("parties_list", self.data.parties.keys())
        sp.for e in parties_list.value:
            value = self.data.parties[e]
            sp.send(e, value)
            self.data.total = sp.balance
Esempio n. 18
0
 def resolveBid(self, params):
     sp.verify(self.data.is_active)
     sp.verify((sp.sender == self.data.highest_bidder) | (sp.sender == self.data.owner))
     # verify more than wait_time end_time 
     
     # send current_bid to owner
     sp.send(self.data.owner, self.data.current_bid)
     self.data.current_bid = sp.mutez(0)
     self.data.is_active = False
     self.data.owner = self.data.highest_bidder
Esempio n. 19
0
 def endContract(self, params):
     self.data.houseaddress = params._houseAddress
     sp.verify(self.data.owner == sp.sender,
               message='Only Owner Can End Contract.')
     sp.send(self.data.propertyList[self.data.houseaddress].tenant,
             self.data.propertyList[self.data.houseaddress].deposit)
     self.data.propertyList[self.data.houseaddress].tenant = self.data.owner
     self.data.propertyList[self.data.houseaddress].active = False
     self.data.propertyList[self.data.houseaddress].dispute = False
     self.data.propertyList[self.data.houseaddress].paidRents = sp.list()
Esempio n. 20
0
    def bid(self, auction_id):
        sp.set_type_expr(auction_id, sp.TNat)
        auction = self.data.auctions[auction_id]

        sp.verify(sp.sender!=auction.seller, message=AuctionErrorMessage.SELLER_CANNOT_BID)
        sp.verify(sp.amount>=auction.bid_amount+BID_STEP_THRESHOLD, message=AuctionErrorMessage.BID_AMOUNT_TOO_LOW)
        sp.verify(sp.now<auction.end_timestamp, message=AuctionErrorMessage.AUCTION_IS_OVER)

        sp.if auction.bidder != auction.seller:
            sp.if auction.bidder>THRESHOLD_ADDRESS:
                sp.send(DEFAULT_ADDRESS, auction.bid_amount)
 def channelAccuseDoubleMove(self, params):
     sp.verify(self.data.active)
     self.data.active = False
     sp.verify(params.msg1.seq == params.msg2.seq)
     sp.set_type(params.msg1.seq, sp.TInt)
     sp.set_type(params.msg1.state, sp.type_of(self.data.baseState))
     sp.set_type(params.msg2.state, sp.type_of(self.data.baseState))
     sp.verify(sp.pack(params.msg1) != sp.pack(params.msg2))
     sp.if params.party == 1:
         self.checkHasDoubleSigned(self.data.party1, params)
         sp.send(self.data.party2.address, self.data.party1.bond + self.data.party2.bond)
Esempio n. 22
0
 def resolveAuction(self, params):
     sp.verify(self.data.started)
     sp.verify(self.data.first_revealed)
     sp.verify(~self.data.ended)
     sp.verify(self.data.sealed_bids.contains(sp.sender))
     sp.verify((self.data.revealed_count == sp.len(self.data.sealed_bids)) | (sp.now > self.data.start_time.add_seconds(2 * self.data.round_time)))
     
     sp.for bidder in self.data.sealed_bids.keys():
         sp.if (~(bidder == self.data.highest_bidder)):
             # refund participation fee to bidder
             sp.send(bidder, sp.mutez(self.data.deposit))
Esempio n. 23
0
 def cancelAuction(self, params):
     sp.verify(self.data.started)
     sp.verify(~self.data.ended)
     sp.verify(sp.sender == self.data.owner)
     # TODO
     # verify now is less/more than end_time = start_time + wait_time
     # sp.verify(sp.now > self.data.start_time.add_seconds(self.data.wait_time))
     
     # send current_bid to highest_bidder
     sp.if ~(self.data.owner == self.data.highest_bidder) :
         sp.send(self.data.highest_bidder, self.data.current_bid)
Esempio n. 24
0
    def withdraw(self, auction_id):
        sp.set_type_expr(auction_id, sp.TNat)
        auction = self.data.auctions[auction_id]

        sp.verify(sp.now>auction.end_timestamp,message=AuctionErrorMessage.AUCTION_IS_ONGOING)

        token_contract = sp.contract(BatchTransfer.get_type(), auction.token_address, entry_point = "transfer").open_some()

        sp.if auction.bidder != auction.seller:
            sp.if auction.seller>THRESHOLD_ADDRESS:
               sp.send(DEFAULT_ADDRESS, auction.bid_amount)
Esempio n. 25
0
    def PayBackLoan(self,params):

        sp.set_type(params, sp.TRecord(loan = sp.TNat))
        sp.verify(sp.sender == self.data.owner)
        sp.verify(self.data.token >= params.loan)

        sp.if self.data.token == params.loan: 
             
            sp.send(self.data.owner,sp.mutez(self.data.xtz))
            self.data.Closed = True
            self.data.xtz = 0 
Esempio n. 26
0
 def payRent(self, params):
     self.data.houseaddress = params._houseAddress
     sp.verify(
         self.data.propertyList[self.data.houseaddress].active == True, message="Property Not Active")
     sp.verify(self.data.propertyList[self.data.houseaddress].tenant ==
               sp.sender, message="Only Tenant can pay the rent.")
     sp.verify(self.data.propertyList[self.data.houseaddress].rent ==
               sp.amount, message="Pay proper amount of Rent.")
     sp.send(self.data.owner,
             self.data.propertyList[self.data.houseaddress].rent)
     self.data.propertyList[self.data.houseaddress].paidRents.push(
         sp.timestamp_from_utc_now())
Esempio n. 27
0
    def redeem(self, params):
        sp.verify(self.data.balances.contains(sp.sender), message = "Address has no balance")
        sp.verify(self.data.balances[sp.sender].balance >= params.tokenAmount, message = "Insufficient token balance")

        period = self.getPeriod() # TODO: needs a concept of minimum holding period

        xtzBalance = sp.split_tokens(self.data.schedule[period], params.tokenAmount, 1)
        releasedCollateral = sp.tez(params.tokenAmount) - xtzBalance

        self.data.freeCollateral += releasedCollateral

        self.data.balances[sp.sender].balance = sp.as_nat(self.data.balances[sp.sender].balance - params.tokenAmount)
        sp.send(sp.sender, xtzBalance)
Esempio n. 28
0
 def withdraw(self, amount):
     sp.set_type(amount, sp.TMutez)
     
     # Verify that you are an owner and
     # that you only can withdraw as much as you contributed.
     sp.verify(
         self.data.owners.contains(sp.sender) &
         (self.data.equity[sp.sender] >= amount)
     )
     
     self.data.equity[sp.sender] -= amount
     self.data.total_contributed -= amount
     sp.send(sp.sender, amount)
Esempio n. 29
0
 def withdraw(self, params): 
     
     bal = self.data.withdrawBalances[sp.sender]
     
     sp.verify(bal != -1, message = "Account already withdrew")
     
     
     #value has increased due to baking
     val = sp.split_tokens( sp.balance, abs(bal), self.data.totalTokens)
     sp.send(sp.sender, val)
     
     
     self.data.withdrawBalances[sp.sender ] = -1
     self.data.totalTokens = abs( self.data.totalTokens - abs(bal) )
Esempio n. 30
0
    def ReduceVault(self,params):

        sp.set_type(params, sp.TRecord(amount = sp.TNat))

        d = sp.contract(sp.TRecord(value = sp.TNat , address = sp.TAddress , owner = sp.TAddress), self.data.stablecoin, entry_point = "burn").open_some()
        
        sp.if params.amount >= self.data.token:
        
            burndata = sp.record(value = self.data.token , address = sp.self_address, owner = self.data.owner)
            self.data.Closed = True
            self.data.xtz = 0 
            self.data.token = 0 
            
            sp.send(self.data.owner,sp.mutez(self.data.xtz))