Skip to content

Commit

Permalink
Merge pull request #159 from renproject/feat/non-eth-stables
Browse files Browse the repository at this point in the history
Support for non-Ethereum stablecoins
  • Loading branch information
jazg authored Sep 7, 2022
2 parents f5bf781 + 2a11cf2 commit 9be0a86
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 47 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -173,7 +173,7 @@ jobs:
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -299,7 +299,7 @@ jobs:
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -424,7 +424,7 @@ jobs:
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -549,7 +549,7 @@ jobs:
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -674,7 +674,7 @@ jobs:
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -801,7 +801,7 @@ jobs:
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -925,7 +925,7 @@ jobs:
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -1049,7 +1049,7 @@ jobs:
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -1173,7 +1173,7 @@ jobs:
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -1297,7 +1297,7 @@ jobs:
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/filecoin-project/go-jsonrpc v0.1.4-0.20210217175800-45ea43ac2bec
github.com/filecoin-project/go-state-types v0.1.1-0.20210506134452-99b279731c48
github.com/filecoin-project/lotus v1.10.0
github.com/filecoin-project/specs-actors v0.9.13
github.com/ipfs/go-cid v0.0.7
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1
github.com/multiformats/go-varint v0.0.6
Expand Down
73 changes: 41 additions & 32 deletions multichain.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,18 @@ const (
ETH = Asset("ETH") // Ether
FIL = Asset("FIL") // Filecoin
FTM = Asset("FTM") // Fantom
GETH = Asset("GETH") // Goerli Ether
GLMR = Asset("GLMR") // Glimmer
KAVA = Asset("KAVA") // Kava
LUNA = Asset("LUNA") // Luna
MATIC = Asset("MATIC") // Matic PoS (Polygon)
oETH = Asset("oETH") // Optimism Ether
SOL = Asset("SOL") // Solana
UST = Asset("UST") // TerraUSD
ZEC = Asset("ZEC") // Zcash

USDC_Avalanche = Asset("USDC_Avalanche") // Circle USD (Avalanche)
USDT_Avalanche = Asset("USDT_Avalanche") // Tether (Avalanche)

BADGER = Asset("BADGER") // Badger DAO
BUSD = Asset("BUSD") // Binance USD
CRV = Asset("CRV") // Curve
Expand All @@ -133,14 +136,16 @@ const (
ROOK = Asset("ROOK") // KeeperDAO
SUSHI = Asset("SUSHI") // Sushiswap
UNI = Asset("UNI") // Uniswap
USDC = Asset("USDC") // Circle USD
USDT = Asset("USDT") // Tether
USDC = Asset("USDC") // Circle USD (Ethereum)
USDT = Asset("USDT") // Tether (Ethereum)

// These assets are defined separately because their purpose is to help us
// differentiate between different testnets for the same blockchain.
DAI_Goerli = Asset("DAI_Goerli") // Dai (Goerli)
REN_Goerli = Asset("REN_Goerli") // Ren (Goerli)
USDC_Goerli = Asset("USDC_Goerli") // Circle USD (Goerli)
USDT_Goerli = Asset("USDT_Goerli") // Tether (Goerli)

KETH = Asset("KETH") // Kovan ETH
GETH = Asset("GETH") // Goerli ETH
USDC_Polygon = Asset("USDC_Polygon") // Circle USD (Polygon)
USDT_Polygon = Asset("USDT_Polygon") // Tether (Polygon)

// These assets are defined separately because they are mock assets. These
// assets should only be used for testing.
Expand Down Expand Up @@ -211,6 +216,8 @@ func (asset Asset) OriginChain() Chain {
return Filecoin
case FTM:
return Fantom
case GETH:
return Goerli
case GLMR:
return Moonbeam
case KAVA:
Expand All @@ -223,19 +230,18 @@ func (asset Asset) OriginChain() Chain {
return Optimism
case SOL:
return Solana
case UST:
return Terra
case ZEC:
return Zcash

case USDC_Avalanche, USDT_Avalanche:
return Avalanche
case BADGER, BUSD, CRV, DAI, EURT, FTT, ibBTC, KNC, LINK, MIM, REN, ROOK,
SUSHI, UNI, USDC, USDT:
return Ethereum

case KETH:
return Kovan
case GETH:
case DAI_Goerli, REN_Goerli, USDC_Goerli, USDT_Goerli:
return Goerli
case USDC_Polygon, USDT_Polygon:
return Polygon

// These assets are handled separately because they are mock assets. These
// assets should only be used for testing.
Expand All @@ -257,15 +263,18 @@ 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, oETH,
SOL, UST:
case ArbETH, AVAX, BNB, CAT, ETH, FIL, FTM, GETH, GLMR, KAVA, LUNA, MATIC,
oETH, SOL:
return ChainTypeAccountBased

case BADGER, BUSD, CRV, DAI, EURT, FTT, ibBTC, KNC, LINK, MIM, REN, ROOK,
SUSHI, UNI, USDC, USDT:
case USDC_Avalanche, USDT_Avalanche:
return ChainTypeAccountBased

case KETH, GETH:
case BADGER, BUSD, CRV, DAI, EURT, FTT, ibBTC, KNC, LINK, MIM,
REN, ROOK, SUSHI, UNI, USDC, USDT:
return ChainTypeAccountBased
case DAI_Goerli, REN_Goerli, USDC_Goerli, USDT_Goerli:
return ChainTypeAccountBased
case USDC_Polygon, USDT_Polygon:
return ChainTypeAccountBased

// These assets are handled separately because they are mock assets. These
Expand All @@ -284,15 +293,18 @@ 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, oETH, SOL, UST:
case ArbETH, AVAX, BNB, CAT, ETH, FTM, GETH, GLMR, KAVA, MATIC, oETH, SOL:
return AssetTypeNative

case BADGER, BUSD, CRV, DAI, EURT, FTT, ibBTC, KNC, LINK, MIM, REN, ROOK,
SUSHI, UNI, USDC, USDT:
case USDC_Avalanche, USDT_Avalanche:
return AssetTypeToken
case BADGER, BUSD, CRV, DAI, EURT, FTT, ibBTC, KNC, LINK, MIM,
REN, ROOK, SUSHI, UNI, USDC, USDT:
return AssetTypeToken
case DAI_Goerli, REN_Goerli, USDC_Goerli, USDT_Goerli:
return AssetTypeToken
case USDC_Polygon, USDT_Polygon:
return AssetTypeToken

case KETH, GETH:
return AssetTypeNative

// These assets are handled separately because they are mock assets. These
// assets should only be used for testing.
Expand Down Expand Up @@ -420,6 +432,8 @@ func (chain Chain) IsUTXOBased() bool {
// root asset of Bitcoin chain is BTC.
func (chain Chain) NativeAsset() Asset {
switch chain {
case Arbitrum:
return ArbETH
case Avalanche:
return AVAX
case BinanceSmartChain:
Expand All @@ -440,6 +454,8 @@ func (chain Chain) NativeAsset() Asset {
return FTM
case Filecoin:
return FIL
case Goerli:
return GETH
case Kava:
return KAVA
case Moonbeam:
Expand All @@ -454,13 +470,6 @@ func (chain Chain) NativeAsset() Asset {
return LUNA
case Zcash:
return ZEC
case Arbitrum:
return ArbETH

case Kovan:
return KETH
case Goerli:
return GETH

// These chains are handled separately because they are mock chains. These
// chains should only be used for testing.
Expand Down
4 changes: 0 additions & 4 deletions multichain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,6 @@ var _ = Describe("Multichain", func() {
multichain.Terra,
multichain.LUNA,
},
{
multichain.Kovan,
multichain.KETH,
},
{
multichain.Goerli,
multichain.GETH,
Expand Down

0 comments on commit 9be0a86

Please sign in to comment.