@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.
- package/dist/BSNeo3.d.ts +13 -13
- package/dist/BSNeo3.js +50 -45
- package/dist/BSNeo3Helper.d.ts +21 -0
- package/dist/BSNeo3Helper.js +74 -0
- package/dist/DoraBDSNeo3.d.ts +3 -2
- package/dist/DoraBDSNeo3.js +4 -7
- package/dist/DoraESNeo3.d.ts +2 -1
- package/dist/DoraESNeo3.js +10 -4
- package/dist/FlamingoEDSNeo3.d.ts +3 -3
- package/dist/FlamingoEDSNeo3.js +2 -3
- package/dist/GhostMarketNDSNeo3.d.ts +5 -4
- package/dist/GhostMarketNDSNeo3.js +51 -41
- package/dist/{LedgerServiceNeo3.d.ts → NeonDappKitLedgerServiceNeo3.d.ts} +1 -1
- package/dist/{LedgerServiceNeo3.js → NeonDappKitLedgerServiceNeo3.js} +3 -3
- package/dist/RpcBDSNeo3.d.ts +3 -2
- package/dist/RpcBDSNeo3.js +7 -4
- package/dist/RpcNDSNeo3.d.ts +2 -1
- package/dist/flamingo-swap/FlamingoSwapControllerService.d.ts +1 -37
- package/dist/flamingo-swap/FlamingoSwapControllerService.js +183 -225
- package/dist/flamingo-swap/FlamingoSwapHelper.d.ts +14 -1
- package/dist/flamingo-swap/FlamingoSwapHelper.js +57 -6
- package/dist/flamingo-swap/FlamingoSwapNeonDappKitInvocationBuilder.d.ts +1 -1
- package/dist/flamingo-swap/FlamingoSwapNeonDappKitInvocationBuilder.js +7 -9
- package/dist/index.d.ts +3 -4
- package/dist/index.js +3 -4
- package/package.json +2 -2
- package/dist/constants.d.ts +0 -21
- package/dist/constants.js +0 -74
- package/dist/flamingo-swap/FlamingoSwapError.d.ts +0 -12
- package/dist/flamingo-swap/FlamingoSwapError.js +0 -28
|
@@ -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
|
|
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,
|
|
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
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
throw new
|
|
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.
|
|
73
|
-
amountToReceive: this
|
|
74
|
-
amountToUse: this
|
|
75
|
-
tokenToReceive: this
|
|
76
|
-
tokenToUse: this
|
|
77
|
-
deadline: this
|
|
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
|
|
81
|
-
if (!this
|
|
82
|
-
throw new
|
|
83
|
-
return Object.assign(Object.assign({}, baseSwapArgs), { maximumSelling: this
|
|
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
|
|
86
|
-
throw new
|
|
87
|
-
return Object.assign(Object.assign({}, baseSwapArgs), { minimumReceived: this
|
|
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
|
|
85
|
+
__classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, account, "a", _FlamingoSwapControllerService_accountToUse_set);
|
|
91
86
|
}
|
|
92
87
|
setAmountToUse(val) {
|
|
93
|
-
this
|
|
94
|
-
this
|
|
95
|
-
this.
|
|
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
|
|
99
|
-
this
|
|
100
|
-
this.
|
|
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
|
|
98
|
+
__classPrivateFieldSet(this, _FlamingoSwapControllerService_instances, deadline, "a", _FlamingoSwapControllerService_deadline_set);
|
|
104
99
|
}
|
|
105
100
|
setSlippage(slippage) {
|
|
106
|
-
this
|
|
107
|
-
this.
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
146
|
-
tokenToUseScriptHash: this.
|
|
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
|
|
153
|
-
this
|
|
154
|
-
this
|
|
155
|
-
this.
|
|
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
|
|
160
|
-
this.
|
|
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.
|
|
160
|
+
__classPrivateFieldGet(this, _FlamingoSwapControllerService_ws, "f").send(JSON.stringify(block_added));
|
|
168
161
|
};
|
|
169
|
-
this.
|
|
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
|
|
175
|
-
this.
|
|
176
|
-
this
|
|
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(),
|
|
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 '../
|
|
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;
|