Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 4b75f5e2edd501742f401055fae6a8476510f9b2
Author: Verisana <account@0112.pro>
Date:   Thu Jun 16 14:12:27 2022 +0300

    2.0.12

commit ba63c55a036b453ad7d364dcc049fcbdeddd615e
Merge: 44fd6c8 0e6b052
Author: Verisana <account@0112.pro>
Date:   Thu Jun 16 14:11:54 2022 +0300

    Merge branch 'master' into feature/back-585

commit 44fd6c865cfd569594dc2a7e0c797cb8bb804474
Author: Verisana <account@0112.pro>
Date:   Thu Jun 2 19:40:33 2022 +0100

    2.0.11

commit 3693df0b9504e3298d79b9d110c49a0b9b4b8bd1
Merge: f9bd877 f5d7319
Author: Verisana <account@0112.pro>
Date:   Thu Jun 2 19:38:43 2022 +0100

    Merge branch 'master' into feature/back-585

commit f9bd87751433899a88a978020b509183ad56c954
Author: Verisana <account@0112.pro>
Date:   Wed Jun 1 22:05:08 2022 +0100

    2.0.10

commit 7dd9ba07b42ee658ca40aada3262a3eec4985d6d
Author: Verisana <account@0112.pro>
Date:   Tue May 31 16:28:03 2022 +0100

    feat: pass userAddress while building transaction in limit-orders

commit bcad272a88faca40627485d60443b492b37cbc8c
Author: Verisana <account@0112.pro>
Date:   Tue May 31 15:15:23 2022 +0100

    feat: make multi and mega swap work

commit 2113d7799c4cf4049009802e13e630a2769015c6
Author: Verisana <account@0112.pro>
Date:   Tue May 31 15:14:01 2022 +0100

    feat: support preprocess transaction on local API SDK

commit 339c4a605bf819cd6d82db9bd5cc9a2260a4b9c6
Author: Verisana <account@0112.pro>
Date:   Tue May 31 15:11:57 2022 +0100

    test: update orders to new ones

commit 3c61b7b727f9990ae3bf79f38ceaebc47f815d47
Author: Verisana <account@0112.pro>
Date:   Mon May 30 20:01:04 2022 +0100

    2.0.9

commit 19ceda4e1df34aa03833a44f7ee159d36ec60e25
Author: Verisana <account@0112.pro>
Date:   Mon May 30 18:34:09 2022 +0100

    fix: filter out zero amounts from priceSummary

commit 3092f9f92a6aefea58d7877672714b177b0cbc21
Author: Verisana <account@0112.pro>
Date:   Mon May 30 18:29:58 2022 +0100

    feat: use swapSide in side

commit 700a9fa32f13a0da218c972ed1f8b941c8ebe531
Author: Verisana <account@0112.pro>
Date:   Mon May 30 16:53:05 2022 +0100

    test: change test orders t new ones

commit 1147e06c2e2528631525c96def96228e3a37cc6a
Author: Verisana <account@0112.pro>
Date:   Mon May 30 16:51:40 2022 +0100

    chore: use tryBatchFillOrderTakerAmount for simpleSwap in limit orders

commit f5127b43b417c33568c47333a259cb699e3de38e
Author: Verisana <account@0112.pro>
Date:   Mon May 30 15:24:48 2022 +0100

    2.0.8

commit f3a193d5bf195d929fcb3c47e1fecd0cf0e7da3a
Author: Verisana <account@0112.pro>
Date:   Mon May 30 12:41:36 2022 +0100

    test: small updates in test files limit orders

commit 7cc34fd002a3b020d78c030689698cf21ffe20b9
Author: Verisana <account@0112.pro>
Date:   Mon May 30 12:41:07 2022 +0100

    feat: update RFQ address config in paraswap limit orders

commit c0b0aa99fbb0455953388d3bca6844c5b5f04be5
Author: Verisana <account@0112.pro>
Date:   Fri May 27 20:20:59 2022 +0100

    2.0.7

commit 88cfd21e6af8dc30f19d979e978e359fb589b0ec
Author: Verisana <account@0112.pro>
Date:   Fri May 27 20:19:57 2022 +0100

    feat: add userAddress to ILimitOrderInterface

