@cityofzion/bs-neo3 1.0.0 → 1.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,11 +1,9 @@
1
1
  import { Account, Network, SwapControllerService, SwapControllerServiceEvents, SwapControllerServiceSwapToReceiveArgs, SwapControllerServiceSwapToUseArgs, Token } from '@cityofzion/blockchain-service';
2
2
  import TypedEmitter from 'typed-emitter';
3
- import WebSocket from 'isomorphic-ws';
4
- import { AvailableNetworkIds } from '../constants';
3
+ import { AvailableNetworkIds } from '../BSNeo3Helper';
5
4
  export declare class FlamingoSwapControllerService implements SwapControllerService<AvailableNetworkIds> {
6
5
  #private;
7
6
  eventEmitter: TypedEmitter<SwapControllerServiceEvents>;
8
- ws: WebSocket;
9
7
  constructor(network: Network<AvailableNetworkIds>);
10
8
  buildSwapArgs(): SwapControllerServiceSwapToReceiveArgs<AvailableNetworkIds> | SwapControllerServiceSwapToUseArgs<AvailableNetworkIds>;
11
9
  setAccountToUse(account: Account | null): void;
@@ -19,38 +17,4 @@ export declare class FlamingoSwapControllerService implements SwapControllerServ
19
17
  setReserves(): Promise<void>;
20
18
  startListeningBlockGeneration(): void;
21
19
  stopListeningBlockGeneration(): void;
22
- private recalculateSwapArguments;
23
- private clearFields;
24
- private get lastAmountChange();
25
- private set lastAmountChange(value);
26
- private get accountToUse();
27
- private set accountToUse(value);
28
- private get amountToUse();
29
- private set amountToUse(value);
30
- private get minimumReceived();
31
- private set minimumReceived(value);
32
- private get maximumSelling();
33
- private set maximumSelling(value);
34
- private get amountToReceive();
35
- private set amountToReceive(value);
36
- private get deadline();
37
- private set deadline(value);
38
- private get liquidityProviderFee();
39
- private set liquidityProviderFee(value);
40
- private get priceImpact();
41
- private set priceImpact(value);
42
- private get priceInverse();
43
- private set priceInverse(value);
44
- private get routes();
45
- private set routes(value);
46
- private get reservesToUse();
47
- private set reservesToUse(value);
48
- private get reservesToReceive();
49
- private set reservesToReceive(value);
50
- private get slippage();
51
- private set slippage(value);
52
- private get tokenToReceive();
53
- private set tokenToReceive(value);
54
- private get tokenToUse();
55
- private set tokenToUse(value);
56
20
  }
@@ -22,99 +22,94 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
22
22
  var __importDefault = (this && this.__importDefault) || function (mod) {
23
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
24
  };
25
- var _FlamingoSwapControllerService_network, _FlamingoSwapControllerService_accountToUse, _FlamingoSwapControllerService_tokenToReceive, _FlamingoSwapControllerService_tokenToUse, _FlamingoSwapControllerService_amountToReceive, _FlamingoSwapControllerService_amountToUse, _FlamingoSwapControllerService_minimumReceived, _FlamingoSwapControllerService_maximumSelling, _FlamingoSwapControllerService_reservesToReceive, _FlamingoSwapControllerService_reservesToUse, _FlamingoSwapControllerService_slippage, _FlamingoSwapControllerService_deadline, _FlamingoSwapControllerService_priceInverse, _FlamingoSwapControllerService_priceImpact, _FlamingoSwapControllerService_liquidityProviderFee, _FlamingoSwapControllerService_routes, _FlamingoSwapControllerService_lastAmountChange;
25
+ var _FlamingoSwapControllerService_instances, _FlamingoSwapControllerService_ws, _FlamingoSwapControllerService_network, _FlamingoSwapControllerService_privateAccountToUse, _FlamingoSwapControllerService_privateTokenToReceive, _FlamingoSwapControllerService_privateTokenToUse, _FlamingoSwapControllerService_privateAmountToReceive, _FlamingoSwapControllerService_privateAmountToUse, _FlamingoSwapControllerService_privateMinimumReceived, _FlamingoSwapControllerService_privateMaximumSelling, _FlamingoSwapControllerService_privateReservesToReceive, _FlamingoSwapControllerService_privateReservesToUse, _FlamingoSwapControllerService_privateSlippage, _FlamingoSwapControllerService_privateDeadline, _FlamingoSwapControllerService_privatePriceInverse, _FlamingoSwapControllerService_privatePriceImpact, _FlamingoSwapControllerService_privateLiquidityProviderFee, _FlamingoSwapControllerService_privateRoutes, _FlamingoSwapControllerService_privateLastAmountChange, _FlamingoSwapControllerService_recalculateSwapArguments, _FlamingoSwapControllerService_clearFields, _FlamingoSwapControllerService_lastAmountChange_get, _FlamingoSwapControllerService_lastAmountChange_set, _FlamingoSwapControllerService_accountToUse_get, _FlamingoSwapControllerService_accountToUse_set, _FlamingoSwapControllerService_amountToUse_get, _FlamingoSwapControllerService_amountToUse_set, _FlamingoSwapControllerService_minimumReceived_get, _FlamingoSwapControllerService_minimumReceived_set, _FlamingoSwapControllerService_maximumSelling_get, _FlamingoSwapControllerService_maximumSelling_set, _FlamingoSwapControllerService_amountToReceive_get, _FlamingoSwapControllerService_amountToReceive_set, _FlamingoSwapControllerService_deadline_get, _FlamingoSwapControllerService_deadline_set, _FlamingoSwapControllerService_liquidityProviderFee_get, _FlamingoSwapControllerService_liquidityProviderFee_set, _FlamingoSwapControllerService_priceImpact_get, _FlamingoSwapControllerService_priceImpact_set, _FlamingoSwapControllerService_priceInverse_get, _FlamingoSwapControllerService_priceInverse_set, _FlamingoSwapControllerService_routes_get, _FlamingoSwapControllerService_routes_set, _FlamingoSwapControllerService_reservesToUse_get, _FlamingoSwapControllerService_reservesToUse_set, _FlamingoSwapControllerService_reservesToReceive_get, _FlamingoSwapControllerService_reservesToReceive_set, _FlamingoSwapControllerService_slippage_get, _FlamingoSwapControllerService_slippage_set, _FlamingoSwapControllerService_tokenToReceive_get, _FlamingoSwapControllerService_tokenToReceive_set, _FlamingoSwapControllerService_tokenToUse_get, _FlamingoSwapControllerService_tokenToUse_set;
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.FlamingoSwapControllerService = void 0;
28
28
  const events_1 = __importDefault(require("events"));
