@cityofzion/bs-neo3 1.2.1 → 1.3.0

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.
Files changed (45) hide show
  1. package/dist/BSNeo3.d.ts +3 -3
  2. package/dist/BSNeo3.js +8 -8
  3. package/dist/builder/invocation/FlamingoSwapInvocationBuilderNeo3.d.ts +7 -0
  4. package/dist/builder/invocation/FlamingoSwapInvocationBuilderNeo3.js +95 -0
  5. package/dist/builder/invocation/NeonDappKitInvocationBuilderNeo3.d.ts +34 -0
  6. package/dist/builder/invocation/NeonDappKitInvocationBuilderNeo3.js +102 -0
  7. package/dist/constants/FlamingoSwapConstants.d.ts +36 -0
  8. package/dist/constants/FlamingoSwapConstants.js +853 -0
  9. package/dist/{BSNeo3Helper.js → helpers/BSNeo3Helper.js} +2 -2
  10. package/dist/helpers/FlamingoSwapHelper.d.ts +19 -0
  11. package/dist/helpers/FlamingoSwapHelper.js +84 -0
  12. package/dist/index.d.ts +13 -11
  13. package/dist/index.js +13 -11
  14. package/dist/{DoraBDSNeo3.d.ts → services/blockchain-data/DoraBDSNeo3.d.ts} +4 -4
  15. package/dist/{DoraBDSNeo3.js → services/blockchain-data/DoraBDSNeo3.js} +3 -3
  16. package/dist/{RpcBDSNeo3.d.ts → services/blockchain-data/RpcBDSNeo3.d.ts} +2 -2
  17. package/dist/{RpcBDSNeo3.js → services/blockchain-data/RpcBDSNeo3.js} +4 -4
  18. package/dist/{FlamingoEDSNeo3.d.ts → services/exchange-data/FlamingoEDSNeo3.d.ts} +1 -1
  19. package/dist/{FlamingoEDSNeo3.js → services/exchange-data/FlamingoEDSNeo3.js} +1 -1
  20. package/dist/{DoraESNeo3.d.ts → services/explorer/DoraESNeo3.d.ts} +2 -2
  21. package/dist/{DoraESNeo3.js → services/explorer/DoraESNeo3.js} +1 -1
  22. package/dist/{GhostMarketNDSNeo3.d.ts → services/nft-data/GhostMarketNDSNeo3.d.ts} +2 -2
  23. package/dist/{RpcNDSNeo3.d.ts → services/nft-data/RpcNDSNeo3.d.ts} +1 -1
  24. package/dist/services/swap/FlamingoSwapServiceNeo3.d.ts +23 -0
  25. package/dist/services/swap/FlamingoSwapServiceNeo3.js +271 -0
  26. package/dist/services/swap/handlers/FlamingoSwapDetailsHandler.d.ts +24 -0
  27. package/dist/services/swap/handlers/FlamingoSwapDetailsHandler.js +178 -0
  28. package/dist/services/swap/handlers/FlamingoSwapRouteHandler.d.ts +13 -0
  29. package/dist/services/swap/handlers/FlamingoSwapRouteHandler.js +181 -0
  30. package/dist/services/swap/handlers/FlamingoSwapSocketHandler.d.ts +9 -0
  31. package/dist/services/swap/handlers/FlamingoSwapSocketHandler.js +57 -0
  32. package/dist/services/swap/handlers/index.d.ts +3 -0
  33. package/dist/services/swap/handlers/index.js +19 -0
  34. package/package.json +8 -6
  35. package/dist/flamingo-swap/FlamingoSwapControllerService.d.ts +0 -20
  36. package/dist/flamingo-swap/FlamingoSwapControllerService.js +0 -290
  37. package/dist/flamingo-swap/FlamingoSwapHelper.d.ts +0 -48
  38. package/dist/flamingo-swap/FlamingoSwapHelper.js +0 -171
  39. package/dist/flamingo-swap/FlamingoSwapNeonDappKitInvocationBuilder.d.ts +0 -19
  40. package/dist/flamingo-swap/FlamingoSwapNeonDappKitInvocationBuilder.js +0 -208
  41. package/dist/{BSNeo3Helper.d.ts → helpers/BSNeo3Helper.d.ts} +0 -0
  42. package/dist/{NeonDappKitLedgerServiceNeo3.d.ts → services/ledger/NeonDappKitLedgerServiceNeo3.d.ts} +1 -1
  43. package/dist/{NeonDappKitLedgerServiceNeo3.js → services/ledger/NeonDappKitLedgerServiceNeo3.js} +1 -1
  44. package/dist/{GhostMarketNDSNeo3.js → services/nft-data/GhostMarketNDSNeo3.js} +1 -1
  45. /package/dist/{RpcNDSNeo3.js → services/nft-data/RpcNDSNeo3.js} +0 -0