commit 232dadf162c1655a01ae14d06092b92b84ecc347
Author: Verisana <account@0112.pro>
Date:   Fri May 27 20:18:17 2022 +0100

    test: update e2e tests for paraswap limit orders

commit 954c6913fab159813f06b8fd106ba18ba67f330f
Author: Verisana <account@0112.pro>
Date:   Fri May 27 14:40:07 2022 +0100

    2.0.6

commit e77d11b8ebb6e069c2ae58a5dcc93fdd74eafcc0
Author: Verisana <account@0112.pro>
Date:   Fri May 27 14:37:36 2022 +0100

    feat: fix all pricing issues

commit d3b35f73bab1e0a1768cd35e1ccfa3b14ddd8f1e
Author: Verisana <account@0112.pro>
Date:   Fri May 27 14:36:17 2022 +0100

    test: update tests for paraswp-limit-orders

commit c22cf76ac280ef9f867f995476c0c27f7b5b5066
Author: Verisana <account@0112.pro>
Date:   Thu May 26 12:58:10 2022 +0100

    2.0.5

commit f75a8fe973391460bf5ecbdc789814906891d77f
Author: Verisana <account@0112.pro>
Date:   Thu May 26 12:49:18 2022 +0100

    fix: undefined new Array issue

commit a2517f2dbe3475ecf51a6c952a071cbc69c3e885
Author: Verisana <account@0112.pro>
Date:   Wed May 25 21:31:43 2022 +0100

    2.0.4

commit 1ff51b22f78f9b1fc7bd60ad8e8c49264006d07f
Author: Verisana <account@0112.pro>
Date:   Wed May 25 20:31:16 2022 +0100

    feat: set proper gascost of one order

commit ae0cdea9c92f5334a435fef0027e54d2ae35adbc
Author: Verisana <account@0112.pro>
Date:   Wed May 25 19:26:47 2022 +0100

    test: update tests with new names

commit 7c4e8d50ae8231d10aace64ddc57e706007a0f5e
Author: Verisana <account@0112.pro>
Date:   Wed May 25 19:26:15 2022 +0100

    feat: rename orderBook to priceSummary, account gas and fix src - dest mismatch

commit 61400388c195b4ad681a091b8a5c3816976b5deb
Author: Verisana <account@0112.pro>
Date:   Wed May 25 19:00:06 2022 +0100

    refactor: remove takerTokenFillAmount handler

commit 4b874215a1d42bcf52ae9ac85cd8d0551258b464
Author: Verisana <account@0112.pro>
Date:   Tue May 24 20:28:44 2022 +0100

    2.0.3

commit 16f44f19c5c813e9413e34f3d795a8687848435b
Author: Verisana <account@0112.pro>
Date:   Tue May 24 20:26:25 2022 +0100

    test: update test utils

commit d453f238ed428cf9857269d4bac1a7cdd69a4c2c
Author: Verisana <account@0112.pro>
Date:   Tue May 24 20:25:56 2022 +0100

    feat: update files for paraswap limit order provider

commit e2373918ab436ecaeeda12502bf228a97507f233
Author: Verisana <account@0112.pro>
Date:   Tue May 24 20:25:13 2022 +0100

    feat: update simpleSwap encoding for paraswap-limit-orders

commit 9c9f45dacd817a8e26f8573bde22c1bc9f9e8a86
Author: Verisana <account@0112.pro>
Date:   Tue May 24 20:24:34 2022 +0100

    feat: add AugustusABI file

commit eca1c511a585f9c2b4fcee94ad4b9578fcbaa076
Author: Verisana <account@0112.pro>
Date:   Tue May 24 20:24:17 2022 +0100

    test: write tests for limit order provider

commit d263460256d06f76b278da37311fef307190d307
Author: Verisana <account@0112.pro>
Date:   Mon May 23 20:54:13 2022 +0100

    2.0.2

commit 4a7b7558ab1fea0822b456c1d4dc8d88ef74fc65
Author: Verisana <account@0112.pro>
Date:   Mon May 23 20:33:04 2022 +0100

    build: add ethers to dependencies

