Skip to content

Commit

Permalink
Merge pull request #1 from gnoswap-labs/workflows
Browse files Browse the repository at this point in the history
feat: Add Workflow
  • Loading branch information
tolelom authored Aug 27, 2024
2 parents 4738cb3 + b65b6f5 commit 396a333
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.X'
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work
go.work.sum

# env file
.env

.idea

.DS_Store
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module router
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import (
"fmt"
)

func main() {
s := "gopher"
fmt.Println("Hello and welcome, %s!", s)

}
4 changes: 4 additions & 0 deletions router/alpha-router-params.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package router

type AlphaRouterParams struct {
}
47 changes: 47 additions & 0 deletions router/alpha-router.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package router

import (
"router/router/core"
"router/router/core/entities"
"router/router/core/entities/fractions"
)

type AlphaRouter struct {
}

func NewAlphaRouter(params AlphaRouterParams) *AlphaRouter {
return &AlphaRouter{}
}

// TODO: 원본 코드에서는 async 함수
// 라우트 한 결과는 SwapRoute
func (a AlphaRouter) route(
amount fractions.CurrencyAmount,
quoteCurrency entities.Currency,
tradeType core.TradeType,
) SwapRoute {
originalAmount := amount

Check failure on line 23 in router/alpha-router.go

View workflow job for this annotation

GitHub Actions / build

originalAmount declared and not used

currencyIn, currencyOut := a.determineCurrencyInOutFromTradeType(tradeType, amount, quoteCurrency)

// currencyIn, currencyOut은 Currency 타입이고
// Currency 타입은 NativeCurrency이거나 Token 타입이다.
// 아래에서 Token 타입이길 원하는 듯하다.
tokenIn := currencyIn

Check failure on line 30 in router/alpha-router.go

View workflow job for this annotation

GitHub Actions / build

tokenIn declared and not used
tokenOut := currencyOut

Check failure on line 31 in router/alpha-router.go

View workflow job for this annotation

GitHub Actions / build

tokenOut declared and not used

swapRoute := SwapRoute{}
return swapRoute
}

func (a AlphaRouter) determineCurrencyInOutFromTradeType(
tradeType core.TradeType,
amount fractions.CurrencyAmount,
quoteCurrency entities.Currency,
) (entities.Currency, entities.Currency) {
if tradeType == core.EXACT_INPUT {
return amount.Currency, quoteCurrency
} else {
return quoteCurrency, amount.Currency
}
}
8 changes: 8 additions & 0 deletions router/core/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package core

type TradeType int

const (
EXACT_INPUT = iota
EXACT_OUTPUT
)
8 changes: 8 additions & 0 deletions router/core/entities/currency.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package entities

// 원문에서는 Currency는 Token | NativeCurrency 이고
// Token과 NativeCurrency 모두 BaseCurrency를 상속받는다.
// 하지만 여기서의 Currency는 NativeCurrency와 Token에 포함된다.
type Currency interface {
wrapped() Token
}
7 changes: 7 additions & 0 deletions router/core/entities/fractions/currencyAmount.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package fractions

import "router/router/core/entities"

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

type Token struct {
Currency
}
4 changes: 4 additions & 0 deletions router/router.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package router

type SwapRoute struct {
}

0 comments on commit 396a333

Please sign in to comment.