29
29
  const FlamingoSwapNeonDappKitInvocationBuilder_1 = require("./FlamingoSwapNeonDappKitInvocationBuilder");
30
30
  const neon_dappkit_1 = require("@cityofzion/neon-dappkit");
31
31
  const neon_core_1 = require("@cityofzion/neon-core");
32
- const FlamingoSwapError_1 = require("./FlamingoSwapError");
33
32
  const FlamingoSwapHelper_1 = require("./FlamingoSwapHelper");
34
33
  const isomorphic_ws_1 = __importDefault(require("isomorphic-ws"));
35
- const constants_1 = require("../constants");
34
+ const BLOCKCHAIN_WSS_URL = 'wss://rpc10.n3.nspcc.ru:10331/ws';
36
35
  class FlamingoSwapControllerService {
37
36
  constructor(network) {
37
+ _FlamingoSwapControllerService_instances.add(this);
38
+ _FlamingoSwapControllerService_ws.set(this, void 0);
38
39
  _FlamingoSwapControllerService_network.set(this, void 0);
39
- _FlamingoSwapControllerService_accountToUse.set(this, null);
40
- _FlamingoSwapControllerService_tokenToReceive.set(this, null);
41
- _FlamingoSwapControllerService_tokenToUse.set(this, null);
42
- _FlamingoSwapControllerService_amountToReceive.set(this, null);
43
- _FlamingoSwapControllerService_amountToUse.set(this, null);
44
- _FlamingoSwapControllerService_minimumReceived.set(this, null);
45
- _FlamingoSwapControllerService_maximumSelling.set(this, null);
46
- _FlamingoSwapControllerService_reservesToReceive.set(this, null);
47
- _FlamingoSwapControllerService_reservesToUse.set(this, null);
48
- _FlamingoSwapControllerService_slippage.set(this, 0.5);
49
- _FlamingoSwapControllerService_deadline.set(this, '10');
50
- _FlamingoSwapControllerService_priceInverse.set(this, null);
51
- _FlamingoSwapControllerService_priceImpact.set(this, null);
52
- _FlamingoSwapControllerService_liquidityProviderFee.set(this, null);
53
- _FlamingoSwapControllerService_routes.set(this, null);
54
- _FlamingoSwapControllerService_lastAmountChange.set(this, null);
55
- if (network.id === 'custom')
56
- throw new FlamingoSwapError_1.CustomNetworkNotSupportedError();
40
+ _FlamingoSwapControllerService_privateAccountToUse.set(this, null);
41
+ _FlamingoSwapControllerService_privateTokenToReceive.set(this, null);
42
+ _FlamingoSwapControllerService_privateTokenToUse.set(this, null);
43
+ _FlamingoSwapControllerService_privateAmountToReceive.set(this, null);
44
+ _FlamingoSwapControllerService_privateAmountToUse.set(this, null);
45
+ _FlamingoSwapControllerService_privateMinimumReceived.set(this, null);
46
+ _FlamingoSwapControllerService_privateMaximumSelling.set(this, null);
47
+ _FlamingoSwapControllerService_privateReservesToReceive.set(this, null);
48
+ _FlamingoSwapControllerService_privateReservesToUse.set(this, null);
49
+ _FlamingoSwapControllerService_privateSlippage.set(this, 0.5);
50
+ _FlamingoSwapControllerService_privateDeadline.set(this, '10');
51
+ _FlamingoSwapControllerService_privatePriceInverse.set(this, null);
52
+ _FlamingoSwapControllerService_privatePriceImpact.set(this, null);
53
+ _FlamingoSwapControllerService_privateLiquidityProviderFee.set(this, null);
54
+ _FlamingoSwapControllerService_privateRoutes.set(this, null);
55
+ _FlamingoSwapControllerService_privateLastAmountChange.set(this, null);
57
56
  __classPrivateFieldSet(this, _FlamingoSwapControllerService_network, network, "f");
58
57
  this.eventEmitter = new events_1.default();
59
58
  }
60
59
  buildSwapArgs() {
61
- if (!this.accountToUse)
62
- throw new FlamingoSwapError_1.FlamingoSwapMissingParametersError('accountToUse');
63
- if (!this.amountToReceive)
64
- throw new FlamingoSwapError_1.FlamingoSwapMissingParametersError('amountToReceive');
65
- if (!this.amountToUse)
66
- throw new FlamingoSwapError_1.FlamingoSwapMissingParametersError('amountToUse');
67
- if (!this.tokenToReceive)
68
- throw new FlamingoSwapError_1.FlamingoSwapMissingParametersError('tokenToReceive');
69
- if (!this.tokenToUse)
70
- throw new FlamingoSwapError_1.FlamingoSwapMissingParametersError('tokenToUse');
60
+ if (!__classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_accountToUse_get) ||
61
+ !__classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_amountToReceive_get) ||
62
+ !__classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_amountToUse_get) ||
63
+ !__classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_tokenToReceive_get) ||
64
+ !__classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_tokenToUse_get))
65
+ throw new Error('Required parameters are not set');
71
66
  const baseSwapArgs = {
72
- address: this.accountToUse.address,
73
- amountToReceive: this.amountToReceive,
74
- amountToUse: this.amountToUse,
75
- tokenToReceive: this.tokenToReceive,
76
- tokenToUse: this.tokenToUse,
77
- deadline: this.deadline,
67
+ address: __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_accountToUse_get).address,
68
+ amountToReceive: __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_amountToReceive_get),
69
+ amountToUse: __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_amountToUse_get),
70
+ tokenToReceive: __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_tokenToReceive_get),
71
+ tokenToUse: __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_tokenToUse_get),
72
+ deadline: __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_deadline_get),
78
73
  network: __classPrivateFieldGet(this, _FlamingoSwapControllerService_network, "f"),
