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 : Expand Curve(two-crypto) on sonic #693

Merged
merged 9 commits into from
Jan 10, 2025
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,293 changes: 1,224 additions & 69 deletions pkg/liquidity-source/curve/plain/abi/CurvePlain.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion pkg/liquidity-source/curve/shared/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ const (
// might not available for all chains, but we only need for some chains so it's ok
CurveAddressProvider = "0x0000000022d53366457f9d5e68ec105046fc4383"

// https://sonicscan.org/address/0x87fe17697d0f14a222e8bef386a0860ecffdd617#code
CurveAddressProvider_Sonic = "0x87fe17697d0f14a222e8bef386a0860ecffdd617"

poolMethodGamma = "gamma"
poolMethodUnderlyingCoins = "underlying_coins"

addressProviderMethodGetAddress = "get_address"

getPoolsEndpoint = "/api/getPools/%s/%s" // <chain>/<registry>
getPoolsEndpoint = "/v1/getPools/%s/%s" // <chain>/<registry>
)
8 changes: 7 additions & 1 deletion pkg/liquidity-source/curve/shared/data_source_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"math/big"

"github.com/KyberNetwork/ethrpc"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/valueobject"
"github.com/KyberNetwork/logger"
"github.com/ethereum/go-ethereum/common"
)
Expand All @@ -25,9 +26,14 @@ func InitDataSourceAddresses(lg logger.Logger, config *Config, ethrpcClient *eth

calls := ethrpcClient.NewRequest()

curveAddressProvider := CurveAddressProvider
if config.ChainID == valueobject.ChainIDSonic {
curveAddressProvider = CurveAddressProvider_Sonic
}

calls.AddCall(&ethrpc.Call{
ABI: addressProviderABI,
Target: CurveAddressProvider,
Target: curveAddressProvider,
Method: addressProviderMethodGetAddress,
Params: []interface{}{big.NewInt(0)},
}, []interface{}{&mainRegistryAddress})
Expand Down
1 change: 1 addition & 0 deletions pkg/liquidity-source/curve/shared/pools_list_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (u *PoolsListUpdater) GetNewPoolsFromDataSource(ctx context.Context, dataSo
req := u.client.R().SetContext(ctx)

var result GetPoolsResult

resp, err := req.SetResult(&result).Get(fmt.Sprintf(getPoolsEndpoint, u.config.ChainCode, dataSource))
if err != nil {
return nil, err
Expand Down
1,698 changes: 1,616 additions & 82 deletions pkg/liquidity-source/curve/stable-meta-ng/abi/CurveStableMetaNG.json

Large diffs are not rendered by default.

1,526 changes: 1,451 additions & 75 deletions pkg/liquidity-source/curve/stable-ng/abi/CurveStableNG.json

Large diffs are not rendered by default.

1,888 changes: 1,796 additions & 92 deletions pkg/liquidity-source/curve/tricrypto-ng/abi/CurveTricryptoNG.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/liquidity-source/curve/tricrypto-ng/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ var (
NumTokensU256 = uint256.NewInt(NumTokens)

// only support CurveTricryptoOptimizedWETH.vy for now
SupportedImplementation = mapset.NewSet("tricrypto-1")
SupportedImplementation = mapset.NewSet("tricrypto-1", "tricrypto-optimized")

Precision = U_1e18
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ func (u *PoolsListUpdater) initPools(_ context.Context, curvePools []shared.Curv
continue
}

if !SupportedImplementation.Contains(curvePool.Implementation) {
lg.Debugf("ignore pool with implementation=%s", curvePool.Implementation)
continue
if curvePool.Implementation != "" {
if !SupportedImplementation.Contains(curvePool.Implementation) {
lg.Debugf("ignore pool with implementation=%s", curvePool.Implementation)
continue
}
}

poolTokens := make([]*entity.PoolToken, 0, len(curvePool.Coins))
Expand Down
1,525 changes: 1,450 additions & 75 deletions pkg/liquidity-source/curve/twocrypto-ng/abi/CurveTwocryptoNG.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ func (u *PoolsListUpdater) initPools(_ context.Context, curvePools []shared.Curv
continue
}

if !SupportedImplementation.Contains(curvePool.Implementation) {
lg.Debugf("ignore pool with implementation=%s", curvePool.Implementation)
continue
if curvePool.Implementation != "" {
if !SupportedImplementation.Contains(curvePool.Implementation) {
lg.Debugf("ignore pool with implementation=%s", curvePool.Implementation)
continue
}
}

poolTokens := make([]*entity.PoolToken, 0, len(curvePool.Coins))
Expand Down
Loading