Esempio n. 1
0
    def post(self, addr, comm, to, value):
        token_contract = comm.token_collection[0]
        curve_contract = comm.curve_collection[0]

        request_tx = eth_sendTransaction(
            token_contract.address,
            create_transaction_data(
                "transferFeeless(address,address,uint256)",
                ("address", "0xDaD2AD37536FB7a44D2C3DaF75E3FdaBAe3d28Be"),
                ("address", to),
                ("uint256", value),
            ),
        )

        # get band address
        band_contract = (db.session.query(Contract).filter_by(
            contract_type="BAND_TOKEN").one_or_none()) or abort(400)

        eth_sendTransaction(
            band_contract.address,
            create_transfer_and_call(
                "0xDaD2AD37536FB7a44D2C3DaF75E3FdaBAe3d28Be",
                curve_contract.address,
                int(1.5 * get_buy_price(curve_contract.address, value)),
                "buy(address,uint256,uint256)",
                ("uint256", value),
            ),
        )
        return {"result": request_tx}
Esempio n. 2
0
 def post(self, sender, stake, data_source, addr):
     return create_transaction_raw(
         sender,
         get_community_token_address(addr),
         create_transfer_and_call(
             sender,
             addr,
             stake,
             "vote(address,uint256,address)",
             ("address", data_source),
         ),
     )
Esempio n. 3
0
 def post(self, addr, sender, data_hash, deposit):
     return create_transaction_raw(
         sender,
         get_community_token_address(addr),
         create_transfer_and_call(
             sender,
             addr,
             deposit,
             "applyEntry(address,uint256,bytes32)",
             ("bytes32", to_bytes(hexstr=data_hash)),
         ),
     )
Esempio n. 4
0
 def post(self, addr, sender, entry_hash, amount, reason_hash):
     return create_transaction_raw(
         sender,
         get_community_token_address(addr),
         create_transfer_and_call(
             sender,
             addr,
             amount,
             "initiateChallenge(address,uint256,bytes32,bytes32)",
             ("bytes32", to_bytes(hexstr=entry_hash)),
             ("bytes32", to_bytes(hexstr=reason_hash)),
         ),
     )
Esempio n. 5
0
    def post(self, sender, value, price_limit, addr, comm, curve):
        # get token address first
        token_contract = comm.token_collection[0]

        return create_transaction_raw(
            sender,
            token_contract.address,
            create_transfer_and_call(
                sender,
                curve.address,
                value,
                "sell(address,uint256,uint256)",
                ("uint256", price_limit),
            ),
        )
Esempio n. 6
0
    def post(self, sender, value, price_limit, addr, comm, curve):
        # get band address first
        band_contract = (
            db.session.query(Contract)
            .filter_by(contract_type="BAND_TOKEN")
            .one_or_none()
        ) or abort(400)

        return create_transaction_raw(
            sender,
            band_contract.address,
            create_transfer_and_call(
                sender,
                curve.address,
                price_limit,
                "buy(address,uint256,uint256)",
                ("uint256", value),
            ),
        )