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

feat/V3 #334

Merged
merged 7 commits into from
Oct 5, 2023
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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
RPC_URI_FOR_1=
RPC_URI_FOR_10=
RPC_URI_FOR_137=
RPC_URI_FOR_250=
RPC_URI_FOR_8453=
RPC_URI_FOR_42161=
Expand Down
1 change: 1 addition & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Run `nano /etc/systemd/system/server.conf` and put the environment variables in
```
RPC_URI_FOR_1=
RPC_URI_FOR_10=
RPC_URI_FOR_137=
RPC_URI_FOR_250=
RPC_URI_FOR_8453=
RPC_URI_FOR_42161=
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ First, ensure [Docker](https://docs.docker.com/get-started/overview/) is install
```
RPC_URI_FOR_1=
RPC_URI_FOR_10=
RPC_URI_FOR_137=
RPC_URI_FOR_250=
RPC_URI_FOR_8453=
RPC_URI_FOR_42161=
Expand All @@ -28,6 +29,7 @@ First, ensure [Go](https://go.dev/) is installed on your system. then, clone the
```
RPC_URI_FOR_1=
RPC_URI_FOR_10=
RPC_URI_FOR_137=
RPC_URI_FOR_250=
RPC_URI_FOR_8453=
RPC_URI_FOR_42161=
Expand All @@ -54,7 +56,7 @@ curl http://localhost:8080/1/vaults/all

## Endpoints
`GET` `[BASE_URL]/[chainID]/vaults/all`
> This endpoint returns all the vaults of the specified chainID. Supported chains are `1`, `10`, `250`, `8453` and `42161`.
> This endpoint returns all the vaults of the specified chainID. Supported chains are `1`, `10`, `137`, `250`, `8453` and `42161`.
>
> **Query**
`?skip=N` will skip N vault from the graphQL query. Default is `0`
Expand All @@ -66,7 +68,7 @@ curl http://localhost:8080/1/vaults/all
-------

`GET` `[BASE_URL]/[chainID]/vaults/[address]`
> This endpoint returns the vault matching the specified address, for the specified chainID. Supported chains are `1`, `10`, `250`, `8453`, and `42161`.
> This endpoint returns the vault matching the specified address, for the specified chainID. Supported chains are `1`, `10`, `137`, `250`, `8453`, and `42161`.
>
> **Query**
> `?strategiesCondition=debtLimit|inQueue|absolute` will select the "active" strategies based on the specified strategy. Default is `debtLimit`
Expand Down
5 changes: 2 additions & 3 deletions cmd/daemons.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/yearn/ydaemon/common/env"
"github.com/yearn/ydaemon/common/helpers"
"github.com/yearn/ydaemon/common/logs"
"github.com/yearn/ydaemon/external/partners"
"github.com/yearn/ydaemon/external/vaults"
Expand Down Expand Up @@ -47,7 +46,7 @@ func runDaemonWithBlocks(chainID uint64, startBlock uint64, endBlock *uint64, wg

// SummonDaemons is a function that summons the daemons for a given chainID.
func SummonDaemons(chainID uint64) {
if !helpers.Contains(env.SUPPORTED_CHAIN_IDS, chainID) {
if _, ok := env.CHAINS[chainID]; !ok {
return
}

Expand All @@ -70,7 +69,7 @@ func SummonDaemons(chainID uint64) {

// LoadDaemons is a function that loads the previous store state for a given chainID
func LoadDaemons(chainID uint64) {
if !helpers.Contains(env.SUPPORTED_CHAIN_IDS, chainID) {
if _, ok := env.CHAINS[chainID]; !ok {
return
}

Expand Down
54 changes: 0 additions & 54 deletions cmd/daemons_test.go

This file was deleted.

26 changes: 6 additions & 20 deletions cmd/flags.chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,21 @@ import (
"github.com/yearn/ydaemon/common/helpers"
)

type arrayFlags []string
type arrayFlags string

var chainFlag arrayFlags

func (i *arrayFlags) String() string {
defaultSupportedChains := env.SUPPORTED_CHAIN_IDS
supportedChainsString := ``
for _, chainID := range defaultSupportedChains {
supportedChainsString += strconv.FormatUint(chainID, 10) + ` `
}
supportedChainsString = strings.Trim(supportedChainsString, ` `)
return supportedChainsString
}
func (i *arrayFlags) Set(value string) error {
*i = append(*i, value)
return nil
}

func handleChainsInitialization() []uint64 {
func handleChainsInitialization(rawChains *string) []uint64 {
/**********************************************************************************************
** chainFlag is an array of strings, so we need to convert it to an array of uint64, excluding
** any invalid chain IDs or duplicates.
**********************************************************************************************/
for _, chainIDString := range chainFlag {
chainStr := strings.Split(*rawChains, `,`)

for _, chainIDString := range chainStr {
chainID, err := strconv.ParseUint(chainIDString, 10, 64)
if err != nil {
continue
}
if !helpers.Contains(env.SUPPORTED_CHAIN_IDS, chainID) {
if _, ok := env.CHAINS[chainID]; !ok {
continue
}
if helpers.Contains(chains, chainID) {
Expand Down
6 changes: 3 additions & 3 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ func initFlags() {
/**********************************************************************************************
** Flag group: Chains
** Description: List of chain IDs to run yDaemon for
** Default: All supported chains (1, 10, 250, 8453, 42161)
** Default: All supported chains (1, 10, 137, 250, 8453, 42161)
**********************************************************************************************/
flag.Var(&chainFlag, "chains", `List of chain IDs to run yDaemon for: --chains 1 10 250 8453 42161`)
rawChains := flag.String(`chains`, `1,10,137,250,8453,42161`, `List of chain IDs to run yDaemon for: --chains 1,10,137,250,8453,42161`)

/**********************************************************************************************
** Flag group: Sentry
Expand Down Expand Up @@ -44,7 +44,7 @@ func initFlags() {
endBlock = nil
}

handleChainsInitialization()
handleChainsInitialization(rawChains)
handleSentryInitialization()
handleProcessInitialization(rawProcess)
}
1 change: 1 addition & 0 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func NewRouter() *gin.Engine {
router.GET(`:chainID/vaults/apy/:address`, c.GetVaultsVisionAPY)
router.GET(`:chainID/earned/:address/:vaults`, c.GetEarnedPerVaultPerUser)
router.GET(`:chainID/earned/:address`, c.GetEarnedPerUser)
router.GET(`earned/:address`, c.GetEarnedPerUserForAllChains)

// Retrieve the strategies for a specific chainID
router.GET(`:chainID/strategies/all`, c.GetAllStrategies)
Expand Down
35 changes: 0 additions & 35 deletions cmd/server_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "github.com/yearn/ydaemon/common/env"
var STATUS_FOR_CHAINID = map[uint64]string{}

func init() {
for _, chainID := range env.SUPPORTED_CHAIN_IDS {
for chainID := range env.CHAINS {
setStatusForChainID(chainID, "Not Started")
}
}
Expand Down
Loading
Loading