commit a1f69a78d4d250d708ef55751333a3db715f6b4a
Author: Verisana <account@0112.pro>
Date:   Mon May 23 20:30:46 2022 +0100

    test: update tests. But teh examples are not correct

commit 010e6bad9d1f445ddf3b58a9fc1b2ed93e166ceb
Author: Verisana <account@0112.pro>
Date:   Mon May 23 20:27:48 2022 +0100

    fix: set gasCost[0] to zero

commit a0d8f96022012d075f93798cafc731009b8f8c46
Author: Verisana <account@0112.pro>
Date:   Mon May 23 19:29:05 2022 +0100

    feat: small fixes on paraswap-limit-order

commit 5aa2c658fe356a261c3592a292d04807aed85bce
Author: Verisana <account@0112.pro>
Date:   Fri May 20 15:08:38 2022 +0100

    feat: make the access restricted in pacjage.json

commit b5b6e09b5a6f87a52bd70a87a07aa99c94742ac1
Author: Verisana <account@0112.pro>
Date:   Fri May 20 15:02:50 2022 +0100

    feat: prepare package.json for publishing

commit 479d1ed65cfd76ed0aa0336ead4b883e733be460
Author: Verisana <account@0112.pro>
Date:   Fri May 20 13:46:18 2022 +0100

    feat: update paraswap-limit-orders

commit b9fdc12d023003e690bad569331dced6cd4e4732
Author: Verisana <account@0112.pro>
Date:   Fri May 20 13:45:20 2022 +0100

    test: update tests for paraswap-limit-orders

commit 132e27e34b5af9553b289d20c9260890f654298f
Author: Verisana <account@0112.pro>
Date:   Fri May 20 12:21:58 2022 +0100

    feat: create DummyLimitORderProvider for tests

commit fbeabbf3d48effef0b043092f8b921ec02710ae3
Author: Verisana <account@0112.pro>
Date:   Fri May 20 12:21:22 2022 +0100

    feat: use swppableBalance whe filling the order

commit b15284910bc464a19dece6d6fd19121f062e1671
Author: Verisana <account@0112.pro>
Date:   Thu May 19 23:47:39 2022 +0100

    feat: add getDexByKey in price-helper and create preprocessTransactionOption type

commit 4ea44c7ef54c291c7fedc1c1ca5cd5817389e577
Author: Verisana <account@0112.pro>
Date:   Thu May 19 23:23:11 2022 +0100

    feat: use payload in buildTransaction

commit 7bd84878516cb33b1e557ca4086139663fe95d2b
Author: Verisana <account@0112.pro>
Date:   Thu May 19 20:46:15 2022 +0100

    fix: small bug fix

commit a023a2e6a747f4874a27ed37e9086e282ecceea9
Author: Verisana <account@0112.pro>
Date:   Thu May 19 20:44:51 2022 +0100

    feat: update fetchOrderBook function in ILimitOrderProvider

commit 03ec2125339833f5bc4d8023963fa2d125c8d4b0
Author: Verisana <account@0112.pro>
Date:   Thu May 19 18:08:22 2022 +0100

    feat: started adding preprocessTransaction to paraswap limit order

commit bd3ebed37ff8b02f8d7a2e22d44fa870d68e8a9e
Author: Verisana <account@0112.pro>
Date:   Thu May 19 13:26:46 2022 +0100

    feat: remove direct cache usage in paraswap limit-order provider

commit 26e08164485e80f62057100309b700c20e987773
Author: Verisana <account@0112.pro>
Date:   Thu May 19 13:24:13 2022 +0100

    feat: add new fetchOrderBook function to limit order provider

commit 14b06b564b4ae838090a863f240ced53bf24f048
Author: Verisana <account@0112.pro>
Date:   Thu May 19 13:13:13 2022 +0100

    refactor: remove getTopPools implementation in paraswap limit order

commit 6cf3017928eb977596b9bef79c0d06e170598e0d
Merge: 123337b 6acc3d6
Author: Verisana <account@0112.pro>
Date:   Wed May 18 20:49:18 2022 +0100

    Merge branch 'master' into feature/back-585

