Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelQZQ committed Jul 15, 2024
1 parent 84e308c commit b295c7a
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 14 deletions.
3 changes: 2 additions & 1 deletion packages/thalaswap-router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ $ npm i @thalalabs/router-sdk
```
const router = new ThalaswapRouter(
Network.MAINNET,
"https://fullnode.mainnet.aptoslabs.com/v1"
"https://fullnode.mainnet.aptoslabs.com/v1",
"0x48271d39d0b05bd6efca2278f22277d6fcc375504f9839fd73f74ace240861af"
);
const fromToken = "0x1::aptos_coin::AptosCoin";
const toToken = "0xec84c05cc40950c86d8a8bed19552f1e8ebb783196bb021c916161d22dc179f7::asset::USDC";
Expand Down
1 change: 1 addition & 0 deletions packages/thalaswap-router/examples/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const account = Account.fromPrivateKey({
const router = new ThalaswapRouter(
Network.MAINNET,
"https://fullnode.mainnet.aptoslabs.com/v1",
"0x48271d39d0b05bd6efca2278f22277d6fcc375504f9839fd73f74ace240861af",
);

// Example 1: Exact input. 1 hop
Expand Down
6 changes: 2 additions & 4 deletions packages/thalaswap-router/src/PoolDataClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Coin, Pool, PoolData } from "./types";
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
import { uniq } from "lodash";
import { fp64ToFloat, parsePoolMetadata, scaleDown } from "./utils";
import { THALASWAP_RESOURCE_ACCOUNT_ADDRESS } from "./constants";

class PoolDataClient {
private poolData: PoolData | null = null;
Expand All @@ -13,9 +12,8 @@ class PoolDataClient {
private coins: Coin[] = [];
private resourceAddress: string;

constructor(network: Network, fullnode: string, resourceAddress?: string) {
this.resourceAddress =
resourceAddress || THALASWAP_RESOURCE_ACCOUNT_ADDRESS;
constructor(network: Network, fullnode: string, resourceAddress: string) {
this.resourceAddress = resourceAddress;

this.client = new Aptos(
new AptosConfig({
Expand Down
8 changes: 2 additions & 6 deletions packages/thalaswap-router/src/ThalaswapRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { STABLE_POOL_SCRIPTS_ABI } from "./abi/stable_pool_scripts";
import { WEIGHTED_POOL_SCRIPTS_ABI } from "./abi/weighted_pool_scripts";
import { MULTIHOP_ROUTER_ABI } from "./abi/multihop_router";
import { Network } from "@aptos-labs/ts-sdk";
import { THALASWAP_RESOURCE_ACCOUNT_ADDRESS } from "./constants";

const NULL_TYPE = `${STABLE_POOL_SCRIPTS_ABI.address}::base_pool::Null`;
const NULL_4 = Array(4).fill(NULL_TYPE);
Expand Down Expand Up @@ -63,12 +62,9 @@ class ThalaswapRouter {
private client: PoolDataClient;
private graph: Graph | null = null;
private coins: Coin[] | null = null;
private resourceAddress: string;

constructor(network: Network, fullnode: string, resourceAddress?: string) {
this.resourceAddress =
resourceAddress || THALASWAP_RESOURCE_ACCOUNT_ADDRESS;
this.client = new PoolDataClient(network, fullnode);
constructor(network: Network, fullnode: string, resourceAddress: string) {
this.client = new PoolDataClient(network, fullnode, resourceAddress);
}

setPoolDataClient(client: PoolDataClient) {
Expand Down
2 changes: 0 additions & 2 deletions packages/thalaswap-router/src/constants.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/thalaswap-router/test/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const mockPoolDataClient = {
}),
};

const router = new ThalaswapRouter(Network.MAINNET, "test");
const router = new ThalaswapRouter(Network.MAINNET, "test", "0x123");
router.setPoolDataClient(mockPoolDataClient as any);

test("Exact input 1 hop", async () => {
Expand Down

0 comments on commit b295c7a

Please sign in to comment.