Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Change Function Params #6

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions core/alpha-router.go

This file was deleted.

64 changes: 64 additions & 0 deletions core/alpha_router.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package core

//import (
// "router/core/coins/fractions"
// "router/core/currency"
//)
//
//type AlphaRouter struct {
// portionProvider IPortionProvider
//}
//
//func NewAlphaRouter(params AlphaRouterParams) *AlphaRouter {
// return &AlphaRouter{}
//}
//
//// TODO: 원본 코드에서는 async 함수
//// 라우트 한 결과는 SwapRoute
//func (a AlphaRouter) route(
// amount fractions.CurrencyAmount,
// quoteCurrency currency.Currency,
// tradeType TradeType,
// swapConfig SwapOptions,
//) SwapRoute {
// //originalAmount := amount
// //
// //currencyIn, currencyOut := a.determineCurrencyInOutFromTradeType(tradeType, amount, quoteCurrency)
// //
// //// currencyIn, currencyOut은 Currency 타입이고
// //// Currency 타입은 NativeCurrency(GNOT)이거나 Token 타입이다.
// //// 아래에서 Token 타입이길 원하는 듯하다.
// //tokenIn := currencyIn.Wrapped()
// //tokenOut := currencyOut.Wrapped()
// //
// //// core 패키지를 TradeType 패키지로 변경하면 가독성이 더 좋아질 듯 하다.
// //if tradeType == EXACT_OUTPUT {
// // // TODO: GetPortionAmount에서 반환 값인 CurrencyAmount을 반환하지 못할 경우가 있을 수도 있다.(높은 확률로)
// // portionAmount := a.portionProvider.GetPortionAmount(
// // amount,
// // tradeType,
// // swapConfig,
// // )
// //
// // //result := portionAmount.GreaterThan(0)
// // //if result {
// // // amount = amount.add(portionAmount)
// // //}
// //}
// //
// //swapRoute := SwapRoute{}
// //return swapRoute
// return SwapRoute{}
//}
//
//func (a AlphaRouter) determineCurrencyInOutFromTradeType(
// tradeType TradeType,
// amount fractions.CurrencyAmount,
// quoteCurrency currency.Currency,
//) (currency.Currency, currency.Currency) {
// if tradeType == EXACT_INPUT {
// return amount.Currency, quoteCurrency
// } else {
// return quoteCurrency, amount.Currency
// }
//}
File renamed without changes.
36 changes: 36 additions & 0 deletions core/currency/base_currency.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package currency

type BaseCurrency struct {
// The chain ID on which this currency resides
chainId int
// The decimals used in representing currency amounts
decimals int

// 이 아래 필드는 옵션
// The symbol of the currency, i.e. a short textual non-unique identifier
symbol string
// The name of the currency, i.e. a descriptive textual non-unique identifier
name string
address string
}

func NewBaseCurrency(chainId int, decimals int, symbol string, name string) *BaseCurrency {
// 아래 코드는 원문
//invariant(Number.isSafeInteger(chainId), 'CHAIN_ID');
//invariant(
// decimals >= 0 && decimals < 255 && Number.isInteger(decimals),
// 'DECIMALS',
//);

// 이 제약이 걸린 이유는 아직 알지 못한다.
if decimals < 0 || 255 < decimals {
panic("decimals must be between 0 and 255")
}

return &BaseCurrency{
chainId: chainId,
decimals: decimals,
symbol: symbol,
name: name,
}
}
6 changes: 6 additions & 0 deletions core/currency/currency.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package currency

// Currency는 Token | NativeCurrency
type Currency interface {
Wrapped() Token
}
5 changes: 5 additions & 0 deletions core/currency/native_currency.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package currency

type NativeCurrency struct {
BaseCurrency
}
5 changes: 5 additions & 0 deletions core/currency/token.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package currency

type Token struct {
BaseCurrency
}
29 changes: 0 additions & 29 deletions core/entities/baseCurrency.go

This file was deleted.

8 changes: 0 additions & 8 deletions core/entities/currency.go

This file was deleted.

16 changes: 0 additions & 16 deletions core/entities/fractions/currencyAmount.go

This file was deleted.

127 changes: 0 additions & 127 deletions core/entities/fractions/fraction.go

This file was deleted.

Loading
Loading