Skip to content

Commit

Permalink
feat: ust support
Browse files Browse the repository at this point in the history
  • Loading branch information
jazg committed May 6, 2022
1 parent db5ad15 commit 4304956
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 5 additions & 3 deletions chain/terra/terra.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ func NewTxBuilder(opts TxBuilderOptions, client *Client) account.TxBuilder {

type GasEstimator struct {
url string
key string
decimals int
fallbackGas pack.U256
}

func NewHttpGasEstimator(url string, decimals int, fallbackGas pack.U256) GasEstimator {
func NewHttpGasEstimator(url, key string, decimals int, fallbackGas pack.U256) GasEstimator {
return GasEstimator{
url: url,
key: key,
decimals: decimals,
fallbackGas: fallbackGas,
}
Expand All @@ -89,9 +91,9 @@ func (gasEstimator GasEstimator) EstimateGas(ctx context.Context) (pack.U256, pa
if err := json.NewDecoder(response.Body).Decode(&results); err != nil {
return gasEstimator.fallbackGas, gasEstimator.fallbackGas, err
}
gasPriceStr, ok := results["uluna"]
gasPriceStr, ok := results[gasEstimator.key]
if !ok {
return gasEstimator.fallbackGas, gasEstimator.fallbackGas, fmt.Errorf("no uluna in response")
return gasEstimator.fallbackGas, gasEstimator.fallbackGas, fmt.Errorf("no %v in response", gasEstimator.key)
}
gasPriceFloat, err := strconv.ParseFloat(gasPriceStr, 64)
if err != nil {
Expand Down
8 changes: 6 additions & 2 deletions multichain.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ const (
LUNA = Asset("LUNA") // Luna
MATIC = Asset("MATIC") // Matic PoS (Polygon)
SOL = Asset("SOL") // Solana
UST = Asset("UST") // TerraUSD
ZEC = Asset("ZEC") // Zcash

BADGER = Asset("BADGER") // Badger DAO
Expand Down Expand Up @@ -219,6 +220,8 @@ func (asset Asset) OriginChain() Chain {
return Polygon
case SOL:
return Solana
case UST:
return Terra
case ZEC:
return Zcash

Expand Down Expand Up @@ -251,7 +254,8 @@ func (asset Asset) ChainType() ChainType {
switch asset {
case BCH, BTC, DGB, DOGE, ZEC:
return ChainTypeUTXOBased
case ArbETH, AVAX, BNB, CAT, ETH, FIL, FTM, GLMR, KAVA, LUNA, MATIC, SOL:
case ArbETH, AVAX, BNB, CAT, ETH, FIL, FTM, GLMR, KAVA, LUNA, MATIC, SOL,
UST:
return ChainTypeAccountBased

case BADGER, BUSD, CRV, DAI, EURT, FTT, ibBTC, KNC, LINK, MIM, REN, ROOK,
Expand All @@ -277,7 +281,7 @@ func (asset Asset) ChainType() ChainType {
// Type returns the asset-type (Native or Token) for the given asset.
func (asset Asset) Type() AssetType {
switch asset {
case ArbETH, AVAX, BNB, CAT, ETH, FTM, GLMR, KAVA, MATIC, SOL:
case ArbETH, AVAX, BNB, CAT, ETH, FTM, GLMR, KAVA, MATIC, SOL, UST:
return AssetTypeNative

case BADGER, BUSD, CRV, DAI, EURT, FTT, ibBTC, KNC, LINK, MIM, REN, ROOK,
Expand Down

0 comments on commit 4304956

Please sign in to comment.