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: /swap endpoint #1269

Draft
wants to merge 38 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
edd3518
feat: /swap handler skeleton
dohaki Nov 7, 2024
9c39be4
feat: uniswap v3 exact output support + UniversalSwapAndBridge (#1268)
dohaki Nov 10, 2024
1e36933
feat: uniswap min output cross swap quotes resolver (#1271)
dohaki Nov 14, 2024
19c0389
get token details for any address in any chainId (#1272)
gsteenkamp89 Nov 15, 2024
b245827
feat: build cross swap tx (#1274)
dohaki Nov 20, 2024
b585972
feat: support native eth as input/output (#1279)
dohaki Nov 21, 2024
3efbc6a
Feat/support arb tokens on coingecko endpoint (#1278)
gsteenkamp89 Nov 22, 2024
fc83780
feat: add allowance and balance check (#1281)
dohaki Nov 22, 2024
60313fd
fix: allowance and balance check
dohaki Nov 22, 2024
334a245
fixup
dohaki Nov 22, 2024
67657dc
Merge branch 'master' into swap-endpoint
dohaki Nov 22, 2024
a0a2e41
fixup
dohaki Nov 22, 2024
2d8627e
feat: add missing response fields
dohaki Nov 22, 2024
f064696
fixup
dohaki Nov 22, 2024
6d8d45a
feat: skip spokepool verifier temp (#1286)
dohaki Nov 22, 2024
11f2640
feat: add more swap and bridge addresses
dohaki Nov 22, 2024
81dee5a
feat: mainnet
dohaki Nov 22, 2024
1addbd7
fixup
dohaki Nov 22, 2024
91c4a56
feat: refund on origin flag (#1284)
dohaki Nov 23, 2024
e9b902a
fix: native eth handling in allowance + balance check
dohaki Nov 23, 2024
8ca1658
fix: amount adjustments
dohaki Nov 23, 2024
0357a38
feat: add approvalTxns to response
dohaki Nov 23, 2024
bd9e370
test: improve test script
dohaki Nov 23, 2024
820d472
feat: support old `SwapAndBridge` and new periphery (#1287)
dohaki Nov 25, 2024
7167488
fix: origin swap recipient address
dohaki Nov 26, 2024
c022818
fix: adjust buffer
dohaki Nov 26, 2024
e5a0353
Gerhard/acx 3321 calculate fee components (#1285)
gsteenkamp89 Nov 27, 2024
129aadd
feat: use trading api + support universal router (#1294)
dohaki Nov 29, 2024
cf83060
Merge branch 'master' into swap-endpoint
gsteenkamp89 Dec 3, 2024
bdd60f1
measure swap/allowance performance (#1301)
gsteenkamp89 Dec 4, 2024
5101979
feat: support `UniversalSwapAndBridge` in swap endpoint (#1311)
dohaki Dec 16, 2024
5eebd02
chore: add swap quotes to response
dohaki Dec 17, 2024
0a14853
perf: bridge quote for min output
dohaki Dec 17, 2024
83dc8c9
chore: improve profiling
dohaki Dec 17, 2024
a0afc7e
fix: bridge quote min output
dohaki Dec 17, 2024
28b6648
chore: allow vercel endpoint override
dohaki Dec 17, 2024
1383980
perf: use indicative quotes as guesstimates (#1337)
dohaki Dec 20, 2024
bf1f33e
feat: support permit swap (#1288)
dohaki Dec 20, 2024
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
6 changes: 4 additions & 2 deletions .github/workflows/dependency-review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
with:
fail-on-severity: high
# Comma-separated list of GHSA IDs to allow.
# We allow @openzeppelin/[email protected] critical vulnerabilities
# We allow the following critical vulnerabilities
# because they are not exploitable in our usage of the package.
allow-ghsas: GHSA-fg47-3c2x-m2wr, GHSA-88g8-f5mf-f5rj, GHSA-3h5v-q93c-6h6q
# - @openzeppelin/[email protected]
# - @openzeppelin/[email protected]
allow-ghsas: GHSA-fg47-3c2x-m2wr, GHSA-88g8-f5mf-f5rj, GHSA-3h5v-q93c-6h6q, GHSA-qh9x-gcfh-pcrw, GHSA-4g63-c64m-25w9, GHSA-xrc4-737v-9q75, GHSA-4h98-2769-gh6h, GHSA-4h98-2769-gh6h, GHSA-93hq-5wgc-jc82
49 changes: 49 additions & 0 deletions api/_abis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,52 @@ export const MINIMAL_MULTICALL3_ABI = [
type: "function",
},
];

export const ERC20_PERMIT_ABI = [
{
inputs: [],
stateMutability: "view",
type: "function",
name: "name",
outputs: [
{
internalType: "string",
name: "",
type: "string",
},
],
},
{
inputs: [
{
internalType: "address",
name: "owner",
type: "address",
},
],
stateMutability: "view",
type: "function",
name: "nonces",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
},
{
inputs: [],
name: "version",
outputs: [{ internalType: "string", name: "", type: "string" }],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "DOMAIN_SEPARATOR",
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
stateMutability: "view",
type: "function",
},
];
27 changes: 12 additions & 15 deletions api/_dexes/1inch.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
import axios from "axios";

import { AcrossSwap, SwapQuoteAndCalldata } from "./types";
import { getSwapAndBridgeAddress } from "./utils";
import { Swap, OriginSwapQuoteAndCalldata } from "./types";
import { getSwapAndBridgeAddress } from "../_swap-and-bridge";

export async function get1inchQuoteAndCalldata(
swap: AcrossSwap
): Promise<SwapQuoteAndCalldata> {
const swapAndBridgeAddress = getSwapAndBridgeAddress(
"1inch",
swap.swapToken.chainId
);
const apiBaseUrl = `https://api.1inch.dev/swap/v6.0/${swap.swapToken.chainId}`;
export async function get1inchQuoteForOriginSwapExactInput(
swap: Omit<Swap, "recipient">
): Promise<OriginSwapQuoteAndCalldata> {
const swapAndBridgeAddress = getSwapAndBridgeAddress("1inch", swap.chainId);
const apiBaseUrl = `https://api.1inch.dev/swap/v6.0/${swap.chainId}`;
const apiHeaders = {
Authorization: `Bearer ${process.env.ONEINCH_API_KEY}`,
accept: "application/json",
};

const swapParams = {
src: swap.swapToken.address,
dst: swap.acrossInputToken.address,
amount: swap.swapTokenAmount,
src: swap.tokenIn.address,
dst: swap.tokenOut.address,
amount: swap.amount,
from: swapAndBridgeAddress,
slippage: swap.slippage,
slippage: swap.slippageTolerance,
disableEstimate: true,
allowPartialFill: false,
receiver: swapAndBridgeAddress,
Expand All @@ -47,6 +44,6 @@ export async function get1inchQuoteAndCalldata(
value: response.data.tx.value,
swapAndBridgeAddress,
dex: "1inch",
slippage: swap.slippage,
slippage: swap.slippageTolerance,
};
}
Loading
Loading