commit 123337b7a9ad2c2b8833f144bfcce5cc3b630270
Author: Verisana <account@0112.pro>
Date:   Wed May 18 20:41:39 2022 +0100

    feat: add cache prefix in constants

commit c1d3006ec250f0ba8377cc27ebe7dc71f20973d9
Author: Verisana <account@0112.pro>
Date:   Wed May 18 20:41:27 2022 +0100

    feat: implement Dex for limit-order

commit 5a4f857f5341151e00411277b02c1c777f2818b2
Author: Verisana <account@0112.pro>
Date:   Wed May 18 20:40:59 2022 +0100

    feat: adjust interface of iLimitOrderProvider to current needs

commit 268ea0b1cc66e5a90267686cc5684ae9966f40d8
Author: Verisana <account@0112.pro>
Date:   Wed May 18 20:40:23 2022 +0100

    feat: make getAdapterParam syncOrAsync

commit f2d3fe1a3ac7db24e4b9b6422eedd03ec2a8486d
Author: Verisana <account@0112.pro>
Date:   Tue May 17 22:50:17 2022 +0100

    feat: update Paraswap limit order service

commit e6e8ed7d3ee846570b13db0777c2f9b431a31927
Merge: 661e2e4 f84ed57
Author: Verisana <account@0112.pro>
Date:   Tue May 17 19:33:36 2022 +0100

    Merge remote-tracking branch 'dexlib/feature/back-585' into feature/back-585

commit 661e2e42e269ee1fb467f0363ac8e17265e6c123
Merge: 08bc977 0f23e27
Author: Verisana <account@0112.pro>
Date:   Tue May 17 14:37:27 2022 +0100

    Merge branch 'master' into feature/back-585

commit 08bc977662794334292bc4c434796296aad88947
Author: Verisana <account@0112.pro>
Date:   Wed May 4 22:02:20 2022 +0100

    feat: remove initialize pricing for paraswap-limit-order provider

commit 7f76f2dd45844a42c331c5e75a54f9ede6c9bdfe
Author: Verisana <account@0112.pro>
Date:   Wed May 4 21:56:50 2022 +0100

    feat: update implementation for paraswap limit order

commit 586c8ae425abde599e85b9d9c112e62c525e2c8a
Author: Verisana <account@0112.pro>
Date:   Wed May 4 21:55:54 2022 +0100

    feat: update ILimitOrderProvider

commit a5fda4d555c7cd747a10068990ece8a024be286d
Author: Verisana <account@0112.pro>
Date:   Wed May 4 21:54:44 2022 +0100

    test: remove event base test for ParaSwap LimitOrder

commit fda0bf6337f976442c4160de4e761e8a8e6d2dae
Author: Verisana <account@0112.pro>
Date:   Wed May 4 16:22:42 2022 +0100

    feat: use generic for limit-order-exchange

commit 6f7c596d22bedd9bb62386e646a5ee463ddb931c
Author: Verisana <account@0112.pro>
Date:   Wed May 4 16:21:28 2022 +0100

    feat: update all parts for paraswap-limit-order

commit 2304e9220ad7c88d2bb315d1dd618935ead2751d
Author: Verisana <account@0112.pro>
Date:   Wed May 4 16:20:23 2022 +0100

    refactor: move AdapterMappings to src types

commit ca71caef99db7ade2fb32d585ab3744ccfb31dd3
Author: Verisana <account@0112.pro>
Date:   Wed May 4 16:17:07 2022 +0100

    feat: update ilimit-order-providers

commit b3bd025d3aeb3a962893454f15b67fb525c0271a
Author: Verisana <account@0112.pro>
Date:   Tue May 3 21:13:14 2022 +0100

    feat: use enum for namings

commit 1eccc1efb42487d8203b40d753760f25359d566c
Author: Verisana <account@0112.pro>
Date:   Tue May 3 20:01:19 2022 +0100

    feat: initialize paraswap-limit-order integration

commit cbcffe8c76ba34381b9d8a3ba0c8899816097105
Author: Verisana <account@0112.pro>
Date:   Tue May 3 20:00:43 2022 +0100

    feat: create ILimitOrderProvider