79
74
  };
80
- if (this.lastAmountChange === 'amountToReceive') {
81
- if (!this.maximumSelling)
82
- throw new FlamingoSwapError_1.FlamingoSwapMissingParametersError('maximumSelling');
83
- return Object.assign(Object.assign({}, baseSwapArgs), { maximumSelling: this.maximumSelling, type: 'swapTokenToReceive' });
75
+ if (__classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_lastAmountChange_get) === 'amountToReceive') {
76
+ if (!__classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_maximumSelling_get))
77
+ throw new Error("maximumSelling is required for 'amountToReceive' swap type");
78
+ return Object.assign(Object.assign({}, baseSwapArgs), { maximumSelling: __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_maximumSelling_get), type: 'swapTokenToReceive' });
84
79
  }
85
- if (!this.minimumReceived)
86
- throw new FlamingoSwapError_1.FlamingoSwapMissingParametersError('minimumReceived');
87
- return Object.assign(Object.assign({}, baseSwapArgs), { minimumReceived: this.minimumReceived, type: 'swapTokenToUse' });
80
+ if (!__classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_minimumReceived_get))
81
+ throw new Error("minimumReceived is required for 'amountToUse' swap type");
82
+ return Object.assign(Object.assign({}, baseSwapArgs), { minimumReceived: __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_minimumReceived_get), type: 'swapTokenToUse' });
88
83
  }
89
84
  setAccountToUse(account) {
90
- this.accountToUse = account;
85
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, account, "a", _FlamingoSwapControllerService_accountToUse_set);
91
86
  }
92
87
  setAmountToUse(val) {
93
- this.amountToUse = val;
94
- this.lastAmountChange = 'amountToUse';
95
- this.recalculateSwapArguments();
88
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, val, "a", _FlamingoSwapControllerService_amountToUse_set);
89
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, 'amountToUse', "a", _FlamingoSwapControllerService_lastAmountChange_set);
90
+ __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "m", _FlamingoSwapControllerService_recalculateSwapArguments).call(this);
96
91
  }
97
92
  setAmountToReceive(val) {
98
- this.amountToReceive = val;
99
- this.lastAmountChange = 'amountToReceive';
100
- this.recalculateSwapArguments();
93
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, val, "a", _FlamingoSwapControllerService_amountToReceive_set);
94
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, 'amountToReceive', "a", _FlamingoSwapControllerService_lastAmountChange_set);
95
+ __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "m", _FlamingoSwapControllerService_recalculateSwapArguments).call(this);
101
96
  }
102
97
  setDeadline(deadline) {
103
- this.deadline = deadline;
98
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, deadline, "a", _FlamingoSwapControllerService_deadline_set);
104
99
  }
105
100
  setSlippage(slippage) {
106
- this.slippage = slippage;
107
- this.recalculateSwapArguments();
101
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, slippage, "a", _FlamingoSwapControllerService_slippage_set);
102
+ __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "m", _FlamingoSwapControllerService_recalculateSwapArguments).call(this);
108
103
  }
109
104
  setTokenToUse(val) {
110
105
  return __awaiter(this, void 0, void 0, function* () {
111
- this.tokenToUse = val;
106
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, val, "a", _FlamingoSwapControllerService_tokenToUse_set);
112
107
  yield this.setReserves();
113
108
  });
114
109
  }
115
110
  setTokenToReceive(val) {
116
111
  return __awaiter(this, void 0, void 0, function* () {
117
- this.tokenToReceive = val;
112
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, val, "a", _FlamingoSwapControllerService_tokenToReceive_set);
118
113
  yield this.setReserves();
119
114
  });
120
115
  }
