Skip to content

Add SEK #13

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

Merged
merged 1 commit into from
May 15, 2021
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
3 changes: 3 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ By default, Tendermint waits 10 seconds for the transaction to be committed. But
And make sure that you include ukrw in minimum gas price in terrad.toml to let users pay the fee by ukrw.

## Changelog
#### v0.0.5-alpha.9
Add vote list for Proposal#38: `{SEK}`

#### v0.0.5-alpha.8-a
Create `terra-oracle_starter` in `$GOPATH`, create `/etc/systemd/system/terra-oracle.service`
Restart oracle when `reveal period` or `failed to execute message` occurs in rawlog
Expand Down
37 changes: 16 additions & 21 deletions cmd/terra-oracle/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import (

"github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/libs/cli"
tenderOS "github.com/tendermint/tendermint/libs/os"
"github.com/tendermint/tendermint/libs/log"
tenderOS "github.com/tendermint/tendermint/libs/os"

"github.com/terra-project/core/app"
"github.com/terra-project/core/types/util"

// "github.com/cosmos/cosmos-sdk/client"
// "github.com/cosmos/cosmos-sdk/client"
flags "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/client/rpc"
flags "github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"

_ "github.com/terra-project/core/client/lcd/statik"
Expand All @@ -31,8 +31,8 @@ import (
)

var (
version = "v0.0.5-alpha.8-a"
logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout))
version = "v0.0.5-alpha.9"
logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout))
)

func main() {
Expand All @@ -42,7 +42,6 @@ func main() {
// Instantiate the codec for the command line application
cdc := app.MakeCodec()


// Read in the configuration file for the sdk
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(util.Bech32PrefixAccAddr, util.Bech32PrefixAccPub)
Expand All @@ -60,7 +59,6 @@ func main() {
return initConfig(rootCmd)
}


// Construct Root Command
rootCmd.AddCommand(
rpc.StatusCommand(),
Expand All @@ -80,7 +78,6 @@ func main() {
os.Exit(1)
}


}

func svcCmd(cdc *amino.Codec) *cobra.Command {
Expand Down Expand Up @@ -113,37 +110,35 @@ func svcCmd(cdc *amino.Codec) *cobra.Command {
},
}

// svcCmd.Flags().String(oracle.FlagValidator, "", "")
// svcCmd.Flags().Float64(oracle.FlagSoftLimit, 0, "")
// svcCmd.Flags().Float64(oracle.FlagHardLimit, 0, "")
// svcCmd.Flags().String(oracle.FlagValidator, "", "")
// svcCmd.Flags().Float64(oracle.FlagSoftLimit, 0, "")
// svcCmd.Flags().Float64(oracle.FlagHardLimit, 0, "")

svcCmd.Flags().String(cfg.ConfigPath, "", "Directory for config.toml")
svcCmd.MarkFlagRequired(cfg.ConfigPath)

svcCmd.Flags().StringP(cfg.VoteMode, "", "aggregate", "Vote mode (singular|aggregate)")
svcCmd.MarkFlagRequired(cfg.VoteMode)
svcCmd.MarkFlagRequired(cfg.VoteMode)

svcCmd = flags.PostCommands(svcCmd)[0]
svcCmd.MarkFlagRequired(flags.FlagFrom)
// svcCmd.MarkFlagRequired(oracle.FlagValidator)
// svcCmd.MarkFlagRequired(oracle.FlagValidator)

return svcCmd
}


func versionCmd() *cobra.Command {
versionCmd := &cobra.Command{
Use: "version",
Short: "Version check",
Run: func(cmd *cobra.Command, args []string) {
versionCmd := &cobra.Command{
Use: "version",
Short: "Version check",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version)
},
}
},
}

return versionCmd
}


func initConfig(cmd *cobra.Command) error {
home, err := cmd.PersistentFlags().GetString(cli.HomeFlag)
if err != nil {
Expand Down
24 changes: 12 additions & 12 deletions oracle/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
voteMode string
salt, exchangeRatesStr = []string{"1234", ""}, []string{"", ""}

denoms = []string{"krw", "usd", "eur", "mnt", "cny", "jpy", "gbp", "inr", "cad", "chf", "hkd", "sgd", "aud", "sdr", "thb"}
denoms = []string{"krw", "usd", "eur", "mnt", "cny", "jpy", "gbp", "inr", "cad", "chf", "hkd", "sgd", "aud", "sdr", "thb", "sek"}
)

func (os *OracleService) init() error {
Expand Down Expand Up @@ -87,7 +87,7 @@ func (os *OracleService) txRoutine() {
var voteMsgs []sdk.Msg
var latestVoteHeight int64 = 0

// denoms := []string{"krw", "usd", "eur", "mnt", "cny", "jpy", "gbp", "inr", "cad", "chf", "hkd", "sgd", "aud", "sdr"}
// denoms := []string{"krw", "usd", "eur", "mnt", "cny", "jpy", "gbp", "inr", "cad", "chf", "hkd", "sgd", "aud", "sdr"}

for {
func() {
Expand Down Expand Up @@ -302,24 +302,24 @@ func (os *OracleService) calculatePrice() (abort bool, err error) {
lunaToKrw := os.ps.GetPrice("luna/krw")

if lunaToKrw.Denom != "krw" {
// return false, errors.New("Can't get luna/krw")
fmt.Println("Can't get luna/krw")
}
// return false, errors.New("Can't get luna/krw")
fmt.Println("Can't get luna/krw")
}
os.Logger.Info(fmt.Sprintf("\033[33m1 luna\033[0m=\033[33m%s %s\033[0m", lunaToKrw.String()[0:10], d))
os.lunaPrices[d] = lunaToKrw

case "usd":
if lunaToUsd.Denom != "usd" {
// return false, errors.New("Can't get luna/usd")
fmt.Println("Can't get luna/usd")
}
if lunaToUsd.Denom != "usd" {
// return false, errors.New("Can't get luna/usd")
fmt.Println("Can't get luna/usd")
}
os.Logger.Info(fmt.Sprintf("\033[33m1 luna\033[0m=\033[33m%s %s\033[0m", lunaToUsd.String()[0:10], d))
os.lunaPrices[d] = lunaToUsd
os.lunaPrices[d] = lunaToUsd

default:
coinToUsd := os.ps.GetPrice(d +"/usd")
coinToUsd := os.ps.GetPrice(d + "/usd")
if coinToUsd.Denom != "usd" {
// return false, errors.New("Can't get " +d +"/usd")
// return false, errors.New("Can't get " +d +"/usd")
}

lunaToCoinAmount := lunaToUsd.Amount.Quo(coinToUsd.Amount)
Expand Down
2 changes: 1 addition & 1 deletion price/stables.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type APILayerResponse struct {
}

var (
stables = []string{"XDR", "MNT", "EUR", "CNY", "JPY", "GBP", "INR", "CAD", "CHF", "HKD", "SGD", "AUD", "THB"}
stables = []string{"XDR", "MNT", "EUR", "CNY", "JPY", "GBP", "INR", "CAD", "CHF", "HKD", "SGD", "AUD", "THB", "SEK"}
)

func (ps *PriceService) stablesToUsd(logger log.Logger) {
Expand Down