Skip to content

Commit

Permalink
Support thalaswap v2
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelQZQ committed Oct 21, 2024
1 parent f1ff6e7 commit 6d4a3fd
Show file tree
Hide file tree
Showing 9 changed files with 3,064 additions and 157 deletions.
5 changes: 5 additions & 0 deletions .changeset/swift-wolves-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@thalalabs/router-sdk": major
---

Support thalaswap v2
20 changes: 12 additions & 8 deletions packages/thalaswap-router/examples/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ const account = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey(privateKey),
});

const router = new ThalaswapRouter(
Network.MAINNET,
"https://fullnode.mainnet.aptoslabs.com/v1",
"0x48271d39d0b05bd6efca2278f22277d6fcc375504f9839fd73f74ace240861af",
"0x60955b957956d79bc80b096d3e41bad525dd400d8ce957cdeb05719ed1e4fc26",
);
const router = new ThalaswapRouter({
network: Network.MAINNET,
fullnode: "https://fullnode.mainnet.aptoslabs.com/v1",
resourceAddress:
"0x48271d39d0b05bd6efca2278f22277d6fcc375504f9839fd73f74ace240861af",
v2ResourceAddress:
"0x60955b957956d79bc80b096d3e41bad525dd400d8ce957cdeb05719ed1e4fc26",
multirouterAddress:
"0x60955b957956d79bc80b096d3e41bad525dd400d8ce957cdeb05719ed1e4fc26",
});

// Example 1: Exact input. 1 hop
async function example1() {
Expand All @@ -43,7 +47,7 @@ async function example1() {

console.log("Route:", route);

const entryPayload = router.encodeRoute(route!, 0.5);
const entryPayload = await router.encodeRoute(route!, 0.5);
console.log("Entry function payload with 0.5% slippage:", entryPayload);

await client.submitTransaction({
Expand All @@ -67,7 +71,7 @@ async function example2() {

console.log("Route:", route);

const entryPayload = router.encodeRoute(route!, 0.5);
const entryPayload = await router.encodeRoute(route!, 0.5);
console.log("Entry function payload with 0.5% slippage:", entryPayload);

await client.submitTransaction({
Expand Down
Loading

0 comments on commit 6d4a3fd

Please sign in to comment.