commit 0b9107ec1c5febf07a0fa7330427b7a6e17a6506
Author: Verisana <account@0112.pro>
Date:   Tue May 3 20:00:02 2022 +0100

    feat: create LimitOrderExchange from SimpleExchange
  • Loading branch information
Verisana committed Jun 21, 2022
1 parent acab2e5 commit 1fc68d4
Show file tree
Hide file tree
Showing 24 changed files with 1,505 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ tests/logs.json
tests/states.json
tests/configs.json
.idea/
local-scripts
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
"version": "2.0.46",
"main": "build/index.js",
"types": "build/index.d.ts",
"repository": "https://github.com/paraswap/paraswap-dex-lib",
"author": "dev@paraswap.io",
"license": "MIT",
"private": false,
"publishConfig": {
"access": "public"
"access": "restricted"
},
"devDependencies": {
"@types/axios": "0.14.0",
Expand Down Expand Up @@ -41,6 +40,7 @@
"@ethersproject/bytes": "^5.6.1",
"@ethersproject/contracts": "5.4.1",
"@ethersproject/providers": "5.4.1",
"ethers": "^5.6.7",
"lens.ts": "^0.5.1",
"lodash": "4.17.21",
"log4js": "6.3.0",
Expand Down
1 change: 1 addition & 0 deletions src/bigint-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export const BI_POWS = new Array(37)
export const BI_MAX_INT = BigInt(MAX_INT);
export const BI_MAX_UINT = 2n ** 256n - 1n;
export const BI_MAX_UINT96 = 2n ** 96n - 1n;

export const BI_ADDR_MASK = (1n << 160n) - 1n;
4 changes: 4 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ export const AugustusAddress: { [nid: number]: Address } = {
};

export const SUBGRAPH_TIMEOUT = 20 * 1000;

export enum LIMIT_ORDER_PROVIDERS {
PARASWAP = 'ParaSwapLimitOrderProvider',
}
81 changes: 81 additions & 0 deletions src/dex-helper/dummy-limit-order-provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { ILimitOrderProvider } from './ilimit-order-provider';
import {
ParaswapLimitOrderResponse,
ParaswapPriceSummaryResponse,
} from '../dex/paraswap-limit-orders/types';
import { SwapSide, Network, LIMIT_ORDER_PROVIDERS } from '../constants';
import { Address, BigIntAsString } from '../types';

export class DummyLimitOrderProvider
implements
ILimitOrderProvider<
ParaswapLimitOrderResponse,
ParaswapPriceSummaryResponse
>
{
readonly name: LIMIT_ORDER_PROVIDERS = LIMIT_ORDER_PROVIDERS.PARASWAP;

private readonly _priceSummary: {
[key in string]: ParaswapPriceSummaryResponse[];
} = {};

private readonly _ordersToExecute: {
[key in number]: ParaswapLimitOrderResponse[];
} = {};

async fetchAndReserveOrders(
network: Network,
srcAddress: Address,
destAddress: Address,
srcAmount: BigIntAsString,
destAmount: BigIntAsString,
swapSide: SwapSide,
userAddress: Address,
backupOrdersMaxPercent?: number,
backupOrdersMinCount?: number,
): Promise<ParaswapLimitOrderResponse[] | null> {
return this._ordersToExecute[network]
? this._ordersToExecute[network]
: null;
}

async fetchPriceSummary(
network: Network,
src: Address,
dest: Address,
): Promise<ParaswapPriceSummaryResponse[] | null> {
const key = DummyLimitOrderProvider.getPriceSummaryCacheKey(
network,
src,
dest,
);
const priceSummary = this._priceSummary[key];
return priceSummary === undefined ? null : priceSummary;
}

setPriceSummary(
network: Network,
src: Address,
dest: Address,
priceSummary: ParaswapPriceSummaryResponse[],
) {
const key = DummyLimitOrderProvider.getPriceSummaryCacheKey(
network,
src,
dest,
);
this._priceSummary[key] = priceSummary;
}

setOrdersToExecute(network: number, orders: ParaswapLimitOrderResponse[]) {
this._ordersToExecute[network] = orders;
}

static getPriceSummaryCacheKey(
network: Network,
src: Address,
dest: Address,
) {
return `${network}_${dest.toLowerCase()}_${src.toLowerCase()}`;
}
}
30 changes: 30 additions & 0 deletions src/dex-helper/ilimit-order-provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { BigIntAsString, Address } from '../types';
import { LIMIT_ORDER_PROVIDERS, Network } from '../constants';
import { SwapSide } from 'paraswap-core';

export interface ILimitOrderProvider<
LimitOrderResponse,
LimitOrderPriceSummaryResponse,
> {
name: LIMIT_ORDER_PROVIDERS;

// null is for the case when some orders are not available after the lag
// between requesting the prices and actually building the order
fetchAndReserveOrders(
network: Network,
srcAddress: Address,
destAddress: Address,
srcAmount: BigIntAsString,
destAmount: BigIntAsString,
swapSide: SwapSide,
userAddress: Address,
backupOrdersMaxPercent?: number,
backupOrdersMinCount?: number,
): Promise<LimitOrderResponse[] | null>;

fetchPriceSummary(
network: Network,
src: Address,
dest: Address,
): Promise<LimitOrderPriceSummaryResponse[] | null>;
}
2 changes: 2 additions & 0 deletions src/dex-helper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ export { IRequestWrapper } from './irequest-wrapper';
export { IBlockManager, EventSubscriber } from './iblock-manager';

export { DummyDexHelper } from './dummy-dex-helper';

export { DummyLimitOrderProvider } from './dummy-limit-order-provider'
15 changes: 15 additions & 0 deletions src/dex/idex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import {
Token,
ExchangePrices,
PoolLiquidity,
OptimalSwapExchange,
ExchangeTxInfo,
PreprocessTransactionOptions,
} from '../types';
import { SwapSide, Network } from '../constants';
import { IDexHelper } from '../dex-helper/idex-helper';
Expand All @@ -27,6 +30,18 @@ export interface IDexTxBuilder<ExchangeData, DirectParam = null> {
side: SwapSide,
): NumberAsString;

// If exists, called before getAdapterParam to use async calls and receive data if needed
preProcessTransaction?(
optimalSwapExchange: OptimalSwapExchange<ExchangeData>,
srcToken: Token,
destToken: Token,
side: SwapSide,
options: PreprocessTransactionOptions,
): AsyncOrSync<[OptimalSwapExchange<ExchangeData>, ExchangeTxInfo]>;

// This is helper a function to support testing if preProcessTransaction is implemented
getTokenFromAddress?(address: Address): Token;

// Encode params required by the exchange adapter
// Used for multiSwap, buy & megaSwap
getAdapterParam(
Expand Down
6 changes: 4 additions & 2 deletions src/dex/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { Platypus } from './platypus/platypus';
import { GMX } from './gmx/gmx';
import { WooFi } from './woo-fi/woo-fi';
import { Dystopia } from './uniswap-v2/dystopia/dystopia';
import { ParaswapLimitOrders } from './paraswap-limit-orders/paraswap-limit-orders';
import { AugustusRFQOrder } from './augustus-rfq';

const LegacyDexes = [
Expand Down Expand Up @@ -84,6 +85,7 @@ const Dexes = [
GMX,
WooFi,
Dystopia,
ParaswapLimitOrders,
];

const AdapterNameAddressMap: {
Expand All @@ -105,8 +107,8 @@ const AdapterNameAddressMap: {
BscBuyAdapter: '0xdA0DAFbbC95d96bAb164c847112e15c0299541f6',
},
[Network.ROPSTEN]: {
RopstenAdapter01: '0x74fF86C61CF66334dCfc999814DE4695B4BaE57b',
RopstenBuyAdapter: '0xDDbaC07C9ef96D6E792c25Ff934E7e111241BFf1',
RopstenAdapter01: '0x59b7F6258e78C3E5234bb651656EDd0e08868cd5',
RopstenBuyAdapter: '0x63e908A4C793a33e40254362ED1A5997a234D85C',
},
[Network.AVALANCHE]: {
AvalancheAdapter01: '0xC79cf51b0951418cb7B010e38c3ceB8801E53184',
Expand Down
39 changes: 39 additions & 0 deletions src/dex/limit-order-exchange.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Provider } from '@ethersproject/providers';
import { LIMIT_ORDER_PROVIDERS } from '../constants';
import { ILimitOrderProvider } from '../dex-helper/ilimit-order-provider';
import { Address } from '../types';
import { SimpleExchange } from './simple-exchange';

export abstract class LimitOrderExchange<
LimitOrderResponse,
LimitOrderPriceSummaryResponse,
> extends SimpleExchange {
protected _limitOrderProvider?: ILimitOrderProvider<
LimitOrderResponse,
LimitOrderPriceSummaryResponse
>;

constructor(augustusAddress: Address, provider: Provider) {
super(augustusAddress, provider);
}

abstract get limitOrderProviderName(): LIMIT_ORDER_PROVIDERS;

set limitOrderProvider(
limitOrderProvider: ILimitOrderProvider<
LimitOrderResponse,
LimitOrderPriceSummaryResponse
>,
) {
if (
this.limitOrderProviderName.toLowerCase() ===
limitOrderProvider.name.toLowerCase()
) {
this._limitOrderProvider = limitOrderProvider;
} else {
throw new Error(
`Given wrong limitOrderProvider: '${limitOrderProvider.name}'. Expected: '${this.limitOrderProviderName}'`,
);
}
}
}
2 changes: 1 addition & 1 deletion src/dex/nerve/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SwapSide } from 'paraswap-core';
import { DexParams } from './types';
import { DexConfigMap, AdapterMappings } from '../../types';
import { AdapterMappings, DexConfigMap } from '../../types';
import { Network } from '../../constants';
import nervePoolABI from '../../abi/nerve/nerve-pool.json';
import axialPoolABI from '../../abi/nerve/axial-pool.json';
Expand Down
38 changes: 38 additions & 0 deletions src/dex/paraswap-limit-orders/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { DexParams } from './types';
import { AdapterMappings, DexConfigMap } from '../../types';
import { Network, SwapSide } from '../../constants';

export const ParaswapLimitOrdersConfig: DexConfigMap<DexParams> = {
ParaswapLimitOrders: {
[Network.ROPSTEN]: {
rfqAddress: '0x34268C38fcbC798814b058656bC0156C7511c0E4',
},
},
};

export const Adapters: Record<number, AdapterMappings> = {
[Network.AVALANCHE]: {
[SwapSide.SELL]: [{ name: 'AvalancheAdapter01', index: 9 }],
[SwapSide.BUY]: [{ name: 'AvalancheBuyAdapter', index: 2 }],
},
[Network.BSC]: {
[SwapSide.SELL]: [{ name: 'BscAdapter01', index: 13 }],
[SwapSide.BUY]: [{ name: 'BscBuyAdapter', index: 2 }],
},
[Network.FANTOM]: {
[SwapSide.SELL]: [{ name: 'FantomAdapter01', index: 6 }],
[SwapSide.BUY]: [{ name: 'FantomBuyAdapter', index: 2 }],
},
[Network.MAINNET]: {
[SwapSide.SELL]: [{ name: 'Adapter03', index: 9 }],
[SwapSide.BUY]: [{ name: 'BuyAdapter', index: 5 }],
},
[Network.POLYGON]: {
[SwapSide.SELL]: [{ name: 'PolygonAdapter01', index: 14 }],
[SwapSide.BUY]: [{ name: 'PolygonBuyAdapter', index: 3 }],
},
[Network.ROPSTEN]: {
[SwapSide.SELL]: [{ name: 'RopstenAdapter01', index: 2 }],
[SwapSide.BUY]: [{ name: 'RopstenBuyAdapter', index: 2 }],
},
};
1 change: 1 addition & 0 deletions src/dex/paraswap-limit-orders/constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const ONE_ORDER_GASCOST = 65500;
Loading

0 comments on commit 1fc68d4

Please sign in to comment.