Search in sources :

Example 21 with Coin

use of wannabit.io.cosmostaion.model.type.Coin in project cosmostation-android by cosmostation.

the class GravityListActivity method getGdexLpTokenPerUsdPrice.

public BigDecimal getGdexLpTokenPerUsdPrice(Liquidity.Pool pool) {
    BigDecimal poolValue = getGdexPoolValue(pool);
    BigDecimal totalShare = BigDecimal.ZERO;
    for (Coin coin : getBaseDao().mGDexPoolTokens) {
        if (coin.denom.equalsIgnoreCase(pool.getPoolCoinDenom())) {
            totalShare = new BigDecimal(coin.amount);
        }
    }
    return poolValue.divide(totalShare.movePointLeft(6).setScale(24, RoundingMode.DOWN), 18, RoundingMode.DOWN);
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) BigDecimal(java.math.BigDecimal)

Example 22 with Coin

use of wannabit.io.cosmostaion.model.type.Coin in project cosmostation-android by cosmostation.

the class SendStep1Fragment method isValidateSendAmount.

private boolean isValidateSendAmount() {
    mToSendCoins.clear();
    try {
        if (isGRPC(getSActivity().mBaseChain)) {
            BigDecimal sendTemp = new BigDecimal(mAmountInput.getText().toString().trim());
            if (sendTemp.compareTo(BigDecimal.ZERO) <= 0)
                return false;
            if (sendTemp.compareTo(mMaxAvailable.movePointLeft(mDpDecimal).setScale(mDpDecimal, RoundingMode.CEILING)) > 0)
                return false;
            Coin coin = new Coin(getSActivity().mDenom, sendTemp.movePointRight(mDpDecimal).setScale(0).toPlainString());
            mToSendCoins.add(coin);
            return true;
        } else {
            if (getSActivity().mBaseChain.equals(BNB_MAIN)) {
                BigDecimal sendTemp = new BigDecimal(mAmountInput.getText().toString().trim());
                if (sendTemp.compareTo(BigDecimal.ZERO) <= 0)
                    return false;
                if (sendTemp.compareTo(mMaxAvailable) > 0)
                    return false;
                if (getSActivity().mBnbToken.type == BnbToken.BNB_TOKEN_TYPE_MINI) {
                    if ((sendTemp.compareTo(BigDecimal.ONE) < 0) && (sendTemp.compareTo(mMaxAvailable) != 0)) {
                        Toast.makeText(getContext(), R.string.error_bnb_mini_amount, Toast.LENGTH_SHORT).show();
                        return false;
                    }
                }
                Coin token = new Coin(getSActivity().mBnbToken.symbol, sendTemp.toPlainString());
                mToSendCoins.add(token);
                return true;
            } else if (getSActivity().mBaseChain.equals(OKEX_MAIN)) {
                BigDecimal sendTemp = new BigDecimal(mAmountInput.getText().toString().trim());
                if (sendTemp.compareTo(BigDecimal.ZERO) <= 0)
                    return false;
                if (sendTemp.compareTo(mMaxAvailable) > 0)
                    return false;
                Coin coin = new Coin(getSActivity().mDenom, sendTemp.setScale(mDpDecimal).toPlainString());
                mToSendCoins.add(coin);
                return true;
            } else {
                BigDecimal sendTemp = new BigDecimal(mAmountInput.getText().toString().trim());
                if (sendTemp.compareTo(BigDecimal.ZERO) <= 0)
                    return false;
                if (sendTemp.compareTo(mMaxAvailable.movePointLeft(mDpDecimal).setScale(mDpDecimal, RoundingMode.CEILING)) > 0)
                    return false;
                Coin coin = new Coin(getSActivity().mDenom, sendTemp.movePointRight(mDpDecimal).setScale(0).toPlainString());
                mToSendCoins.add(coin);
                return true;
            }
        }
    } catch (Exception e) {
        mToSendCoins.clear();
        return false;
    }
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) BigDecimal(java.math.BigDecimal)

