Skip to content

Commit

Permalink
feat: arbitrum realted changes
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-98 committed Mar 1, 2024
1 parent cef9d80 commit c76f6a3
Show file tree
Hide file tree
Showing 18 changed files with 262 additions and 640 deletions.
7 changes: 5 additions & 2 deletions debts/tf_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ type FarmingCalculator struct {
}

func NewFarmingCalculator(chainId int64, testing bool) *FarmingCalculator {
tradingTokens := []string{"WETH", "stETH", "DAI", "SUSD", "FRAX", "GUSD", "LUSD", "WBTC", "USDC", "USDT", "LQTY", "LDO", "CVX", "FXS", "CRV", "SNX"}
tradingTokens := []string{"WETH", "stETH", "DAI", "SUSD", "FRAX", "GUSD", "LUSD", "WBTC", "USDC", "USDT", "LQTY", "LDO", "CVX", "FXS", "CRV", "SNX", // mainnet
"wstETH"} // arbitrum
tradingTokensMap := map[string]bool{}
syms := core.GetSymToAddrByChainId(chainId)
for _, tradingSym := range tradingTokens {
if addr, ok := syms.Tokens[tradingSym]; ok {
tradingTokensMap[addr.Hex()] = true
} else if (tradingSym == "stETH" || tradingSym == "GUSD") && log.GetBaseNet(chainId) == "ARBITRUM" { // these tokens are not present on arbitrum
// ignore
} else {
log.Fatalf("Trading token(%s) for tf_index missing from sdk config:", tradingSym, addr)
log.Warnf("Trading token(%s) for tf_index missing from sdk config: %s", tradingSym, addr)
}
}
return &FarmingCalculator{
Expand Down
7 changes: 7 additions & 0 deletions docs/arbitrum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Changes
- geth client doesn't support different tx types on arbitrum. Use offchainlabs geth fork where they added webhook for support the tx and there know custom types for blocks etc. that are compatible with geth.
- stETH contract is not available on arbitrum. wstETH is used. so, no need to track the rebase token such as stETH and don't use logic for converting shares to balance of stETH on arbitrum.
- Multicall2 address on arbitrum is different from ethereum. Ethereum multicall2 is deployed by aave and has different address. https://arbiscan.io/address/0x842eC2c7D803033Edf55E478F461FC547Bc54EB2#code
- There are USDC, USDC.e on arbitrum due to bridged and native versions of USDC. Change chainlink adapter to support multiple tokens.
- Since we use zappers, the liquidity providing user is replaced with zapper address in the AddLiquidity/RemoveLiquidity event, we have to track user call to get the actual user address and replace in the event. We have logic for dUSDC-> farmedUSDCv3 zappers too, but these zappers are not present on arbitrum disable them.
- farming pools info is not added to sdk-gov , like it is added for mainnet. In the tokens.ts for mainnet we have sdUSDCv3 , sdWETHv3 and other token details that are farmed tokens. This info is missing handle this in the ts-> go config generator.
15 changes: 2 additions & 13 deletions ds/mergedPFVersion.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ import (
type entry struct {
BlockNumber int64 `json:"blockNum"`
MergedPFVersion schemas.MergedPFVersion `json:"mergedPFVersion"`
Token string `json:"-"`
}
type MergedPFManager []entry

func (mdl *MergedPFManager) add(v int64, details core.Json, discoveredAt int64) {
*mdl = append(*mdl, entry{
MergedPFVersion: schemas.MergedPFVersion(v),
BlockNumber: discoveredAt,
Token: details["token"].(string),
})

delete(details, "mergedPFVersion")
Expand All @@ -49,7 +47,6 @@ func (mdl *MergedPFManager) Load(details core.Json, discoveredAt int64) {
*mdl = append(*mdl, entry{
MergedPFVersion: schemas.MergedPFVersion(x["mergedPFVersion"].(float64)),
BlockNumber: int64(x["blockNum"].(float64)),
Token: details["token"].(string),
})
}
default:
Expand All @@ -74,34 +71,26 @@ func (mdl MergedPFManager) GetMergedPFVersion(blockNum int64, syncAdapterAddr st
log.Fatal("Can't get mergedPFVersion", mdl, blockNum, syncAdapterAddr)
return schemas.MergedPFVersion(0)
}
func (mdl *MergedPFManager) AddToken(token string, blockNum int64, pfVersion schemas.PFVersion) {
func (mdl *MergedPFManager) AddToken(oracle string, blockNum int64, pfVersion schemas.PFVersion) {
var last schemas.MergedPFVersion
if len(*mdl) != 0 {
obj := (*mdl)[len(*mdl)-1]
if obj.Token != token {
log.Fatal("stored token for chainlink is different from new added token", obj.Token, token)
}
last = obj.MergedPFVersion
}
*mdl = append(*mdl, entry{
Token: token,
MergedPFVersion: schemas.MergedPFVersion(pfVersion) | last,
BlockNumber: blockNum,
})
}

func (mdl *MergedPFManager) DisableToken(token string, blockNum int64, pfVersion schemas.PFVersion) {
func (mdl *MergedPFManager) DisableToken(blockNum int64, pfVersion schemas.PFVersion) {
var last schemas.MergedPFVersion
if len(*mdl) != 0 {
obj := (*mdl)[len(*mdl)-1]
if obj.Token != token {
log.Fatal("stored token for chainlink is different from new added token", obj.Token, token)
}
last = obj.MergedPFVersion
}
final := last ^ schemas.MergedPFVersion(pfVersion)
*mdl = append(*mdl, entry{
Token: token,
MergedPFVersion: final,
BlockNumber: blockNum,
})
Expand Down
8 changes: 6 additions & 2 deletions engine/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ func (e *Engine) addstETHToken() {
return
}
addr := core.GetSymToAddrByChainId(chainId).Tokens["stETH"]
stETHToken := rebase_token.NewRebaseToken(addr.Hex(), e.Client, e.repo)
e.repo.AddSyncAdapter(stETHToken)
if core.NULL_ADDR != addr { // on arbitrum
stETHToken := rebase_token.NewRebaseToken(addr.Hex(), e.Client, e.repo)
e.repo.AddSyncAdapter(stETHToken)
} else if log.GetBaseNet(core.GetChainId(e.Client)) != "ARBITRUM" {
log.Warnf("stETH is not present on %s", log.GetBaseNet(core.GetChainId(e.Client)))
}
}

func (e *Engine) getLastSyncedTill() int64 {
Expand Down
40 changes: 22 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ module github.com/Gearbox-protocol/third-eye
go 1.19

require (
github.com/Gearbox-protocol/sdk-go v0.0.0-20240229061540-fbeed251e8d7
github.com/Gearbox-protocol/sdk-go v0.0.0-20240229094238-b688e4404716
github.com/ethereum/go-ethereum v1.10.17
github.com/go-playground/validator/v10 v10.4.1
github.com/google/go-cmp v0.5.8
github.com/google/go-cmp v0.5.9
github.com/heroku/x v0.0.42
github.com/joho/godotenv v1.3.0
github.com/prometheus/client_golang v1.14.0
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.8.1
go.uber.org/fx v1.13.1
gorm.io/driver/postgres v1.2.2
gorm.io/gorm v1.22.2
Expand All @@ -19,19 +19,22 @@ require (
require (
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.1.3 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gammazero/deque v0.2.1 // indirect
github.com/go-ole/go-ole v1.2.6-0.20210915003542-8b1f7f90f6b1 // indirect
github.com/go-playground/locales v0.13.0 // indirect
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-jsonnet v0.18.0 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c // indirect
github.com/howeyc/gopass v0.0.0-20210920133722-c8aef6fb66ef // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.10.0 // indirect
Expand All @@ -44,33 +47,34 @@ require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.2 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/metachris/flashbotsrpc v0.5.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/common v0.39.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/rabbitmq/amqp091-go v1.2.0 // indirect
github.com/rjeczalik/notify v0.9.1 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/tklauser/go-sysconf v0.3.9 // indirect
github.com/tklauser/numcpus v0.3.0 // indirect
go.uber.org/atomic v1.6.0 // indirect
go.uber.org/dig v1.10.0 // indirect
go.uber.org/multierr v1.5.0 // indirect
golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.8 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.1.0 // indirect
golang.org/x/text v0.8.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
sigs.k8s.io/yaml v1.1.0 // indirect
)

replace github.com/btcsuite/btcd => github.com/btcsuite/btcd v0.22.1

replace github.com/Gearbox-protocol/sdk-go v0.0.0-20240221203600-33735e3641f6 => ../sdk-go
replace github.com/Gearbox-protocol/sdk-go v0.0.0-20240229094238-b688e4404716 => ../sdk-go

replace github.com/ethereum/go-ethereum v1.10.17 => github.com/OffchainLabs/go-ethereum v0.0.0-20230822203130-9a31b6205dba
Loading

0 comments on commit c76f6a3

Please sign in to comment.