@orbs-network/twap 1.25.3 → 2.0.1

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.
@@ -1,81 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.chainConfig = exports.Configs = exports.ChainConfigs = exports.zeroAddress = exports.nativeTokenAddresses = void 0;
30
- const web3_candies_1 = require("@defi.org/web3-candies");
31
- const lodash_1 = __importDefault(require("lodash"));
32
- const TWAP_json_1 = __importDefault(require("../artifacts/contracts/TWAP.sol/TWAP.json"));
33
- const Lens_json_1 = __importDefault(require("../artifacts/contracts/periphery/Lens.sol/Lens.json"));
34
- const Taker_json_1 = __importDefault(require("../artifacts/contracts/periphery/Taker.sol/Taker.json"));
35
- const legacyAbis = __importStar(require("./legacy-abi"));
36
- const bnbConfig = __importStar(require("../script/input/56/config.json"));
37
- const polyConfig = __importStar(require("../script/input/137/config.json"));
38
- const ftmConfig = __importStar(require("../script/input/250/config.json"));
39
- const zkSyncConfig = __importStar(require("../script/input/324/config.json"));
40
- const baseConfig = __importStar(require("../script/input/8453/config.json"));
41
- const arbConfig = __importStar(require("../script/input/42161/config.json"));
42
- const avaxConfig = __importStar(require("../script/input/43114/config.json"));
43
- const lineaConfig = __importStar(require("../script/input/59144/config.json"));
44
- var web3_candies_2 = require("@defi.org/web3-candies");
45
- Object.defineProperty(exports, "nativeTokenAddresses", { enumerable: true, get: function () { return web3_candies_2.nativeTokenAddresses; } });
46
- Object.defineProperty(exports, "zeroAddress", { enumerable: true, get: function () { return web3_candies_2.zeroAddress; } });
47
- const abis = {
48
- twapAbi: TWAP_json_1.default.abi,
49
- lensAbi: Lens_json_1.default.abi,
50
- takerAbi: Taker_json_1.default.abi,
51
- };
52
- exports.ChainConfigs = {
53
- eth: Object.assign({ chainName: "eth", chainId: 1, twapVersion: 0, twapAddress: "", lensAddress: "", bidDelaySeconds: 60, minChunkSizeUsd: 500, nativeToken: web3_candies_1.networks.eth.native, wToken: web3_candies_1.networks.eth.wToken }, abis),
54
- bsc: Object.assign({ chainName: "bsc", chainId: 56, twapVersion: 4, twapAddress: bnbConfig.twap, lensAddress: bnbConfig.lens, bidDelaySeconds: 60, minChunkSizeUsd: 50, nativeToken: web3_candies_1.networks.bsc.native, wToken: web3_candies_1.networks.bsc.wToken }, abis),
55
- arb: Object.assign({ chainName: "arb", chainId: 42161, twapVersion: 4, twapAddress: arbConfig.twap, lensAddress: arbConfig.lens, bidDelaySeconds: 60, minChunkSizeUsd: 50, nativeToken: web3_candies_1.networks.arb.native, wToken: web3_candies_1.networks.arb.wToken }, abis),
56
- ftm: Object.assign({ chainName: "ftm", chainId: 250, twapVersion: 4, twapAddress: ftmConfig.twap, lensAddress: ftmConfig.lens, bidDelaySeconds: 60, minChunkSizeUsd: 10, nativeToken: web3_candies_1.networks.ftm.native, wToken: web3_candies_1.networks.ftm.wToken }, abis),
57
- poly: Object.assign({ chainName: "poly", chainId: 137, twapVersion: 4, twapAddress: polyConfig.twap, lensAddress: polyConfig.lens, bidDelaySeconds: 60, minChunkSizeUsd: 10, nativeToken: web3_candies_1.networks.poly.native, wToken: web3_candies_1.networks.poly.wToken }, abis),
58
- avax: Object.assign({ chainName: "avax", chainId: 43114, twapVersion: 4, twapAddress: avaxConfig.twap, lensAddress: avaxConfig.lens, bidDelaySeconds: 60, minChunkSizeUsd: 100, nativeToken: web3_candies_1.networks.avax.native, wToken: web3_candies_1.networks.avax.wToken }, abis),
59
- base: Object.assign({ chainName: "base", chainId: 8453, twapVersion: 4, twapAddress: baseConfig.twap, lensAddress: baseConfig.lens, bidDelaySeconds: 60, minChunkSizeUsd: 50, nativeToken: web3_candies_1.networks.base.native, wToken: web3_candies_1.networks.base.wToken }, abis),
60
- linea: Object.assign({ chainName: "linea", chainId: 59144, twapVersion: 4, twapAddress: lineaConfig.twap, lensAddress: lineaConfig.lens, bidDelaySeconds: 60, minChunkSizeUsd: 100, nativeToken: web3_candies_1.networks.linea.native, wToken: web3_candies_1.networks.linea.wToken }, abis),
61
- zkSync: Object.assign({ chainName: "zkSync", chainId: 324, twapVersion: 4, twapAddress: zkSyncConfig.twap, lensAddress: zkSyncConfig.lens, bidDelaySeconds: 60, minChunkSizeUsd: 100, nativeToken: web3_candies_1.networks.zksync.native, wToken: web3_candies_1.networks.zksync.wToken }, abis),
62
- };
63
- exports.Configs = {
64
- SpiritSwap: Object.assign(Object.assign({}, exports.ChainConfigs.ftm), { twapVersion: 3, twapAddress: "0xBb9F828E34A1327607c3e4eA3dD35891398DD5EE", lensAddress: "0x042799657E971855eD619046aeDf7F30DB56d2D6", twapAbi: legacyAbis.twapAbiV3, lensAbi: legacyAbis.lensAbiV3, takerAbi: legacyAbis.takerAbiV3, name: "SpiritSwap", partner: "Orbs:TWAP:SpiritSwap", exchangeAddress: "0xAd19179201be5A51D1cBd3bB2fC651BB05822404", exchangeType: "ParaswapExchange", pathfinderKey: "SpiritSwap,SpiritSwapV2,SpiritSwapV3" }),
65
- SpookySwap: Object.assign(Object.assign({}, exports.ChainConfigs.ftm), { name: "SpookySwap", partner: "Orbs:TWAP:SpookySwap", exchangeAddress: "0x704b9764cb36B8856f3097845dcc594d82192638", exchangeType: "UniswapV2Exchange", pathfinderKey: "SpookySwap" }),
66
- Pangolin: Object.assign(Object.assign({}, exports.ChainConfigs.avax), { name: "Pangolin", partner: "Orbs:TWAP:Pangolin", exchangeAddress: "0xf2d96E7BE676153d202e1453804E2749923C7c5b", exchangeType: "UniswapV2Exchange", pathfinderKey: "PangolinSwap" }),
67
- PangolinDaas: Object.assign(Object.assign({}, exports.ChainConfigs.avax), { name: "PangolinDaas", partner: "Orbs:TWAP:PangolinDaas", exchangeAddress: "0x1579EED0527781B1A748043AA1f59a3858Ace4a7", exchangeType: "PangolinDaasExchange", pathfinderKey: "PangolinSwap" }),
68
- QuickSwap: Object.assign(Object.assign({}, exports.ChainConfigs.poly), { name: "QuickSwap", partner: "Orbs:TWAP:QuickSwap", exchangeAddress: "0x26D0ec4Be402BCE03AAa8aAf0CF67e9428ba54eF", exchangeType: "ParaswapExchange", pathfinderKey: "QuickSwap,QuickSwapV3" }),
69
- Chronos: Object.assign(Object.assign({}, exports.ChainConfigs.arb), { name: "Chronos", partner: "Orbs:TWAP:Chronos", exchangeAddress: "0xceFf098C9199c5d9cf24078dc14Eb8F787631cC0", exchangeType: "OdosExchange", pathfinderKey: "Chronos Stable,Chronos Volatile,Chronos V3" }),
70
- BaseSwap: Object.assign(Object.assign({}, exports.ChainConfigs.base), { name: "BaseSwap", partner: "Orbs:TWAP:BaseSwap", exchangeAddress: "0xeFE1B6096838949156e5130604434A2a13c68C68", exchangeType: "OdosExchange", pathfinderKey: "BaseSwap,BaseSwapX" }),
71
- Arbidex: Object.assign(Object.assign({}, exports.ChainConfigs.arb), { name: "Arbidex", partner: "Orbs:TWAP:Arbidex", exchangeAddress: "0x8ffde23Fba2d7Aea9C3CBf2d5B7B533BB46754a8", exchangeType: "OdosExchange", pathfinderKey: "Arbidex Classic,Arbidex Quantum" }),
72
- Thena: Object.assign(Object.assign({}, exports.ChainConfigs.bsc), { name: "Thena", partner: "Orbs:TWAP:Thena", exchangeAddress: "0xc2aBC02acd77Bb2407efA22348dA9afC8B375290", exchangeType: "OpenOceanExchange", pathfinderKey: "43,47" }),
73
- PancakeSwap: Object.assign(Object.assign({}, exports.ChainConfigs.bsc), { name: "PancakeSwap", partner: "Orbs:TWAP:PancakeSwap", exchangeAddress: "0xb2BAFe188faD927240038cC4FfF2d771d8A58905", exchangeType: "RouterExchange", pathfinderKey: "" }),
74
- Lynex: Object.assign(Object.assign({}, exports.ChainConfigs.linea), { name: "Lynex", partner: "Orbs:TWAP:Lynex", exchangeAddress: "0x72e3e1fD5D2Ee2F1C2Eb695206D490a1D45C3835", exchangeType: "OpenOceanExchange", pathfinderKey: "19,18" }),
75
- SyncSwap: Object.assign(Object.assign({}, exports.ChainConfigs.zkSync), { name: "SyncSwap", partner: "Orbs:TWAP:SyncSwap", exchangeAddress: "0x5D96A072B2854d9a9D56C68806b0Bbcf7Db60b6d", exchangeType: "OpenOceanExchange", pathfinderKey: "2,3" }),
76
- Retro: Object.assign(Object.assign({}, exports.ChainConfigs.poly), { name: "Retro", partner: "Orbs:TWAP:Retro", exchangeAddress: "0xC454Abb5b0CA974a4397139764478C736327d2B0", exchangeType: "KyberExchange", pathfinderKey: "retro,retro-v3" }),
77
- SushiArb: Object.assign(Object.assign({}, exports.ChainConfigs.arb), { name: "SushiArb", partner: "Orbs:TWAP:Sushi", exchangeAddress: "0x10695E3C265639e46D45C7bB427A4a4Fd449Af1E", exchangeType: "RouterExchange", pathfinderKey: "" }),
78
- SushiBase: Object.assign(Object.assign({}, exports.ChainConfigs.base), { name: "SushiBase", partner: "Orbs:TWAP:Sushi", exchangeAddress: "0xF6875cEE4098e24B068254D94062e6701904968d", exchangeType: "RouterExchange", pathfinderKey: "" }),
79
- };
80
- const chainConfig = (chainId) => lodash_1.default.find(exports.ChainConfigs, (c) => c.chainId === chainId);
81
- exports.chainConfig = chainConfig;
@@ -1,2 +0,0 @@
1
- export * from "./lib";
2
- export * from "./configs";
package/dist/src/index.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./lib"), exports);
18
- __exportStar(require("./configs"), exports);
@@ -1,178 +0,0 @@
1
- export declare const twapAbiV3: ({
2
- inputs: {
3
- internalType: string;
4
- name: string;
5
- type: string;
6
- }[];
7
- stateMutability: string;
8
- type: string;
9
- anonymous?: undefined;
10
- name?: undefined;
11
- outputs?: undefined;
12
- } | {
13
- anonymous: boolean;
14
- inputs: ({
15
- indexed: boolean;
16
- internalType: string;
17
- name: string;
18
- type: string;
19
- components?: undefined;
20
- } | {
21
- components: {
22
- internalType: string;
23
- name: string;
24
- type: string;
25
- }[];
26
- indexed: boolean;
27
- internalType: string;
28
- name: string;
29
- type: string;
30
- })[];
31
- name: string;
32
- type: string;
33
- stateMutability?: undefined;
34
- outputs?: undefined;
35
- } | {
36
- inputs: {
37
- internalType: string;
38
- name: string;
39
- type: string;
40
- }[];
41
- name: string;
42
- outputs: ({
43
- internalType: string;
44
- name: string;
45
- type: string;
46
- components?: undefined;
47
- } | {
48
- components: {
49
- internalType: string;
50
- name: string;
51
- type: string;
52
- }[];
53
- internalType: string;
54
- name: string;
55
- type: string;
56
- })[];
57
- stateMutability: string;
58
- type: string;
59
- anonymous?: undefined;
60
- } | {
61
- inputs: {
62
- internalType: string;
63
- name: string;
64
- type: string;
65
- }[];
66
- name: string;
67
- outputs: {
68
- components: ({
69
- internalType: string;
70
- name: string;
71
- type: string;
72
- components?: undefined;
73
- } | {
74
- components: {
75
- internalType: string;
76
- name: string;
77
- type: string;
78
- }[];
79
- internalType: string;
80
- name: string;
81
- type: string;
82
- })[];
83
- internalType: string;
84
- name: string;
85
- type: string;
86
- }[];
87
- stateMutability: string;
88
- type: string;
89
- anonymous?: undefined;
90
- } | {
91
- stateMutability: string;
92
- type: string;
93
- inputs?: undefined;
94
- anonymous?: undefined;
95
- name?: undefined;
96
- outputs?: undefined;
97
- })[];
98
- export declare const lensAbiV3: ({
99
- inputs: {
100
- internalType: string;
101
- name: string;
102
- type: string;
103
- }[];
104
- stateMutability: string;
105
- type: string;
106
- name?: undefined;
107
- outputs?: undefined;
108
- } | {
109
- inputs: any[];
110
- name: string;
111
- outputs: {
112
- internalType: string;
113
- name: string;
114
- type: string;
115
- }[];
116
- stateMutability: string;
117
- type: string;
118
- } | {
119
- inputs: {
120
- internalType: string;
121
- name: string;
122
- type: string;
123
- }[];
124
- name: string;
125
- outputs: {
126
- components: ({
127
- internalType: string;
128
- name: string;
129
- type: string;
130
- components?: undefined;
131
- } | {
132
- components: {
133
- internalType: string;
134
- name: string;
135
- type: string;
136
- }[];
137
- internalType: string;
138
- name: string;
139
- type: string;
140
- })[];
141
- internalType: string;
142
- name: string;
143
- type: string;
144
- }[];
145
- stateMutability: string;
146
- type: string;
147
- })[];
148
- export declare const takerAbiV3: ({
149
- inputs: {
150
- internalType: string;
151
- name: string;
152
- type: string;
153
- }[];
154
- stateMutability: string;
155
- type: string;
156
- name?: undefined;
157
- outputs?: undefined;
158
- } | {
159
- inputs: {
160
- internalType: string;
161
- name: string;
162
- type: string;
163
- }[];
164
- name: string;
165
- outputs: {
166
- internalType: string;
167
- name: string;
168
- type: string;
169
- }[];
170
- stateMutability: string;
171
- type: string;
172
- } | {
173
- stateMutability: string;
174
- type: string;
175
- inputs?: undefined;
176
- name?: undefined;
177
- outputs?: undefined;
178
- })[];
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.takerAbiV3 = exports.lensAbiV3 = exports.twapAbiV3 = void 0;
4
- // prettier-ignore
5
- exports.twapAbiV3 = [{ "inputs": [{ "internalType": "address", "name": "_iweth", "type": "address" }], "stateMutability": "nonpayable", "type": "constructor" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "uint64", "name": "id", "type": "uint64" }, { "indexed": true, "internalType": "address", "name": "maker", "type": "address" }, { "indexed": true, "internalType": "address", "name": "exchange", "type": "address" }, { "indexed": false, "internalType": "uint32", "name": "slippagePercent", "type": "uint32" }, { "components": [{ "internalType": "uint32", "name": "time", "type": "uint32" }, { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "address", "name": "exchange", "type": "address" }, { "internalType": "uint256", "name": "dstAmount", "type": "uint256" }, { "internalType": "uint256", "name": "dstFee", "type": "uint256" }, { "internalType": "bytes", "name": "data", "type": "bytes" }], "indexed": false, "internalType": "struct OrderLib.Bid", "name": "bid", "type": "tuple" }], "name": "OrderBid", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "uint64", "name": "id", "type": "uint64" }, { "indexed": true, "internalType": "address", "name": "maker", "type": "address" }, { "indexed": false, "internalType": "address", "name": "sender", "type": "address" }], "name": "OrderCanceled", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "uint64", "name": "id", "type": "uint64" }, { "indexed": true, "internalType": "address", "name": "maker", "type": "address" }, { "indexed": true, "internalType": "address", "name": "exchange", "type": "address" }, { "indexed": false, "internalType": "address", "name": "taker", "type": "address" }], "name": "OrderCompleted", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "uint64", "name": "id", "type": "uint64" }, { "indexed": true, "internalType": "address", "name": "maker", "type": "address" }, { "indexed": true, "internalType": "address", "name": "exchange", "type": "address" }, { "components": [{ "internalType": "uint32", "name": "time", "type": "uint32" }, { "internalType": "uint32", "name": "deadline", "type": "uint32" }, { "internalType": "uint32", "name": "bidDelay", "type": "uint32" }, { "internalType": "uint32", "name": "fillDelay", "type": "uint32" }, { "internalType": "address", "name": "maker", "type": "address" }, { "internalType": "address", "name": "exchange", "type": "address" }, { "internalType": "address", "name": "srcToken", "type": "address" }, { "internalType": "address", "name": "dstToken", "type": "address" }, { "internalType": "uint256", "name": "srcAmount", "type": "uint256" }, { "internalType": "uint256", "name": "srcBidAmount", "type": "uint256" }, { "internalType": "uint256", "name": "dstMinAmount", "type": "uint256" }], "indexed": false, "internalType": "struct OrderLib.Ask", "name": "ask", "type": "tuple" }], "name": "OrderCreated", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "uint64", "name": "id", "type": "uint64" }, { "indexed": true, "internalType": "address", "name": "maker", "type": "address" }, { "indexed": true, "internalType": "address", "name": "exchange", "type": "address" }, { "indexed": false, "internalType": "address", "name": "taker", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "srcAmountIn", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "dstAmountOut", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "dstFee", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "srcFilledAmount", "type": "uint256" }], "name": "OrderFilled", "type": "event" }, { "inputs": [], "name": "MIN_BID_DELAY_SECONDS", "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "MIN_OUTBID_PERCENT", "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "PERCENT_BASE", "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "STALE_BID_DELAY_MUL", "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "STATUS_CANCELED", "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "STATUS_COMPLETED", "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "VERSION", "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "exchange", "type": "address" }, { "internalType": "address", "name": "srcToken", "type": "address" }, { "internalType": "address", "name": "dstToken", "type": "address" }, { "internalType": "uint256", "name": "srcAmount", "type": "uint256" }, { "internalType": "uint256", "name": "srcBidAmount", "type": "uint256" }, { "internalType": "uint256", "name": "dstMinAmount", "type": "uint256" }, { "internalType": "uint32", "name": "deadline", "type": "uint32" }, { "internalType": "uint32", "name": "bidDelay", "type": "uint32" }, { "internalType": "uint32", "name": "fillDelay", "type": "uint32" }], "name": "ask", "outputs": [{ "internalType": "uint64", "name": "id", "type": "uint64" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint64", "name": "id", "type": "uint64" }, { "internalType": "address", "name": "exchange", "type": "address" }, { "internalType": "uint256", "name": "dstFee", "type": "uint256" }, { "internalType": "uint32", "name": "slippagePercent", "type": "uint32" }, { "internalType": "bytes", "name": "data", "type": "bytes" }], "name": "bid", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "name": "book", "outputs": [{ "internalType": "uint64", "name": "id", "type": "uint64" }, { "internalType": "uint32", "name": "status", "type": "uint32" }, { "internalType": "uint32", "name": "filledTime", "type": "uint32" }, { "internalType": "uint256", "name": "srcFilledAmount", "type": "uint256" }, { "components": [{ "internalType": "uint32", "name": "time", "type": "uint32" }, { "internalType": "uint32", "name": "deadline", "type": "uint32" }, { "internalType": "uint32", "name": "bidDelay", "type": "uint32" }, { "internalType": "uint32", "name": "fillDelay", "type": "uint32" }, { "internalType": "address", "name": "maker", "type": "address" }, { "internalType": "address", "name": "exchange", "type": "address" }, { "internalType": "address", "name": "srcToken", "type": "address" }, { "internalType": "address", "name": "dstToken", "type": "address" }, { "internalType": "uint256", "name": "srcAmount", "type": "uint256" }, { "internalType": "uint256", "name": "srcBidAmount", "type": "uint256" }, { "internalType": "uint256", "name": "dstMinAmount", "type": "uint256" }], "internalType": "struct OrderLib.Ask", "name": "ask", "type": "tuple" }, { "components": [{ "internalType": "uint32", "name": "time", "type": "uint32" }, { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "address", "name": "exchange", "type": "address" }, { "internalType": "uint256", "name": "dstAmount", "type": "uint256" }, { "internalType": "uint256", "name": "dstFee", "type": "uint256" }, { "internalType": "bytes", "name": "data", "type": "bytes" }], "internalType": "struct OrderLib.Bid", "name": "bid", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint64", "name": "id", "type": "uint64" }], "name": "cancel", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint64", "name": "id", "type": "uint64" }], "name": "fill", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "iweth", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "length", "outputs": [{ "internalType": "uint64", "name": "", "type": "uint64" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "", "type": "address" }, { "internalType": "uint256", "name": "", "type": "uint256" }], "name": "makerOrders", "outputs": [{ "internalType": "uint64", "name": "", "type": "uint64" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint64", "name": "id", "type": "uint64" }], "name": "order", "outputs": [{ "components": [{ "internalType": "uint64", "name": "id", "type": "uint64" }, { "internalType": "uint32", "name": "status", "type": "uint32" }, { "internalType": "uint32", "name": "filledTime", "type": "uint32" }, { "internalType": "uint256", "name": "srcFilledAmount", "type": "uint256" }, { "components": [{ "internalType": "uint32", "name": "time", "type": "uint32" }, { "internalType": "uint32", "name": "deadline", "type": "uint32" }, { "internalType": "uint32", "name": "bidDelay", "type": "uint32" }, { "internalType": "uint32", "name": "fillDelay", "type": "uint32" }, { "internalType": "address", "name": "maker", "type": "address" }, { "internalType": "address", "name": "exchange", "type": "address" }, { "internalType": "address", "name": "srcToken", "type": "address" }, { "internalType": "address", "name": "dstToken", "type": "address" }, { "internalType": "uint256", "name": "srcAmount", "type": "uint256" }, { "internalType": "uint256", "name": "srcBidAmount", "type": "uint256" }, { "internalType": "uint256", "name": "dstMinAmount", "type": "uint256" }], "internalType": "struct OrderLib.Ask", "name": "ask", "type": "tuple" }, { "components": [{ "internalType": "uint32", "name": "time", "type": "uint32" }, { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "address", "name": "exchange", "type": "address" }, { "internalType": "uint256", "name": "dstAmount", "type": "uint256" }, { "internalType": "uint256", "name": "dstFee", "type": "uint256" }, { "internalType": "bytes", "name": "data", "type": "bytes" }], "internalType": "struct OrderLib.Bid", "name": "bid", "type": "tuple" }], "internalType": "struct OrderLib.Order", "name": "", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "maker", "type": "address" }], "name": "orderIdsByMaker", "outputs": [{ "internalType": "uint64[]", "name": "", "type": "uint64[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint64", "name": "id", "type": "uint64" }], "name": "prune", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "name": "status", "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }], "stateMutability": "view", "type": "function" }, { "stateMutability": "payable", "type": "receive" }];
6
- // prettier-ignore
7
- exports.lensAbiV3 = [{ "inputs": [{ "internalType": "contract TWAP", "name": "_twap", "type": "address" }], "stateMutability": "nonpayable", "type": "constructor" }, { "inputs": [], "name": "length", "outputs": [{ "internalType": "uint64", "name": "", "type": "uint64" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "maker", "type": "address" }], "name": "makerOrders", "outputs": [{ "components": [{ "internalType": "uint64", "name": "id", "type": "uint64" }, { "internalType": "uint32", "name": "status", "type": "uint32" }, { "internalType": "uint32", "name": "filledTime", "type": "uint32" }, { "internalType": "uint256", "name": "srcFilledAmount", "type": "uint256" }, { "components": [{ "internalType": "uint32", "name": "time", "type": "uint32" }, { "internalType": "uint32", "name": "deadline", "type": "uint32" }, { "internalType": "uint32", "name": "bidDelay", "type": "uint32" }, { "internalType": "uint32", "name": "fillDelay", "type": "uint32" }, { "internalType": "address", "name": "maker", "type": "address" }, { "internalType": "address", "name": "exchange", "type": "address" }, { "internalType": "address", "name": "srcToken", "type": "address" }, { "internalType": "address", "name": "dstToken", "type": "address" }, { "internalType": "uint256", "name": "srcAmount", "type": "uint256" }, { "internalType": "uint256", "name": "srcBidAmount", "type": "uint256" }, { "internalType": "uint256", "name": "dstMinAmount", "type": "uint256" }], "internalType": "struct OrderLib.Ask", "name": "ask", "type": "tuple" }, { "components": [{ "internalType": "uint32", "name": "time", "type": "uint32" }, { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "address", "name": "exchange", "type": "address" }, { "internalType": "uint256", "name": "dstAmount", "type": "uint256" }, { "internalType": "uint256", "name": "dstFee", "type": "uint256" }, { "internalType": "bytes", "name": "data", "type": "bytes" }], "internalType": "struct OrderLib.Bid", "name": "bid", "type": "tuple" }], "internalType": "struct OrderLib.Order[]", "name": "result", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint64", "name": "lastIndex", "type": "uint64" }, { "internalType": "uint64", "name": "pageSize", "type": "uint64" }], "name": "takerBiddableOrders", "outputs": [{ "components": [{ "internalType": "uint64", "name": "id", "type": "uint64" }, { "internalType": "uint32", "name": "status", "type": "uint32" }, { "internalType": "uint32", "name": "filledTime", "type": "uint32" }, { "internalType": "uint256", "name": "srcFilledAmount", "type": "uint256" }, { "components": [{ "internalType": "uint32", "name": "time", "type": "uint32" }, { "internalType": "uint32", "name": "deadline", "type": "uint32" }, { "internalType": "uint32", "name": "bidDelay", "type": "uint32" }, { "internalType": "uint32", "name": "fillDelay", "type": "uint32" }, { "internalType": "address", "name": "maker", "type": "address" }, { "internalType": "address", "name": "exchange", "type": "address" }, { "internalType": "address", "name": "srcToken", "type": "address" }, { "internalType": "address", "name": "dstToken", "type": "address" }, { "internalType": "uint256", "name": "srcAmount", "type": "uint256" }, { "internalType": "uint256", "name": "srcBidAmount", "type": "uint256" }, { "internalType": "uint256", "name": "dstMinAmount", "type": "uint256" }], "internalType": "struct OrderLib.Ask", "name": "ask", "type": "tuple" }, { "components": [{ "internalType": "uint32", "name": "time", "type": "uint32" }, { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "address", "name": "exchange", "type": "address" }, { "internalType": "uint256", "name": "dstAmount", "type": "uint256" }, { "internalType": "uint256", "name": "dstFee", "type": "uint256" }, { "internalType": "bytes", "name": "data", "type": "bytes" }], "internalType": "struct OrderLib.Bid", "name": "bid", "type": "tuple" }], "internalType": "struct OrderLib.Order[]", "name": "result", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint64", "name": "lastIndex", "type": "uint64" }, { "internalType": "uint64", "name": "pageSize", "type": "uint64" }], "name": "takerFillableOrders", "outputs": [{ "components": [{ "internalType": "uint64", "name": "id", "type": "uint64" }, { "internalType": "uint32", "name": "status", "type": "uint32" }, { "internalType": "uint32", "name": "filledTime", "type": "uint32" }, { "internalType": "uint256", "name": "srcFilledAmount", "type": "uint256" }, { "components": [{ "internalType": "uint32", "name": "time", "type": "uint32" }, { "internalType": "uint32", "name": "deadline", "type": "uint32" }, { "internalType": "uint32", "name": "bidDelay", "type": "uint32" }, { "internalType": "uint32", "name": "fillDelay", "type": "uint32" }, { "internalType": "address", "name": "maker", "type": "address" }, { "internalType": "address", "name": "exchange", "type": "address" }, { "internalType": "address", "name": "srcToken", "type": "address" }, { "internalType": "address", "name": "dstToken", "type": "address" }, { "internalType": "uint256", "name": "srcAmount", "type": "uint256" }, { "internalType": "uint256", "name": "srcBidAmount", "type": "uint256" }, { "internalType": "uint256", "name": "dstMinAmount", "type": "uint256" }], "internalType": "struct OrderLib.Ask", "name": "ask", "type": "tuple" }, { "components": [{ "internalType": "uint32", "name": "time", "type": "uint32" }, { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "address", "name": "exchange", "type": "address" }, { "internalType": "uint256", "name": "dstAmount", "type": "uint256" }, { "internalType": "uint256", "name": "dstFee", "type": "uint256" }, { "internalType": "bytes", "name": "data", "type": "bytes" }], "internalType": "struct OrderLib.Bid", "name": "bid", "type": "tuple" }], "internalType": "struct OrderLib.Order[]", "name": "result", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "twap", "outputs": [{ "internalType": "contract TWAP", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }];
8
- // prettier-ignore
9
- exports.takerAbiV3 = [{ "inputs": [{ "internalType": "contract TWAP", "name": "_twap", "type": "address" }, { "internalType": "address[]", "name": "_owners", "type": "address[]" }], "stateMutability": "nonpayable", "type": "constructor" }, { "inputs": [{ "internalType": "uint64", "name": "id", "type": "uint64" }, { "internalType": "address", "name": "exchange", "type": "address" }, { "internalType": "uint256", "name": "dstFee", "type": "uint256" }, { "internalType": "uint32", "name": "slippagePercent", "type": "uint32" }, { "internalType": "bytes", "name": "data", "type": "bytes" }], "name": "bid", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint64", "name": "id", "type": "uint64" }, { "internalType": "address", "name": "feeExchange", "type": "address" }, { "internalType": "uint256", "name": "feeMinAmountOut", "type": "uint256" }, { "internalType": "bytes", "name": "feeData", "type": "bytes" }], "name": "fill", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "", "type": "address" }], "name": "owners", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "token", "type": "address" }], "name": "rescue", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "twap", "outputs": [{ "internalType": "contract TWAP", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "stateMutability": "payable", "type": "receive" }];
package/dist/src/lib.d.ts DELETED
@@ -1,102 +0,0 @@
1
- import { Config } from "./configs";
2
- import BN from "bignumber.js";
3
- import { TokenData } from "@defi.org/web3-candies";
4
- export declare class TWAPLib {
5
- config: Config;
6
- maker: string;
7
- provider?: any;
8
- static VERSION: number;
9
- twap: any;
10
- lens: any;
11
- constructor(config: Config, maker: string, provider?: any);
12
- isNativeToken: (token: TokenData) => boolean;
13
- isWrappedToken: (token: TokenData) => boolean;
14
- isValidChain: (chainId: number) => boolean;
15
- maxPossibleChunks: (srcToken: TokenData, srcAmount: BN.Value, srcUsd: BN.Value) => number;
16
- srcChunkAmount: (srcAmount: BN.Value, totalChunks: BN.Value) => BN;
17
- totalChunks: (srcAmount: BN.Value, srcChunkAmount: BN.Value) => number;
18
- estimatedDelayBetweenChunksMillis: () => number;
19
- /**
20
- * includes the bidding war and block settelment
21
- */
22
- fillDelayUiMillis: (totalChunks: BN.Value, maxDurationMillis: BN.Value) => number;
23
- fillDelayMillis: (totalChunks: BN.Value, maxDurationMillis: BN.Value) => number;
24
- dstMinAmountOut: (srcToken: TokenData, dstToken: TokenData, srcChunkAmount: BN.Value, limitDstPriceFor1Src: BN.Value, isMarketOrder: boolean) => BN;
25
- dstPriceFor1Src: (srcToken: TokenData, dstToken: TokenData, srcUsdMarket: BN.Value, dstUsdMarket: BN.Value, srcChunkAmount: BN.Value, dstMinAmountOut: BN.Value) => BN;
26
- isMarketOrder: (order: Order) => boolean;
27
- orderProgress: (order: Order) => number;
28
- percentAboveMarket: (srcUsdMarket: BN.Value, dstUsdMarket: BN.Value, limitDstPriceFor1Src: BN.Value) => number;
29
- status: (order: Order) => Status;
30
- makerBalance(token: TokenData): Promise<BN>;
31
- wrapNativeToken(amount: BN.Value, maxPriorityFeePerGas?: BN.Value, maxFeePerGas?: BN.Value): Promise<void>;
32
- unwrapNativeToken(amount: BN.Value, maxPriorityFeePerGas?: BN.Value, maxFeePerGas?: BN.Value): Promise<void>;
33
- hasAllowance(srcToken: TokenData, amount: BN.Value): Promise<boolean>;
34
- approve(srcToken: TokenData, amount: BN.Value, maxPriorityFeePerGas?: BN.Value, maxFeePerGas?: BN.Value): Promise<void>;
35
- validateTokens(srcToken: TokenData, dstToken: TokenData): TokensValidation;
36
- 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, askDataParams?: any[], maxPriorityFeePerGas?: BN.Value, maxFeePerGas?: BN.Value): Promise<{
38
- txHash: string;
39
- orderId: number;
40
- }>;
41
- getOrder(id: number): Promise<Order>;
42
- cancelOrder(id: number, maxPriorityFeePerGas?: BN.Value, maxFeePerGas?: BN.Value): Promise<void>;
43
- getAllOrders(): Promise<Order[]>;
44
- getAllOrdersWithTokens(): Promise<(Order & {
45
- srcToken: import("./configs").TokenData;
46
- dstToken: import("./configs").TokenData;
47
- })[]>;
48
- parseOrder(r: any): Order;
49
- getToken(address: string): Promise<import("./configs").TokenData>;
50
- }
51
- export interface Order {
52
- id: number;
53
- status: number;
54
- time: number;
55
- filledTime: number;
56
- srcFilledAmount: BN;
57
- maker: string;
58
- ask: {
59
- deadline: number;
60
- bidDelay: number;
61
- fillDelay: number;
62
- exchange: string;
63
- srcToken: string;
64
- dstToken: string;
65
- srcAmount: BN;
66
- srcBidAmount: BN;
67
- dstMinAmount: BN;
68
- };
69
- bid: {
70
- time: number;
71
- taker: string;
72
- exchange: string;
73
- dstAmount: BN;
74
- dstFee: BN;
75
- data: string;
76
- };
77
- }
78
- export declare enum Status {
79
- Open = "Open",
80
- Canceled = "Canceled",
81
- Completed = "Completed",
82
- Expired = "Expired"
83
- }
84
- export declare enum OrderInputValidation {
85
- valid = "valid",
86
- invalidTokens = "invalidTokens",
87
- invalidSrcAmount = "invalidSrcAmount",
88
- invalidSrcChunkAmount = "invalidSrcChunkAmount",
89
- invalidDstMinChunkAmountOut = "invalidDstMinChunkAmountOut",
90
- invalidDeadline = "invalidDeadline",
91
- invalidFillDelaySeconds = "invalidFillDelaySeconds",
92
- invalidSrcUsd = "invalidSrcUsd",
93
- invalidSmallestSrcChunkUsd = "invalidSmallestSrcChunkUsd"
94
- }
95
- export declare enum TokensValidation {
96
- valid = "valid",
97
- invalid = "invalid",
98
- wrapOnly = "wrapOnly",
99
- unwrapOnly = "unwrapOnly",
100
- wrapAndOrder = "wrapAndOrder",
101
- dstTokenZero = "dstTokenZero"
102
- }