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

[DO NOT MERGE] feat(sdk-router): Synapse Intent Router #3449

Draft
wants to merge 125 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
1e440c5
feat: scaffold `getBestRFQQuote`
ChiTimesChi Nov 6, 2024
6572f96
test: add coverage for getBestRFQQuote
ChiTimesChi Nov 6, 2024
6c66758
feat: initial impl for `getBestRFQQuote`
ChiTimesChi Nov 6, 2024
685a191
Merge branch 'master' into feat/sdk-rfq-endpoint
ChiTimesChi Nov 8, 2024
1795948
test: follow #3379 to silence console in tests
ChiTimesChi Nov 8, 2024
3643f19
fix: log -> error
ChiTimesChi Nov 8, 2024
9b146b7
feat: `isSameAddress`
ChiTimesChi Nov 8, 2024
da73636
refactor: use `isSameAddress`
ChiTimesChi Nov 8, 2024
e2d71cf
fix: return a zero quote instead of null for easier chaining
ChiTimesChi Nov 8, 2024
140cc45
feat: use `getBestQuote` instead of calculating the quote
ChiTimesChi Nov 8, 2024
9e14676
refactor: another futile attempt at keeping the codebase comprehensible
ChiTimesChi Nov 8, 2024
c0bcd7c
[REVERT IN PROD] enable test build
ChiTimesChi Nov 8, 2024
e027265
refactor: remove unused quote calculation
ChiTimesChi Nov 8, 2024
d0ec047
fix: don't force user address to display quotes for unconnected wallets
ChiTimesChi Nov 8, 2024
40d2ad2
chore: add TODOs, docs
ChiTimesChi Nov 11, 2024
e0127e3
Merge branch 'master' into feat/sdk-rfq-endpoint
ChiTimesChi Nov 11, 2024
5a8c853
fix: fill headers for `/rfq` request
ChiTimesChi Nov 11, 2024
1501333
refactor: use isSameAddress in log utils
ChiTimesChi Nov 11, 2024
192fb72
Merge branch 'master' into feat/sdk-rfq-endpoint
ChiTimesChi Nov 19, 2024
e1a1a77
fix: update for #3372
ChiTimesChi Nov 19, 2024
cd50179
Revert "[REVERT IN PROD] enable test build"
ChiTimesChi Dec 5, 2024
1d7323a
docs: remove API_TIMEOUT docs for easier merging into staging branch
ChiTimesChi Dec 5, 2024
8942a74
Merge branch 'master' into feat/sdk-rfq-endpoint
ChiTimesChi Dec 9, 2024
b5ac2ad
feat: use temporary V2 routers [REVERT IN PROD]
ChiTimesChi Dec 4, 2024
a22a55c
feat: use staging API URL [REVERT IN PROD]
ChiTimesChi Dec 4, 2024
db2039e
chore: add a staging log in the SDK
ChiTimesChi Dec 5, 2024
cda408a
fix: URL
ChiTimesChi Dec 5, 2024
2f62c62
feat: add typechain bindings
ChiTimesChi Dec 5, 2024
d35f011
feat: add ABIs
ChiTimesChi Dec 5, 2024
8b261be
feat: scaffold SIR module
ChiTimesChi Dec 5, 2024
3c5fa34
feat: scaffold `bridge` implementation
ChiTimesChi Dec 5, 2024
f190092
feat: steps array encoding
ChiTimesChi Dec 6, 2024
d0ecf2d
feat: initial impl of SIR module
ChiTimesChi Dec 6, 2024
4563869
feat: encoding of saved params for FB V2
ChiTimesChi Dec 6, 2024
1f07de0
feat: SIR module set
ChiTimesChi Dec 6, 2024
f5a14f9
feat: expose SIR in SDK
ChiTimesChi Dec 6, 2024
bc23abf
fix: update SIP, TkenZap deployments, ABIs
ChiTimesChi Dec 9, 2024
994a6d7
fix: don't use forwarding for origin swap / bridge
ChiTimesChi Dec 9, 2024
e0b0189
fix(sdk-router): bridge module name
ChiTimesChi Dec 6, 2024
6b45d72
feat: prioritize SIN quotes on the FE [REVERT IN PROD]
ChiTimesChi Dec 9, 2024
f1bf72c
feat: add more options to /rfq requests
ChiTimesChi Dec 10, 2024
1d22b1c
refactor: isolate zapData manipulation
ChiTimesChi Dec 10, 2024
64e3ab5
feat: save decoded destination chain ZapData
ChiTimesChi Dec 10, 2024
1e84bb5
refactor: simplify `getBridgeRoutes`
ChiTimesChi Dec 10, 2024
dcfb2c5
feat: zap data encoding/decoding
ChiTimesChi Dec 10, 2024
84b50a6
feat: update saved params, extract zap data from steps
ChiTimesChi Dec 11, 2024
c98d236
feat: quoting for destination swaps
ChiTimesChi Dec 11, 2024
1b47dc7
fix: save dest Recipient
ChiTimesChi Dec 13, 2024
723d883
feat: setting SIR slippage
ChiTimesChi Dec 13, 2024
0180c24
feat: isolate finding route logic into swpa engines
ChiTimesChi Dec 16, 2024
4eaf8b9
fix: empty steps encoding, don't save decoded zap data
ChiTimesChi Dec 17, 2024
543d738
fix: id -> engineID
ChiTimesChi Dec 17, 2024
cba20c2
feat: continue isolating swap logic
ChiTimesChi Dec 17, 2024
7b67cd9
fix: only use strict slippage when generating final destination zap data
ChiTimesChi Dec 17, 2024
39d601c
fix: use `0x` prefix for API requests
ChiTimesChi Dec 17, 2024
2a0dff3
Merge branch 'master' into feat/sdk-rfq-endpoint
ChiTimesChi Dec 17, 2024
6f99540
Merge branch 'feat/sdk-rfq-endpoint' into feat/sdk-syn-intents
ChiTimesChi Dec 17, 2024
0ce3647
fix: disable amount check for Intents [REVERT LATER]
ChiTimesChi Dec 17, 2024
a786281
refactor: consistent naming
ChiTimesChi Dec 17, 2024
8c566a6
feat: save destination engine ID
ChiTimesChi Dec 17, 2024
c61abda
refactor: remove unused code
ChiTimesChi Dec 17, 2024
c6e2616
fix: modifyMinAmountOut -> applySlippage
ChiTimesChi Dec 18, 2024
2a0fe3b
feat: scaffold ParaSwap engine
ChiTimesChi Dec 17, 2024
d13041c
fix(synapse-interface): non-RFQ quotes
ChiTimesChi Dec 18, 2024
efd9d4c
fix: include exact amounts in BridgeRoute
ChiTimesChi Dec 18, 2024
27f8791
feat: paraswap impl first pass
ChiTimesChi Dec 18, 2024
a6b85be
feat: disable SynapseRFQ module [REVERT LATER]
ChiTimesChi Dec 18, 2024
28c2d71
feat: reduce timeout, improve timeout logging
ChiTimesChi Dec 19, 2024
33e15bf
refactor: remove unnecessary binding
ChiTimesChi Dec 19, 2024
a126e13
feat: update to the latest SIP
ChiTimesChi Dec 19, 2024
6c0b236
feat: update to latest TokenZap
ChiTimesChi Dec 19, 2024
0819f24
refactor: better SavedParamsV1 names, rm applySlippage
ChiTimesChi Dec 19, 2024
27c1730
fix: cap slippage at 1%
ChiTimesChi Dec 20, 2024
ecc8305
refactor: RouteInput
ChiTimesChi Dec 20, 2024
7aeb06c
fix: increase ParaSwap timeout to 2s
ChiTimesChi Dec 20, 2024
b4bfc47
fix: better max slippage handling
ChiTimesChi Dec 20, 2024
16180b8
refactor: unify external API step generation
ChiTimesChi Dec 20, 2024
fd287c1
feat: scaffold Odos
ChiTimesChi Dec 20, 2024
76b43a9
feat: complete Odos
ChiTimesChi Dec 20, 2024
3380877
fix: native token address in Odos
ChiTimesChi Dec 20, 2024
caef792
refactor: isolate slippage from route search
ChiTimesChi Dec 26, 2024
2bc142f
refactor: rm ParaSwap for the time being
ChiTimesChi Dec 26, 2024
f2705bf
refactor: split findRoute -> getQuote + generateRoute
ChiTimesChi Dec 27, 2024
68bc168
refactor: SIR quotes wokrflow
ChiTimesChi Dec 27, 2024
1157193
fix: forwards params for external engines
ChiTimesChi Dec 29, 2024
d65cc5d
chore: improve error/info logging
ChiTimesChi Dec 30, 2024
60881f0
chore: clean up API fetching
ChiTimesChi Dec 30, 2024
d3bbee3
feat: update to latest SIP, TokenZap
ChiTimesChi Dec 30, 2024
b601830
Revert "feat: use temporary V2 routers [REVERT IN PROD]"
ChiTimesChi Dec 30, 2024
70c8852
Merge branch 'master' into feat/sdk-syn-intents
ChiTimesChi Dec 30, 2024
0e8a512
fix: separate set of chains for intents
ChiTimesChi Dec 30, 2024
a539254
Revert "feat: prioritize SIN quotes on the FE [REVERT IN PROD]"
ChiTimesChi Dec 30, 2024
eb33a1e
Revert "fix(synapse-interface): non-RFQ quotes"
ChiTimesChi Dec 30, 2024
a70a4a6
Revert "chore: add a staging log in the SDK"
ChiTimesChi Dec 30, 2024
fc67a32
refactor: isolate logging utils for easier staging
ChiTimesChi Dec 30, 2024
6322184
feat: different timeouts for quote and generate
ChiTimesChi Dec 30, 2024
1eaf140
feat: update to latest SIP, SIR, TokenZap
ChiTimesChi Jan 2, 2025
5e78038
fix: origin slippage
ChiTimesChi Jan 2, 2025
4236442
fix: error logging
ChiTimesChi Jan 2, 2025
9384789
fix: forwardTo extraction
ChiTimesChi Jan 2, 2025
203e266
fix: return the SIR quotes with zero slippage by default
ChiTimesChi Jan 9, 2025
76c8f63
feat: scaffold KyberSwap
ChiTimesChi Jan 10, 2025
50a82e5
feat: getQuote, generateRoute
ChiTimesChi Jan 10, 2025
ffc64d0
feat: enable KyberSwap engine
ChiTimesChi Jan 10, 2025
f64cf73
chore: execution time logging
ChiTimesChi Jan 10, 2025
69efd3b
fix: pass function name for logging
ChiTimesChi Jan 10, 2025
ed9fc21
feat: disable Odos engine for the time being
ChiTimesChi Jan 13, 2025
98ba898
refactor: enable Quoter API time logging
ChiTimesChi Jan 13, 2025
28aa40a
cleanup: reuse saved dest route input
ChiTimesChi Jan 13, 2025
498ab2a
feat: add restrict complexity flag
ChiTimesChi Jan 13, 2025
c863842
feat: restict complexity in engines
ChiTimesChi Jan 13, 2025
75582aa
refactor: isolate `getFullQuotes`
ChiTimesChi Jan 13, 2025
30a246e
chore: SIR detailed time logging, other modules not so much
ChiTimesChi Jan 13, 2025
11cfcee
feat: cache /quotes requests in Intents
ChiTimesChi Jan 14, 2025
9ea7dbb
feat: process each intermediary token candidate separately
ChiTimesChi Jan 14, 2025
8ffd841
cleanup: engiveSet.getBestQuote
ChiTimesChi Jan 14, 2025
15523be
cleanup: options types
ChiTimesChi Jan 14, 2025
f3b7423
feat: exit early if quote is zero
ChiTimesChi Jan 14, 2025
542fc78
refactor: move final getQuote call for destination
ChiTimesChi Jan 14, 2025
0db259d
feat: add chainId to Quote/Route types
ChiTimesChi Jan 14, 2025
11cac46
cleanup: types
ChiTimesChi Jan 14, 2025
65386c8
chore: API calls logging
ChiTimesChi Jan 15, 2025
013e562
fix: take gas costs into account for KyberSwap
ChiTimesChi Jan 15, 2025
029dbe3
Merge branch 'master' into feat/sdk-syn-intents
ChiTimesChi Jan 15, 2025
f5c91d9
Merge branch 'master' into feat/sdk-syn-intents
ChiTimesChi Jan 16, 2025
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,203 changes: 1,203 additions & 0 deletions packages/sdk-router/src/abi/FastBridgeV2.json

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions packages/sdk-router/src/abi/IDefaultActions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[
{
"type": "function",
"name": "addLiquidity",
"inputs": [
{ "name": "amounts", "type": "uint256[]", "internalType": "uint256[]" },
{ "name": "minToMint", "type": "uint256", "internalType": "uint256" },
{ "name": "deadline", "type": "uint256", "internalType": "uint256" }
],
"outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "deposit",
"inputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }],
"outputs": [],
"stateMutability": "payable"
},
{
"type": "function",
"name": "removeLiquidityOneToken",
"inputs": [
{ "name": "tokenAmount", "type": "uint256", "internalType": "uint256" },
{ "name": "tokenIndex", "type": "uint8", "internalType": "uint8" },
{ "name": "minAmount", "type": "uint256", "internalType": "uint256" },
{ "name": "deadline", "type": "uint256", "internalType": "uint256" }
],
"outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "swap",
"inputs": [
{ "name": "tokenIndexFrom", "type": "uint8", "internalType": "uint8" },
{ "name": "tokenIndexTo", "type": "uint8", "internalType": "uint8" },
{ "name": "dx", "type": "uint256", "internalType": "uint256" },
{ "name": "minDy", "type": "uint256", "internalType": "uint256" },
{ "name": "deadline", "type": "uint256", "internalType": "uint256" }
],
"outputs": [
{ "name": "amountOut", "type": "uint256", "internalType": "uint256" }
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "withdraw",
"inputs": [
{ "name": "amount", "type": "uint256", "internalType": "uint256" }
],
"outputs": [],
"stateMutability": "nonpayable"
}
]
130 changes: 130 additions & 0 deletions packages/sdk-router/src/abi/IERC20Metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
[
{
"type": "function",
"name": "allowance",
"inputs": [
{ "name": "owner", "type": "address", "internalType": "address" },
{ "name": "spender", "type": "address", "internalType": "address" }
],
"outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }],
"stateMutability": "view"
},
{
"type": "function",
"name": "approve",
"inputs": [
{ "name": "spender", "type": "address", "internalType": "address" },
{ "name": "value", "type": "uint256", "internalType": "uint256" }
],
"outputs": [{ "name": "", "type": "bool", "internalType": "bool" }],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "balanceOf",
"inputs": [
{ "name": "account", "type": "address", "internalType": "address" }
],
"outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }],
"stateMutability": "view"
},
{
"type": "function",
"name": "decimals",
"inputs": [],
"outputs": [{ "name": "", "type": "uint8", "internalType": "uint8" }],
"stateMutability": "view"
},
{
"type": "function",
"name": "name",
"inputs": [],
"outputs": [{ "name": "", "type": "string", "internalType": "string" }],
"stateMutability": "view"
},
{
"type": "function",
"name": "symbol",
"inputs": [],
"outputs": [{ "name": "", "type": "string", "internalType": "string" }],
"stateMutability": "view"
},
{
"type": "function",
"name": "totalSupply",
"inputs": [],
"outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }],
"stateMutability": "view"
},
{
"type": "function",
"name": "transfer",
"inputs": [
{ "name": "to", "type": "address", "internalType": "address" },
{ "name": "value", "type": "uint256", "internalType": "uint256" }
],
"outputs": [{ "name": "", "type": "bool", "internalType": "bool" }],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "transferFrom",
"inputs": [
{ "name": "from", "type": "address", "internalType": "address" },
{ "name": "to", "type": "address", "internalType": "address" },
{ "name": "value", "type": "uint256", "internalType": "uint256" }
],
"outputs": [{ "name": "", "type": "bool", "internalType": "bool" }],
"stateMutability": "nonpayable"
},
{
"type": "event",
"name": "Approval",
"inputs": [
{
"name": "owner",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "spender",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
}
],
"anonymous": false
},
{
"type": "event",
"name": "Transfer",
"inputs": [
{
"name": "from",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "to",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
}
],
"anonymous": false
}
]
57 changes: 57 additions & 0 deletions packages/sdk-router/src/abi/SynapseIntentPreviewer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[
{
"type": "function",
"name": "NATIVE_GAS_TOKEN",
"inputs": [],
"outputs": [{ "name": "", "type": "address", "internalType": "address" }],
"stateMutability": "view"
},
{
"type": "function",
"name": "previewIntent",
"inputs": [
{ "name": "swapQuoter", "type": "address", "internalType": "address" },
{ "name": "forwardTo", "type": "address", "internalType": "address" },
{ "name": "slippageWei", "type": "uint256", "internalType": "uint256" },
{ "name": "tokenIn", "type": "address", "internalType": "address" },
{ "name": "tokenOut", "type": "address", "internalType": "address" },
{ "name": "amountIn", "type": "uint256", "internalType": "uint256" }
],
"outputs": [
{ "name": "amountOut", "type": "uint256", "internalType": "uint256" },
{
"name": "steps",
"type": "tuple[]",
"internalType": "struct ISynapseIntentRouter.StepParams[]",
"components": [
{ "name": "token", "type": "address", "internalType": "address" },
{ "name": "amount", "type": "uint256", "internalType": "uint256" },
{
"name": "msgValue",
"type": "uint256",
"internalType": "uint256"
},
{ "name": "zapData", "type": "bytes", "internalType": "bytes" }
]
}
],
"stateMutability": "view"
},
{ "type": "error", "name": "SIP__NoOpForwardNotSupported", "inputs": [] },
{ "type": "error", "name": "SIP__PoolTokenMismatch", "inputs": [] },
{ "type": "error", "name": "SIP__PoolZeroAddress", "inputs": [] },
{ "type": "error", "name": "SIP__RawParamsEmpty", "inputs": [] },
{ "type": "error", "name": "SIP__TokenNotNative", "inputs": [] },
{
"type": "error",
"name": "ZapDataV1__FinalTokenNotSpecified",
"inputs": []
},
{ "type": "error", "name": "ZapDataV1__InvalidEncoding", "inputs": [] },
{
"type": "error",
"name": "ZapDataV1__PayloadLengthAboveMax",
"inputs": []
},
{ "type": "error", "name": "ZapDataV1__TargetZeroAddress", "inputs": [] }
]
98 changes: 98 additions & 0 deletions packages/sdk-router/src/abi/SynapseIntentRouter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
[
{
"type": "function",
"name": "NATIVE_GAS_TOKEN",
"inputs": [],
"outputs": [{ "name": "", "type": "address", "internalType": "address" }],
"stateMutability": "view"
},
{
"type": "function",
"name": "completeIntent",
"inputs": [
{
"name": "zapRecipient",
"type": "address",
"internalType": "address"
},
{ "name": "amountIn", "type": "uint256", "internalType": "uint256" },
{ "name": "deadline", "type": "uint256", "internalType": "uint256" },
{
"name": "steps",
"type": "tuple[]",
"internalType": "struct ISynapseIntentRouter.StepParams[]",
"components": [
{ "name": "token", "type": "address", "internalType": "address" },
{ "name": "amount", "type": "uint256", "internalType": "uint256" },
{
"name": "msgValue",
"type": "uint256",
"internalType": "uint256"
},
{ "name": "zapData", "type": "bytes", "internalType": "bytes" }
]
}
],
"outputs": [],
"stateMutability": "payable"
},
{
"type": "function",
"name": "completeIntentWithBalanceChecks",
"inputs": [
{
"name": "zapRecipient",
"type": "address",
"internalType": "address"
},
{ "name": "amountIn", "type": "uint256", "internalType": "uint256" },
{ "name": "deadline", "type": "uint256", "internalType": "uint256" },
{
"name": "steps",
"type": "tuple[]",
"internalType": "struct ISynapseIntentRouter.StepParams[]",
"components": [
{ "name": "token", "type": "address", "internalType": "address" },
{ "name": "amount", "type": "uint256", "internalType": "uint256" },
{
"name": "msgValue",
"type": "uint256",
"internalType": "uint256"
},
{ "name": "zapData", "type": "bytes", "internalType": "bytes" }
]
}
],
"outputs": [],
"stateMutability": "payable"
},
{
"type": "error",
"name": "AddressEmptyCode",
"inputs": [
{ "name": "target", "type": "address", "internalType": "address" }
]
},
{
"type": "error",
"name": "AddressInsufficientBalance",
"inputs": [
{ "name": "account", "type": "address", "internalType": "address" }
]
},
{ "type": "error", "name": "FailedInnerCall", "inputs": [] },
{ "type": "error", "name": "SIR__DeadlineExceeded", "inputs": [] },
{ "type": "error", "name": "SIR__MsgValueIncorrect", "inputs": [] },
{ "type": "error", "name": "SIR__StepsNotProvided", "inputs": [] },
{ "type": "error", "name": "SIR__TokenNotContract", "inputs": [] },
{ "type": "error", "name": "SIR__UnspentFunds", "inputs": [] },
{ "type": "error", "name": "SIR__ZapIncorrectReturnValue", "inputs": [] },
{ "type": "error", "name": "SIR__ZapNoReturnValue", "inputs": [] },
{
"type": "error",
"name": "SafeERC20FailedOperation",
"inputs": [
{ "name": "token", "type": "address", "internalType": "address" }
]
}
]
Loading
Loading