-
Notifications
You must be signed in to change notification settings - Fork 608
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
refactor: arb filter for new authz exec swap #7210
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,36 @@ func (suite *KeeperTestSuite) TestIsArbTxLooseAuthz_AffiliateSwapMsg() { | |
suite.Require().True(isArb) | ||
} | ||
|
||
// Tests that the arb filter is enabled on swap msg. | ||
func (suite *KeeperTestSuite) TestIsArbTxLooseAuthz_SwapMsg() { | ||
contractSwapMsg := &txfee_filters.ContractSwapMsg{ | ||
ContractSwap: txfee_filters.ContractSwap{ | ||
InputCoin: txfee_filters.InputCoin{ | ||
Amount: "2775854", | ||
Denom: "ibc/D1542AA8762DB13087D8364F3EA6509FD6F009A34F00426AF9E4F9FA85CBBF1F", | ||
}, | ||
OutputDenom: "ibc/D1542AA8762DB13087D8364F3EA6509FD6F009A34F00426AF9E4F9FA85CBBF1F", | ||
Slippage: txfee_filters.Slippage{ | ||
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. Some of the contracts allow to set slippage as a percentage instead of MinOutputAmount. Maybe we should consider that as an option too? |
||
MinOutputAmount: "2775854", | ||
}, | ||
}, | ||
} | ||
|
||
msgBz, err := json.Marshal(contractSwapMsg) | ||
suite.Require().NoError(err) | ||
|
||
// https://celatone.osmosis.zone/osmosis-1/txs/8D20755D4E009CB72C763963A76886BCCCC5C2EBFC3F57266332710216A0D10D | ||
executeMsg := &wasmtypes.MsgExecuteContract{ | ||
Contract: "osmo1etpha3a65tds0hmn3wfjeag6wgxgrkuwg2zh94cf5hapz7mz04dq6c25s5", | ||
Sender: "osmo1dldrxz5p8uezxz3qstpv92de7wgfp7hvr72dcm", | ||
Funds: sdk.NewCoins(sdk.NewCoin("ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4", sdk.NewInt(217084399))), | ||
Msg: msgBz, | ||
} | ||
|
||
_, isArb := txfee_filters.IsArbTxLooseAuthz(executeMsg, executeMsg.Funds[0].Denom, map[types.LiquidityChangeType]bool{}) | ||
suite.Require().True(isArb) | ||
} | ||
|
||
func (suite *KeeperTestSuite) TestIsArbTxLooseAuthz_OtherMsg() { | ||
otherMsg := []byte(`{"update_feed": {}}`) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If we want to be more strict here we can check that the input and output denoms are either (1) the same, or (2) in a list of equivalent denoms (usdc/usdt/axlusdc/etc)
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.
This should work for now, but we are considering any contract swap as an attack, instead of just arbs