Example 23 with Coin

use of wannabit.io.cosmostaion.model.type.Coin in project cosmostation-android by cosmostation.

the class StepFeeSetFragment method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK) {
        getSActivity().onShowWaitDialog();
        if (getSActivity().mTxType == CONST_PW_TX_SIMPLE_SEND) {
            new SimulSendGrpcTask(getBaseApplication(), this, getSActivity().mBaseChain, getSActivity().mAccount, getSActivity().mToAddress, getSActivity().mAmounts, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_SIMPLE_DELEGATE) {
            new SimulDelegateGrpcTask(getBaseApplication(), this, getSActivity().mBaseChain, getSActivity().mAccount, getSActivity().mValAddress, getSActivity().mAmount, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_SIMPLE_UNDELEGATE) {
            new SimulUndelegateGrpcTask(getBaseApplication(), this, getSActivity().mBaseChain, getSActivity().mAccount, getSActivity().mValAddress, getSActivity().mAmount, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_SIMPLE_REDELEGATE) {
            new SimulRedelegateGrpcTask(getBaseApplication(), this, getSActivity().mBaseChain, getSActivity().mAccount, getSActivity().mValAddress, getSActivity().mToValAddress, getSActivity().mAmount, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_SIMPLE_REWARD) {
            new SimulClaimRewardsGrpcTask(getBaseApplication(), this, getSActivity().mBaseChain, getSActivity().mAccount, getSActivity().mValAddresses, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_REINVEST) {
            new SimulReInvestGrpcTask(getBaseApplication(), this, getSActivity().mBaseChain, getSActivity().mAccount, getSActivity().mValAddress, getSActivity().mAmount, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_SIMPLE_CHANGE_REWARD_ADDRESS) {
            new SimulChangeRewardAddressGrpcTask(getBaseApplication(), this, getSActivity().mBaseChain, getSActivity().mAccount, getSActivity().mNewRewardAddress, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_VOTE) {
            new SimulVoteGrpcTask(getBaseApplication(), this, getSActivity().mBaseChain, getSActivity().mAccount, getSActivity().mProposalId, getSActivity().mOpinion, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_REGISTER_DOMAIN) {
            new SimulRegisterDomainGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mStarNameDomain, getSActivity().mStarNameDomainType, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_REGISTER_ACCOUNT) {
            new SimulRegisterAccountGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mStarNameDomain, getSActivity().mStarNameAccount, getSActivity().mStarNameResources, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_DELETE_DOMAIN) {
            new SimulDeleteDomainGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mStarNameDomain, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_DELETE_ACCOUNT) {
            new SimulDeleteAccountGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mStarNameDomain, getSActivity().mStarNameAccount, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_RENEW_DOMAIN) {
            new SimulRenewDomainGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mStarNameDomain, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_RENEW_ACCOUNT) {
            new SimulRenewAccountGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mStarNameDomain, getSActivity().mStarNameAccount, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_REPLACE_STARNAME) {
            if (getSActivity().mIsDomain) {
                new SimulReplaceStarNameGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mStarNameDomain, "", getSActivity().mStarNameResources, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
            } else {
                new SimulReplaceStarNameGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mStarNameDomain, getSActivity().mStarNameAccount, getSActivity().mStarNameResources, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
            }
        } else if (getSActivity().mTxType == CONST_PW_TX_OSMOSIS_SWAP) {
            new SimulOsmosisSwaplnGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mOsmosisSwapAmountInRoute, getSActivity().mSwapInCoin, getSActivity().mSwapOutCoin, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_OSMOSIS_JOIN_POOL) {
            new SimulOsmosisJoinPoolGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mOsmosisPoolId, getSActivity().mPoolCoin0, getSActivity().mPoolCoin1, getSActivity().mLpToken.amount, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_OSMOSIS_EXIT_POOL) {
            new SimulOsmosisExitPoolGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mOsmosisPoolId, getSActivity().mPoolCoin0, getSActivity().mPoolCoin1, getSActivity().mLpToken.amount, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_OSMOSIS_EARNING) {
            new SimulOsmosisStartLockGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mOsmosisLockupDuration, getSActivity().mLpToken, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_OSMOSIS_BEGIN_UNBONDING) {
            ArrayList<Long> tempList = new ArrayList<>();
            for (Lock.PeriodLock lockup : getSActivity().mOsmosisLockups) {
                tempList.add(lockup.getID());
            }
            new SimulOsmosisBeginUnbondingGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, tempList, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_GDEX_SWAP) {
            BigDecimal offerFee = new BigDecimal(getSActivity().mSwapInCoin.amount).multiply(new BigDecimal("0.0015")).setScale(0, RoundingMode.CEILING);
            Coin coinFee = new Coin(getSActivity().mSwapInCoin.denom, offerFee.toPlainString());
            new SimulGravitySwapGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mGDexPool.getId(), getSActivity().mSwapInCoin, getSActivity().mSwapOutCoin.denom, coinFee, getSActivity().mGDexSwapOrderPrice, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_GDEX_DEPOSIT) {
            new SimulGravityDepositGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mGDexPoolId, getSActivity().mPoolCoin0, getSActivity().mPoolCoin1, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_GDEX_WITHDRAW) {
            new SimulGravityWithdrawGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mGDexPoolId, getSActivity().mLpToken, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_IBC_TRANSFER) {
            new SimulIBCTransferGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mToAddress, getSActivity().mAmounts.get(0).denom, getSActivity().mAmounts.get(0).amount, getSActivity().mPath.port_id, getSActivity().mPath.channel_id, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_SIF_CLAIM_INCENTIVE) {
            new SimulSifIncentiveGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_SIF_SWAP) {
            new SimulSifSwapGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mSifSwapInCoin.denom, getSActivity().mSifSwapInCoin.amount, getSActivity().mSifSwapOutCoin.denom, getSActivity().mSifSwapOutCoin.amount, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_SIF_JOIN_POOL) {
            new SimulSifDepositGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mSifDepositCoin1.denom, getSActivity().mSifDepositCoin0.amount, getSActivity().mSifDepositCoin1.amount, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_SIF_EXIT_POOL) {
            BigDecimal myShareAllAmount = new BigDecimal(getSActivity().mMyProvider.getLiquidityProvider().getLiquidityProviderUnits());
            BigDecimal myShareWithdrawAmount = new BigDecimal(getSActivity().mSifWithdrawCoin.amount);
            String basisPoint = myShareWithdrawAmount.movePointRight(4).divide(myShareAllAmount, 0, RoundingMode.DOWN).toPlainString();
            new SimulSifWithdrawGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mSifWithdrawCoin.denom, basisPoint, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_MINT_NFT) {
            StationNFTData nftData = new StationNFTData(getSActivity().mAccount.address, getSActivity().mNftName, getSActivity().mNftDescription, getSActivity().mNftDenomId, NFT_INFURA + getSActivity().mNftHash);
            Gson gson = new Gson();
            String jsonData = gson.toJson(nftData);
            new SimulMintNFTGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mNftDenomId, getSActivity().mNftDenomName, getSActivity().mNftHash.toLowerCase(), getSActivity().mNftName, NFT_INFURA + getSActivity().mNftHash, jsonData, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_SEND_NFT) {
            new SimulTransferNFTGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mToAddress, getSActivity().mNftDenomId, getSActivity().mNftTokenId, getSActivity().mIrisResponse, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_PROFILE) {
            String profileUri = "";
            String coverUri = "";
            if (getSActivity().mProfileImg != null) {
                profileUri = "https://ipfs.infura.io/ipfs/" + getSActivity().mProfileImg;
            } else {
                profileUri = "";
            }
            if (getSActivity().mCoverImg != null) {
                coverUri = "https://ipfs.infura.io/ipfs/" + getSActivity().mCoverImg;
            } else {
                coverUri = "";
            }
            new SimulCreateProfileGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mDtag, getSActivity().mNickname, getSActivity().mBio, profileUri, coverUri, getSActivity().mAccount.address, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_LINK_ACCOUNT) {
            Account toAccount = getBaseDao().onSelectAccount(getSActivity().mDesmosToLinkAccountId.toString());
            ECKey ecKey;
            if (toAccount.fromMnemonic) {
                String entropy = CryptoHelper.doDecryptData(getSActivity().getString(R.string.key_mnemonic) + toAccount.uuid, toAccount.resource, toAccount.spec);
                DeterministicKey deterministicKey = WKey.getKeyWithPathfromEntropy(toAccount, entropy);
                ecKey = ECKey.fromPrivate(new BigInteger(deterministicKey.getPrivateKeyAsHex(), 16));
            } else {
                String privateKey = CryptoHelper.doDecryptData(getSActivity().getString(R.string.key_private) + toAccount.uuid, toAccount.resource, toAccount.spec);
                ecKey = ECKey.fromPrivate(new BigInteger(privateKey, 16));
            }
            new SimulLinkAccountGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mDesmosToLinkChain, toAccount, ecKey, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_KAVA_SWAP) {
            new SimulKavaSwapGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mKavaSwapIn, getSActivity().mKavaSwapOut, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_KAVA_JOIN_POOL) {
            new SimulKavaDepositGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mKavaPoolTokenA, getSActivity().mKavaPoolTokenB, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_KAVA_EXIT_POOL) {
            new SimulKavaWithdrawGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mKavaShareAmount.toPlainString(), getSActivity().mKavaMinTokenA, getSActivity().mKavaMinTokenB, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_CREATE_CDP) {
            new SimulKavaCreateCdpGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mCollateral, getSActivity().mPrincipal, getSActivity().mCollateralType, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_DEPOSIT_CDP) {
            new SimulKavaDepositCdpGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mAccount.address, getSActivity().mCollateral, getSActivity().mCollateralType, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_WITHDRAW_CDP) {
            new SimulKavaWithDrawCdpGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mAccount.address, getSActivity().mCollateral, getSActivity().mCollateralType, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_DRAW_DEBT_CDP) {
            new SimulKavaDrawDebtCdpGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mPrincipal, getSActivity().mCollateralType, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_REPAY_CDP) {
            new SimulKavaRepayCdpGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mPayment, getSActivity().mCollateralType, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_DEPOSIT_HARD) {
            new SimulKavaDepositHardGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mHardPoolCoins, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_WITHDRAW_HARD) {
            new SimulKavaWithdrawHardGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mHardPoolCoins, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_BORROW_HARD) {
            new SimulKavaBorrowHardGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mHardPoolCoins, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_REPAY_HARD) {
            new SimulKavaRepayHardGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mAccount.address, getSActivity().mHardPoolCoins, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_CLAIM_INCENTIVE) {
            new SimulKavaClaimIncentiveAllGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mIncentiveMultiplier, getSActivity().getBaseDao(), getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (getSActivity().mTxType == CONST_PW_TX_EXECUTE_CONTRACT) {
            new SimulCw20SendGrpcTask(getBaseApplication(), this, getSActivity().mAccount, getSActivity().mBaseChain, getSActivity().mAccount.address, getSActivity().mToAddress, getSActivity().mContractAddress, getSActivity().mAmounts, getSActivity().mTxMemo, getSActivity().mTxFee, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }
    }
}
Also used : Account(wannabit.io.cosmostaion.dao.Account) SimulKavaDepositHardGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulKavaDepositHardGrpcTask) SimulLinkAccountGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulLinkAccountGrpcTask) ArrayList(java.util.ArrayList) ECKey(org.bitcoinj.core.ECKey) SimulKavaDepositCdpGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulKavaDepositCdpGrpcTask) SimulClaimRewardsGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulClaimRewardsGrpcTask) SimulSifDepositGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulSifDepositGrpcTask) SimulCreateProfileGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulCreateProfileGrpcTask) SimulRegisterAccountGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulRegisterAccountGrpcTask) SimulUndelegateGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulUndelegateGrpcTask) Coin(wannabit.io.cosmostaion.model.type.Coin) SimulRegisterDomainGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulRegisterDomainGrpcTask) SimulKavaCreateCdpGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulKavaCreateCdpGrpcTask) SimulDeleteAccountGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulDeleteAccountGrpcTask) SimulDelegateGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulDelegateGrpcTask) SimulGravityDepositGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulGravityDepositGrpcTask) SimulSifIncentiveGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulSifIncentiveGrpcTask) SimulGravityWithdrawGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulGravityWithdrawGrpcTask) SimulSifSwapGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulSifSwapGrpcTask) SimulChangeRewardAddressGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulChangeRewardAddressGrpcTask) SimulVoteGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulVoteGrpcTask) SimulKavaRepayHardGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulKavaRepayHardGrpcTask) BigInteger(java.math.BigInteger) SimulOsmosisExitPoolGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulOsmosisExitPoolGrpcTask) SimulKavaSwapGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulKavaSwapGrpcTask) SimulKavaDepositGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulKavaDepositGrpcTask) SimulReplaceStarNameGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulReplaceStarNameGrpcTask) SimulMintNFTGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulMintNFTGrpcTask) DeterministicKey(org.bitcoinj.crypto.DeterministicKey) SimulKavaWithdrawGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulKavaWithdrawGrpcTask) SimulKavaDrawDebtCdpGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulKavaDrawDebtCdpGrpcTask) SimulRedelegateGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulRedelegateGrpcTask) SimulRenewDomainGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulRenewDomainGrpcTask) Gson(com.google.gson.Gson) SimulOsmosisBeginUnbondingGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulOsmosisBeginUnbondingGrpcTask) StationNFTData(wannabit.io.cosmostaion.dao.StationNFTData) SimulTransferNFTGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulTransferNFTGrpcTask) SimulKavaRepayCdpGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulKavaRepayCdpGrpcTask) SimulKavaWithdrawHardGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulKavaWithdrawHardGrpcTask) SimulCw20SendGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulCw20SendGrpcTask) SimulKavaBorrowHardGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulKavaBorrowHardGrpcTask) SimulOsmosisJoinPoolGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulOsmosisJoinPoolGrpcTask) SimulSendGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulSendGrpcTask) SimulDeleteDomainGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulDeleteDomainGrpcTask) SimulGravitySwapGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulGravitySwapGrpcTask) SimulKavaWithDrawCdpGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulKavaWithDrawCdpGrpcTask) SimulReInvestGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulReInvestGrpcTask) SimulRenewAccountGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulRenewAccountGrpcTask) SimulOsmosisStartLockGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulOsmosisStartLockGrpcTask) SimulKavaClaimIncentiveAllGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulKavaClaimIncentiveAllGrpcTask) BigDecimal(java.math.BigDecimal) SimulOsmosisSwaplnGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulOsmosisSwaplnGrpcTask) SimulIBCTransferGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulIBCTransferGrpcTask) SimulSifWithdrawGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.simulate.SimulSifWithdrawGrpcTask)

