-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-liquidity-file.ts
106 lines (98 loc) · 2.42 KB
/
create-liquidity-file.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { Args } from '@oclif/core';
import { BaseCommand } from '../../base/BaseCommand.js';
import writeXlsxFile from 'write-excel-file/node';
import { fileExists } from '../../utils/file-utils.js';
import { confirmPrompt, makeSpinner } from '../../utils/tty-utils.js';
import {
token1AmountField,
token1ContractField,
token1SymbolField,
token2AmountField,
token2ContractField,
token2SymbolField,
} from '../../services/swap-service.js';
export default class GenerateCreateLiquidityFileCommand extends BaseCommand {
static readonly examples = [
{
command: '<%= config.bin %> <%= command.id %> pools.xlsx',
description: 'Generates the file to create liquidity pools into a file called pools.xlsx.',
},
];
static readonly description = 'Generates the file to create liquidity pools.';
static readonly args = {
output: Args.file({
description: 'Location where the file will be generated.',
required: true,
}),
};
public async run(): Promise<void> {
const { args } = await this.parse(GenerateCreateLiquidityFileCommand);
const output = args.output;
if (fileExists(output)) {
const proceed = await confirmPrompt('File already exists. Do you want to overwrite it?');
if (!proceed) {
return;
}
}
const data = [
[
{
value: token1ContractField,
type: String,
},
{
value: token1SymbolField,
type: String,
},
{
value: token1AmountField,
type: String,
},
{
value: token2ContractField,
type: String,
},
{
value: token2SymbolField,
type: String,
},
{
value: token2AmountField,
type: String,
},
],
[
{
value: 'token.nefty',
type: String,
},
{
value: 'NEFTY',
type: String,
},
{
value: 1,
type: Number,
},
{
value: 'eosio.token',
type: String,
},
{
value: 'WAX',
type: String,
},
{
value: 1,
type: Number,
},
],
];
const spinner = makeSpinner('Generating file...').start();
await writeXlsxFile(data, {
filePath: output,
});
spinner.succeed();
this.log(`File generated at ${output}`);
}
}