@orbs-network/twap 1.7.12 → 1.7.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/configs.d.ts +1 -0
- package/dist/src/configs.js +6 -10
- package/dist/src/lib.d.ts +13 -7
- package/dist/src/lib.js +57 -31
- package/dist/src/paraswap.d.ts +3 -1
- package/dist/src/paraswap.js +7 -2
- package/dist/typechain-hardhat/contracts/IExchange.d.ts +2 -3
- package/dist/typechain-hardhat/contracts/IWETH.d.ts +1 -2
- package/dist/typechain-hardhat/contracts/TWAP.d.ts +9 -10
- package/dist/typechain-hardhat/contracts/exchange/IUniswapV2.d.ts +3 -4
- package/dist/typechain-hardhat/contracts/exchange/ParaswapExchange.d.ts +2 -3
- package/dist/typechain-hardhat/contracts/exchange/UniswapV2Exchange.d.ts +2 -3
- package/dist/typechain-hardhat/contracts/periphery/Lens.d.ts +2 -3
- package/dist/typechain-hardhat/contracts/periphery/Taker.d.ts +2 -3
- package/dist/typechain-hardhat/contracts/test/MockDeflationaryToken.d.ts +5 -6
- package/dist/typechain-hardhat/contracts/test/MockExchange.d.ts +4 -5
- package/dist/typechain-hardhat/types.d.ts +9 -10
- package/package.json +8 -7
package/dist/src/configs.d.ts
CHANGED
package/dist/src/configs.js
CHANGED
|
@@ -36,8 +36,8 @@ exports.ChainConfigs = {
|
|
|
36
36
|
},
|
|
37
37
|
poly: {
|
|
38
38
|
chainId: 137,
|
|
39
|
-
twapAddress: "",
|
|
40
|
-
lensAddress: "",
|
|
39
|
+
twapAddress: "0xBAFdE1cc254BB94Be5866d5a86ddafde4BB44EEF",
|
|
40
|
+
lensAddress: "0xc918bdC47264687796Cd54FE362FaC4f8b99Eb55",
|
|
41
41
|
bidDelaySeconds: 60,
|
|
42
42
|
minChunkSizeUsd: 10,
|
|
43
43
|
wToken: {
|
|
@@ -49,8 +49,8 @@ exports.ChainConfigs = {
|
|
|
49
49
|
},
|
|
50
50
|
avax: {
|
|
51
51
|
chainId: 43114,
|
|
52
|
-
twapAddress: "",
|
|
53
|
-
lensAddress: "",
|
|
52
|
+
twapAddress: "0xD63430c74C8E70D9dbdCA04C6a9E6E9E929028DA",
|
|
53
|
+
lensAddress: "0xD13609A8ace04D11Ea2FFE176B69dF77C6d9375E",
|
|
54
54
|
bidDelaySeconds: 60,
|
|
55
55
|
minChunkSizeUsd: 10,
|
|
56
56
|
wToken: {
|
|
@@ -64,7 +64,8 @@ exports.ChainConfigs = {
|
|
|
64
64
|
exports.Configs = {
|
|
65
65
|
SpiritSwap: Object.assign(Object.assign({}, exports.ChainConfigs.ftm), { partner: "SpiritSwap", exchangeAddress: "0xAd19179201be5A51D1cBd3bB2fC651BB05822404", exchangeType: "ParaswapExchange", pathfinderKey: paraswap_1.Paraswap.OnlyDex.SpiritSwap }),
|
|
66
66
|
SpookySwap: Object.assign(Object.assign({}, exports.ChainConfigs.ftm), { partner: "SpookySwap", exchangeAddress: "0x37F427DA0D12Fe2C80aCa09EE08e7e92A1B2B114", exchangeType: "UniswapV2Exchange", pathfinderKey: paraswap_1.Paraswap.OnlyDex.SpookySwap }),
|
|
67
|
-
Pangolin: Object.assign(Object.assign({}, exports.ChainConfigs.avax), { partner: "Pangolin", exchangeAddress: "", exchangeType: "UniswapV2Exchange", pathfinderKey: paraswap_1.Paraswap.OnlyDex.Pangolin }),
|
|
67
|
+
Pangolin: Object.assign(Object.assign({}, exports.ChainConfigs.avax), { partner: "Pangolin", exchangeAddress: "0x25a0A78f5ad07b2474D3D42F1c1432178465936d", exchangeType: "UniswapV2Exchange", pathfinderKey: paraswap_1.Paraswap.OnlyDex.Pangolin }),
|
|
68
|
+
QuickSwap: Object.assign(Object.assign({}, exports.ChainConfigs.poly), { partner: "QuickSwap", exchangeAddress: "0xeFE1B6096838949156e5130604434A2a13c68C68", exchangeType: "UniswapV2Exchange", pathfinderKey: paraswap_1.Paraswap.OnlyDex.QuickSwap }),
|
|
68
69
|
};
|
|
69
70
|
// export const UniswapV2Config: Config = {
|
|
70
71
|
// ...ChainConfigs.eth,
|
|
@@ -76,11 +77,6 @@ exports.Configs = {
|
|
|
76
77
|
// partner: "SushiSwap",
|
|
77
78
|
// exchangeAddress: "0x72a18A408e329E7052d08aA0746243Dc30Ad2530",
|
|
78
79
|
// };
|
|
79
|
-
// export const QuickSwapConfig: Config = {
|
|
80
|
-
// ...ChainConfigs.poly,
|
|
81
|
-
// partner: "QuickSwap",
|
|
82
|
-
// exchangeAddress: "0xeFE1B6096838949156e5130604434A2a13c68C68",
|
|
83
|
-
// };
|
|
84
80
|
exports.nativeTokenAddresses = [
|
|
85
81
|
web3_candies_1.zeroAddress,
|
|
86
82
|
"0x0000000000000000000000000000000000001010",
|
package/dist/src/lib.d.ts
CHANGED
|
@@ -27,20 +27,26 @@ export declare class TWAPLib {
|
|
|
27
27
|
percentAboveMarket: (srcUsdMarket: BN.Value, dstUsdMarket: BN.Value, limitDstPriceFor1Src: BN.Value) => number;
|
|
28
28
|
status: (order: Order) => Status;
|
|
29
29
|
makerBalance(token: TokenData): Promise<BN>;
|
|
30
|
-
wrapNativeToken(amount: BN.Value,
|
|
31
|
-
unwrapNativeToken(amount: BN.Value,
|
|
32
|
-
waitForConfirmation<T>(fn: () => Promise<T>): Promise<T>;
|
|
30
|
+
wrapNativeToken(amount: BN.Value, maxPriorityFeePerGas?: BN.Value, maxFeePerGas?: BN.Value): Promise<void>;
|
|
31
|
+
unwrapNativeToken(amount: BN.Value, maxPriorityFeePerGas?: BN.Value, maxFeePerGas?: BN.Value): Promise<void>;
|
|
33
32
|
hasAllowance(srcToken: TokenData, amount: BN.Value): Promise<boolean>;
|
|
34
|
-
approve(srcToken: TokenData, amount: BN.Value,
|
|
33
|
+
approve(srcToken: TokenData, amount: BN.Value, maxPriorityFeePerGas?: BN.Value, maxFeePerGas?: BN.Value): Promise<void>;
|
|
35
34
|
validateTokens(srcToken: TokenData, dstToken: TokenData): TokensValidation;
|
|
36
35
|
validateOrderInputs(srcToken: TokenData, dstToken: TokenData, srcAmount: BN.Value, srcChunkAmount: BN.Value, dstMinChunkAmountOut: BN.Value, deadline: BN.Value, fillDelaySeconds: BN.Value, srcUsd: BN.Value): OrderInputValidation;
|
|
37
|
-
submitOrder(srcToken: TokenData, dstToken: TokenData, srcAmount: BN.Value, srcChunkAmount: BN.Value, dstMinChunkAmountOut: BN.Value, deadline: number, fillDelaySeconds: number, srcUsd: BN.Value,
|
|
36
|
+
submitOrder(srcToken: TokenData, dstToken: TokenData, srcAmount: BN.Value, srcChunkAmount: BN.Value, dstMinChunkAmountOut: BN.Value, deadline: number, fillDelaySeconds: number, srcUsd: BN.Value, maxPriorityFeePerGas?: BN.Value, maxFeePerGas?: BN.Value): Promise<number>;
|
|
38
37
|
getOrder(id: number): Promise<Order>;
|
|
39
|
-
cancelOrder(id: number,
|
|
38
|
+
cancelOrder(id: number, maxPriorityFeePerGas?: BN.Value, maxFeePerGas?: BN.Value): Promise<void>;
|
|
40
39
|
getAllOrders(): Promise<Order[]>;
|
|
41
|
-
private sendTx;
|
|
42
40
|
parseOrder(r: any): Order;
|
|
43
41
|
getToken(address: string): Promise<TokenData>;
|
|
42
|
+
getSwapData(orderId: number): Promise<{
|
|
43
|
+
srcToken: TokenData;
|
|
44
|
+
dstToken: TokenData;
|
|
45
|
+
srcAmountIn: BN;
|
|
46
|
+
dstAmountOut: BN;
|
|
47
|
+
path: any;
|
|
48
|
+
data: string;
|
|
49
|
+
}>;
|
|
44
50
|
}
|
|
45
51
|
export interface Order {
|
|
46
52
|
id: number;
|
package/dist/src/lib.js
CHANGED
|
@@ -20,6 +20,7 @@ const web3_candies_1 = require("@defi.org/web3-candies");
|
|
|
20
20
|
const TWAP_json_1 = __importDefault(require("../artifacts/contracts/TWAP.sol/TWAP.json"));
|
|
21
21
|
const Lens_json_1 = __importDefault(require("../artifacts/contracts/periphery/Lens.sol/Lens.json"));
|
|
22
22
|
const Taker_json_1 = __importDefault(require("../artifacts/contracts/periphery/Taker.sol/Taker.json"));
|
|
23
|
+
const paraswap_1 = require("./paraswap");
|
|
23
24
|
const lodash_1 = __importDefault(require("lodash"));
|
|
24
25
|
exports.twapAbi = TWAP_json_1.default.abi;
|
|
25
26
|
exports.lensAbi = Lens_json_1.default.abi;
|
|
@@ -72,24 +73,14 @@ class TWAPLib {
|
|
|
72
73
|
return (0, web3_candies_1.erc20)(token.symbol, token.address, token.decimals).methods.balanceOf(this.maker).call().then(bignumber_js_1.default);
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
|
-
wrapNativeToken(amount,
|
|
76
|
+
wrapNativeToken(amount, maxPriorityFeePerGas, maxFeePerGas) {
|
|
76
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
|
|
78
|
+
yield (0, web3_candies_1.sendAndWaitForConfirmations)((0, web3_candies_1.erc20)(this.config.wToken.symbol, this.config.wToken.address, this.config.wToken.decimals, web3_candies_1.iwethabi).methods.deposit(), { from: this.maker, maxPriorityFeePerGas, maxFeePerGas, value: amount });
|
|
78
79
|
});
|
|
79
80
|
}
|
|
80
|
-
unwrapNativeToken(amount,
|
|
81
|
+
unwrapNativeToken(amount, maxPriorityFeePerGas, maxFeePerGas) {
|
|
81
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
waitForConfirmation(fn) {
|
|
86
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
const nonceBefore = yield (0, web3_candies_1.web3)().eth.getTransactionCount(this.maker);
|
|
88
|
-
const result = yield fn();
|
|
89
|
-
while ((yield (0, web3_candies_1.web3)().eth.getTransactionCount(this.maker)) === nonceBefore) {
|
|
90
|
-
yield new Promise((r) => setTimeout(r, 1000));
|
|
91
|
-
}
|
|
92
|
-
return result;
|
|
83
|
+
yield (0, web3_candies_1.sendAndWaitForConfirmations)((0, web3_candies_1.erc20)(this.config.wToken.symbol, this.config.wToken.address, this.config.wToken.decimals, web3_candies_1.iwethabi).methods.withdraw((0, bignumber_js_1.default)(amount).toFixed(0)), { from: this.maker, maxPriorityFeePerGas, maxFeePerGas });
|
|
93
84
|
});
|
|
94
85
|
}
|
|
95
86
|
hasAllowance(srcToken, amount) {
|
|
@@ -101,10 +92,14 @@ class TWAPLib {
|
|
|
101
92
|
return allowance.gte(amount);
|
|
102
93
|
});
|
|
103
94
|
}
|
|
104
|
-
approve(srcToken, amount,
|
|
95
|
+
approve(srcToken, amount, maxPriorityFeePerGas, maxFeePerGas) {
|
|
105
96
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
97
|
const token = (0, web3_candies_1.erc20)(srcToken.symbol, srcToken.address, srcToken.decimals);
|
|
107
|
-
yield
|
|
98
|
+
yield (0, web3_candies_1.sendAndWaitForConfirmations)(token.methods.approve(this.config.twapAddress, (0, bignumber_js_1.default)(amount).toFixed(0)), {
|
|
99
|
+
from: this.maker,
|
|
100
|
+
maxPriorityFeePerGas,
|
|
101
|
+
maxFeePerGas,
|
|
102
|
+
});
|
|
108
103
|
});
|
|
109
104
|
}
|
|
110
105
|
validateTokens(srcToken, dstToken) {
|
|
@@ -143,12 +138,16 @@ class TWAPLib {
|
|
|
143
138
|
return OrderInputValidation.invalidSmallestSrcChunkUsd;
|
|
144
139
|
return OrderInputValidation.valid;
|
|
145
140
|
}
|
|
146
|
-
submitOrder(srcToken, dstToken, srcAmount, srcChunkAmount, dstMinChunkAmountOut, deadline, fillDelaySeconds, srcUsd,
|
|
141
|
+
submitOrder(srcToken, dstToken, srcAmount, srcChunkAmount, dstMinChunkAmountOut, deadline, fillDelaySeconds, srcUsd, maxPriorityFeePerGas, maxFeePerGas) {
|
|
147
142
|
return __awaiter(this, void 0, void 0, function* () {
|
|
148
143
|
let validation = this.validateOrderInputs(srcToken, dstToken, srcAmount, srcChunkAmount, dstMinChunkAmountOut, deadline, fillDelaySeconds, srcUsd);
|
|
149
144
|
if (validation !== OrderInputValidation.valid)
|
|
150
145
|
throw new Error(`invalid inputs: ${validation}`);
|
|
151
|
-
const tx = yield
|
|
146
|
+
const tx = yield (0, web3_candies_1.sendAndWaitForConfirmations)(this.twap.methods.ask(this.config.exchangeAddress, srcToken.address, dstToken.address, (0, bignumber_js_1.default)(srcAmount).toFixed(0), (0, bignumber_js_1.default)(srcChunkAmount).toFixed(0), (0, bignumber_js_1.default)(dstMinChunkAmountOut).toFixed(0), (0, bignumber_js_1.default)(deadline).div(1000).toFixed(0), (0, bignumber_js_1.default)(this.config.bidDelaySeconds).toFixed(0), (0, bignumber_js_1.default)(fillDelaySeconds).toFixed(0)), {
|
|
147
|
+
from: this.maker,
|
|
148
|
+
maxPriorityFeePerGas,
|
|
149
|
+
maxFeePerGas,
|
|
150
|
+
});
|
|
152
151
|
const events = (0, web3_candies_1.parseEvents)(tx, this.twap.options.jsonInterface);
|
|
153
152
|
return Number(events[0].returnValues.id);
|
|
154
153
|
});
|
|
@@ -158,9 +157,13 @@ class TWAPLib {
|
|
|
158
157
|
return this.parseOrder(yield this.twap.methods.order(id).call());
|
|
159
158
|
});
|
|
160
159
|
}
|
|
161
|
-
cancelOrder(id,
|
|
160
|
+
cancelOrder(id, maxPriorityFeePerGas, maxFeePerGas) {
|
|
162
161
|
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
-
yield
|
|
162
|
+
yield (0, web3_candies_1.sendAndWaitForConfirmations)(this.twap.methods.cancel(id), {
|
|
163
|
+
from: this.maker,
|
|
164
|
+
maxPriorityFeePerGas,
|
|
165
|
+
maxFeePerGas,
|
|
166
|
+
});
|
|
164
167
|
});
|
|
165
168
|
}
|
|
166
169
|
getAllOrders() {
|
|
@@ -168,17 +171,6 @@ class TWAPLib {
|
|
|
168
171
|
return lodash_1.default.map(yield this.lens.methods.makerOrders(this.maker).call(), (o) => this.parseOrder(o));
|
|
169
172
|
});
|
|
170
173
|
}
|
|
171
|
-
sendTx(tx, priorityFeePerGas, maxFeePerGas, amount) {
|
|
172
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
173
|
-
return yield tx.send({
|
|
174
|
-
from: this.maker,
|
|
175
|
-
gas: Math.floor((yield tx.estimateGas({ from: this.maker, value: amount ? (0, bignumber_js_1.default)(amount).toFixed(0) : undefined })) * 1.2),
|
|
176
|
-
maxPriorityFeePerGas: priorityFeePerGas ? (0, bignumber_js_1.default)(priorityFeePerGas).toFixed(0) : undefined,
|
|
177
|
-
maxFeePerGas: maxFeePerGas ? (0, bignumber_js_1.default)(maxFeePerGas).toFixed(0) : undefined,
|
|
178
|
-
value: amount ? (0, bignumber_js_1.default)(amount).toFixed(0) : undefined,
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
174
|
parseOrder(r) {
|
|
183
175
|
var _a, _b, _c, _d, _e, _f;
|
|
184
176
|
return {
|
|
@@ -217,6 +209,40 @@ class TWAPLib {
|
|
|
217
209
|
return { address, decimals: yield t.decimals(), symbol: yield t.methods.symbol().call() };
|
|
218
210
|
});
|
|
219
211
|
}
|
|
212
|
+
//TODO
|
|
213
|
+
getSwapData(orderId) {
|
|
214
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
const order = yield this.getOrder(orderId);
|
|
216
|
+
const srcAmountIn = order.ask.srcBidAmount;
|
|
217
|
+
const srcToken = yield this.getToken(order.ask.srcToken);
|
|
218
|
+
const dstToken = yield this.getToken(order.ask.dstToken);
|
|
219
|
+
const paraswapRoute = yield paraswap_1.Paraswap.findRoute(this.config.chainId, srcToken, dstToken, srcAmountIn, this.config.pathfinderKey);
|
|
220
|
+
const dstAmountOut = (0, bignumber_js_1.default)(paraswapRoute.destAmount);
|
|
221
|
+
const path = paraswap_1.Paraswap.directPath(paraswapRoute, this.config.pathfinderKey);
|
|
222
|
+
switch (this.config.exchangeType) {
|
|
223
|
+
case "UniswapV2Exchange":
|
|
224
|
+
return {
|
|
225
|
+
srcToken,
|
|
226
|
+
dstToken,
|
|
227
|
+
srcAmountIn,
|
|
228
|
+
dstAmountOut,
|
|
229
|
+
path,
|
|
230
|
+
data: (0, web3_candies_1.web3)().eth.abi.encodeParameters(["bool", "address[]"], [false, path]),
|
|
231
|
+
};
|
|
232
|
+
case "ParaswapExchange":
|
|
233
|
+
return {
|
|
234
|
+
srcToken,
|
|
235
|
+
dstToken,
|
|
236
|
+
srcAmountIn,
|
|
237
|
+
dstAmountOut,
|
|
238
|
+
path,
|
|
239
|
+
data: yield paraswap_1.Paraswap.buildSwapData(paraswapRoute, this.config.twapAddress),
|
|
240
|
+
};
|
|
241
|
+
default:
|
|
242
|
+
throw new Error(`unhandled exchange ${this.config.exchangeType}`);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
220
246
|
}
|
|
221
247
|
exports.TWAPLib = TWAPLib;
|
|
222
248
|
var Status;
|
package/dist/src/paraswap.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ export declare namespace Paraswap {
|
|
|
7
7
|
QuickSwap = "QuickSwap",
|
|
8
8
|
SpiritSwap = "SpiritSwap,SpiritSwapV2",
|
|
9
9
|
SpookySwap = "SpookySwap",
|
|
10
|
-
Pangolin = "
|
|
10
|
+
Pangolin = "PangolinDEX",
|
|
11
|
+
TraderJoe = "TraderJoe"
|
|
11
12
|
}
|
|
12
13
|
interface ParaswapRoute {
|
|
13
14
|
blockNumber: number;
|
|
@@ -39,5 +40,6 @@ export declare namespace Paraswap {
|
|
|
39
40
|
}>;
|
|
40
41
|
function priceUsd(chainId: number, token: TokenData): Promise<BN>;
|
|
41
42
|
function findRoute(chainId: number, src: TokenData, dst: TokenData, amountIn: BN.Value, onlyDex?: OnlyDex): Promise<ParaswapRoute>;
|
|
43
|
+
function directPath(route: ParaswapRoute, onlyDex: OnlyDex): any;
|
|
42
44
|
function buildSwapData(paraswapRoute: ParaswapRoute, exchangeAdapter: string): Promise<string>;
|
|
43
45
|
}
|
package/dist/src/paraswap.js
CHANGED
|
@@ -26,7 +26,8 @@ var Paraswap;
|
|
|
26
26
|
OnlyDex["QuickSwap"] = "QuickSwap";
|
|
27
27
|
OnlyDex["SpiritSwap"] = "SpiritSwap,SpiritSwapV2";
|
|
28
28
|
OnlyDex["SpookySwap"] = "SpookySwap";
|
|
29
|
-
OnlyDex["Pangolin"] = "
|
|
29
|
+
OnlyDex["Pangolin"] = "PangolinDEX";
|
|
30
|
+
OnlyDex["TraderJoe"] = "TraderJoe";
|
|
30
31
|
})(OnlyDex = Paraswap.OnlyDex || (Paraswap.OnlyDex = {}));
|
|
31
32
|
function gasPrices(chainId) {
|
|
32
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -69,10 +70,14 @@ var Paraswap;
|
|
|
69
70
|
const response = yield fetch(`${URL}/prices/?${params}`);
|
|
70
71
|
if (response.status < 200 || response.status >= 400)
|
|
71
72
|
throw new Error(`${response.statusText}`);
|
|
72
|
-
return (yield response.json()).priceRoute;
|
|
73
|
+
return (yield response.json()).priceRoute; //TODO pangolin onlyDex not working?
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
76
|
Paraswap.findRoute = findRoute;
|
|
77
|
+
function directPath(route, onlyDex) {
|
|
78
|
+
return route.bestRoute[0].swaps[0].swapExchanges[0].data.path; // TODO find?
|
|
79
|
+
}
|
|
80
|
+
Paraswap.directPath = directPath;
|
|
76
81
|
function buildSwapData(paraswapRoute, exchangeAdapter) {
|
|
77
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
83
|
const response = yield fetch(`${URL}/transactions/${paraswapRoute.network}?ignoreChecks=true`, {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type BN from "bn.js";
|
|
3
2
|
import type BigNumber from "bignumber.js";
|
|
4
3
|
import type { ContractOptions } from "web3-eth-contract";
|
|
5
4
|
import type { EventLog } from "web3-core";
|
|
@@ -14,8 +13,8 @@ export interface IExchange extends BaseContract {
|
|
|
14
13
|
constructor(jsonInterface: any[], address?: string, options?: ContractOptions): IExchange;
|
|
15
14
|
clone(): IExchange;
|
|
16
15
|
methods: {
|
|
17
|
-
getAmountOut(srcToken: string, dstToken: string, amountIn: number | string |
|
|
18
|
-
swap(srcToken: string, dstToken: string, amountIn: number | string |
|
|
16
|
+
getAmountOut(srcToken: string, dstToken: string, amountIn: number | string | BigNumber, data: string | number[]): NonPayableTransactionObject<string>;
|
|
17
|
+
swap(srcToken: string, dstToken: string, amountIn: number | string | BigNumber, amountOutMin: number | string | BigNumber, data: string | number[]): NonPayableTransactionObject<void>;
|
|
19
18
|
};
|
|
20
19
|
events: {
|
|
21
20
|
allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type BN from "bn.js";
|
|
3
2
|
import type BigNumber from "bignumber.js";
|
|
4
3
|
import type { ContractOptions } from "web3-eth-contract";
|
|
5
4
|
import type { EventLog } from "web3-core";
|
|
@@ -14,7 +13,7 @@ export interface IWETH extends BaseContract {
|
|
|
14
13
|
constructor(jsonInterface: any[], address?: string, options?: ContractOptions): IWETH;
|
|
15
14
|
clone(): IWETH;
|
|
16
15
|
methods: {
|
|
17
|
-
withdraw(wad: number | string |
|
|
16
|
+
withdraw(wad: number | string | BigNumber): NonPayableTransactionObject<void>;
|
|
18
17
|
};
|
|
19
18
|
events: {
|
|
20
19
|
allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type BN from "bn.js";
|
|
3
2
|
import type BigNumber from "bignumber.js";
|
|
4
3
|
import type { ContractOptions } from "web3-eth-contract";
|
|
5
4
|
import type { EventLog } from "web3-core";
|
|
@@ -103,9 +102,9 @@ export interface TWAP extends BaseContract {
|
|
|
103
102
|
STATUS_CANCELED(): NonPayableTransactionObject<string>;
|
|
104
103
|
STATUS_COMPLETED(): NonPayableTransactionObject<string>;
|
|
105
104
|
VERSION(): NonPayableTransactionObject<string>;
|
|
106
|
-
ask(exchange: string, srcToken: string, dstToken: string, srcAmount: number | string |
|
|
107
|
-
bid(id: number | string |
|
|
108
|
-
book(arg0: number | string |
|
|
105
|
+
ask(exchange: string, srcToken: string, dstToken: string, srcAmount: number | string | BigNumber, srcBidAmount: number | string | BigNumber, dstMinAmount: number | string | BigNumber, deadline: number | string | BigNumber, bidDelay: number | string | BigNumber, fillDelay: number | string | BigNumber): NonPayableTransactionObject<string>;
|
|
106
|
+
bid(id: number | string | BigNumber, exchange: string, dstFee: number | string | BigNumber, slippagePercent: number | string | BigNumber, data: string | number[]): NonPayableTransactionObject<void>;
|
|
107
|
+
book(arg0: number | string | BigNumber): NonPayableTransactionObject<{
|
|
109
108
|
id: string;
|
|
110
109
|
status: string;
|
|
111
110
|
filledTime: string;
|
|
@@ -143,12 +142,12 @@ export interface TWAP extends BaseContract {
|
|
|
143
142
|
];
|
|
144
143
|
5: [string, string, string, string, string, string];
|
|
145
144
|
}>;
|
|
146
|
-
cancel(id: number | string |
|
|
147
|
-
fill(id: number | string |
|
|
145
|
+
cancel(id: number | string | BigNumber): NonPayableTransactionObject<void>;
|
|
146
|
+
fill(id: number | string | BigNumber): NonPayableTransactionObject<void>;
|
|
148
147
|
iweth(): NonPayableTransactionObject<string>;
|
|
149
148
|
length(): NonPayableTransactionObject<string>;
|
|
150
|
-
makerOrders(arg0: string, arg1: number | string |
|
|
151
|
-
order(id: number | string |
|
|
149
|
+
makerOrders(arg0: string, arg1: number | string | BigNumber): NonPayableTransactionObject<string>;
|
|
150
|
+
order(id: number | string | BigNumber): NonPayableTransactionObject<[
|
|
152
151
|
string,
|
|
153
152
|
string,
|
|
154
153
|
string,
|
|
@@ -176,8 +175,8 @@ export interface TWAP extends BaseContract {
|
|
|
176
175
|
]
|
|
177
176
|
]>;
|
|
178
177
|
orderIdsByMaker(maker: string): NonPayableTransactionObject<string[]>;
|
|
179
|
-
prune(id: number | string |
|
|
180
|
-
status(arg0: number | string |
|
|
178
|
+
prune(id: number | string | BigNumber): NonPayableTransactionObject<void>;
|
|
179
|
+
status(arg0: number | string | BigNumber): NonPayableTransactionObject<string>;
|
|
181
180
|
};
|
|
182
181
|
events: {
|
|
183
182
|
OrderBid(cb?: Callback<OrderBid>): EventEmitter;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type BN from "bn.js";
|
|
3
2
|
import type BigNumber from "bignumber.js";
|
|
4
3
|
import type { ContractOptions } from "web3-eth-contract";
|
|
5
4
|
import type { EventLog } from "web3-core";
|
|
@@ -14,9 +13,9 @@ export interface IUniswapV2 extends BaseContract {
|
|
|
14
13
|
constructor(jsonInterface: any[], address?: string, options?: ContractOptions): IUniswapV2;
|
|
15
14
|
clone(): IUniswapV2;
|
|
16
15
|
methods: {
|
|
17
|
-
getAmountsOut(amountIn: number | string |
|
|
18
|
-
swapExactTokensForTokens(amountIn: number | string |
|
|
19
|
-
swapExactTokensForTokensSupportingFeeOnTransferTokens(amountIn: number | string |
|
|
16
|
+
getAmountsOut(amountIn: number | string | BigNumber, path: string[]): NonPayableTransactionObject<string[]>;
|
|
17
|
+
swapExactTokensForTokens(amountIn: number | string | BigNumber, amountOutMin: number | string | BigNumber, path: string[], to: string, deadline: number | string | BigNumber): NonPayableTransactionObject<string[]>;
|
|
18
|
+
swapExactTokensForTokensSupportingFeeOnTransferTokens(amountIn: number | string | BigNumber, amountOutMin: number | string | BigNumber, path: string[], to: string, deadline: number | string | BigNumber): NonPayableTransactionObject<void>;
|
|
20
19
|
};
|
|
21
20
|
events: {
|
|
22
21
|
allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type BN from "bn.js";
|
|
3
2
|
import type BigNumber from "bignumber.js";
|
|
4
3
|
import type { ContractOptions } from "web3-eth-contract";
|
|
5
4
|
import type { EventLog } from "web3-core";
|
|
@@ -14,9 +13,9 @@ export interface ParaswapExchange extends BaseContract {
|
|
|
14
13
|
constructor(jsonInterface: any[], address?: string, options?: ContractOptions): ParaswapExchange;
|
|
15
14
|
clone(): ParaswapExchange;
|
|
16
15
|
methods: {
|
|
17
|
-
getAmountOut(arg0: string, arg1: string, arg2: number | string |
|
|
16
|
+
getAmountOut(arg0: string, arg1: string, arg2: number | string | BigNumber, data: string | number[]): NonPayableTransactionObject<string>;
|
|
18
17
|
paraswap(): NonPayableTransactionObject<string>;
|
|
19
|
-
swap(_srcToken: string, _dstToken: string, amountIn: number | string |
|
|
18
|
+
swap(_srcToken: string, _dstToken: string, amountIn: number | string | BigNumber, amountOutMin: number | string | BigNumber, data: string | number[]): NonPayableTransactionObject<void>;
|
|
20
19
|
};
|
|
21
20
|
events: {
|
|
22
21
|
allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type BN from "bn.js";
|
|
3
2
|
import type BigNumber from "bignumber.js";
|
|
4
3
|
import type { ContractOptions } from "web3-eth-contract";
|
|
5
4
|
import type { EventLog } from "web3-core";
|
|
@@ -14,8 +13,8 @@ export interface UniswapV2Exchange extends BaseContract {
|
|
|
14
13
|
constructor(jsonInterface: any[], address?: string, options?: ContractOptions): UniswapV2Exchange;
|
|
15
14
|
clone(): UniswapV2Exchange;
|
|
16
15
|
methods: {
|
|
17
|
-
getAmountOut(arg0: string, arg1: string, amountIn: number | string |
|
|
18
|
-
swap(_srcToken: string, arg1: string, amountIn: number | string |
|
|
16
|
+
getAmountOut(arg0: string, arg1: string, amountIn: number | string | BigNumber, data: string | number[]): NonPayableTransactionObject<string>;
|
|
17
|
+
swap(_srcToken: string, arg1: string, amountIn: number | string | BigNumber, amountOutMin: number | string | BigNumber, data: string | number[]): NonPayableTransactionObject<void>;
|
|
19
18
|
uniswap(): NonPayableTransactionObject<string>;
|
|
20
19
|
};
|
|
21
20
|
events: {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type BN from "bn.js";
|
|
3
2
|
import type BigNumber from "bignumber.js";
|
|
4
3
|
import type { ContractOptions } from "web3-eth-contract";
|
|
5
4
|
import type { EventLog } from "web3-core";
|
|
@@ -42,7 +41,7 @@ export interface Lens extends BaseContract {
|
|
|
42
41
|
string
|
|
43
42
|
]
|
|
44
43
|
][]>;
|
|
45
|
-
takerBiddableOrders(taker: string, lastIndex: number | string |
|
|
44
|
+
takerBiddableOrders(taker: string, lastIndex: number | string | BigNumber, pageSize: number | string | BigNumber): NonPayableTransactionObject<[
|
|
46
45
|
string,
|
|
47
46
|
string,
|
|
48
47
|
string,
|
|
@@ -69,7 +68,7 @@ export interface Lens extends BaseContract {
|
|
|
69
68
|
string
|
|
70
69
|
]
|
|
71
70
|
][]>;
|
|
72
|
-
takerFillableOrders(taker: string, lastIndex: number | string |
|
|
71
|
+
takerFillableOrders(taker: string, lastIndex: number | string | BigNumber, pageSize: number | string | BigNumber): NonPayableTransactionObject<[
|
|
73
72
|
string,
|
|
74
73
|
string,
|
|
75
74
|
string,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type BN from "bn.js";
|
|
3
2
|
import type BigNumber from "bignumber.js";
|
|
4
3
|
import type { ContractOptions } from "web3-eth-contract";
|
|
5
4
|
import type { EventLog } from "web3-core";
|
|
@@ -14,8 +13,8 @@ export interface Taker extends BaseContract {
|
|
|
14
13
|
constructor(jsonInterface: any[], address?: string, options?: ContractOptions): Taker;
|
|
15
14
|
clone(): Taker;
|
|
16
15
|
methods: {
|
|
17
|
-
bid(id: number | string |
|
|
18
|
-
fill(id: number | string |
|
|
16
|
+
bid(id: number | string | BigNumber, exchange: string, dstFee: number | string | BigNumber, slippagePercent: number | string | BigNumber, data: string | number[]): NonPayableTransactionObject<void>;
|
|
17
|
+
fill(id: number | string | BigNumber, feeExchange: string, feeMinAmountOut: number | string | BigNumber, feeData: string | number[]): NonPayableTransactionObject<void>;
|
|
19
18
|
owners(arg0: string): NonPayableTransactionObject<boolean>;
|
|
20
19
|
rescue(token: string): NonPayableTransactionObject<void>;
|
|
21
20
|
twap(): NonPayableTransactionObject<string>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type BN from "bn.js";
|
|
3
2
|
import type BigNumber from "bignumber.js";
|
|
4
3
|
import type { ContractOptions } from "web3-eth-contract";
|
|
5
4
|
import type { EventLog } from "web3-core";
|
|
@@ -31,16 +30,16 @@ export interface MockDeflationaryToken extends BaseContract {
|
|
|
31
30
|
clone(): MockDeflationaryToken;
|
|
32
31
|
methods: {
|
|
33
32
|
allowance(owner: string, spender: string): NonPayableTransactionObject<string>;
|
|
34
|
-
approve(spender: string, amount: number | string |
|
|
33
|
+
approve(spender: string, amount: number | string | BigNumber): NonPayableTransactionObject<boolean>;
|
|
35
34
|
balanceOf(account: string): NonPayableTransactionObject<string>;
|
|
36
35
|
decimals(): NonPayableTransactionObject<string>;
|
|
37
|
-
decreaseAllowance(spender: string, subtractedValue: number | string |
|
|
38
|
-
increaseAllowance(spender: string, addedValue: number | string |
|
|
36
|
+
decreaseAllowance(spender: string, subtractedValue: number | string | BigNumber): NonPayableTransactionObject<boolean>;
|
|
37
|
+
increaseAllowance(spender: string, addedValue: number | string | BigNumber): NonPayableTransactionObject<boolean>;
|
|
39
38
|
name(): NonPayableTransactionObject<string>;
|
|
40
39
|
symbol(): NonPayableTransactionObject<string>;
|
|
41
40
|
totalSupply(): NonPayableTransactionObject<string>;
|
|
42
|
-
transfer(to: string, amount: number | string |
|
|
43
|
-
transferFrom(from: string, to: string, amount: number | string |
|
|
41
|
+
transfer(to: string, amount: number | string | BigNumber): NonPayableTransactionObject<boolean>;
|
|
42
|
+
transferFrom(from: string, to: string, amount: number | string | BigNumber): NonPayableTransactionObject<boolean>;
|
|
44
43
|
};
|
|
45
44
|
events: {
|
|
46
45
|
Approval(cb?: Callback<Approval>): EventEmitter;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type BN from "bn.js";
|
|
3
2
|
import type BigNumber from "bignumber.js";
|
|
4
3
|
import type { ContractOptions } from "web3-eth-contract";
|
|
5
4
|
import type { EventLog } from "web3-core";
|
|
@@ -14,10 +13,10 @@ export interface MockExchange extends BaseContract {
|
|
|
14
13
|
constructor(jsonInterface: any[], address?: string, options?: ContractOptions): MockExchange;
|
|
15
14
|
clone(): MockExchange;
|
|
16
15
|
methods: {
|
|
17
|
-
amounts(arg0: number | string |
|
|
18
|
-
getAmountOut(arg0: string, arg1: string, arg2: number | string |
|
|
19
|
-
setMockAmounts(_amounts: (number | string |
|
|
20
|
-
swap(_srcToken: string, _dstToken: string, amountIn: number | string |
|
|
16
|
+
amounts(arg0: number | string | BigNumber): NonPayableTransactionObject<string>;
|
|
17
|
+
getAmountOut(arg0: string, arg1: string, arg2: number | string | BigNumber, arg3: string | number[]): NonPayableTransactionObject<string>;
|
|
18
|
+
setMockAmounts(_amounts: (number | string | BigNumber)[]): NonPayableTransactionObject<void>;
|
|
19
|
+
swap(_srcToken: string, _dstToken: string, amountIn: number | string | BigNumber, arg3: number | string | BigNumber, arg4: string | number[]): NonPayableTransactionObject<void>;
|
|
21
20
|
};
|
|
22
21
|
events: {
|
|
23
22
|
allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type BN from "bn.js";
|
|
3
2
|
import type BigNumber from "bignumber.js";
|
|
4
3
|
import type { EventEmitter } from "events";
|
|
5
4
|
import type { EventLog, PromiEvent, TransactionReceipt } from "web3-core/types";
|
|
@@ -7,7 +6,7 @@ import type { Contract } from "web3-eth-contract";
|
|
|
7
6
|
export interface EstimateGasOptions {
|
|
8
7
|
from?: string;
|
|
9
8
|
gas?: number;
|
|
10
|
-
value?: number | string |
|
|
9
|
+
value?: number | string | BigNumber;
|
|
11
10
|
}
|
|
12
11
|
export interface EventOptions {
|
|
13
12
|
filter?: object;
|
|
@@ -24,18 +23,18 @@ export interface ContractEventEmitter<T> extends EventEmitter {
|
|
|
24
23
|
on(event: "error", listener: (error: Error) => void): this;
|
|
25
24
|
}
|
|
26
25
|
export interface NonPayableTx {
|
|
27
|
-
nonce?: string | number |
|
|
28
|
-
chainId?: string | number |
|
|
26
|
+
nonce?: string | number | BigNumber;
|
|
27
|
+
chainId?: string | number | BigNumber;
|
|
29
28
|
from?: string;
|
|
30
29
|
to?: string;
|
|
31
30
|
data?: string;
|
|
32
|
-
gas?: string | number |
|
|
33
|
-
maxPriorityFeePerGas?: string | number |
|
|
34
|
-
maxFeePerGas?: string | number |
|
|
35
|
-
gasPrice?: string | number |
|
|
31
|
+
gas?: string | number | BigNumber;
|
|
32
|
+
maxPriorityFeePerGas?: string | number | BigNumber;
|
|
33
|
+
maxFeePerGas?: string | number | BigNumber;
|
|
34
|
+
gasPrice?: string | number | BigNumber;
|
|
36
35
|
}
|
|
37
36
|
export interface PayableTx extends NonPayableTx {
|
|
38
|
-
value?: string | number |
|
|
37
|
+
value?: string | number | BigNumber;
|
|
39
38
|
}
|
|
40
39
|
export interface NonPayableTransactionObject<T> {
|
|
41
40
|
arguments: any[];
|
|
@@ -51,5 +50,5 @@ export interface PayableTransactionObject<T> {
|
|
|
51
50
|
estimateGas(tx?: PayableTx): Promise<number>;
|
|
52
51
|
encodeABI(): string;
|
|
53
52
|
}
|
|
54
|
-
export type BlockType = "latest" | "pending" | "genesis" | "earliest" | number |
|
|
53
|
+
export type BlockType = "latest" | "pending" | "genesis" | "earliest" | number | BigNumber;
|
|
55
54
|
export type BaseContract = Omit<Contract, "clone" | "once">;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbs-network/twap",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.14",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/orbs-network/twap.git"
|
|
@@ -24,12 +24,13 @@
|
|
|
24
24
|
"typechain": "npm run clean && hardhat typechain",
|
|
25
25
|
"prebuild": "npm run prettier && npm run typechain",
|
|
26
26
|
"build": "hardhat compile && solhint 'contracts/**/*.sol' && tsc",
|
|
27
|
-
"
|
|
28
|
-
"test": "for t in eth ftm poly; do npm run test:$t; done",
|
|
29
|
-
"test
|
|
30
|
-
"test:
|
|
31
|
-
"test:
|
|
32
|
-
"
|
|
27
|
+
"prepublishOnly": "npm run build",
|
|
28
|
+
"test:logs": "for t in eth ftm poly avax; do DEBUG=web3-candies npm run test:$t -- --logs; done",
|
|
29
|
+
"test": "for t in eth ftm poly avax; do npm run test:$t; done",
|
|
30
|
+
"test:eth": "NETWORK=ETH BLOCK=14905987 hardhat test",
|
|
31
|
+
"test:ftm": "NETWORK=FTM BLOCK=39800909 hardhat test",
|
|
32
|
+
"test:poly": "NETWORK=POLY BLOCK=29174252 hardhat test",
|
|
33
|
+
"test:avax": "NETWORK=AVAX BLOCK=15609313 hardhat test"
|
|
33
34
|
},
|
|
34
35
|
"prettier": {
|
|
35
36
|
"printWidth": 120
|