Skip to content

Commit fbd2ff8

Browse files
authored
Strategyupd (#438)
* wip * feat: comments and APY for strategies * wip: kong * feat: update meta * feat: add cove registry support * chores: meta cove * feat: kong db setup * update metas
1 parent 648e81a commit fbd2ff8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+21476
-7859
lines changed

cmd/flags.process.go

+2-16
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
package main
22

3-
import "strings"
4-
53
type TProcess string
64

75
const (
8-
ProcessServer TProcess = "server"
9-
ProcessVaultMigrations TProcess = "vaultmigrations"
10-
ProcessAPY TProcess = "apy"
6+
ProcessServer TProcess = "server"
117
)
128

139
func handleProcessInitialization(rawProcess *string) TProcess {
14-
switch strings.ToLower(*rawProcess) {
15-
case string(ProcessServer):
16-
process = ProcessServer
17-
case string(ProcessVaultMigrations):
18-
process = ProcessVaultMigrations
19-
case string(ProcessAPY):
20-
process = ProcessAPY
21-
default:
22-
process = ProcessServer
23-
}
24-
return process
10+
return ProcessServer
2511
}

cmd/main.go

+7-50
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
package main
22

33
import (
4-
"sync"
5-
64
"github.com/yearn/ydaemon/common/ethereum"
75
"github.com/yearn/ydaemon/common/logs"
86
"github.com/yearn/ydaemon/internal"
97
"github.com/yearn/ydaemon/internal/storage"
10-
"github.com/yearn/ydaemon/processes/apr"
11-
"github.com/yearn/ydaemon/processes/vaultsMigrations"
128
)
139

1410
func processServer(chainID uint64) {
@@ -31,52 +27,13 @@ func main() {
3127
storage.InitializeStorage()
3228
go ListenToSignals()
3329

34-
var wg sync.WaitGroup
35-
logs.Info(`Running external processes...`)
36-
37-
/** 🔵 - Yearn *************************************************************************************
38-
** This section of the code is responsible for running external processes. Each process is associated
39-
** with a specific chain ID and is run concurrently for efficiency. The processes include fetching
40-
** and updating prices, initializing V2, building token lists, running vault migrations, initializing
41-
** daily blocks, initializing APY, etc.
42-
**
43-
** The status of each process is tracked and updated for each chain ID. Once all processes for a
44-
** chain ID have completed, the status is set to "OK".
45-
**
46-
** The server is ready to accept requests once all processes have completed.
47-
**************************************************************************************************/
48-
switch process {
49-
case ProcessServer:
50-
logs.Info(`Running yDaemon server process...`)
51-
go NewRouter().Run(`:8080`)
52-
go TriggerTgMessage(`💛 - yDaemon v` + GetVersion() + ` is ready to accept requests: https://ydaemon.yearn.fi/`)
53-
54-
for _, chainID := range chains {
55-
go processServer(chainID)
56-
}
57-
logs.Success(`Server ready on port 8080 !`)
58-
select {}
59-
60-
case ProcessVaultMigrations:
61-
logs.Info(`Running yDaemon vault migrations process...`)
62-
for _, chainID := range chains {
63-
wg.Add(1)
64-
go func(chainID uint64) {
65-
vaultsMigrations.Run(chainID)
66-
wg.Done()
67-
}(chainID)
68-
}
69-
wg.Wait()
30+
logs.Info(`Running yDaemon server process...`)
31+
go NewRouter().Run(`:8080`)
32+
go TriggerTgMessage(`💛 - yDaemon v` + GetVersion() + ` is ready to accept requests: https://ydaemon.yearn.fi/`)
7033

71-
case ProcessAPY:
72-
logs.Info(`Running yDaemon APY Initializer process...`)
73-
for _, chainID := range chains {
74-
wg.Add(1)
75-
go func(chainID uint64) {
76-
apr.Run(chainID)
77-
wg.Done()
78-
}(chainID)
79-
}
80-
wg.Wait()
34+
for _, chainID := range chains {
35+
go processServer(chainID)
8136
}
37+
logs.Success(`Server ready on port 8080 !`)
38+
select {}
8239
}

cmd/server.go

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func NewRouter() *gin.Engine {
7171
router.GET(`vaults/pendle`, CacheSimplifiedVaults(cachingStore, 5*time.Minute, c.GetIsYearnPendle))
7272
router.GET(`vaults/optimism`, CacheSimplifiedVaults(cachingStore, 5*time.Minute, c.GetIsOptimism))
7373
router.GET(`vaults/pooltogether`, CacheSimplifiedVaults(cachingStore, 5*time.Minute, c.GetIsYearnPoolTogether))
74+
router.GET(`vaults/cove`, CacheSimplifiedVaults(cachingStore, 5*time.Minute, c.GetIsYearnCove))
7475
router.GET(`vaults/morpho`, CacheSimplifiedVaults(cachingStore, 5*time.Minute, c.GetIsMorpho))
7576
router.GET(`vaults/ajna`, CacheSimplifiedVaults(cachingStore, 5*time.Minute, c.GetIsAjna))
7677
router.GET(`vaults/velodrome`, CacheSimplifiedVaults(cachingStore, 5*time.Minute, c.GetIsVelodrome))

cmd/status.go

+35-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,50 @@
11
package main
22

3-
import "github.com/yearn/ydaemon/common/env"
3+
import (
4+
"sync"
45

5-
var STATUS_FOR_CHAINID = map[uint64]string{}
6+
"github.com/yearn/ydaemon/common/env"
7+
)
68

9+
/**************************************************************************************************
10+
** statusStore is a thread-safe map for storing chain status information
11+
** It uses sync.Map to handle concurrent access safely
12+
**************************************************************************************************/
13+
var (
14+
statusStore sync.Map
15+
)
16+
17+
/**************************************************************************************************
18+
** init initializes the status store for all configured chains
19+
** Sets initial status as "Not Started" for each chain
20+
**************************************************************************************************/
721
func init() {
822
for chainID := range env.GetChains() {
923
setStatusForChainID(chainID, "Not Started")
1024
}
1125
}
1226

27+
/**************************************************************************************************
28+
** setStatusForChainID updates the status for a specific chain ID
29+
** Thread-safe operation using sync.Map.Store
30+
**
31+
** @param chainID uint64 - The chain ID to update
32+
** @param status string - The new status to set
33+
**************************************************************************************************/
1334
func setStatusForChainID(chainID uint64, status string) {
14-
STATUS_FOR_CHAINID[chainID] = status
35+
statusStore.Store(chainID, status)
1536
}
1637

38+
/**************************************************************************************************
39+
** getStatusForChainID retrieves the status for a specific chain ID
40+
** Thread-safe operation using sync.Map.Load
41+
**
42+
** @param chainID uint64 - The chain ID to query
43+
** @return string - The current status of the chain
44+
**************************************************************************************************/
1745
func getStatusForChainID(chainID uint64) string {
18-
return STATUS_FOR_CHAINID[chainID]
46+
if status, ok := statusStore.Load(chainID); ok {
47+
return status.(string)
48+
}
49+
return "Not Started"
1950
}

common/bigNumber/float.go

+3
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ func (b *Float) String() string {
289289
** @return bool True if the value is zero, false otherwise
290290
**************************************************************************************************/
291291
func (b *Float) IsZero() bool {
292+
if b == nil {
293+
return true
294+
}
292295
return b.Cmp(big.NewFloat(0)) == 0
293296
}
294297

common/contracts/abi

-1
This file was deleted.

0 commit comments

Comments
 (0)