@@ -10,8 +10,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
10
10
  var _a, _BSNeo3Helper_EXTRA_TOKENS_BY_NETWORK_ID, _BSNeo3Helper_RPC_LIST_BY_NETWORK_ID;
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.BSNeo3Helper = void 0;
13
- const mainnet_json_1 = __importDefault(require("./assets/tokens/mainnet.json"));
14
- const common_json_1 = __importDefault(require("./assets/tokens/common.json"));
13
+ const common_json_1 = __importDefault(require("../assets/tokens/common.json"));
14
+ const mainnet_json_1 = __importDefault(require("../assets/tokens/mainnet.json"));
15
15
  class BSNeo3Helper {
16
16
  static getTokens(network) {
17
17
  var _b;
@@ -0,0 +1,19 @@
1
+ import { Network, SwapRoute, Token } from '@cityofzion/blockchain-service';
2
+ import BigNumber from 'bignumber.js';
3
+ import { FlamingoSwapPoolInfo, FlamingoSwapPools, FlamingoSwapScriptHashes, FlamingoSwapTokens } from '../constants/FlamingoSwapConstants';
4
+ import { BSNeo3NetworkId } from './BSNeo3Helper';
5
+ export declare class FlamingoSwapHelper {
6
+ static getFlamingoSwapPools(network: Network<BSNeo3NetworkId>): FlamingoSwapPools;
7
+ static getFlamingoSwapPool(network: Network<BSNeo3NetworkId>, name: string): FlamingoSwapPoolInfo;
8
+ static getFlamingoSwapTokens(network: Network<BSNeo3NetworkId>): FlamingoSwapTokens;
9
+ static getFlamingoSwapToken(network: Network<BSNeo3NetworkId>, name: string): Token;
10
+ static getFlamingoSwapScriptHashes(network: Network<BSNeo3NetworkId>): FlamingoSwapScriptHashes;
11
+ static getRoutePath(route: SwapRoute[]): Token[];
12
+ static overrideToken(network: Network<BSNeo3NetworkId>, token: Token): Token;
13
+ static overrideAmountInput(network: Network<BSNeo3NetworkId>, amount: string, token: Token): BigNumber;
14
+ static overrideAmountToDisplay(network: Network<BSNeo3NetworkId>, amount: string, token: Token): string;
15
+ static overrideRoute(network: Network<BSNeo3NetworkId>, route: SwapRoute[]): SwapRoute[];
16
+ static normalizeHash(hash: string): string;
17
+ static isNeoToken(network: Network<BSNeo3NetworkId>, token: Token): boolean;
18
+ static formatAmount(amount: string, decimals: number): string;
19
+ }
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FlamingoSwapHelper = void 0;
7
+ const neon_core_1 = require("@cityofzion/neon-core");
8
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
9
+ const FlamingoSwapConstants_1 = require("../constants/FlamingoSwapConstants");
10
+ class FlamingoSwapHelper {
11
+ static getFlamingoSwapPools(network) {
12
+ const pools = FlamingoSwapConstants_1.FlamingoSwapConstants.FLAMINGO_SWAP_POOLS[network.id];
13
+ if (!pools) {
14
+ throw new Error('Invalid network');
15
+ }
16
+ return pools;
17
+ }
18
+ static getFlamingoSwapPool(network, name) {
19
+ const pools = this.getFlamingoSwapPools(network);
20
+ const pool = pools[name];
21
+ if (!pool) {
22
+ throw new Error('Invalid pool');
23
+ }
24
+ return pool;
25
+ }
26
+ static getFlamingoSwapTokens(network) {
27
+ const tokens = FlamingoSwapConstants_1.FlamingoSwapConstants.FLAMINGO_SWAP_TOKENS[network.id];
28
+ if (!tokens) {
29
+ throw new Error('Invalid network');
30
+ }
31
+ return tokens;
32
+ }
33
+ static getFlamingoSwapToken(network, name) {
34
+ const tokens = this.getFlamingoSwapTokens(network);
35
+ const token = tokens[name];
36
+ if (!token) {
37
+ throw new Error('Invalid token');
38
+ }
39
+ return token;
40
+ }
41
+ static getFlamingoSwapScriptHashes(network) {
42
+ const swapScriptHashes = FlamingoSwapConstants_1.FlamingoSwapConstants.FLAMINGO_SWAP_SCRIPT_HASHES[network.id];
43
+ if (!swapScriptHashes) {
44
+ throw new Error('Invalid network');
45
+ }
46
+ return swapScriptHashes;
47
+ }
48
+ static getRoutePath(route) {
49
+ return route
50
+ .flatMap(item => [item.tokenToUse, item.tokenToReceive])
51
+ .filter((item, index, arr) => arr.indexOf(item) === index);
52
+ }
53
+ static overrideToken(network, token) {
54
+ return this.isNeoToken(network, token) ? this.getFlamingoSwapToken(network, 'bNEO') : token;
55
+ }
56
+ static overrideAmountInput(network, amount, token) {
57
+ const overrodeToken = this.overrideToken(network, token);
58
+ return new bignumber_js_1.default(amount).shiftedBy(overrodeToken.decimals);
59
+ }
60
+ static overrideAmountToDisplay(network, amount, token) {
61
+ const overrodeToken = this.overrideToken(network, token);
62
+ return new bignumber_js_1.default(amount).shiftedBy(-overrodeToken.decimals).toFixed();
63
+ }
64
+ static overrideRoute(network, route) {
65
+ const overrodeRoute = [];
66
+ for (const routeItem of route) {
67
+ if (!this.isNeoToken(network, routeItem.tokenToUse) && !this.isNeoToken(network, routeItem.tokenToReceive)) {
68
+ overrodeRoute.push(routeItem);
69
+ }
70
+ }
71
+ return overrodeRoute;
72
+ }
73
+ static normalizeHash(hash) {
74
+ return hash.startsWith('0x') ? hash.slice(2) : hash;
75
+ }
76
+ static isNeoToken(network, token) {
77
+ const NEO = this.getFlamingoSwapToken(network, 'NEO');
78
+ return this.normalizeHash(token.hash) === this.normalizeHash(NEO.hash);
79
+ }
80
+ static formatAmount(amount, decimals) {
81
+ return neon_core_1.u.BigInteger.fromDecimal(Number(amount), decimals).toString();
82
+ }
83
+ }
84
+ exports.FlamingoSwapHelper = FlamingoSwapHelper;
package/dist/index.d.ts CHANGED
@@ -1,12 +1,14 @@
1
- export * from './flamingo-swap/FlamingoSwapControllerService';
2
- export * from './flamingo-swap/FlamingoSwapHelper';
3
- export * from './flamingo-swap/FlamingoSwapNeonDappKitInvocationBuilder';
4
1
  export * from './BSNeo3';
5
- export * from './BSNeo3Helper';
6
- export * from './DoraBDSNeo3';
7
- export * from './DoraESNeo3';
8
- export * from './FlamingoEDSNeo3';
9
- export * from './GhostMarketNDSNeo3';
10
- export * from './NeonDappKitLedgerServiceNeo3';
11
- export * from './RpcBDSNeo3';
12
- export * from './RpcNDSNeo3';
2
+ export * from './builder/invocation/FlamingoSwapInvocationBuilderNeo3';
3
+ export * from './builder/invocation/NeonDappKitInvocationBuilderNeo3';
4
+ export * from './constants/FlamingoSwapConstants';
5
+ export * from './helpers/BSNeo3Helper';
6
+ export * from './helpers/FlamingoSwapHelper';
7
+ export * from './services/blockchain-data/DoraBDSNeo3';
8
+ export * from './services/blockchain-data/RpcBDSNeo3';
9
+ export * from './services/exchange-data/FlamingoEDSNeo3';
10
+ export * from './services/explorer/DoraESNeo3';
11
+ export * from './services/ledger/NeonDappKitLedgerServiceNeo3';
12
+ export * from './services/nft-data/GhostMarketNDSNeo3';
13
+ export * from './services/nft-data/RpcNDSNeo3';
14
+ export * from './services/swap/FlamingoSwapServiceNeo3';
package/dist/index.js CHANGED
@@ -14,15 +14,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./flamingo-swap/FlamingoSwapControllerService"), exports);
18
- __exportStar(require("./flamingo-swap/FlamingoSwapHelper"), exports);
19
- __exportStar(require("./flamingo-swap/FlamingoSwapNeonDappKitInvocationBuilder"), exports);
20
17
  __exportStar(require("./BSNeo3"), exports);
21
- __exportStar(require("./BSNeo3Helper"), exports);
22
- __exportStar(require("./DoraBDSNeo3"), exports);
23
- __exportStar(require("./DoraESNeo3"), exports);
24
- __exportStar(require("./FlamingoEDSNeo3"), exports);
25
- __exportStar(require("./GhostMarketNDSNeo3"), exports);
26
- __exportStar(require("./NeonDappKitLedgerServiceNeo3"), exports);
27
- __exportStar(require("./RpcBDSNeo3"), exports);
28
- __exportStar(require("./RpcNDSNeo3"), exports);
18
+ __exportStar(require("./builder/invocation/FlamingoSwapInvocationBuilderNeo3"), exports);
19
+ __exportStar(require("./builder/invocation/NeonDappKitInvocationBuilderNeo3"), exports);
20
+ __exportStar(require("./constants/FlamingoSwapConstants"), exports);
21
+ __exportStar(require("./helpers/BSNeo3Helper"), exports);
22
+ __exportStar(require("./helpers/FlamingoSwapHelper"), exports);
23
+ __exportStar(require("./services/blockchain-data/DoraBDSNeo3"), exports);
24
+ __exportStar(require("./services/blockchain-data/RpcBDSNeo3"), exports);
25
+ __exportStar(require("./services/exchange-data/FlamingoEDSNeo3"), exports);
26
+ __exportStar(require("./services/explorer/DoraESNeo3"), exports);
27
+ __exportStar(require("./services/ledger/NeonDappKitLedgerServiceNeo3"), exports);
28
+ __exportStar(require("./services/nft-data/GhostMarketNDSNeo3"), exports);
29
+ __exportStar(require("./services/nft-data/RpcNDSNeo3"), exports);
30
+ __exportStar(require("./services/swap/FlamingoSwapServiceNeo3"), exports);
@@ -1,7 +1,7 @@
1
- import { BalanceResponse, ContractResponse, TransactionsByAddressParams, TransactionsByAddressResponse, TransactionResponse, Network, Token } from '@cityofzion/blockchain-service';
2
- import { RPCBDSNeo3 } from './RpcBDSNeo3';
3
- import { BSNeo3NetworkId } from './BSNeo3Helper';
4
- export declare class DoraBDSNeo3 extends RPCBDSNeo3 {
1
+ import { BalanceResponse, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
2
+ import { BSNeo3NetworkId } from '../../helpers/BSNeo3Helper';
3
+ import { RpcBDSNeo3 } from './RpcBDSNeo3';
4
+ export declare class DoraBDSNeo3 extends RpcBDSNeo3 {
5
5
  constructor(network: Network<BSNeo3NetworkId>, feeToken: Token, claimToken: Token, tokens: Token[]);
6
6
  getTransaction(hash: string): Promise<TransactionResponse>;
7
7
  getTransactionsByAddress({ address, nextPageParams, }: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
@@ -10,15 +10,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.DoraBDSNeo3 = void 0;
13
- const neon_js_1 = require("@cityofzion/neon-js");
14
13
  const api_1 = require("@cityofzion/dora-ts/dist/api");
14
+ const neon_js_1 = require("@cityofzion/neon-js");
15
+ const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
15
16
  const RpcBDSNeo3_1 = require("./RpcBDSNeo3");
16
- const BSNeo3Helper_1 = require("./BSNeo3Helper");
17
17
  const NeoRest = new api_1.NeoRESTApi({
18
18
  doraUrl: 'https://dora.coz.io',
19
19
  endpoint: '/api/v2/neo3',
20
20
  });
21
- class DoraBDSNeo3 extends RpcBDSNeo3_1.RPCBDSNeo3 {
21
+ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
22
22
  constructor(network, feeToken, claimToken, tokens) {
23
23
  super(network, feeToken, claimToken, tokens);
24
24
  }
@@ -1,6 +1,6 @@
1
1
  import { BDSClaimable, BalanceResponse, BlockchainDataService, ContractResponse, Network, RpcResponse, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
2
- import { BSNeo3NetworkId } from './BSNeo3Helper';
3
- export declare class RPCBDSNeo3 implements BlockchainDataService, BDSClaimable {
2
+ import { BSNeo3NetworkId } from '../../helpers/BSNeo3Helper';
3
+ export declare class RpcBDSNeo3 implements BlockchainDataService, BDSClaimable {
4
4
  readonly _tokenCache: Map<string, Token>;
5
5
  readonly _feeToken: Token;
6
6
  readonly _claimToken: Token;
@@ -9,11 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.RPCBDSNeo3 = void 0;
12
+ exports.RpcBDSNeo3 = void 0;
13
13
  const neon_core_1 = require("@cityofzion/neon-core");
14
14
  const neon_dappkit_1 = require("@cityofzion/neon-dappkit");
15
- const BSNeo3Helper_1 = require("./BSNeo3Helper");
16
- class RPCBDSNeo3 {
15
+ const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
16
+ class RpcBDSNeo3 {
17
17
  constructor(network, feeToken, claimToken, tokens) {
18
18
  this._tokenCache = new Map();
19
19
  this._tokens = [];
@@ -185,4 +185,4 @@ class RPCBDSNeo3 {
185
185
  });
186
186
  }
187
187
  }
188
- exports.RPCBDSNeo3 = RPCBDSNeo3;
188
+ exports.RpcBDSNeo3 = RpcBDSNeo3;
@@ -1,5 +1,5 @@
1
1
  import { CryptoCompareEDS, ExchangeDataService, GetTokenPriceHistoryParams, GetTokenPricesParams, Network, TokenPricesHistoryResponse, TokenPricesResponse } from '@cityofzion/blockchain-service';
2
- import { BSNeo3NetworkId } from './BSNeo3Helper';
2
+ import { BSNeo3NetworkId } from '../../helpers/BSNeo3Helper';
3
3
  export declare class FlamingoEDSNeo3 extends CryptoCompareEDS implements ExchangeDataService {
4
4
  #private;
5
5
  constructor(network: Network<BSNeo3NetworkId>);
@@ -27,7 +27,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.FlamingoEDSNeo3 = void 0;
28
28
  const blockchain_service_1 = require("@cityofzion/blockchain-service");
29
29
  const axios_1 = __importDefault(require("axios"));
30
- const BSNeo3Helper_1 = require("./BSNeo3Helper");
30
+ const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
31
31
  class FlamingoEDSNeo3 extends blockchain_service_1.CryptoCompareEDS {
32
32
  constructor(network) {
33
33
  super();
@@ -1,5 +1,5 @@
1
- import { ExplorerService, BuildNftUrlParams, Network } from '@cityofzion/blockchain-service';
2
- import { BSNeo3NetworkId } from './BSNeo3Helper';
1
+ import { BuildNftUrlParams, ExplorerService, Network } from '@cityofzion/blockchain-service';
2
+ import { BSNeo3NetworkId } from '../../helpers/BSNeo3Helper';
3
3
  export declare class DoraESNeo3 implements ExplorerService {
4
4
  #private;
5
5
  constructor(network: Network<BSNeo3NetworkId>);
@@ -13,7 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  var _DoraESNeo3_network;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.DoraESNeo3 = void 0;
16
- const BSNeo3Helper_1 = require("./BSNeo3Helper");
16
+ const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
17
17
  class DoraESNeo3 {
18
18
  constructor(network) {
19
19
  _DoraESNeo3_network.set(this, void 0);
@@ -1,5 +1,5 @@
1
- import { NftResponse, NftsResponse, GetNftParam, GetNftsByAddressParams, Network } from '@cityofzion/blockchain-service';
2
- import { BSNeo3NetworkId } from './BSNeo3Helper';
1
+ import { GetNftParam, GetNftsByAddressParams, Network, NftResponse, NftsResponse } from '@cityofzion/blockchain-service';
2
+ import { BSNeo3NetworkId } from '../../helpers/BSNeo3Helper';
3
3
  import { RpcNDSNeo3 } from './RpcNDSNeo3';
4
4
  export declare class GhostMarketNDSNeo3 extends RpcNDSNeo3 {
5
5
  #private;
@@ -1,5 +1,5 @@
1
1
  import { GetNftParam, GetNftsByAddressParams, HasTokenParam, Network, NftDataService, NftResponse, NftsResponse } from '@cityofzion/blockchain-service';
2
- import { BSNeo3NetworkId } from './BSNeo3Helper';
2
+ import { BSNeo3NetworkId } from '../../helpers/BSNeo3Helper';
3
3
  export declare abstract class RpcNDSNeo3 implements NftDataService {
4
4
  #private;
5
5
  protected constructor(network: Network<BSNeo3NetworkId>);
@@ -0,0 +1,23 @@
1
+ import { Account, Network, PoolGraph, SwapService, SwapServiceEvents, SwapServiceSwapToReceiveArgs, SwapServiceSwapToUseArgs, Token } from '@cityofzion/blockchain-service';
2
+ import TypedEmitter from 'typed-emitter';
3
+ import { BSNeo3NetworkId } from '../../helpers/BSNeo3Helper';
4
+ import { NeonDappKitLedgerServiceNeo3 } from '../ledger/NeonDappKitLedgerServiceNeo3';
5
+ type BuildSwapInvocationArgs = SwapServiceSwapToUseArgs<BSNeo3NetworkId> | SwapServiceSwapToReceiveArgs<BSNeo3NetworkId>;
6
+ export declare class FlamingoSwapServiceNeo3 implements SwapService<BSNeo3NetworkId> {
7
+ #private;
8
+ eventEmitter: TypedEmitter<SwapServiceEvents>;
9
+ constructor(network: Network<BSNeo3NetworkId>, ledgerService: NeonDappKitLedgerServiceNeo3);
10
+ buildSwapInvocationArgs(): BuildSwapInvocationArgs;
11
+ listSwappableTokens(network: Network<BSNeo3NetworkId>): PoolGraph;
12
+ swap(isLedger?: boolean): Promise<void>;
13
+ startListeningBlockGeneration(): void;
14
+ stopListeningBlockGeneration(): void;
15
+ setAccountToUse(account: Account | null): void;
16
+ setAmountToUse(val: string | null): void;
17
+ setAmountToReceive(val: string | null): void;
18
+ setDeadline(deadline: string): void;
19
+ setSlippage(slippage: number): void;
20
+ setTokenToUse(val: Token | null): Promise<void>;
21
+ setTokenToReceive(val: Token | null): Promise<void>;
22
+ }
23
+ export {};
@@ -0,0 +1,271 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12
+ if (kind === "m") throw new TypeError("Private method is not writable");
13
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
14
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
15
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
16
+ };
17
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
18
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
19
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
20
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21
+ };
22
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
+ };
25
+ var _FlamingoSwapServiceNeo3_instances, _FlamingoSwapServiceNeo3_ledgerService, _FlamingoSwapServiceNeo3_network, _FlamingoSwapServiceNeo3_privateAccountToUse, _FlamingoSwapServiceNeo3_privateTokenToReceive, _FlamingoSwapServiceNeo3_privateTokenToUse, _FlamingoSwapServiceNeo3_privateAmountToReceive, _FlamingoSwapServiceNeo3_privateAmountToUse, _FlamingoSwapServiceNeo3_privateMinimumReceived, _FlamingoSwapServiceNeo3_privateMaximumSelling, _FlamingoSwapServiceNeo3_privateSlippage, _FlamingoSwapServiceNeo3_privateDeadline, _FlamingoSwapServiceNeo3_privatePriceInverse, _FlamingoSwapServiceNeo3_privatePriceImpact, _FlamingoSwapServiceNeo3_privateLiquidityProviderFee, _FlamingoSwapServiceNeo3_privateRoute, _FlamingoSwapServiceNeo3_privateLastAmountChanged, _FlamingoSwapServiceNeo3_socket, _FlamingoSwapServiceNeo3_setReserves, _FlamingoSwapServiceNeo3_clearFields, _FlamingoSwapServiceNeo3_recalculateSwapArguments, _FlamingoSwapServiceNeo3_recalculateRoute, _FlamingoSwapServiceNeo3_lastAmountChanged_get, _FlamingoSwapServiceNeo3_lastAmountChanged_set, _FlamingoSwapServiceNeo3_accountToUse_get, _FlamingoSwapServiceNeo3_accountToUse_set, _FlamingoSwapServiceNeo3_amountToUse_get, _FlamingoSwapServiceNeo3_amountToUse_set, _FlamingoSwapServiceNeo3_minimumReceived_get, _FlamingoSwapServiceNeo3_minimumReceived_set, _FlamingoSwapServiceNeo3_maximumSelling_get, _FlamingoSwapServiceNeo3_maximumSelling_set, _FlamingoSwapServiceNeo3_amountToReceive_get, _FlamingoSwapServiceNeo3_amountToReceive_set, _FlamingoSwapServiceNeo3_deadline_get, _FlamingoSwapServiceNeo3_deadline_set, _FlamingoSwapServiceNeo3_liquidityProviderFee_get, _FlamingoSwapServiceNeo3_liquidityProviderFee_set, _FlamingoSwapServiceNeo3_priceImpact_get, _FlamingoSwapServiceNeo3_priceImpact_set, _FlamingoSwapServiceNeo3_priceInverse_get, _FlamingoSwapServiceNeo3_priceInverse_set, _FlamingoSwapServiceNeo3_route_get, _FlamingoSwapServiceNeo3_route_set, _FlamingoSwapServiceNeo3_slippage_get, _FlamingoSwapServiceNeo3_slippage_set, _FlamingoSwapServiceNeo3_tokenToReceive_get, _FlamingoSwapServiceNeo3_tokenToReceive_set, _FlamingoSwapServiceNeo3_tokenToUse_get, _FlamingoSwapServiceNeo3_tokenToUse_set;
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.FlamingoSwapServiceNeo3 = void 0;
28
+ const neon_core_1 = require("@cityofzion/neon-core");
29
+ const neon_dappkit_1 = require("@cityofzion/neon-dappkit");
30
+ const events_1 = __importDefault(require("events"));
31
+ const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
32
+ const FlamingoSwapInvocationBuilderNeo3_1 = require("../../builder/invocation/FlamingoSwapInvocationBuilderNeo3");
33
+ const FlamingoSwapHelper_1 = require("../../helpers/FlamingoSwapHelper");
34
+ const handlers_1 = require("./handlers");
35
+ class FlamingoSwapServiceNeo3 {
36
+ constructor(network, ledgerService) {
37
+ _FlamingoSwapServiceNeo3_instances.add(this);
38
+ _FlamingoSwapServiceNeo3_ledgerService.set(this, void 0);
39
+ _FlamingoSwapServiceNeo3_network.set(this, void 0);
40
+ _FlamingoSwapServiceNeo3_privateAccountToUse.set(this, null);
41
+ _FlamingoSwapServiceNeo3_privateTokenToReceive.set(this, null);
42
+ _FlamingoSwapServiceNeo3_privateTokenToUse.set(this, null);
43
+ _FlamingoSwapServiceNeo3_privateAmountToReceive.set(this, null);
44
+ _FlamingoSwapServiceNeo3_privateAmountToUse.set(this, null);
45
+ _FlamingoSwapServiceNeo3_privateMinimumReceived.set(this, null);
46
+ _FlamingoSwapServiceNeo3_privateMaximumSelling.set(this, null);
47
+ _FlamingoSwapServiceNeo3_privateSlippage.set(this, 0.5);
48
+ _FlamingoSwapServiceNeo3_privateDeadline.set(this, '10');
49
+ _FlamingoSwapServiceNeo3_privatePriceInverse.set(this, null);
50
+ _FlamingoSwapServiceNeo3_privatePriceImpact.set(this, null);
51
+ _FlamingoSwapServiceNeo3_privateLiquidityProviderFee.set(this, null);
52
+ _FlamingoSwapServiceNeo3_privateRoute.set(this, []);
53
+ _FlamingoSwapServiceNeo3_privateLastAmountChanged.set(this, null);
54
+ _FlamingoSwapServiceNeo3_socket.set(this, new handlers_1.FlamingoSwapSocketService());
55
+ this.eventEmitter = new events_1.default();
56
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_network, network, "f");
57
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_ledgerService, ledgerService, "f");
58
+ }
59
+ buildSwapInvocationArgs() {
60
+ if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_accountToUse_get) ||
61
+ !__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_amountToReceive_get) ||
62
+ !__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_amountToUse_get) ||
63
+ !__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToReceive_get) ||
64
+ !__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToUse_get) ||
65
+ __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_route_get).length <= 0) {
66
+ throw new Error('Required parameters are not set');
67
+ }
68
+ const routePath = FlamingoSwapHelper_1.FlamingoSwapHelper.getRoutePath(__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_route_get));
69
+ const baseSwapArgs = {
70
+ address: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_accountToUse_get).address,
71
+ deadline: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_deadline_get),
72
+ network: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_network, "f"),
73
+ routePath,
74
+ };
75
+ if (__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_lastAmountChanged_get) === 'amountToReceive') {
76
+ if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_maximumSelling_get))
77
+ throw new Error("maximumSelling is required for 'amountToReceive' swap type");
78
+ return Object.assign(Object.assign({}, baseSwapArgs), { amountToReceive: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_amountToReceive_get), maximumSelling: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_maximumSelling_get), type: 'swapTokenToReceive' });
79
+ }
80
+ if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_minimumReceived_get))
81
+ throw new Error("minimumReceived is required for 'amountToUse' swap type");
82
+ return Object.assign(Object.assign({}, baseSwapArgs), { amountToUse: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_amountToUse_get), minimumReceived: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_minimumReceived_get), type: 'swapTokenToUse' });
83
+ }
84
+ listSwappableTokens(network) {
85
+ return handlers_1.FlamingoSwapRouteHandler.createPoolGraph(network);
86
+ }
87
+ swap(isLedger) {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ const swapInvocationArgs = this.buildSwapInvocationArgs();
90
+ let ledgerTransport;
91
+ if (isLedger) {
92
+ if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_ledgerService, "f").getLedgerTransport) {
93
+ throw new Error('You must provide a getLedgerTransport function to use Ledger');
94
+ }
95
+ ledgerTransport = yield __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_ledgerService, "f").getLedgerTransport(__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_accountToUse_get));
96
+ }
97
+ const account = new neon_core_1.wallet.Account(__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_accountToUse_get).key);
98
+ const invoker = yield neon_dappkit_1.NeonInvoker.init({
99
+ rpcAddress: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_network, "f").url,
100
+ account,
101
+ signingCallback: ledgerTransport ? __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_ledgerService, "f").getSigningCallback(ledgerTransport) : undefined,
102
+ });
103
+ yield invoker.invokeFunction(FlamingoSwapInvocationBuilderNeo3_1.FlamingoSwapInvocationBuilderNeo3.swapInvocation(swapInvocationArgs));
104
+ });
105
+ }
106
+ startListeningBlockGeneration() {
107
+ const callback = () => __awaiter(this, void 0, void 0, function* () { return yield __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_setReserves).call(this); });
108
+ callback();
109
+ __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_socket, "f").onBlockAdded({ callback });
110
+ }
111
+ stopListeningBlockGeneration() {
112
+ __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_socket, "f").closeConnection();
113
+ }
114
+ setAccountToUse(account) {
115
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, account, "a", _FlamingoSwapServiceNeo3_accountToUse_set);
116
+ }
117
+ setAmountToUse(val) {
118
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, val, "a", _FlamingoSwapServiceNeo3_amountToUse_set);
119
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, 'amountToUse', "a", _FlamingoSwapServiceNeo3_lastAmountChanged_set);
120
+ __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_recalculateSwapArguments).call(this);
121
+ }
122
+ setAmountToReceive(val) {
123
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, val, "a", _FlamingoSwapServiceNeo3_amountToReceive_set);
124
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, 'amountToReceive', "a", _FlamingoSwapServiceNeo3_lastAmountChanged_set);
125
+ __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_recalculateSwapArguments).call(this);
126
+ }
127
+ setDeadline(deadline) {
128
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, deadline, "a", _FlamingoSwapServiceNeo3_deadline_set);
129
+ }
130
+ setSlippage(slippage) {
131
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, slippage, "a", _FlamingoSwapServiceNeo3_slippage_set);
132
+ __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_recalculateSwapArguments).call(this);
133
+ }
134
+ setTokenToUse(val) {
135
+ return __awaiter(this, void 0, void 0, function* () {
136
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, val, "a", _FlamingoSwapServiceNeo3_tokenToUse_set);
137
+ yield __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_recalculateRoute).call(this);
138
+ __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_recalculateSwapArguments).call(this);
139
+ });
140
+ }
141
+ setTokenToReceive(val) {
142
+ return __awaiter(this, void 0, void 0, function* () {
143
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, val, "a", _FlamingoSwapServiceNeo3_tokenToReceive_set);
144
+ yield __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_recalculateRoute).call(this);
145
+ __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_recalculateSwapArguments).call(this);
146
+ });
147
+ }
148
+ }
149
+ exports.FlamingoSwapServiceNeo3 = FlamingoSwapServiceNeo3;
150
+ _FlamingoSwapServiceNeo3_ledgerService = new WeakMap(), _FlamingoSwapServiceNeo3_network = new WeakMap(), _FlamingoSwapServiceNeo3_privateAccountToUse = new WeakMap(), _FlamingoSwapServiceNeo3_privateTokenToReceive = new WeakMap(), _FlamingoSwapServiceNeo3_privateTokenToUse = new WeakMap(), _FlamingoSwapServiceNeo3_privateAmountToReceive = new WeakMap(), _FlamingoSwapServiceNeo3_privateAmountToUse = new WeakMap(), _FlamingoSwapServiceNeo3_privateMinimumReceived = new WeakMap(), _FlamingoSwapServiceNeo3_privateMaximumSelling = new WeakMap(), _FlamingoSwapServiceNeo3_privateSlippage = new WeakMap(), _FlamingoSwapServiceNeo3_privateDeadline = new WeakMap(), _FlamingoSwapServiceNeo3_privatePriceInverse = new WeakMap(), _FlamingoSwapServiceNeo3_privatePriceImpact = new WeakMap(), _FlamingoSwapServiceNeo3_privateLiquidityProviderFee = new WeakMap(), _FlamingoSwapServiceNeo3_privateRoute = new WeakMap(), _FlamingoSwapServiceNeo3_privateLastAmountChanged = new WeakMap(), _FlamingoSwapServiceNeo3_socket = new WeakMap(), _FlamingoSwapServiceNeo3_instances = new WeakSet(), _FlamingoSwapServiceNeo3_setReserves = function _FlamingoSwapServiceNeo3_setReserves() {
151
+ return __awaiter(this, void 0, void 0, function* () {
152
+ if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToReceive_get) || !__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToUse_get))
153
+ return;
154
+ yield __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_recalculateRoute).call(this);
155
+ __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_recalculateSwapArguments).call(this);
156
+ });
157
+ }, _FlamingoSwapServiceNeo3_clearFields = function _FlamingoSwapServiceNeo3_clearFields() {
158
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, null, "a", _FlamingoSwapServiceNeo3_amountToUse_set);
159
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, null, "a", _FlamingoSwapServiceNeo3_amountToReceive_set);
160
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, null, "a", _FlamingoSwapServiceNeo3_minimumReceived_set);
161
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, null, "a", _FlamingoSwapServiceNeo3_maximumSelling_set);
162
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, null, "a", _FlamingoSwapServiceNeo3_liquidityProviderFee_set);
163
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, null, "a", _FlamingoSwapServiceNeo3_priceImpact_set);
164
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, null, "a", _FlamingoSwapServiceNeo3_priceInverse_set);
165
+ }, _FlamingoSwapServiceNeo3_recalculateSwapArguments = function _FlamingoSwapServiceNeo3_recalculateSwapArguments() {
166
+ if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToReceive_get) || !__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToUse_get))
167
+ return;
168
+ if ((__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_lastAmountChanged_get) === 'amountToReceive' && __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_amountToReceive_get)) ||
169
+ (__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_lastAmountChanged_get) === 'amountToUse' && __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_amountToUse_get))) {
170
+ const amountToReceive = __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_lastAmountChanged_get) === 'amountToReceive' ? __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_amountToReceive_get) : null;
171
+ const amountToUse = __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_lastAmountChanged_get) === 'amountToUse' ? __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_amountToUse_get) : null;
172
+ const { amountToUseToDisplay, amountToReceiveToDisplay, maximumSelling, minimumReceived, liquidityProviderFee, priceImpact, priceInverse, } = handlers_1.FlamingoSwapDetailsHandler.calculateSwapDetails({
173
+ network: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_network, "f"),
174
+ amountToReceive,
175
+ amountToUse,
176
+ tokenToUse: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToUse_get),
177
+ tokenToReceive: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToReceive_get),
178
+ slippage: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_slippage_get),
179
+ route: (0, lodash_clonedeep_1.default)(__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_route_get)),
180
+ });
181
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, amountToUseToDisplay, "a", _FlamingoSwapServiceNeo3_amountToUse_set);
182
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, amountToReceiveToDisplay, "a", _FlamingoSwapServiceNeo3_amountToReceive_set);
183
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, maximumSelling, "a", _FlamingoSwapServiceNeo3_maximumSelling_set);
184
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, minimumReceived, "a", _FlamingoSwapServiceNeo3_minimumReceived_set);
185
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, liquidityProviderFee, "a", _FlamingoSwapServiceNeo3_liquidityProviderFee_set);
186
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, priceImpact, "a", _FlamingoSwapServiceNeo3_priceImpact_set);
187
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, priceInverse, "a", _FlamingoSwapServiceNeo3_priceInverse_set);
188
+ return;
189
+ }
190
+ __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_clearFields).call(this);
191
+ }, _FlamingoSwapServiceNeo3_recalculateRoute = function _FlamingoSwapServiceNeo3_recalculateRoute() {
192
+ return __awaiter(this, void 0, void 0, function* () {
193
+ if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToReceive_get) || !__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToUse_get))
194
+ return;
195
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, yield handlers_1.FlamingoSwapRouteHandler.calculateBestRouteForSwap({
196
+ tokenToReceive: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToReceive_get),
197
+ tokenToUse: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToUse_get),
198
+ network: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_network, "f"),
199
+ }), "a", _FlamingoSwapServiceNeo3_route_set);
200
+ });
201
+ }, _FlamingoSwapServiceNeo3_lastAmountChanged_get = function _FlamingoSwapServiceNeo3_lastAmountChanged_get() {
202
+ return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateLastAmountChanged, "f");
203
+ }, _FlamingoSwapServiceNeo3_lastAmountChanged_set = function _FlamingoSwapServiceNeo3_lastAmountChanged_set(val) {
204
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateLastAmountChanged, val, "f");
205
+ this.eventEmitter.emit('lastAmountChanged', val);
206
+ }, _FlamingoSwapServiceNeo3_accountToUse_get = function _FlamingoSwapServiceNeo3_accountToUse_get() {
207
+ return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateAccountToUse, "f");
208
+ }, _FlamingoSwapServiceNeo3_accountToUse_set = function _FlamingoSwapServiceNeo3_accountToUse_set(val) {
209
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateAccountToUse, val, "f");
210
+ this.eventEmitter.emit('accountToUse', val);
211
+ }, _FlamingoSwapServiceNeo3_amountToUse_get = function _FlamingoSwapServiceNeo3_amountToUse_get() {
212
+ return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateAmountToUse, "f");
213
+ }, _FlamingoSwapServiceNeo3_amountToUse_set = function _FlamingoSwapServiceNeo3_amountToUse_set(val) {
214
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateAmountToUse, val, "f");
215
+ this.eventEmitter.emit('amountToUse', val);
216
+ }, _FlamingoSwapServiceNeo3_minimumReceived_get = function _FlamingoSwapServiceNeo3_minimumReceived_get() {
217
+ return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateMinimumReceived, "f");
218
+ }, _FlamingoSwapServiceNeo3_minimumReceived_set = function _FlamingoSwapServiceNeo3_minimumReceived_set(val) {
219
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateMinimumReceived, val, "f");
220
+ this.eventEmitter.emit('minimumReceived', val);
221
+ }, _FlamingoSwapServiceNeo3_maximumSelling_get = function _FlamingoSwapServiceNeo3_maximumSelling_get() {
222
+ return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateMaximumSelling, "f");
223
+ }, _FlamingoSwapServiceNeo3_maximumSelling_set = function _FlamingoSwapServiceNeo3_maximumSelling_set(val) {
224
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateMaximumSelling, val, "f");
225
+ this.eventEmitter.emit('maximumSelling', val);
226
+ }, _FlamingoSwapServiceNeo3_amountToReceive_get = function _FlamingoSwapServiceNeo3_amountToReceive_get() {
227
+ return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateAmountToReceive, "f");
228
+ }, _FlamingoSwapServiceNeo3_amountToReceive_set = function _FlamingoSwapServiceNeo3_amountToReceive_set(val) {
229
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateAmountToReceive, val, "f");
230
+ this.eventEmitter.emit('amountToReceive', val);
231
+ }, _FlamingoSwapServiceNeo3_deadline_get = function _FlamingoSwapServiceNeo3_deadline_get() {
232
+ return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateDeadline, "f");
233
+ }, _FlamingoSwapServiceNeo3_deadline_set = function _FlamingoSwapServiceNeo3_deadline_set(val) {
234
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateDeadline, val, "f");
235
+ this.eventEmitter.emit('deadline', val);
236
+ }, _FlamingoSwapServiceNeo3_liquidityProviderFee_get = function _FlamingoSwapServiceNeo3_liquidityProviderFee_get() {
237
+ return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateLiquidityProviderFee, "f");
238
+ }, _FlamingoSwapServiceNeo3_liquidityProviderFee_set = function _FlamingoSwapServiceNeo3_liquidityProviderFee_set(val) {
239
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateLiquidityProviderFee, val, "f");
240
+ this.eventEmitter.emit('liquidityProviderFee', val);
241
+ }, _FlamingoSwapServiceNeo3_priceImpact_get = function _FlamingoSwapServiceNeo3_priceImpact_get() {
242
+ return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privatePriceImpact, "f");
243
+ }, _FlamingoSwapServiceNeo3_priceImpact_set = function _FlamingoSwapServiceNeo3_priceImpact_set(val) {
244
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privatePriceImpact, val, "f");
245
+ this.eventEmitter.emit('priceImpact', val);
246
+ }, _FlamingoSwapServiceNeo3_priceInverse_get = function _FlamingoSwapServiceNeo3_priceInverse_get() {
247
+ return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privatePriceInverse, "f");
248
+ }, _FlamingoSwapServiceNeo3_priceInverse_set = function _FlamingoSwapServiceNeo3_priceInverse_set(val) {
249
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privatePriceInverse, val, "f");
250
+ this.eventEmitter.emit('priceInverse', val);
251
+ }, _FlamingoSwapServiceNeo3_route_get = function _FlamingoSwapServiceNeo3_route_get() {
252
+ return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateRoute, "f");
253
+ }, _FlamingoSwapServiceNeo3_route_set = function _FlamingoSwapServiceNeo3_route_set(val) {
254
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateRoute, val, "f");
255
+ this.eventEmitter.emit('route', val);
256
+ }, _FlamingoSwapServiceNeo3_slippage_get = function _FlamingoSwapServiceNeo3_slippage_get() {
257
+ return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateSlippage, "f");
258
+ }, _FlamingoSwapServiceNeo3_slippage_set = function _FlamingoSwapServiceNeo3_slippage_set(val) {
259
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateSlippage, val, "f");
260
+ this.eventEmitter.emit('slippage', val);
261
+ }, _FlamingoSwapServiceNeo3_tokenToReceive_get = function _FlamingoSwapServiceNeo3_tokenToReceive_get() {
262
+ return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateTokenToReceive, "f");
263
+ }, _FlamingoSwapServiceNeo3_tokenToReceive_set = function _FlamingoSwapServiceNeo3_tokenToReceive_set(val) {
264
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateTokenToReceive, val, "f");
265
+ this.eventEmitter.emit('tokenToReceive', val);
266
+ }, _FlamingoSwapServiceNeo3_tokenToUse_get = function _FlamingoSwapServiceNeo3_tokenToUse_get() {
267
+ return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateTokenToUse, "f");
268
+ }, _FlamingoSwapServiceNeo3_tokenToUse_set = function _FlamingoSwapServiceNeo3_tokenToUse_set(val) {
269
+ __classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateTokenToUse, val, "f");
270
+ this.eventEmitter.emit('tokenToUse', val);
271
+ };