func (coin DecCoin) Sub(coinB DecCoin) DecCoin {
	if coin.Denom != coinB.Denom {
		panic(fmt.Sprintf("coin denom different: %v %v\n", coin.Denom, coinB.Denom))
	}
	res := DecCoin{coin.Denom, coin.Amount.Sub(coinB.Amount)}
	if res.IsNegative() {
		panic("negative decimal coin amount")
	}
	return res
}
Sub subtracts amounts of two decimal coins with same denom.
package coin
import (
	"fmt"
	"sort"
	"strings"
	sdk "github.com/cosmos/cosmos-sdk/types"
	"github.com/pkg/errors"
)
type DecCoin struct {
	Denom  string `json:"denom"`
	Amount Dec    `json:"amount"`
}
func (d DecCoin) ToSDK() sdk.DecCoin {
	return sdk.DecCoin{
		Denom: d.Denom,
		Amount: sdk.Dec{
			d.Amount.Int,
		},
	}
}
func NewDecCoin(denom string, amount Int) DecCoin {
	if err := validate(denom, amount); err != nil {
		panic(err)
	}
	return DecCoin{
		Denom:  denom,
		Amount: amount.ToDec(),
	}
}
func NewDecCoinFromDec(denom string, amount Dec) DecCoin {
	mustValidateDenom(denom)
	if amount.IsNegative() {
		panic(fmt.Sprintf("negative decimal coin amount: %v\n", amount))
	}
	return DecCoin{
		Denom:  denom,
		Amount: amount,
	}
}
func NewDecCoinFromCoin(coin Coin) DecCoin {
	if err := validate(coin.Denom, coin.Amount); err != nil {
		panic(err)
	}
	return DecCoin{
		Denom:  coin.Denom,
		Amount: coin.Amount.ToDec(),
	}
}
func NewInt64DecCoin(denom string, amount int64) DecCoin {
	return NewDecCoin(denom, NewInt(amount))
}
func (coin DecCoin) IsZero() bool {
	return coin.Amount.IsZero()
}
func (coin DecCoin) IsGTE(other DecCoin) bool {
	if coin.Denom != other.Denom {
		panic(fmt.Sprintf("invalid coin denominations; %s, %s", coin.Denom, other.Denom))
	}
	return !coin.Amount.LT(other.Amount)
}
func (coin DecCoin) IsLT(other DecCoin) bool {
	if coin.Denom != other.Denom {
		panic(fmt.Sprintf("invalid coin denominations; %s, %s", coin.Denom, other.Denom))
	}
	return coin.Amount.LT(other.Amount)
}
func (coin DecCoin) IsEqual(other DecCoin) bool {
	if coin.Denom != other.Denom {
		panic(fmt.Sprintf("invalid coin denominations; %s, %s", coin.Denom, other.Denom))
	}
	return coin.Amount.Equal(other.Amount)
}
func (coin DecCoin) Add(coinB DecCoin) DecCoin {
	if coin.Denom != coinB.Denom {
		panic(fmt.Sprintf("coin denom different: %v %v\n", coin.Denom, coinB.Denom))
	}
	return DecCoin{coin.Denom, coin.Amount.Add(coinB.Amount)}
}