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: add stackswap swap #4

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 23 additions & 0 deletions chainhooks/stackswap/stackswap-swap-v5k.swap-x-for-y.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"chain": "stacks",
"uuid": "1",
"name": "stackswap-swap-v5k.swap-x-for-y",
"version": 1,
"networks": {
"mainnet": {
"if_this": {
"scope": "contract_call",
"contract_identifier": "SP1Z92MPDQEWZXW36VX71Q25HKF5K2EPCJ304F275.stackswap-swap-v5k",
"method": "swap-x-for-y"
},
"then_that": {
"http_post": {
"url": "http://localhost:3000/api/chainhooks/swap",
"authorization_header": "Bearer dev-api-token"
}
},
"start_block": 37537,
"decode_clarity_values": false
}
}
}
23 changes: 23 additions & 0 deletions chainhooks/stackswap/stackswap-swap-v5k.swap-y-for-x.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"chain": "stacks",
"uuid": "1",
"name": "stackswap-swap-v5k.swap-y-for-x",
"version": 1,
"networks": {
"mainnet": {
"if_this": {
"scope": "contract_call",
"contract_identifier": "SP1Z92MPDQEWZXW36VX71Q25HKF5K2EPCJ304F275.stackswap-swap-v5k",
"method": "swap-y-for-x"
},
"then_that": {
"http_post": {
"url": "http://localhost:3000/api/chainhooks/swap",
"authorization_header": "Bearer dev-api-token"
}
},
"start_block": 37537,
"decode_clarity_values": false
}
}
}
Binary file added public/protocols/stackswap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/app/api/chainhooks/swap/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ export async function POST(request: Request) {
"SP2C2YFP12AJZB4MABJBAJ55XECVS7E4PMMZ89YZR.arkadiko-swap-v2-1"
) {
protocol = "arkadiko";
} else if (
transactionToProcess.metadata.kind.data.contract_identifier ===
"SP1Z92MPDQEWZXW36VX71Q25HKF5K2EPCJ304F275.stackswap-swap-v5k"
) {
protocol = "stackswap";
} else {
throw new Error("Unknown protocol");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use client";
import type { Protocol } from "@/lib/protocols";
import { Card, Separator, Text } from "@radix-ui/themes";
import {
Bar,
Expand All @@ -12,7 +13,7 @@ import {

interface UniqueUsersBarChartProps {
data: {
protocol: "alex" | "arkadiko";
protocol: Protocol;
month: string;
uniqueSenders: number;
}[];
Expand All @@ -26,6 +27,7 @@ export const UniqueUsersBarChartClient = ({
date: string;
arkadiko: number;
alex: number;
stackswap: number;
}[] = [];

for (const item of data) {
Expand All @@ -41,6 +43,7 @@ export const UniqueUsersBarChartClient = ({
date: month,
arkadiko: protocol === "arkadiko" ? uniqueSenders : 0,
alex: protocol === "alex" ? uniqueSenders : 0,
stackswap: protocol === "stackswap" ? uniqueSenders : 0,
});
}
}
Expand Down Expand Up @@ -109,6 +112,7 @@ export const UniqueUsersBarChartClient = ({
</div>
)}
/>
<Bar dataKey="stackswap" stackId="a" className="fill-cyan-9" />
<Bar dataKey="arkadiko" stackId="a" className="fill-iris-9" />
<Bar dataKey="alex" stackId="a" className="fill-blue-9" />
</BarChart>
Expand Down
1 change: 1 addition & 0 deletions src/lib/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ export const protocolsActions: {
} = {
alex: ["swap"],
arkadiko: ["swap", "add-liquidity", "remove-liquidity"],
stackswap: ["swap"],
} as const;
9 changes: 8 additions & 1 deletion src/lib/protocols.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const protocols = ["alex", "arkadiko"] as const;
export const protocols = ["alex", "arkadiko", "stackswap"] as const;

export type Protocol = (typeof protocols)[number];

Expand All @@ -20,4 +20,11 @@ export const protocolsInfo = {
website: "https://arkadiko.finance/",
x: "https://twitter.com/ArkadikoFinance",
},
stackswap: {
name: "StackSwap",
description:
"Stackswap is a combination of DEX and token launchpad on Stacks blockchain.",
website: "https://app.stackswap.org/",
x: "https://twitter.com/Stackswap_BTC",
},
} as const;
Loading