Skip to content

Commit

Permalink
Merge branch 'master' into aburkut/back-1758-maverick-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aburkut committed Dec 17, 2024
2 parents 2108e06 + f0d3764 commit aa89b0d
Show file tree
Hide file tree
Showing 142 changed files with 27,698 additions and 1,070 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: ['16.x']
node: ['20.x']
name: Node ${{ matrix.node }} sample
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ tests/states.json
tests/configs.json
.idea/
local-scripts
tests/debug-price-route.json
tests/debug-price-route.json
19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@paraswap/dex-lib",
"version": "3.9.3",
"version": "4.0.7",
"main": "build/index.js",
"types": "build/index.d.ts",
"repository": "https://github.com/paraswap/paraswap-dex-lib",
Expand All @@ -17,11 +17,11 @@
"@types/express": "^4.17.14",
"@types/jest": "26.0.24",
"@types/lodash": "4.14.178",
"@types/node": "^17.0.21",
"@types/node": "^20",
"@types/uuid": "^9.0.1",
"@types/websocket": "^1.0.10",
"@typescript-eslint/eslint-plugin": "^5.47.0",
"@typescript-eslint/parser": "^5.47.0",
"@typescript-eslint/eslint-plugin": "^8.17.0",
"@typescript-eslint/parser": "^8.17.0",
"change-case": "^4.1.2",
"dotenv": "16.0.0",
"eslint": "^8.30.0",
Expand All @@ -33,9 +33,9 @@
"jest": "^29.0.3",
"prettier": "^2.8.1",
"pretty-quick": "^3.1.3",
"ts-jest": "^29.0.3",
"ts-node": "^10.6.0",
"typescript": "4.6.4",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.7.2",
"yargs": "^17.0.1"
},
"scripts": {
Expand All @@ -52,12 +52,14 @@
},
"dependencies": {
"@0x/utils": "^4.5.2",
"@balancer-labs/balancer-maths": "^0.0.19",
"@balancer-labs/sor": "4.1.1-beta.4",
"@bgd-labs/aave-address-book": "2.21.1",
"@ethersproject/abi": "^5.7.0",
"@hashflow/sdk": "^2.2.7",
"@hashflow/taker-js": "^0.3.7",
"@paraswap/core": "2.4.0",
"@types/ws": "^8.5.12",
"async": "^3.2.4",
"axios": "0.27.2",
"bignumber.js": "9.1.0",
Expand All @@ -69,6 +71,7 @@
"lodash": "4.17.21",
"log4js": "6.6.1",
"node-cache": "^5.1.2",
"protobufjs": "^7.4.0",
"ts-essentials": "9.1.2",
"uuid": "^9.0.0",
"web3": "1.6.0",
Expand All @@ -77,7 +80,7 @@
"web3-eth-abi": "1.4.0",
"web3-eth-contract": "1.6.0",
"web3-utils": "1.6.0",
"websocket": "1.0.35"
"ws": "^8.18.0"
},
"sideEffects": false
}
78 changes: 78 additions & 0 deletions scripts/run-dex-integration-v3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// npx ts-node scripts/run-dex-integration-v3.ts
/* eslint-disable no-console */
import dotenv from 'dotenv';
dotenv.config();

import { Network, SwapSide } from '../src/constants';
import { BalancerV3 } from '../src/dex/balancer-v3/balancer-v3';
import { DummyDexHelper } from '../src/dex-helper/index';
import { BI_POWS } from '../src/bigint-constants';

const stataUSDC = {
address: '0x8a88124522dbbf1e56352ba3de1d9f78c143751e'.toLowerCase(),
decimals: 6,
};

const stataDAI = {
address: '0xde46e43f46ff74a23a65ebb0580cbe3dfe684a17'.toLowerCase(),
decimals: 18,
};

const stataUSDT = {
address: '0x978206fae13faf5a8d293fb614326b237684b750'.toLowerCase(),
decimals: 6,
};

const bal = {
address: '0xb19382073c7a0addbb56ac6af1808fa49e377b75'.toLowerCase(),
decimals: 18,
};

const daiAave = {
address: '0xff34b3d4aee8ddcd6f9afffb6fe49bd371b8a357'.toLowerCase(),
decimals: 18,
};

const usdcAave = {
address: '0x94a9d9ac8a22534e3faca9f4e7f2e2cf85d5e4c8'.toLowerCase(),
decimals: 6,
};

const amounts = [0n, BI_POWS[6], BI_POWS[7], BI_POWS[8]];

async function main() {
const dexHelper = new DummyDexHelper(Network.SEPOLIA);
const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();

const balancerV3 = new BalancerV3(Network.SEPOLIA, 'BalancerV3', dexHelper);

await balancerV3.initializePricing(blocknumber);

const from = stataUSDC;
const to = stataUSDT;
// const from = daiAave;
// const to = usdcAave;

const pools = await balancerV3.getPoolIdentifiers(
from,
to,
SwapSide.SELL,
blocknumber,
);
console.log('Pool Identifiers: ', from.address, to.address, pools);

const prices = await balancerV3.getPricesVolume(
from,
to,
amounts,
SwapSide.SELL,
blocknumber,
pools,
);
console.log('Pool Prices: ', prices);

const poolLiquidity = await balancerV3.getTopPoolsForToken(from.address, 10);
console.log('Top Pools:', poolLiquidity);
}

main();
Loading

0 comments on commit aa89b0d

Please sign in to comment.