Example 24 with Coin

use of wannabit.io.cosmostaion.model.type.Coin in project cosmostation-android by cosmostation.

the class UndelegateStep0Fragment method isValidateUnDelegateAmount.

private boolean isValidateUnDelegateAmount() {
    try {
        BigDecimal userInput = new BigDecimal(mAmountInput.getText().toString().trim()).movePointRight(mDpDecimal).setScale(0);
        if (userInput.compareTo(BigDecimal.ZERO) <= 0)
            return false;
        if (userInput.compareTo(mMaxAvailable) > 0)
            return false;
        Coin coin = new Coin(WDp.mainDenom(getSActivity().mBaseChain), userInput.toPlainString());
        getSActivity().mAmount = coin;
        return true;
    } catch (Exception e) {
        getSActivity().mAmount = null;
        return false;
    }
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) BigDecimal(java.math.BigDecimal)

Example 25 with Coin

use of wannabit.io.cosmostaion.model.type.Coin in project cosmostation-android by cosmostation.

the class GDexSwapStep0Fragment method isValidateSwapInputAmount.

private boolean isValidateSwapInputAmount() {
    try {
        BigDecimal InputAmountTemp = new BigDecimal(mSwapInputAmount.getText().toString().trim());
        BigDecimal OutAmountTemp = new BigDecimal(mSwapOutputAmount.getText().toString().trim());
        if (InputAmountTemp.compareTo(BigDecimal.ZERO) <= 0)
            return false;
        if (InputAmountTemp.compareTo(mAvailableMaxAmount.movePointLeft(mInputCoinDecimal).setScale(mInputCoinDecimal, RoundingMode.CEILING)) > 0)
            return false;
        getSActivity().mSwapInCoin = new Coin(getSActivity().mInputDenom, InputAmountTemp.movePointRight(mInputCoinDecimal).setScale(0).toPlainString());
        getSActivity().mSwapOutCoin = new Coin(getSActivity().mOutputDenom, OutAmountTemp.movePointRight(mOutputCoinDecimal).setScale(0).toPlainString());
        BigDecimal lpInputAmount = getLocalLpAmount(getSActivity().mInputDenom);
        BigDecimal lpOutputAmount = getLocalLpAmount(getSActivity().mOutputDenom);
        BigDecimal padding = BigDecimal.ONE;
        if (getSActivity().mInputDenom.equalsIgnoreCase(getSActivity().mGDexPool.getReserveCoinDenoms(0))) {
            padding = new BigDecimal("1.03");
        } else if (getSActivity().mInputDenom.equalsIgnoreCase(getSActivity().mGDexPool.getReserveCoinDenoms(1))) {
            padding = new BigDecimal("0.97");
        }
        BigDecimal orderPrice = lpInputAmount.multiply(padding).divide(lpOutputAmount, 18, RoundingMode.DOWN);
        getSActivity().mGDexSwapOrderPrice = orderPrice.movePointRight(18).toPlainString();
        WLog.w("mGDexSwapOrderPrice " + getSActivity().mGDexSwapOrderPrice);
        return true;
    } catch (Exception e) {
        getSActivity().mSwapInCoin = null;
        getSActivity().mSwapOutCoin = null;
        return false;
    }
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) BigDecimal(java.math.BigDecimal)

Aggregations

Coin (wannabit.io.cosmostaion.model.type.Coin)126 BigDecimal (java.math.BigDecimal)85 ArrayList (java.util.ArrayList)28 TextView (android.widget.TextView)27 CardView (androidx.cardview.widget.CardView)27 View (android.view.View)25 RecyclerView (androidx.recyclerview.widget.RecyclerView)17 Intent (android.content.Intent)15 Abci (cosmos.base.abci.v1beta1.Abci)13 ImageView (android.widget.ImageView)12 Matcher (java.util.regex.Matcher)12 Pattern (java.util.regex.Pattern)12 CoinOuterClass (cosmos.base.v1beta1.CoinOuterClass)9 SpannableString (android.text.SpannableString)6 Balance (wannabit.io.cosmostaion.dao.Balance)6 Date (java.util.Date)5 IbcToken (wannabit.io.cosmostaion.dao.IbcToken)5 Fee (wannabit.io.cosmostaion.model.type.Fee)5 Bundle (android.os.Bundle)4 Lock (osmosis.lockup.Lock)4