@cityofzion/bs-neo3 1.7.1 → 1.8.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.
- package/dist/BSNeo3.d.ts +13 -14
- package/dist/BSNeo3.js +46 -43
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -5
- package/dist/services/ledger/NeonDappKitLedgerServiceNeo3.d.ts +6 -6
- package/dist/services/ledger/NeonDappKitLedgerServiceNeo3.js +4 -3
- package/package.json +2 -2
- package/dist/builder/invocation/FlamingoSwapInvocationBuilderNeo3.d.ts +0 -7
- package/dist/builder/invocation/FlamingoSwapInvocationBuilderNeo3.js +0 -217
- package/dist/constants/FlamingoSwapConstants.d.ts +0 -36
- package/dist/constants/FlamingoSwapConstants.js +0 -691
- package/dist/helpers/FlamingoSwapHelper.d.ts +0 -27
- package/dist/helpers/FlamingoSwapHelper.js +0 -129
- package/dist/services/swap/FlamingoSwapServiceNeo3.d.ts +0 -22
- package/dist/services/swap/FlamingoSwapServiceNeo3.js +0 -283
- package/dist/services/swap/handlers/FlamingoSwapDetailsHandler.d.ts +0 -24
- package/dist/services/swap/handlers/FlamingoSwapDetailsHandler.js +0 -178
- package/dist/services/swap/handlers/FlamingoSwapRouteHandler.d.ts +0 -13
- package/dist/services/swap/handlers/FlamingoSwapRouteHandler.js +0 -194
- package/dist/services/swap/handlers/FlamingoSwapSocketHandler.d.ts +0 -9
- package/dist/services/swap/handlers/FlamingoSwapSocketHandler.js +0 -57
- package/dist/services/swap/handlers/index.d.ts +0 -3
- package/dist/services/swap/handlers/index.js +0 -19
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Network, SwapRoute, Token } from '@cityofzion/blockchain-service';
|
|
2
|
-
import BigNumber from 'bignumber.js';
|
|
3
|
-
import { BSNeo3NetworkId } from '../constants/BSNeo3Constants';
|
|
4
|
-
import { FlamingoSwapPoolInfo, FlamingoSwapPools, FlamingoSwapScriptHashes, FlamingoSwapTokens } from '../constants/FlamingoSwapConstants';
|
|
5
|
-
export declare class FlamingoSwapHelper {
|
|
6
|
-
static listSwappableTokensSymbol(network: Network<BSNeo3NetworkId>): string[];
|
|
7
|
-
static getFlamingoSwapPools(network: Network<BSNeo3NetworkId>): FlamingoSwapPools;
|
|
8
|
-
static getFlamingoSwapPool(network: Network<BSNeo3NetworkId>, name: string): FlamingoSwapPoolInfo;
|
|
9
|
-
static getFlamingoSwapTokens(network: Network<BSNeo3NetworkId>): FlamingoSwapTokens;
|
|
10
|
-
static getFlamingoSwapToken(network: Network<BSNeo3NetworkId>, name: string): Token;
|
|
11
|
-
static getFlamingoSwapScriptHashes(network: Network<BSNeo3NetworkId>): FlamingoSwapScriptHashes;
|
|
12
|
-
static getRoutePath(route: SwapRoute[]): Token[];
|
|
13
|
-
static overrideToken(network: Network<BSNeo3NetworkId>, token: Token): Token;
|
|
14
|
-
static overrideAmountInput(network: Network<BSNeo3NetworkId>, amount: string, token: Token): BigNumber;
|
|
15
|
-
static overrideAmountToDisplay(network: Network<BSNeo3NetworkId>, amount: string, token: Token): string;
|
|
16
|
-
static overrideRoute(network: Network<BSNeo3NetworkId>, route: SwapRoute[]): SwapRoute[];
|
|
17
|
-
static overrideRoutePath(network: Network<BSNeo3NetworkId>, routePath: Token[]): Token[];
|
|
18
|
-
static normalizeHash(hash: string): string;
|
|
19
|
-
static isNeoToken(network: Network<BSNeo3NetworkId>, token: Token): boolean;
|
|
20
|
-
static isBneoToken(network: Network<BSNeo3NetworkId>, token: Token): boolean;
|
|
21
|
-
static formatAmount(amount: string, decimals: number): string;
|
|
22
|
-
static isSwapUnwrappingNeo(network: Network<BSNeo3NetworkId>, route: Token[]): boolean;
|
|
23
|
-
static isSwapWrappingNeo(network: Network<BSNeo3NetworkId>, route: Token[]): boolean;
|
|
24
|
-
static isWrapNeo(network: Network<BSNeo3NetworkId>, route: Token[]): boolean;
|
|
25
|
-
static isUnwrapNeo(network: Network<BSNeo3NetworkId>, route: Token[]): boolean;
|
|
26
|
-
static getUnwrappedAmount(amount: string): string;
|
|
27
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
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
|
-
const handlers_1 = require("../services/swap/handlers");
|
|
11
|
-
class FlamingoSwapHelper {
|
|
12
|
-
static listSwappableTokensSymbol(network) {
|
|
13
|
-
return Object.keys(handlers_1.FlamingoSwapRouteHandler.createPoolGraph(network));
|
|
14
|
-
}
|
|
15
|
-
static getFlamingoSwapPools(network) {
|
|
16
|
-
const pools = FlamingoSwapConstants_1.FlamingoSwapConstants.FLAMINGO_SWAP_POOLS[network.id];
|
|
17
|
-
if (!pools) {
|
|
18
|
-
throw new Error('Invalid network');
|
|
19
|
-
}
|
|
20
|
-
return pools;
|
|
21
|
-
}
|
|
22
|
-
static getFlamingoSwapPool(network, name) {
|
|
23
|
-
const pools = this.getFlamingoSwapPools(network);
|
|
24
|
-
const pool = pools[name];
|
|
25
|
-
if (!pool) {
|
|
26
|
-
throw new Error('Invalid pool');
|
|
27
|
-
}
|
|
28
|
-
return pool;
|
|
29
|
-
}
|
|
30
|
-
static getFlamingoSwapTokens(network) {
|
|
31
|
-
const tokens = FlamingoSwapConstants_1.FlamingoSwapConstants.FLAMINGO_SWAP_TOKENS[network.id];
|
|
32
|
-
if (!tokens) {
|
|
33
|
-
throw new Error('Invalid network');
|
|
34
|
-
}
|
|
35
|
-
return tokens;
|
|
36
|
-
}
|
|
37
|
-
static getFlamingoSwapToken(network, name) {
|
|
38
|
-
const tokens = this.getFlamingoSwapTokens(network);
|
|
39
|
-
const token = tokens[name];
|
|
40
|
-
if (!token) {
|
|
41
|
-
throw new Error('Invalid token');
|
|
42
|
-
}
|
|
43
|
-
return token;
|
|
44
|
-
}
|
|
45
|
-
static getFlamingoSwapScriptHashes(network) {
|
|
46
|
-
const swapScriptHashes = FlamingoSwapConstants_1.FlamingoSwapConstants.FLAMINGO_SWAP_SCRIPT_HASHES[network.id];
|
|
47
|
-
if (!swapScriptHashes) {
|
|
48
|
-
throw new Error('Invalid network');
|
|
49
|
-
}
|
|
50
|
-
return swapScriptHashes;
|
|
51
|
-
}
|
|
52
|
-
static getRoutePath(route) {
|
|
53
|
-
return route
|
|
54
|
-
.flatMap(item => [item.tokenToUse, item.tokenToReceive])
|
|
55
|
-
.filter((item, index, arr) => arr.indexOf(item) === index);
|
|
56
|
-
}
|
|
57
|
-
static overrideToken(network, token) {
|
|
58
|
-
return this.isNeoToken(network, token) ? this.getFlamingoSwapToken(network, 'bNEO') : token;
|
|
59
|
-
}
|
|
60
|
-
static overrideAmountInput(network, amount, token) {
|
|
61
|
-
const overrodeToken = this.overrideToken(network, token);
|
|
62
|
-
return new bignumber_js_1.default(amount).shiftedBy(overrodeToken.decimals);
|
|
63
|
-
}
|
|
64
|
-
static overrideAmountToDisplay(network, amount, token) {
|
|
65
|
-
const overrodeToken = this.overrideToken(network, token);
|
|
66
|
-
return new bignumber_js_1.default(amount).shiftedBy(-overrodeToken.decimals).toFixed();
|
|
67
|
-
}
|
|
68
|
-
static overrideRoute(network, route) {
|
|
69
|
-
const overrodeRoute = [];
|
|
70
|
-
for (const routeItem of route) {
|
|
71
|
-
if (!this.isNeoToken(network, routeItem.tokenToUse) && !this.isNeoToken(network, routeItem.tokenToReceive)) {
|
|
72
|
-
overrodeRoute.push(routeItem);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return overrodeRoute;
|
|
76
|
-
}
|
|
77
|
-
static overrideRoutePath(network, routePath) {
|
|
78
|
-
const overrodeRoutePath = routePath.map(token => this.overrideToken(network, token));
|
|
79
|
-
return overrodeRoutePath.filter((item, index, arr) => arr.indexOf(item) === index);
|
|
80
|
-
}
|
|
81
|
-
static normalizeHash(hash) {
|
|
82
|
-
return hash.startsWith('0x') ? hash.slice(2) : hash;
|
|
83
|
-
}
|
|
84
|
-
static isNeoToken(network, token) {
|
|
85
|
-
const NEO = this.getFlamingoSwapToken(network, 'NEO');
|
|
86
|
-
return this.normalizeHash(token.hash) === this.normalizeHash(NEO.hash);
|
|
87
|
-
}
|
|
88
|
-
static isBneoToken(network, token) {
|
|
89
|
-
const bNEO = this.getFlamingoSwapToken(network, 'bNEO');
|
|
90
|
-
return this.normalizeHash(token.hash) === this.normalizeHash(bNEO.hash);
|
|
91
|
-
}
|
|
92
|
-
static formatAmount(amount, decimals) {
|
|
93
|
-
return neon_core_1.u.BigInteger.fromDecimal(Number(amount), decimals).toString();
|
|
94
|
-
}
|
|
95
|
-
static isSwapUnwrappingNeo(network, route) {
|
|
96
|
-
if (route.length < 3) {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
const lastToken = route[route.length - 1];
|
|
100
|
-
return this.isNeoToken(network, lastToken);
|
|
101
|
-
}
|
|
102
|
-
static isSwapWrappingNeo(network, route) {
|
|
103
|
-
if (route.length < 3) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
const firstToken = route[0];
|
|
107
|
-
return this.isNeoToken(network, firstToken);
|
|
108
|
-
}
|
|
109
|
-
static isWrapNeo(network, route) {
|
|
110
|
-
if (route.length !== 2) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
const firstToken = route[0];
|
|
114
|
-
const lastToken = route[1];
|
|
115
|
-
return this.isNeoToken(network, firstToken) && this.isBneoToken(network, lastToken);
|
|
116
|
-
}
|
|
117
|
-
static isUnwrapNeo(network, route) {
|
|
118
|
-
if (route.length !== 2) {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
const firstToken = route[0];
|
|
122
|
-
const lastToken = route[1];
|
|
123
|
-
return this.isBneoToken(network, firstToken) && this.isNeoToken(network, lastToken);
|
|
124
|
-
}
|
|
125
|
-
static getUnwrappedAmount(amount) {
|
|
126
|
-
return neon_core_1.u.BigInteger.fromNumber(Number(amount) * FlamingoSwapConstants_1.FlamingoSwapConstants.UNWRAPPING_FEE).toString();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
exports.FlamingoSwapHelper = FlamingoSwapHelper;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Account, Network, SwapService, SwapServiceEvents, SwapServiceSwapToReceiveArgs, SwapServiceSwapToUseArgs, Token } from '@cityofzion/blockchain-service';
|
|
2
|
-
import TypedEmitter from 'typed-emitter';
|
|
3
|
-
import { BSNeo3 } from '../../BSNeo3';
|
|
4
|
-
import { BSNeo3NetworkId } from '../../constants/BSNeo3Constants';
|
|
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>, blockchainService: BSNeo3);
|
|
10
|
-
buildSwapInvocationArgs(): BuildSwapInvocationArgs;
|
|
11
|
-
swap(isLedger?: boolean): Promise<void>;
|
|
12
|
-
startListeningBlockGeneration(): void;
|
|
13
|
-
stopListeningBlockGeneration(): void;
|
|
14
|
-
setAccountToUse(account: Account | null): void;
|
|
15
|
-
setAmountToUse(val: string | null): void;
|
|
16
|
-
setAmountToReceive(val: string | null): void;
|
|
17
|
-
setDeadline(deadline: string): void;
|
|
18
|
-
setSlippage(slippage: number): void;
|
|
19
|
-
setTokenToUse(val: Token | null): Promise<void>;
|
|
20
|
-
setTokenToReceive(val: Token | null): Promise<void>;
|
|
21
|
-
}
|
|
22
|
-
export {};
|
|
@@ -1,283 +0,0 @@
|
|
|
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_blockchainService, _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_dappkit_1 = require("@cityofzion/neon-dappkit");
|
|
29
|
-
const events_1 = __importDefault(require("events"));
|
|
30
|
-
const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
|
|
31
|
-
const FlamingoSwapInvocationBuilderNeo3_1 = require("../../builder/invocation/FlamingoSwapInvocationBuilderNeo3");
|
|
32
|
-
const FlamingoSwapHelper_1 = require("../../helpers/FlamingoSwapHelper");
|
|
33
|
-
const handlers_1 = require("./handlers");
|
|
34
|
-
class FlamingoSwapServiceNeo3 {
|
|
35
|
-
constructor(network, blockchainService) {
|
|
36
|
-
_FlamingoSwapServiceNeo3_instances.add(this);
|
|
37
|
-
_FlamingoSwapServiceNeo3_blockchainService.set(this, void 0);
|
|
38
|
-
_FlamingoSwapServiceNeo3_network.set(this, void 0);
|
|
39
|
-
_FlamingoSwapServiceNeo3_privateAccountToUse.set(this, null);
|
|
40
|
-
_FlamingoSwapServiceNeo3_privateTokenToReceive.set(this, null);
|
|
41
|
-
_FlamingoSwapServiceNeo3_privateTokenToUse.set(this, null);
|
|
42
|
-
_FlamingoSwapServiceNeo3_privateAmountToReceive.set(this, null);
|
|
43
|
-
_FlamingoSwapServiceNeo3_privateAmountToUse.set(this, null);
|
|
44
|
-
_FlamingoSwapServiceNeo3_privateMinimumReceived.set(this, null);
|
|
45
|
-
_FlamingoSwapServiceNeo3_privateMaximumSelling.set(this, null);
|
|
46
|
-
_FlamingoSwapServiceNeo3_privateSlippage.set(this, 0.5);
|
|
47
|
-
_FlamingoSwapServiceNeo3_privateDeadline.set(this, '10');
|
|
48
|
-
_FlamingoSwapServiceNeo3_privatePriceInverse.set(this, null);
|
|
49
|
-
_FlamingoSwapServiceNeo3_privatePriceImpact.set(this, null);
|
|
50
|
-
_FlamingoSwapServiceNeo3_privateLiquidityProviderFee.set(this, null);
|
|
51
|
-
_FlamingoSwapServiceNeo3_privateRoute.set(this, []);
|
|
52
|
-
_FlamingoSwapServiceNeo3_privateLastAmountChanged.set(this, null);
|
|
53
|
-
_FlamingoSwapServiceNeo3_socket.set(this, new handlers_1.FlamingoSwapSocketService());
|
|
54
|
-
this.eventEmitter = new events_1.default();
|
|
55
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_network, network, "f");
|
|
56
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_blockchainService, blockchainService, "f");
|
|
57
|
-
}
|
|
58
|
-
buildSwapInvocationArgs() {
|
|
59
|
-
if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_accountToUse_get) ||
|
|
60
|
-
!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_amountToReceive_get) ||
|
|
61
|
-
!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_amountToUse_get) ||
|
|
62
|
-
!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToReceive_get) ||
|
|
63
|
-
!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToUse_get) ||
|
|
64
|
-
__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_route_get).length <= 0) {
|
|
65
|
-
throw new Error('Required parameters are not set');
|
|
66
|
-
}
|
|
67
|
-
const routePath = FlamingoSwapHelper_1.FlamingoSwapHelper.getRoutePath(__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_route_get));
|
|
68
|
-
const baseSwapArgs = {
|
|
69
|
-
address: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_accountToUse_get).address,
|
|
70
|
-
deadline: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_deadline_get),
|
|
71
|
-
network: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_network, "f"),
|
|
72
|
-
routePath,
|
|
73
|
-
};
|
|
74
|
-
if (__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_lastAmountChanged_get) === 'amountToReceive') {
|
|
75
|
-
if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_maximumSelling_get))
|
|
76
|
-
throw new Error("maximumSelling is required for 'amountToReceive' swap type");
|
|
77
|
-
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' });
|
|
78
|
-
}
|
|
79
|
-
if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_minimumReceived_get))
|
|
80
|
-
throw new Error("minimumReceived is required for 'amountToUse' swap type");
|
|
81
|
-
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' });
|
|
82
|
-
}
|
|
83
|
-
swap(isLedger) {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
const swapInvocationArgs = this.buildSwapInvocationArgs();
|
|
86
|
-
if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_accountToUse_get))
|
|
87
|
-
throw new Error('Account to use is not set');
|
|
88
|
-
const { neonJsAccount, signingCallback } = yield __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_blockchainService, "f").generateSigningCallback(__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_accountToUse_get), isLedger);
|
|
89
|
-
const invoker = yield neon_dappkit_1.NeonInvoker.init({
|
|
90
|
-
rpcAddress: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_network, "f").url,
|
|
91
|
-
account: neonJsAccount,
|
|
92
|
-
signingCallback,
|
|
93
|
-
});
|
|
94
|
-
yield invoker.invokeFunction(FlamingoSwapInvocationBuilderNeo3_1.FlamingoSwapInvocationBuilderNeo3.swapInvocation(swapInvocationArgs));
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
startListeningBlockGeneration() {
|
|
98
|
-
const callback = () => __awaiter(this, void 0, void 0, function* () { return yield __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_setReserves).call(this); });
|
|
99
|
-
callback();
|
|
100
|
-
__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_socket, "f").onBlockAdded({ callback });
|
|
101
|
-
}
|
|
102
|
-
stopListeningBlockGeneration() {
|
|
103
|
-
__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_socket, "f").closeConnection();
|
|
104
|
-
}
|
|
105
|
-
setAccountToUse(account) {
|
|
106
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, account, "a", _FlamingoSwapServiceNeo3_accountToUse_set);
|
|
107
|
-
}
|
|
108
|
-
setAmountToUse(val) {
|
|
109
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, val, "a", _FlamingoSwapServiceNeo3_amountToUse_set);
|
|
110
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, 'amountToUse', "a", _FlamingoSwapServiceNeo3_lastAmountChanged_set);
|
|
111
|
-
__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_recalculateSwapArguments).call(this);
|
|
112
|
-
}
|
|
113
|
-
setAmountToReceive(val) {
|
|
114
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, val, "a", _FlamingoSwapServiceNeo3_amountToReceive_set);
|
|
115
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, 'amountToReceive', "a", _FlamingoSwapServiceNeo3_lastAmountChanged_set);
|
|
116
|
-
__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_recalculateSwapArguments).call(this);
|
|
117
|
-
}
|
|
118
|
-
setDeadline(deadline) {
|
|
119
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, deadline, "a", _FlamingoSwapServiceNeo3_deadline_set);
|
|
120
|
-
}
|
|
121
|
-
setSlippage(slippage) {
|
|
122
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, slippage, "a", _FlamingoSwapServiceNeo3_slippage_set);
|
|
123
|
-
__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_recalculateSwapArguments).call(this);
|
|
124
|
-
}
|
|
125
|
-
setTokenToUse(val) {
|
|
126
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, val, "a", _FlamingoSwapServiceNeo3_tokenToUse_set);
|
|
128
|
-
yield __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_recalculateRoute).call(this);
|
|
129
|
-
__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_recalculateSwapArguments).call(this);
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
setTokenToReceive(val) {
|
|
133
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, val, "a", _FlamingoSwapServiceNeo3_tokenToReceive_set);
|
|
135
|
-
yield __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_recalculateRoute).call(this);
|
|
136
|
-
__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_recalculateSwapArguments).call(this);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
exports.FlamingoSwapServiceNeo3 = FlamingoSwapServiceNeo3;
|
|
141
|
-
_FlamingoSwapServiceNeo3_blockchainService = 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() {
|
|
142
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
-
if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToReceive_get) || !__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToUse_get))
|
|
144
|
-
return;
|
|
145
|
-
yield __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_recalculateRoute).call(this);
|
|
146
|
-
__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_recalculateSwapArguments).call(this);
|
|
147
|
-
});
|
|
148
|
-
}, _FlamingoSwapServiceNeo3_clearFields = function _FlamingoSwapServiceNeo3_clearFields() {
|
|
149
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, null, "a", _FlamingoSwapServiceNeo3_amountToUse_set);
|
|
150
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, null, "a", _FlamingoSwapServiceNeo3_amountToReceive_set);
|
|
151
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, null, "a", _FlamingoSwapServiceNeo3_minimumReceived_set);
|
|
152
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, null, "a", _FlamingoSwapServiceNeo3_maximumSelling_set);
|
|
153
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, null, "a", _FlamingoSwapServiceNeo3_liquidityProviderFee_set);
|
|
154
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, null, "a", _FlamingoSwapServiceNeo3_priceImpact_set);
|
|
155
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, null, "a", _FlamingoSwapServiceNeo3_priceInverse_set);
|
|
156
|
-
}, _FlamingoSwapServiceNeo3_recalculateSwapArguments = function _FlamingoSwapServiceNeo3_recalculateSwapArguments() {
|
|
157
|
-
if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToReceive_get) || !__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToUse_get))
|
|
158
|
-
return;
|
|
159
|
-
if ((__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_lastAmountChanged_get) === 'amountToReceive' && __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_amountToReceive_get)) ||
|
|
160
|
-
(__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_lastAmountChanged_get) === 'amountToUse' && __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_amountToUse_get))) {
|
|
161
|
-
const amountToReceive = __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_lastAmountChanged_get) === 'amountToReceive' ? __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_amountToReceive_get) : null;
|
|
162
|
-
const amountToUse = __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_lastAmountChanged_get) === 'amountToUse' ? __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_amountToUse_get) : null;
|
|
163
|
-
const initialRoutePath = [__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToReceive_get), __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToUse_get)];
|
|
164
|
-
if (FlamingoSwapHelper_1.FlamingoSwapHelper.isWrapNeo(__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_network, "f"), initialRoutePath) ||
|
|
165
|
-
FlamingoSwapHelper_1.FlamingoSwapHelper.isUnwrapNeo(__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_network, "f"), initialRoutePath)) {
|
|
166
|
-
const amount = amountToUse !== null && amountToUse !== void 0 ? amountToUse : amountToReceive;
|
|
167
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, amount, "a", _FlamingoSwapServiceNeo3_amountToUse_set);
|
|
168
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, amount, "a", _FlamingoSwapServiceNeo3_amountToReceive_set);
|
|
169
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, amount, "a", _FlamingoSwapServiceNeo3_maximumSelling_set);
|
|
170
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, amount, "a", _FlamingoSwapServiceNeo3_minimumReceived_set);
|
|
171
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, null, "a", _FlamingoSwapServiceNeo3_liquidityProviderFee_set);
|
|
172
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, null, "a", _FlamingoSwapServiceNeo3_priceImpact_set);
|
|
173
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, null, "a", _FlamingoSwapServiceNeo3_priceInverse_set);
|
|
174
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, [
|
|
175
|
-
{
|
|
176
|
-
reserveTokenToReceive: '0',
|
|
177
|
-
reserveTokenToUse: '0',
|
|
178
|
-
tokenToReceive: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToReceive_get),
|
|
179
|
-
tokenToUse: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToUse_get),
|
|
180
|
-
},
|
|
181
|
-
], "a", _FlamingoSwapServiceNeo3_route_set);
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
const { amountToUseToDisplay, amountToReceiveToDisplay, maximumSelling, minimumReceived, liquidityProviderFee, priceImpact, priceInverse, } = handlers_1.FlamingoSwapDetailsHandler.calculateSwapDetails({
|
|
185
|
-
network: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_network, "f"),
|
|
186
|
-
amountToReceive,
|
|
187
|
-
amountToUse,
|
|
188
|
-
tokenToUse: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToUse_get),
|
|
189
|
-
tokenToReceive: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToReceive_get),
|
|
190
|
-
slippage: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_slippage_get),
|
|
191
|
-
route: (0, lodash_clonedeep_1.default)(__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_route_get)),
|
|
192
|
-
});
|
|
193
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, amountToUseToDisplay, "a", _FlamingoSwapServiceNeo3_amountToUse_set);
|
|
194
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, amountToReceiveToDisplay, "a", _FlamingoSwapServiceNeo3_amountToReceive_set);
|
|
195
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, maximumSelling, "a", _FlamingoSwapServiceNeo3_maximumSelling_set);
|
|
196
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, minimumReceived, "a", _FlamingoSwapServiceNeo3_minimumReceived_set);
|
|
197
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, liquidityProviderFee, "a", _FlamingoSwapServiceNeo3_liquidityProviderFee_set);
|
|
198
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, priceImpact, "a", _FlamingoSwapServiceNeo3_priceImpact_set);
|
|
199
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, priceInverse, "a", _FlamingoSwapServiceNeo3_priceInverse_set);
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "m", _FlamingoSwapServiceNeo3_clearFields).call(this);
|
|
203
|
-
}, _FlamingoSwapServiceNeo3_recalculateRoute = function _FlamingoSwapServiceNeo3_recalculateRoute() {
|
|
204
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
205
|
-
if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToReceive_get) || !__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToUse_get))
|
|
206
|
-
return;
|
|
207
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_instances, yield handlers_1.FlamingoSwapRouteHandler.calculateBestRouteForSwap({
|
|
208
|
-
tokenToReceive: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToReceive_get),
|
|
209
|
-
tokenToUse: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToUse_get),
|
|
210
|
-
network: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_network, "f"),
|
|
211
|
-
}), "a", _FlamingoSwapServiceNeo3_route_set);
|
|
212
|
-
});
|
|
213
|
-
}, _FlamingoSwapServiceNeo3_lastAmountChanged_get = function _FlamingoSwapServiceNeo3_lastAmountChanged_get() {
|
|
214
|
-
return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateLastAmountChanged, "f");
|
|
215
|
-
}, _FlamingoSwapServiceNeo3_lastAmountChanged_set = function _FlamingoSwapServiceNeo3_lastAmountChanged_set(val) {
|
|
216
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateLastAmountChanged, val, "f");
|
|
217
|
-
this.eventEmitter.emit('lastAmountChanged', val);
|
|
218
|
-
}, _FlamingoSwapServiceNeo3_accountToUse_get = function _FlamingoSwapServiceNeo3_accountToUse_get() {
|
|
219
|
-
return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateAccountToUse, "f");
|
|
220
|
-
}, _FlamingoSwapServiceNeo3_accountToUse_set = function _FlamingoSwapServiceNeo3_accountToUse_set(val) {
|
|
221
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateAccountToUse, val, "f");
|
|
222
|
-
this.eventEmitter.emit('accountToUse', val);
|
|
223
|
-
}, _FlamingoSwapServiceNeo3_amountToUse_get = function _FlamingoSwapServiceNeo3_amountToUse_get() {
|
|
224
|
-
return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateAmountToUse, "f");
|
|
225
|
-
}, _FlamingoSwapServiceNeo3_amountToUse_set = function _FlamingoSwapServiceNeo3_amountToUse_set(val) {
|
|
226
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateAmountToUse, val, "f");
|
|
227
|
-
this.eventEmitter.emit('amountToUse', val);
|
|
228
|
-
}, _FlamingoSwapServiceNeo3_minimumReceived_get = function _FlamingoSwapServiceNeo3_minimumReceived_get() {
|
|
229
|
-
return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateMinimumReceived, "f");
|
|
230
|
-
}, _FlamingoSwapServiceNeo3_minimumReceived_set = function _FlamingoSwapServiceNeo3_minimumReceived_set(val) {
|
|
231
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateMinimumReceived, val, "f");
|
|
232
|
-
this.eventEmitter.emit('minimumReceived', val);
|
|
233
|
-
}, _FlamingoSwapServiceNeo3_maximumSelling_get = function _FlamingoSwapServiceNeo3_maximumSelling_get() {
|
|
234
|
-
return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateMaximumSelling, "f");
|
|
235
|
-
}, _FlamingoSwapServiceNeo3_maximumSelling_set = function _FlamingoSwapServiceNeo3_maximumSelling_set(val) {
|
|
236
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateMaximumSelling, val, "f");
|
|
237
|
-
this.eventEmitter.emit('maximumSelling', val);
|
|
238
|
-
}, _FlamingoSwapServiceNeo3_amountToReceive_get = function _FlamingoSwapServiceNeo3_amountToReceive_get() {
|
|
239
|
-
return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateAmountToReceive, "f");
|
|
240
|
-
}, _FlamingoSwapServiceNeo3_amountToReceive_set = function _FlamingoSwapServiceNeo3_amountToReceive_set(val) {
|
|
241
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateAmountToReceive, val, "f");
|
|
242
|
-
this.eventEmitter.emit('amountToReceive', val);
|
|
243
|
-
}, _FlamingoSwapServiceNeo3_deadline_get = function _FlamingoSwapServiceNeo3_deadline_get() {
|
|
244
|
-
return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateDeadline, "f");
|
|
245
|
-
}, _FlamingoSwapServiceNeo3_deadline_set = function _FlamingoSwapServiceNeo3_deadline_set(val) {
|
|
246
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateDeadline, val, "f");
|
|
247
|
-
this.eventEmitter.emit('deadline', val);
|
|
248
|
-
}, _FlamingoSwapServiceNeo3_liquidityProviderFee_get = function _FlamingoSwapServiceNeo3_liquidityProviderFee_get() {
|
|
249
|
-
return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateLiquidityProviderFee, "f");
|
|
250
|
-
}, _FlamingoSwapServiceNeo3_liquidityProviderFee_set = function _FlamingoSwapServiceNeo3_liquidityProviderFee_set(val) {
|
|
251
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateLiquidityProviderFee, val, "f");
|
|
252
|
-
this.eventEmitter.emit('liquidityProviderFee', val);
|
|
253
|
-
}, _FlamingoSwapServiceNeo3_priceImpact_get = function _FlamingoSwapServiceNeo3_priceImpact_get() {
|
|
254
|
-
return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privatePriceImpact, "f");
|
|
255
|
-
}, _FlamingoSwapServiceNeo3_priceImpact_set = function _FlamingoSwapServiceNeo3_priceImpact_set(val) {
|
|
256
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privatePriceImpact, val, "f");
|
|
257
|
-
this.eventEmitter.emit('priceImpact', val);
|
|
258
|
-
}, _FlamingoSwapServiceNeo3_priceInverse_get = function _FlamingoSwapServiceNeo3_priceInverse_get() {
|
|
259
|
-
return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privatePriceInverse, "f");
|
|
260
|
-
}, _FlamingoSwapServiceNeo3_priceInverse_set = function _FlamingoSwapServiceNeo3_priceInverse_set(val) {
|
|
261
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privatePriceInverse, val, "f");
|
|
262
|
-
this.eventEmitter.emit('priceInverse', val);
|
|
263
|
-
}, _FlamingoSwapServiceNeo3_route_get = function _FlamingoSwapServiceNeo3_route_get() {
|
|
264
|
-
return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateRoute, "f");
|
|
265
|
-
}, _FlamingoSwapServiceNeo3_route_set = function _FlamingoSwapServiceNeo3_route_set(val) {
|
|
266
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateRoute, val, "f");
|
|
267
|
-
this.eventEmitter.emit('route', val);
|
|
268
|
-
}, _FlamingoSwapServiceNeo3_slippage_get = function _FlamingoSwapServiceNeo3_slippage_get() {
|
|
269
|
-
return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateSlippage, "f");
|
|
270
|
-
}, _FlamingoSwapServiceNeo3_slippage_set = function _FlamingoSwapServiceNeo3_slippage_set(val) {
|
|
271
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateSlippage, val, "f");
|
|
272
|
-
this.eventEmitter.emit('slippage', val);
|
|
273
|
-
}, _FlamingoSwapServiceNeo3_tokenToReceive_get = function _FlamingoSwapServiceNeo3_tokenToReceive_get() {
|
|
274
|
-
return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateTokenToReceive, "f");
|
|
275
|
-
}, _FlamingoSwapServiceNeo3_tokenToReceive_set = function _FlamingoSwapServiceNeo3_tokenToReceive_set(val) {
|
|
276
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateTokenToReceive, val, "f");
|
|
277
|
-
this.eventEmitter.emit('tokenToReceive', val);
|
|
278
|
-
}, _FlamingoSwapServiceNeo3_tokenToUse_get = function _FlamingoSwapServiceNeo3_tokenToUse_get() {
|
|
279
|
-
return __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_privateTokenToUse, "f");
|
|
280
|
-
}, _FlamingoSwapServiceNeo3_tokenToUse_set = function _FlamingoSwapServiceNeo3_tokenToUse_set(val) {
|
|
281
|
-
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_privateTokenToUse, val, "f");
|
|
282
|
-
this.eventEmitter.emit('tokenToUse', val);
|
|
283
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Network, SwapRoute, Token } from '@cityofzion/blockchain-service';
|
|
2
|
-
import { BSNeo3NetworkId } from '../../../constants/BSNeo3Constants';
|
|
3
|
-
type CalculateSwapDetailsArgs = {
|
|
4
|
-
amountToUse: string | null;
|
|
5
|
-
amountToReceive: string | null;
|
|
6
|
-
tokenToUse: Token;
|
|
7
|
-
tokenToReceive: Token;
|
|
8
|
-
slippage: number;
|
|
9
|
-
network: Network<BSNeo3NetworkId>;
|
|
10
|
-
route: SwapRoute[];
|
|
11
|
-
};
|
|
12
|
-
export declare class FlamingoSwapDetailsHandler {
|
|
13
|
-
#private;
|
|
14
|
-
static calculateSwapDetails({ amountToReceive, amountToUse, network, route, slippage, tokenToReceive, tokenToUse, }: CalculateSwapDetailsArgs): {
|
|
15
|
-
amountToReceiveToDisplay: string;
|
|
16
|
-
amountToUseToDisplay: string;
|
|
17
|
-
liquidityProviderFee: string;
|
|
18
|
-
priceImpact: string | null;
|
|
19
|
-
priceInverse: string | null;
|
|
20
|
-
minimumReceived: string | null;
|
|
21
|
-
maximumSelling: string | null;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export {};
|