diff --git a/router/alpha-router-params.go b/core/alpha-router-params.go similarity index 70% rename from router/alpha-router-params.go rename to core/alpha-router-params.go index 6c258dd..e9c8e8d 100644 --- a/router/alpha-router-params.go +++ b/core/alpha-router-params.go @@ -1,4 +1,4 @@ -package router +package core type AlphaRouterParams struct { } diff --git a/router/alpha-router.go b/core/alpha-router.go similarity index 77% rename from router/alpha-router.go rename to core/alpha-router.go index c89e162..7d5351a 100644 --- a/router/alpha-router.go +++ b/core/alpha-router.go @@ -1,10 +1,9 @@ -package router +package core import ( - "router/router/core" - "router/router/core/entities" - "router/router/core/entities/fractions" - "router/router/providers" + "router/core/entities" + "router/core/entities/fractions" + "router/core/providers" ) type AlphaRouter struct { @@ -20,7 +19,7 @@ func NewAlphaRouter(params AlphaRouterParams) *AlphaRouter { func (a AlphaRouter) route( amount fractions.CurrencyAmount, quoteCurrency entities.Currency, - tradeType core.TradeType, + tradeType TradeType, swapConfig SwapOptions, ) SwapRoute { originalAmount := amount @@ -34,7 +33,7 @@ func (a AlphaRouter) route( tokenOut := currencyOut.Wrapped() // core 패키지를 TradeType 패키지로 변경하면 가독성이 더 좋아질 듯 하다. - if tradeType == core.EXACT_OUTPUT { + if tradeType == EXACT_OUTPUT { // TODO: GetPortionAmount에서 반환 값인 CurrencyAmount을 반환하지 못할 경우가 있을 수도 있다.(높은 확률로) portionAmount := a.portionProvider.GetPortionAmount( amount, @@ -42,13 +41,10 @@ func (a AlphaRouter) route( swapConfig, ) - result, err := portionAmount.GreaterThan(0) - if err != nil { - // 오류 - } - if result { - amount = amount.add(portionAmount) - } + //result := portionAmount.GreaterThan(0) + //if result { + // amount = amount.add(portionAmount) + //} } swapRoute := SwapRoute{} @@ -56,11 +52,11 @@ func (a AlphaRouter) route( } func (a AlphaRouter) determineCurrencyInOutFromTradeType( - tradeType core.TradeType, + tradeType TradeType, amount fractions.CurrencyAmount, quoteCurrency entities.Currency, ) (entities.Currency, entities.Currency) { - if tradeType == core.EXACT_INPUT { + if tradeType == EXACT_INPUT { return amount.Currency, quoteCurrency } else { return quoteCurrency, amount.Currency diff --git a/router/core/constants.go b/core/constants.go similarity index 100% rename from router/core/constants.go rename to core/constants.go diff --git a/router/core/entities/baseCurrency.go b/core/entities/baseCurrency.go similarity index 100% rename from router/core/entities/baseCurrency.go rename to core/entities/baseCurrency.go diff --git a/router/core/entities/currency.go b/core/entities/currency.go similarity index 100% rename from router/core/entities/currency.go rename to core/entities/currency.go diff --git a/router/core/entities/fractions/currencyAmount.go b/core/entities/fractions/currencyAmount.go similarity index 86% rename from router/core/entities/fractions/currencyAmount.go rename to core/entities/fractions/currencyAmount.go index 0089822..4fe107a 100644 --- a/router/core/entities/fractions/currencyAmount.go +++ b/core/entities/fractions/currencyAmount.go @@ -1,6 +1,8 @@ package fractions -import "router/router/core/entities" +import ( + "router/core/entities" +) type CurrencyAmount struct { Fraction diff --git a/router/core/entities/fractions/fraction.go b/core/entities/fractions/fraction.go similarity index 100% rename from router/core/entities/fractions/fraction.go rename to core/entities/fractions/fraction.go diff --git a/router/core/entities/fractions/fraction_test.go b/core/entities/fractions/fraction_test.go similarity index 100% rename from router/core/entities/fractions/fraction_test.go rename to core/entities/fractions/fraction_test.go diff --git a/router/core/entities/gnot.go b/core/entities/gnot.go similarity index 100% rename from router/core/entities/gnot.go rename to core/entities/gnot.go diff --git a/router/core/entities/nativeCurrency.go b/core/entities/nativeCurrency.go similarity index 100% rename from router/core/entities/nativeCurrency.go rename to core/entities/nativeCurrency.go diff --git a/router/core/entities/token.go b/core/entities/token.go similarity index 100% rename from router/core/entities/token.go rename to core/entities/token.go diff --git a/router/core/entities/utils/math.go b/core/entities/utils/math.go similarity index 100% rename from router/core/entities/utils/math.go rename to core/entities/utils/math.go diff --git a/router/core/entities/wgnot.go b/core/entities/wgnot.go similarity index 100% rename from router/core/entities/wgnot.go rename to core/entities/wgnot.go diff --git a/router/providers/portion-provider.go b/core/providers/portion-provider.go similarity index 59% rename from router/providers/portion-provider.go rename to core/providers/portion-provider.go index 22b82db..dc0f639 100644 --- a/router/providers/portion-provider.go +++ b/core/providers/portion-provider.go @@ -1,14 +1,13 @@ package providers import ( - "router/router" - "router/router/core" - "router/router/core/entities/fractions" + "router/core" + "router/core/entities/fractions" ) // interface는 I 접두사를 붙이는 것이 관행인가? type IPortionProvider interface { - GetPortionAmount(tokenOutAmount fractions.CurrencyAmount, tradeType core.TradeType, swapConfig router.SwapOptions) fractions.CurrencyAmount + GetPortionAmount(tokenOutAmount fractions.CurrencyAmount, tradeType core.TradeType, swapConfig core.SwapOptions) fractions.CurrencyAmount } type PortionProvider struct { diff --git a/router/router.go b/core/router.go similarity index 93% rename from router/router.go rename to core/router.go index 4d4904e..3ff9580 100644 --- a/router/router.go +++ b/core/router.go @@ -1,4 +1,4 @@ -package router +package core type SwapRoute struct { }