@@ -122,10 +117,8 @@ class FlamingoSwapControllerService {
122
117
  return __awaiter(this, void 0, void 0, function* () {
123
118
  if (isLedger)
124
119
  throw new Error('Method not implemented.');
125
- if (!this.accountToUse)
126
- throw new FlamingoSwapError_1.FlamingoSwapMissingParametersError('accountToUse');
127
120
  const swapArguments = this.buildSwapArgs();
128
- const neonInvokerAccount = new neon_core_1.wallet.Account(this.accountToUse);
121
+ const neonInvokerAccount = new neon_core_1.wallet.Account(__classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_accountToUse_get));
129
122
  const invoker = yield neon_dappkit_1.NeonInvoker.init({
130
123
  rpcAddress: __classPrivateFieldGet(this, _FlamingoSwapControllerService_network, "f").url,
131
124
  account: neonInvokerAccount,
@@ -135,198 +128,163 @@ class FlamingoSwapControllerService {
135
128
  }
136
129
  setReserves() {
137
130
  return __awaiter(this, void 0, void 0, function* () {
138
- if (!this.tokenToReceive || !this.tokenToUse)
131
+ if (!__classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_tokenToReceive_get) || !__classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_tokenToUse_get))
139
132
  return;
140
133
  const invoker = yield neon_dappkit_1.NeonInvoker.init({
141
134
  rpcAddress: __classPrivateFieldGet(this, _FlamingoSwapControllerService_network, "f").url,
142
135
  });
143
136
  const invocation = FlamingoSwapNeonDappKitInvocationBuilder_1.FlamingoSwapNeonDappKitInvocationBuilder.getReservesInvocation({
144
137
  network: __classPrivateFieldGet(this, _FlamingoSwapControllerService_network, "f"),
145
- tokenToReceiveScriptHash: this.tokenToReceive.hash,
146
- tokenToUseScriptHash: this.tokenToUse.hash,
138
+ tokenToReceiveScriptHash: __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_tokenToReceive_get).hash,
139
+ tokenToUseScriptHash: __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_tokenToUse_get).hash,
147
140
  });
148
141
  const { stack } = yield invoker.testInvoke(invocation);
149
142
  if (!neon_dappkit_1.TypeChecker.isStackTypeArray(stack[0]) ||
150
143
  !neon_dappkit_1.TypeChecker.isStackTypeInteger(stack[0].value[0]) ||
151
144
  !neon_dappkit_1.TypeChecker.isStackTypeInteger(stack[0].value[1]))
152
- throw new FlamingoSwapError_1.FlamingoInvalidReservesResponseError();
153
- this.reservesToReceive = stack[0].value[0].value;
154
- this.reservesToUse = stack[0].value[1].value;
155
- this.recalculateSwapArguments();
145
+ throw new Error('Invalid reserves response');
146
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, stack[0].value[0].value, "a", _FlamingoSwapControllerService_reservesToReceive_set);
147
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, stack[0].value[1].value, "a", _FlamingoSwapControllerService_reservesToUse_set);
148
+ __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "m", _FlamingoSwapControllerService_recalculateSwapArguments).call(this);
156
149
  });
157
150
  }
