Repository navigation
Conversation
LimitSwapVMRouter executes programs against the LimitOpcodes table, whose opcode bytes differ from the full Opcodes table (e.g. limitSwap1D is 0x15 there and 0x19 in Opcodes). The SDK had no table or builder for it, so programs built with RegularProgramBuilder executed different instructions on these routers. - Add instructions.limitInstructions mirroring LimitOpcodes._opcodes() (41 slots, wire bytes 0x00-0x28) - Add LimitProgramBuilder with typed methods for every instruction of the table and a static decode(); FeeExperimental methods are marked experimental; no debug helpers - Document the three program builders and the routers each one targets in the README Co-authored-by: k.kuznetsov <k.kuznetsov@1inch.io>
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


Summary
LimitSwapVMRouterandLimitSwapVMRouterDebugexecute programs against theLimitOpcodestable. Its opcode bytes match the fullOpcodestable up tostaticBalancesXD(0x11) and differ from0x12on. The SDK had no table or builder for these routers, so a program built withRegularProgramBuilderruns different instructions there. For example,limitSwap1Dis0x19inOpcodesbut0x15inLimitOpcodes, where0x19isdutchAuctionBalanceIn1D.Changes
instructions.limitInstructionsmirrorsLimitOpcodes._opcodes(): 41 slots, bytes0x00-0x28.LimitOpcodes.solis identical in the pinned contracts and in v1.0.2.LimitProgramBuilder(exported fromprograms) has a typed method for every instruction in the table and a staticdecode(). ItsFeeExperimentalmethods are marked experimental. It has no debug helpers.Testing
pnpm nx run-many -t build,pnpm lint,pnpm lint:typesandpnpm testpass (swap-vm: 55 files / 690 tests).decode();limitSwap1Dis0x15here and0x19inRegularProgramBuilder;LimitOpcodes(not committed) passes:LimitProgramBuilderprograms execute on it: the0x150101limit swap returns the expected amount, as doesdeadline+limitSwap1D+salt;requireMinRate1D(0x17) passes and reverts as expected;RegularProgramBuilder(limitSwap1D=0x19) reverts on the limit table.Notes
RegularProgramBuilderonmaster. When these land, the same changes apply here:jumpIfTokenIn/jumpIfTokenOuttaketoken, and balances usetoken;salttakesbigint | HexString;progressiveFeeInXD/progressiveFeeOutXDuseProgressiveFeeArgs;@seelink are pinned tov1.0.2, the deployed version. Onmainof1inch/swap-vm, the sources moved tocontracts/andLimitOpcodes.solis a redesigned table with a different instruction set, so routers deployed frommainwill need a new table. Themain/src/...@seelinks of the other two tables no longer resolve for the same reason.LimitOpcodesDebuginjects the same debug slots as the other debug routers, so awithDebug()can be added once fix(swap-vm): install debug opcodes in the SwapVM Debug layout #134 settles the debug layout.