-
Notifications
You must be signed in to change notification settings - Fork 10
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(oracle): support update for eth-native-restaking balance change #170
Changes from 3 commits
a5433e5
359d0f2
d2e117d
a4d13e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,44 @@ | ||||||||||||||||||
syntax = "proto3"; | ||||||||||||||||||
|
||||||||||||||||||
package exocore.oracle.v1; | ||||||||||||||||||
|
||||||||||||||||||
import "gogoproto/gogo.proto"; | ||||||||||||||||||
|
||||||||||||||||||
option go_package = "github.com/ExocoreNetwork/exocore/x/oracle/types"; | ||||||||||||||||||
|
||||||||||||||||||
message PriceInfo { | ||||||||||||||||||
string price = 1[(gogoproto.customtype)="cosmossdk.io/math.LegacyDec",(gogoproto.nullable) = false ]; | ||||||||||||||||||
uint64 block = 2; | ||||||||||||||||||
uint64 round_id = 3 [(gogoproto.customname)="RoundID"]; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
message OperatorInfo { | ||||||||||||||||||
string operator_addr = 1; | ||||||||||||||||||
string total_amount = 2[(gogoproto.customtype)="cosmossdk.io/math.Int",(gogoproto.nullable) = false]; | ||||||||||||||||||
repeated PriceInfo price_list = 3; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
message StakerInfo { | ||||||||||||||||||
string staker_addr = 1; | ||||||||||||||||||
int64 staker_index = 2; | ||||||||||||||||||
repeated uint64 validator_indexs = 3; | ||||||||||||||||||
string total_deposit = 4[(gogoproto.customtype)="cosmossdk.io/math.Int",(gogoproto.nullable) = false]; | ||||||||||||||||||
repeated PriceInfo price_list = 5; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
message NativeTokenPrice { | ||||||||||||||||||
string token = 1; | ||||||||||||||||||
repeated PriceInfo prece_list = 2; | ||||||||||||||||||
} | ||||||||||||||||||
Comment on lines
+29
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix the typo in the field name. There is a typo in the field name Apply this diff to fix the typo: message NativeTokenPrice {
string token = 1;
- repeated PriceInfo prece_list = 2;
+ repeated PriceInfo price_list = 2;
} Committable suggestion
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
message StakerList { | ||||||||||||||||||
repeated string staker_addrs = 1; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
message DelegationInfo { | ||||||||||||||||||
string operator_addr = 1; | ||||||||||||||||||
string amount = 2[(gogoproto.customtype)="cosmossdk.io/math.Int",(gogoproto.nullable) = false]; | ||||||||||||||||||
} | ||||||||||||||||||
message StakerDelegationInfo { | ||||||||||||||||||
repeated DelegationInfo delegations = 1; | ||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -6,8 +6,11 @@ | |||||||
errorsmod "cosmossdk.io/errors" | ||||||||
sdkmath "cosmossdk.io/math" | ||||||||
|
||||||||
"github.com/ExocoreNetwork/exocore/x/assets/types" | ||||||||
assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove duplicate import. The package Apply this diff to remove the duplicate import: - "github.com/ExocoreNetwork/exocore/x/assets/types" Committable suggestion
Suggested change
ToolsGitHub Check: Run golangci-lint
|
||||||||
sdk "github.com/cosmos/cosmos-sdk/types" | ||||||||
|
||||||||
"github.com/ethereum/go-ethereum/common/hexutil" | ||||||||
) | ||||||||
|
||||||||
type DepositWithdrawParams struct { | ||||||||
|
@@ -43,6 +46,11 @@ | |||||||
return errorsmod.Wrapf(assetstypes.ErrInvalidOperationType, "the operation type is: %v", params.Action) | ||||||||
} | ||||||||
|
||||||||
if types.IsNativeToken(assetID) { | ||||||||
// TODO: we skip check for case like withdraw amount>withdrawable is fine since it will fail for later check and the state will be rollback | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder: Address the TODO comment. The TODO comment indicates a potential edge case regarding withdrawal amounts. Ensure that this edge case is handled appropriately in the future. Do you want me to help address this TODO comment or open a GitHub issue to track this task? |
||||||||
actualOpAmount = k.UpdateNativeTokenByDepositOrWithdraw(ctx, assetID, hexutil.Encode(params.StakerAddress), params.OpAmount) | ||||||||
} | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder: Add tests for the new logic. Ensure that the Do you want me to generate the unit testing code or open a GitHub issue to track this task? |
||||||||
|
||||||||
changeAmount := assetstypes.DeltaStakerSingleAsset{ | ||||||||
TotalDepositAmount: actualOpAmount, | ||||||||
WithdrawableAmount: actualOpAmount, | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
package types | ||
|
||
import ( | ||
sdkmath "cosmossdk.io/math" | ||
oracletypes "github.com/ExocoreNetwork/exocore/x/oracle/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
type OracleKeeper interface { | ||
GetSpecifiedAssetsPrice(ctx sdk.Context, assetID string) (oracletypes.Price, error) | ||
UpdateNativeTokenByDepositOrWithdraw(ctx sdk.Context, assetID, stakerAddr string, amount sdkmath.Int) sdkmath.Int | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ | |
} | ||
// and the other is the fact that it matures at the next block | ||
err = k.StorePendingUndelegationRecord(ctx, recordKey, record) | ||
//TODO: remove previous index with currentHeight for pendingUndelegationRecord | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acknowledged TODO comment. The TODO comment about removing the previous index with currentHeight for pendingUndelegationRecord is noted. If you need assistance with this task, please let me know. Do you want me to generate the code for this task or open a GitHub issue to track it? ToolsGitHub Check: Run golangci-lint
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder: Address the TODO comment. The TODO comment indicates a planned enhancement to remove the previous index with the current height for Do you want me to open a GitHub issue to track this task? Toolsgolangci-lint
GitHub Check: Run golangci-lint
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,10 @@ package keeper | |
|
||
import ( | ||
"errors" | ||
"strings" | ||
|
||
sdkmath "cosmossdk.io/math" | ||
assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" | ||
operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" | ||
oracletypes "github.com/ExocoreNetwork/exocore/x/oracle/types" | ||
abci "github.com/cometbft/cometbft/abci/types" | ||
|
@@ -62,6 +64,11 @@ func (k *Keeper) UpdateVotingPower(ctx sdk.Context, avsAddr string) error { | |
SelfUSDValue: sdkmath.LegacyNewDec(0), | ||
ActiveUSDValue: sdkmath.LegacyNewDec(0), | ||
} | ||
for _, assetID := range assetstypes.GetNativeTokenAssetIDs() { | ||
if _, ok := prices[assetID]; ok { | ||
prices[assetID], err = k.oracleKeeper.GetSpecifiedAssetsPrice(ctx, strings.Join([]string{assetID, operator}, "_")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should the returned error be addressed? |
||
} | ||
} | ||
Comment on lines
+67
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder: Add tests for the new logic. Ensure that the asset price retrieval logic is thoroughly tested to verify its correctness. Do you want me to generate the unit testing code or open a GitHub issue to track this task? |
||
stakingInfo, err := k.CalculateUSDValueForOperator(ctx, false, operator, assets, decimals, prices) | ||
if err != nil { | ||
return err | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the typo in the field name.
There is a typo in the field name
prece_list
. It should beprice_list
.Apply this diff to fix the typo:
Committable suggestion