158
151
  startListeningBlockGeneration() {
159
- this.ws = new isomorphic_ws_1.default(constants_1.BLOCKCHAIN_WSS_URL);
160
- this.ws.onopen = () => {
152
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_ws, new isomorphic_ws_1.default(BLOCKCHAIN_WSS_URL), "f");
153
+ __classPrivateFieldGet(this, _FlamingoSwapControllerService_ws, "f").onopen = () => {
161
154
  const block_added = {
162
155
  jsonrpc: '2.0',
163
156
  method: 'subscribe',
164
157
  params: ['block_added'],
165
158
  id: 1,
166
159
  };
167
- this.ws.send(JSON.stringify(block_added));
160
+ __classPrivateFieldGet(this, _FlamingoSwapControllerService_ws, "f").send(JSON.stringify(block_added));
168
161
  };
169
- this.ws.onmessage = () => __awaiter(this, void 0, void 0, function* () {
162
+ __classPrivateFieldGet(this, _FlamingoSwapControllerService_ws, "f").onmessage = () => __awaiter(this, void 0, void 0, function* () {
170
163
  this.setReserves();
171
164
  });
172
165
  }
173
166
  stopListeningBlockGeneration() {
174
- if (this.ws) {
175
- this.ws.close();
176
- this.ws = null;
167
+ if (__classPrivateFieldGet(this, _FlamingoSwapControllerService_ws, "f")) {
168
+ __classPrivateFieldGet(this, _FlamingoSwapControllerService_ws, "f").close();
169
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_ws, null, "f");
177
170
  }
178
171
  }
179
- recalculateSwapArguments() {
180
- if (!this.tokenToReceive || !this.tokenToUse || !this.reservesToReceive || !this.reservesToUse)
181
- return;
182
- if ((this.lastAmountChange === 'amountToReceive' && this.amountToReceive) ||
183
- (this.lastAmountChange === 'amountToUse' && this.amountToUse)) {
184
- const amountToReceive = this.lastAmountChange === 'amountToReceive' ? this.amountToReceive : null;
185
- const amountToUse = this.lastAmountChange === 'amountToUse' ? this.amountToUse : null;
186
- const { amountToUseToDisplay, amountToReceiveToDisplay, maximumSelling, minimumReceived, liquidityProviderFee, priceImpact, priceInverse, } = FlamingoSwapHelper_1.FlamingoSwapHelper.getSwapFields({
187
- network: __classPrivateFieldGet(this, _FlamingoSwapControllerService_network, "f"),
188
- amountToReceive,
189
- amountToUse,
190
- tokenToUse: this.tokenToUse,
191
- tokenToReceive: this.tokenToReceive,
192
- reservesToUse: this.reservesToUse,
193
- reservesToReceive: this.reservesToReceive,
194
- slippage: this.slippage,
195
- });
196
- this.amountToUse = amountToUseToDisplay;
197
- this.amountToReceive = amountToReceiveToDisplay;
198
- this.maximumSelling = maximumSelling;
199
- this.minimumReceived = minimumReceived;
200
- this.liquidityProviderFee = liquidityProviderFee;
201
- this.priceImpact = priceImpact;
202
- this.priceInverse = priceInverse;
203
- this.routes = []; // TODO: It will be implemented in Swap Multi Invoke issue
204
- return;
205
- }
206
- this.clearFields();
207
- }
208
- clearFields() {
209
- this.amountToUse = null;
210
- this.amountToReceive = null;
211
- this.minimumReceived = null;
212
- this.maximumSelling = null;
213
- this.liquidityProviderFee = null;
214
- this.priceImpact = null;
215
- this.priceInverse = null;
216
- }
217
- // Getters and setters
218
- get lastAmountChange() {
219
- return __classPrivateFieldGet(this, _FlamingoSwapControllerService_lastAmountChange, "f");
220
- }
221
- set lastAmountChange(val) {
222
- __classPrivateFieldSet(this, _FlamingoSwapControllerService_lastAmountChange, val, "f");
223
- this.eventEmitter.emit('lastAmountChanged', val);
224
- }
225
- get accountToUse() {
226
- return __classPrivateFieldGet(this, _FlamingoSwapControllerService_accountToUse, "f");
227
- }
228
- set accountToUse(val) {
229
- __classPrivateFieldSet(this, _FlamingoSwapControllerService_accountToUse, val, "f");
230
- this.eventEmitter.emit('accountToUse', val);
231
- }
232
- get amountToUse() {
233
- return __classPrivateFieldGet(this, _FlamingoSwapControllerService_amountToUse, "f");
234
- }
235
- set amountToUse(val) {
236
- __classPrivateFieldSet(this, _FlamingoSwapControllerService_amountToUse, val, "f");
237
- this.eventEmitter.emit('amountToUse', val);
238
- }
239
- get minimumReceived() {
240
- return __classPrivateFieldGet(this, _FlamingoSwapControllerService_minimumReceived, "f");
241
- }
242
- set minimumReceived(val) {
243
- __classPrivateFieldSet(this, _FlamingoSwapControllerService_minimumReceived, val, "f");
244
- this.eventEmitter.emit('minimumReceived', val);
245
- }
246
- get maximumSelling() {
247
- return __classPrivateFieldGet(this, _FlamingoSwapControllerService_maximumSelling, "f");
248
- }
249
- set maximumSelling(val) {
250
- __classPrivateFieldSet(this, _FlamingoSwapControllerService_maximumSelling, val, "f");
251
- this.eventEmitter.emit('maximumSelling', val);
252
- }
253
- get amountToReceive() {
254
- return __classPrivateFieldGet(this, _FlamingoSwapControllerService_amountToReceive, "f");
255
- }
256
- set amountToReceive(val) {
257
- __classPrivateFieldSet(this, _FlamingoSwapControllerService_amountToReceive, val, "f");
258
- this.eventEmitter.emit('amountToReceive', val);
259
- }
260
- get deadline() {
261
- return __classPrivateFieldGet(this, _FlamingoSwapControllerService_deadline, "f");
262
- }
263
- set deadline(val) {
264
- __classPrivateFieldSet(this, _FlamingoSwapControllerService_deadline, val, "f");
265
- this.eventEmitter.emit('deadline', val);
266
- }
267
- get liquidityProviderFee() {
268
- return __classPrivateFieldGet(this, _FlamingoSwapControllerService_liquidityProviderFee, "f");
269
- }
270
- set liquidityProviderFee(val) {
271
- __classPrivateFieldSet(this, _FlamingoSwapControllerService_liquidityProviderFee, val, "f");
272
- this.eventEmitter.emit('liquidityProviderFee', val);
273
- }
274
- get priceImpact() {
275
- return __classPrivateFieldGet(this, _FlamingoSwapControllerService_priceImpact, "f");
276
- }
277
- set priceImpact(val) {
278
- __classPrivateFieldSet(this, _FlamingoSwapControllerService_priceImpact, val, "f");
279
- this.eventEmitter.emit('priceImpact', val);
280
- }
281
- get priceInverse() {
282
- return __classPrivateFieldGet(this, _FlamingoSwapControllerService_priceInverse, "f");
283
- }
284
- set priceInverse(val) {
285
- __classPrivateFieldSet(this, _FlamingoSwapControllerService_priceInverse, val, "f");
286
- this.eventEmitter.emit('priceInverse', val);
287
- }
288
- get routes() {
289
- return __classPrivateFieldGet(this, _FlamingoSwapControllerService_routes, "f");
290
- }
291
- set routes(val) {
292
- __classPrivateFieldSet(this, _FlamingoSwapControllerService_routes, val, "f");
293
- this.eventEmitter.emit('routes', val);
294
- }
295
- get reservesToUse() {
296
- return __classPrivateFieldGet(this, _FlamingoSwapControllerService_reservesToUse, "f");
297
- }
298
- set reservesToUse(val) {
299
- __classPrivateFieldSet(this, _FlamingoSwapControllerService_reservesToUse, val, "f");
300
- this.eventEmitter.emit('reservesToUse', val);
301
- }
302
- get reservesToReceive() {
303
- return __classPrivateFieldGet(this, _FlamingoSwapControllerService_reservesToReceive, "f");
304
- }
305
- set reservesToReceive(val) {
306
- __classPrivateFieldSet(this, _FlamingoSwapControllerService_reservesToReceive, val, "f");
307
- this.eventEmitter.emit('reservesToReceive', val);
308
- }
309
- get slippage() {
310
- return __classPrivateFieldGet(this, _FlamingoSwapControllerService_slippage, "f");
311
- }
312
- set slippage(val) {
313
- __classPrivateFieldSet(this, _FlamingoSwapControllerService_slippage, val, "f");
314
- this.eventEmitter.emit('slippage', val);
315
- }
316
- get tokenToReceive() {
317
- return __classPrivateFieldGet(this, _FlamingoSwapControllerService_tokenToReceive, "f");
318
- }
319
- set tokenToReceive(val) {
320
- __classPrivateFieldSet(this, _FlamingoSwapControllerService_tokenToReceive, val, "f");
321
- this.eventEmitter.emit('tokenToReceive', val);
322
- }
323
- get tokenToUse() {
324
- return __classPrivateFieldGet(this, _FlamingoSwapControllerService_tokenToUse, "f");
325
- }
326
- set tokenToUse(val) {
327
- __classPrivateFieldSet(this, _FlamingoSwapControllerService_tokenToUse, val, "f");
328
- this.eventEmitter.emit('tokenToUse', val);
329
- }
330
172
  }
331
173
  exports.FlamingoSwapControllerService = FlamingoSwapControllerService;
332
- _FlamingoSwapControllerService_network = new WeakMap(), _FlamingoSwapControllerService_accountToUse = new WeakMap(), _FlamingoSwapControllerService_tokenToReceive = new WeakMap(), _FlamingoSwapControllerService_tokenToUse = new WeakMap(), _FlamingoSwapControllerService_amountToReceive = new WeakMap(), _FlamingoSwapControllerService_amountToUse = new WeakMap(), _FlamingoSwapControllerService_minimumReceived = new WeakMap(), _FlamingoSwapControllerService_maximumSelling = new WeakMap(), _FlamingoSwapControllerService_reservesToReceive = new WeakMap(), _FlamingoSwapControllerService_reservesToUse = new WeakMap(), _FlamingoSwapControllerService_slippage = new WeakMap(), _FlamingoSwapControllerService_deadline = new WeakMap(), _FlamingoSwapControllerService_priceInverse = new WeakMap(), _FlamingoSwapControllerService_priceImpact = new WeakMap(), _FlamingoSwapControllerService_liquidityProviderFee = new WeakMap(), _FlamingoSwapControllerService_routes = new WeakMap(), _FlamingoSwapControllerService_lastAmountChange = new WeakMap();
174
+ _FlamingoSwapControllerService_ws = new WeakMap(), _FlamingoSwapControllerService_network = new WeakMap(), _FlamingoSwapControllerService_privateAccountToUse = new WeakMap(), _FlamingoSwapControllerService_privateTokenToReceive = new WeakMap(), _FlamingoSwapControllerService_privateTokenToUse = new WeakMap(), _FlamingoSwapControllerService_privateAmountToReceive = new WeakMap(), _FlamingoSwapControllerService_privateAmountToUse = new WeakMap(), _FlamingoSwapControllerService_privateMinimumReceived = new WeakMap(), _FlamingoSwapControllerService_privateMaximumSelling = new WeakMap(), _FlamingoSwapControllerService_privateReservesToReceive = new WeakMap(), _FlamingoSwapControllerService_privateReservesToUse = new WeakMap(), _FlamingoSwapControllerService_privateSlippage = new WeakMap(), _FlamingoSwapControllerService_privateDeadline = new WeakMap(), _FlamingoSwapControllerService_privatePriceInverse = new WeakMap(), _FlamingoSwapControllerService_privatePriceImpact = new WeakMap(), _FlamingoSwapControllerService_privateLiquidityProviderFee = new WeakMap(), _FlamingoSwapControllerService_privateRoutes = new WeakMap(), _FlamingoSwapControllerService_privateLastAmountChange = new WeakMap(), _FlamingoSwapControllerService_instances = new WeakSet(), _FlamingoSwapControllerService_recalculateSwapArguments = function _FlamingoSwapControllerService_recalculateSwapArguments() {
175
+ if (!__classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_tokenToReceive_get) || !__classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_tokenToUse_get) || !__classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_reservesToReceive_get) || !__classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_reservesToUse_get))
176
+ return;
177
+ if ((__classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_lastAmountChange_get) === 'amountToReceive' && __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_amountToReceive_get)) ||
178
+ (__classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_lastAmountChange_get) === 'amountToUse' && __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_amountToUse_get))) {
179
+ const amountToReceive = __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_lastAmountChange_get) === 'amountToReceive' ? __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_amountToReceive_get) : null;
180
+ const amountToUse = __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_lastAmountChange_get) === 'amountToUse' ? __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_amountToUse_get) : null;
181
+ const { amountToUseToDisplay, amountToReceiveToDisplay, maximumSelling, minimumReceived, liquidityProviderFee, priceImpact, priceInverse, } = FlamingoSwapHelper_1.FlamingoSwapHelper.getSwapFields({
182
+ network: __classPrivateFieldGet(this, _FlamingoSwapControllerService_network, "f"),
183
+ amountToReceive,
184
+ amountToUse,
185
+ tokenToUse: __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_tokenToUse_get),
186
+ tokenToReceive: __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_tokenToReceive_get),
187
+ reservesToUse: __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_reservesToUse_get),
188
+ reservesToReceive: __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_reservesToReceive_get),
189
+ slippage: __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "a", _FlamingoSwapControllerService_slippage_get),
190
+ });
191
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, amountToUseToDisplay, "a", _FlamingoSwapControllerService_amountToUse_set);
192
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, amountToReceiveToDisplay, "a", _FlamingoSwapControllerService_amountToReceive_set);
193
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, maximumSelling, "a", _FlamingoSwapControllerService_maximumSelling_set);
194
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, minimumReceived, "a", _FlamingoSwapControllerService_minimumReceived_set);
195
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, liquidityProviderFee, "a", _FlamingoSwapControllerService_liquidityProviderFee_set);
196
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, priceImpact, "a", _FlamingoSwapControllerService_priceImpact_set);
197
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, priceInverse, "a", _FlamingoSwapControllerService_priceInverse_set);
198
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, [], "a", _FlamingoSwapControllerService_routes_set); // TODO: It will be implemented in Swap Multi Invoke issue
199
+ return;
200
+ }
201
+ __classPrivateFieldGet(this, _FlamingoSwapControllerService_instances, "m", _FlamingoSwapControllerService_clearFields).call(this);
202
+ }, _FlamingoSwapControllerService_clearFields = function _FlamingoSwapControllerService_clearFields() {
203
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, null, "a", _FlamingoSwapControllerService_amountToUse_set);
204
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, null, "a", _FlamingoSwapControllerService_amountToReceive_set);
205
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, null, "a", _FlamingoSwapControllerService_minimumReceived_set);
206
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, null, "a", _FlamingoSwapControllerService_maximumSelling_set);
207
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, null, "a", _FlamingoSwapControllerService_liquidityProviderFee_set);
208
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, null, "a", _FlamingoSwapControllerService_priceImpact_set);
209
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, null, "a", _FlamingoSwapControllerService_priceInverse_set);
210
+ }, _FlamingoSwapControllerService_lastAmountChange_get = function _FlamingoSwapControllerService_lastAmountChange_get() {
211
+ return __classPrivateFieldGet(this, _FlamingoSwapControllerService_privateLastAmountChange, "f");
212
+ }, _FlamingoSwapControllerService_lastAmountChange_set = function _FlamingoSwapControllerService_lastAmountChange_set(val) {
213
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_privateLastAmountChange, val, "f");
214
+ this.eventEmitter.emit('lastAmountChanged', val);
215
+ }, _FlamingoSwapControllerService_accountToUse_get = function _FlamingoSwapControllerService_accountToUse_get() {
216
+ return __classPrivateFieldGet(this, _FlamingoSwapControllerService_privateAccountToUse, "f");
217
+ }, _FlamingoSwapControllerService_accountToUse_set = function _FlamingoSwapControllerService_accountToUse_set(val) {
218
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_privateAccountToUse, val, "f");
219
+ this.eventEmitter.emit('accountToUse', val);
220
+ }, _FlamingoSwapControllerService_amountToUse_get = function _FlamingoSwapControllerService_amountToUse_get() {
221
+ return __classPrivateFieldGet(this, _FlamingoSwapControllerService_privateAmountToUse, "f");
222
+ }, _FlamingoSwapControllerService_amountToUse_set = function _FlamingoSwapControllerService_amountToUse_set(val) {
223
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_privateAmountToUse, val, "f");
224
+ this.eventEmitter.emit('amountToUse', val);
225
+ }, _FlamingoSwapControllerService_minimumReceived_get = function _FlamingoSwapControllerService_minimumReceived_get() {
226
+ return __classPrivateFieldGet(this, _FlamingoSwapControllerService_privateMinimumReceived, "f");
227
+ }, _FlamingoSwapControllerService_minimumReceived_set = function _FlamingoSwapControllerService_minimumReceived_set(val) {
228
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_privateMinimumReceived, val, "f");
229
+ this.eventEmitter.emit('minimumReceived', val);
230
+ }, _FlamingoSwapControllerService_maximumSelling_get = function _FlamingoSwapControllerService_maximumSelling_get() {
231
+ return __classPrivateFieldGet(this, _FlamingoSwapControllerService_privateMaximumSelling, "f");
232
+ }, _FlamingoSwapControllerService_maximumSelling_set = function _FlamingoSwapControllerService_maximumSelling_set(val) {
233
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_privateMaximumSelling, val, "f");
234
+ this.eventEmitter.emit('maximumSelling', val);
235
+ }, _FlamingoSwapControllerService_amountToReceive_get = function _FlamingoSwapControllerService_amountToReceive_get() {
236
+ return __classPrivateFieldGet(this, _FlamingoSwapControllerService_privateAmountToReceive, "f");
237
+ }, _FlamingoSwapControllerService_amountToReceive_set = function _FlamingoSwapControllerService_amountToReceive_set(val) {
238
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_privateAmountToReceive, val, "f");
239
+ this.eventEmitter.emit('amountToReceive', val);
240
+ }, _FlamingoSwapControllerService_deadline_get = function _FlamingoSwapControllerService_deadline_get() {
241
+ return __classPrivateFieldGet(this, _FlamingoSwapControllerService_privateDeadline, "f");
242
+ }, _FlamingoSwapControllerService_deadline_set = function _FlamingoSwapControllerService_deadline_set(val) {
243
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_privateDeadline, val, "f");
244
+ this.eventEmitter.emit('deadline', val);
245
+ }, _FlamingoSwapControllerService_liquidityProviderFee_get = function _FlamingoSwapControllerService_liquidityProviderFee_get() {
246
+ return __classPrivateFieldGet(this, _FlamingoSwapControllerService_privateLiquidityProviderFee, "f");
247
+ }, _FlamingoSwapControllerService_liquidityProviderFee_set = function _FlamingoSwapControllerService_liquidityProviderFee_set(val) {
248
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_privateLiquidityProviderFee, val, "f");
249
+ this.eventEmitter.emit('liquidityProviderFee', val);
250
+ }, _FlamingoSwapControllerService_priceImpact_get = function _FlamingoSwapControllerService_priceImpact_get() {
251
+ return __classPrivateFieldGet(this, _FlamingoSwapControllerService_privatePriceImpact, "f");
252
+ }, _FlamingoSwapControllerService_priceImpact_set = function _FlamingoSwapControllerService_priceImpact_set(val) {
253
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_privatePriceImpact, val, "f");
254
+ this.eventEmitter.emit('priceImpact', val);
255
+ }, _FlamingoSwapControllerService_priceInverse_get = function _FlamingoSwapControllerService_priceInverse_get() {
256
+ return __classPrivateFieldGet(this, _FlamingoSwapControllerService_privatePriceInverse, "f");
257
+ }, _FlamingoSwapControllerService_priceInverse_set = function _FlamingoSwapControllerService_priceInverse_set(val) {
258
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_privatePriceInverse, val, "f");
259
+ this.eventEmitter.emit('priceInverse', val);
260
+ }, _FlamingoSwapControllerService_routes_get = function _FlamingoSwapControllerService_routes_get() {
261
+ return __classPrivateFieldGet(this, _FlamingoSwapControllerService_privateRoutes, "f");
262
+ }, _FlamingoSwapControllerService_routes_set = function _FlamingoSwapControllerService_routes_set(val) {
263
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_privateRoutes, val, "f");
264
+ this.eventEmitter.emit('routes', val);
265
+ }, _FlamingoSwapControllerService_reservesToUse_get = function _FlamingoSwapControllerService_reservesToUse_get() {
266
+ return __classPrivateFieldGet(this, _FlamingoSwapControllerService_privateReservesToUse, "f");
267
+ }, _FlamingoSwapControllerService_reservesToUse_set = function _FlamingoSwapControllerService_reservesToUse_set(val) {
268
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_privateReservesToUse, val, "f");
269
+ this.eventEmitter.emit('reservesToUse', val);
270
+ }, _FlamingoSwapControllerService_reservesToReceive_get = function _FlamingoSwapControllerService_reservesToReceive_get() {
271
+ return __classPrivateFieldGet(this, _FlamingoSwapControllerService_privateReservesToReceive, "f");
272
+ }, _FlamingoSwapControllerService_reservesToReceive_set = function _FlamingoSwapControllerService_reservesToReceive_set(val) {
273
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_privateReservesToReceive, val, "f");
274
+ this.eventEmitter.emit('reservesToReceive', val);
275
+ }, _FlamingoSwapControllerService_slippage_get = function _FlamingoSwapControllerService_slippage_get() {
276
+ return __classPrivateFieldGet(this, _FlamingoSwapControllerService_privateSlippage, "f");
277
+ }, _FlamingoSwapControllerService_slippage_set = function _FlamingoSwapControllerService_slippage_set(val) {
278
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_privateSlippage, val, "f");
279
+ this.eventEmitter.emit('slippage', val);
280
+ }, _FlamingoSwapControllerService_tokenToReceive_get = function _FlamingoSwapControllerService_tokenToReceive_get() {
281
+ return __classPrivateFieldGet(this, _FlamingoSwapControllerService_privateTokenToReceive, "f");
282
+ }, _FlamingoSwapControllerService_tokenToReceive_set = function _FlamingoSwapControllerService_tokenToReceive_set(val) {
283
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_privateTokenToReceive, val, "f");
284
+ this.eventEmitter.emit('tokenToReceive', val);
285
+ }, _FlamingoSwapControllerService_tokenToUse_get = function _FlamingoSwapControllerService_tokenToUse_get() {
286
+ return __classPrivateFieldGet(this, _FlamingoSwapControllerService_privateTokenToUse, "f");
287
+ }, _FlamingoSwapControllerService_tokenToUse_set = function _FlamingoSwapControllerService_tokenToUse_set(val) {
288
+ __classPrivateFieldSet(this, _FlamingoSwapControllerService_privateTokenToUse, val, "f");
289
+ this.eventEmitter.emit('tokenToUse', val);
290
+ };
@@ -1,6 +1,6 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import { Network, Token } from '@cityofzion/blockchain-service';
3
- import { AvailableNetworkIds } from '../constants';
3
+ import { AvailableNetworkIds } from '../BSNeo3Helper';
4
4
  type TGetSwapArgs = {
5
5
  amountToUse: string | null;
6
6
  amountToReceive: string | null;
@@ -11,12 +11,25 @@ type TGetSwapArgs = {
11
11
  slippage: number;
12
12
  network: Network<AvailableNetworkIds>;
13
13
  };
14
+ export type SwapScriptHashes = {
15
+ flamingoSwapRouter: string;
16
+ flamingoPairWhiteList: string;
17
+ flamingoFactory: string;
18
+ neo: string;
19
+ gas: string;
20
+ bneo: string;
21
+ flpBneoGas: string;
22
+ };
14
23
  export declare class FlamingoSwapHelper {
24
+ #private;
15
25
  static readonly BN_0: BigNumber;
16
26
  static readonly BN_1: BigNumber;
17
27
  static readonly BN_997: BigNumber;
18
28
  static readonly BN_1000: BigNumber;
19
29
  static readonly FEE_RATE: BigNumber;
30
+ static readonly GAS_PER_NEO = 0.001;
31
+ static getSwapScriptHashes(network: Network<AvailableNetworkIds>): SwapScriptHashes;
32
+ static getBneoToken(network: Network<AvailableNetworkIds>): Token;
20
33
  static getSwapFields(params: TGetSwapArgs): {
21
34
  amountToReceiveToDisplay: string;
22
35
  amountToUseToDisplay: string;