@ultrade/ultrade-js-sdk 0.2.6 → 2.0.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.
@@ -1,14 +0,0 @@
1
- export declare const MASTER_ABI: {
2
- name: string;
3
- methods: {
4
- name: string;
5
- args: {
6
- type: string;
7
- name: string;
8
- }[];
9
- returns: {
10
- type: string;
11
- };
12
- }[];
13
- networks: {};
14
- };
@@ -1,89 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MASTER_ABI = void 0;
4
- exports.MASTER_ABI = {
5
- name: 'Master',
6
- methods: [
7
- {
8
- name: 'bootstrap',
9
- args: [
10
- {
11
- type: 'application',
12
- name: 'tmp_pool'
13
- },
14
- {
15
- type: 'application',
16
- name: 'tmp_stable_pool'
17
- }
18
- ],
19
- returns: {
20
- type: 'void'
21
- }
22
- },
23
- {
24
- name: 'add_stable_coin',
25
- args: [
26
- {
27
- type: 'asset',
28
- name: 'token'
29
- }
30
- ],
31
- returns: {
32
- type: 'void'
33
- }
34
- },
35
- {
36
- name: 'remove_stable_coin',
37
- args: [
38
- {
39
- type: 'asset',
40
- name: 'token'
41
- }
42
- ],
43
- returns: {
44
- type: 'void'
45
- }
46
- },
47
- {
48
- name: 'create_pool',
49
- args: [
50
- {
51
- type: 'pay',
52
- name: 'seed'
53
- },
54
- {
55
- type: 'uint64',
56
- name: 'asset_a'
57
- },
58
- {
59
- type: 'uint64',
60
- name: 'asset_b'
61
- }
62
- ],
63
- returns: {
64
- type: 'void'
65
- }
66
- },
67
- {
68
- name: 'set_governor',
69
- args: [
70
- {
71
- type: 'uint64',
72
- name: 'asset_a'
73
- },
74
- {
75
- type: 'uint64',
76
- name: 'asset_b'
77
- },
78
- {
79
- type: 'account',
80
- name: 'governor'
81
- }
82
- ],
83
- returns: {
84
- type: 'void'
85
- }
86
- }
87
- ],
88
- networks: {}
89
- };
@@ -1,25 +0,0 @@
1
- export declare const POOL_ABI: {
2
- name: string;
3
- methods: ({
4
- name: string;
5
- args: {
6
- type: string;
7
- name: string;
8
- }[];
9
- returns: {
10
- type: string;
11
- };
12
- desc: string;
13
- } | {
14
- name: string;
15
- args: {
16
- type: string;
17
- name: string;
18
- }[];
19
- returns: {
20
- type: string;
21
- };
22
- desc?: undefined;
23
- })[];
24
- networks: {};
25
- };
@@ -1,123 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.POOL_ABI = void 0;
4
- exports.POOL_ABI = {
5
- name: 'Pool',
6
- methods: [
7
- {
8
- name: 'set_governor',
9
- args: [
10
- {
11
- type: 'account',
12
- name: 'new_governor'
13
- }
14
- ],
15
- returns: {
16
- type: 'void'
17
- },
18
- desc: 'sets the governor of the contract, may only be called by the current governor'
19
- },
20
- {
21
- name: 'bootstrap',
22
- args: [
23
- {
24
- type: 'uint64',
25
- name: 'asset_a'
26
- },
27
- {
28
- type: 'uint64',
29
- name: 'asset_b'
30
- }
31
- ],
32
- returns: {
33
- type: 'void'
34
- },
35
- desc: 'bootstraps the contract by opting into the assets and creating the pool token.'
36
- },
37
- {
38
- name: 'fund',
39
- args: [
40
- {
41
- type: 'txn',
42
- name: 'txn_a'
43
- },
44
- {
45
- type: 'txn',
46
- name: 'txn_b'
47
- }
48
- ],
49
- returns: {
50
- type: 'void'
51
- }
52
- },
53
- {
54
- name: 'mint',
55
- args: [
56
- {
57
- type: 'txn',
58
- name: 'txn_a'
59
- },
60
- {
61
- type: 'txn',
62
- name: 'txn_b'
63
- },
64
- {
65
- type: 'uint64',
66
- name: 'min_out_amt'
67
- }
68
- ],
69
- returns: {
70
- type: 'void'
71
- }
72
- },
73
- {
74
- name: 'burn',
75
- args: [
76
- {
77
- type: 'axfer',
78
- name: 'txn'
79
- },
80
- {
81
- type: 'uint64',
82
- name: 'min_out_amt_a'
83
- },
84
- {
85
- type: 'uint64',
86
- name: 'min_out_amt_b'
87
- }
88
- ],
89
- returns: {
90
- type: 'void'
91
- }
92
- },
93
- {
94
- name: 'swap',
95
- args: [
96
- {
97
- type: 'txn',
98
- name: 'txn'
99
- },
100
- {
101
- type: 'uint64',
102
- name: 'min_swap_amt'
103
- }
104
- ],
105
- returns: {
106
- type: 'uint64'
107
- }
108
- },
109
- {
110
- name: 'redeem',
111
- args: [
112
- {
113
- type: 'uint64',
114
- name: 'amount'
115
- }
116
- ],
117
- returns: {
118
- type: 'void'
119
- }
120
- }
121
- ],
122
- networks: {}
123
- };
@@ -1,25 +0,0 @@
1
- export declare const STABLE_ABI: {
2
- name: string;
3
- methods: ({
4
- name: string;
5
- args: {
6
- type: string;
7
- name: string;
8
- }[];
9
- returns: {
10
- type: string;
11
- };
12
- desc: string;
13
- } | {
14
- name: string;
15
- args: {
16
- type: string;
17
- name: string;
18
- }[];
19
- returns: {
20
- type: string;
21
- };
22
- desc?: undefined;
23
- })[];
24
- networks: {};
25
- };
@@ -1,155 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STABLE_ABI = void 0;
4
- exports.STABLE_ABI = {
5
- name: 'StablePool',
6
- methods: [
7
- {
8
- name: 'set_governor',
9
- args: [
10
- {
11
- type: 'account',
12
- name: 'new_governor'
13
- }
14
- ],
15
- returns: {
16
- type: 'void'
17
- },
18
- desc: 'sets the governor of the contract, may only be called by the current governor'
19
- },
20
- {
21
- name: 'bootstrap',
22
- args: [
23
- {
24
- type: 'uint64',
25
- name: 'asset_a'
26
- },
27
- {
28
- type: 'uint64',
29
- name: 'asset_b'
30
- }
31
- ],
32
- returns: {
33
- type: 'void'
34
- },
35
- desc: 'bootstraps the contract by opting into the assets and creating the pool token.'
36
- },
37
- {
38
- name: 'fund',
39
- args: [
40
- {
41
- type: 'axfer',
42
- name: 'txn_a'
43
- },
44
- {
45
- type: 'axfer',
46
- name: 'txn_b'
47
- }
48
- ],
49
- returns: {
50
- type: 'void'
51
- }
52
- },
53
- {
54
- name: 'mint',
55
- args: [
56
- {
57
- type: 'uint64',
58
- name: 'a_amt'
59
- },
60
- {
61
- type: 'uint64',
62
- name: 'b_amt'
63
- },
64
- {
65
- type: 'uint64',
66
- name: 'min_out_amt'
67
- },
68
- {
69
- type: 'axfer',
70
- name: 'txn_a'
71
- },
72
- {
73
- type: 'axfer',
74
- name: 'txn_b'
75
- }
76
- ],
77
- returns: {
78
- type: 'void'
79
- }
80
- },
81
- {
82
- name: 'burn',
83
- args: [
84
- {
85
- type: 'axfer',
86
- name: 'txn'
87
- },
88
- {
89
- type: 'uint64',
90
- name: 'min_out_amt_a'
91
- },
92
- {
93
- type: 'uint64',
94
- name: 'min_out_amt_b'
95
- }
96
- ],
97
- returns: {
98
- type: 'void'
99
- }
100
- },
101
- {
102
- name: 'burn_imbalance',
103
- args: [
104
- {
105
- type: 'uint64',
106
- name: 'a_amt'
107
- },
108
- {
109
- type: 'uint64',
110
- name: 'b_amt'
111
- },
112
- {
113
- type: 'uint64',
114
- name: 'max_burn_amt'
115
- },
116
- {
117
- type: 'axfer',
118
- name: 'txn'
119
- }
120
- ],
121
- returns: {
122
- type: 'void'
123
- }
124
- },
125
- {
126
- name: 'swap',
127
- args: [
128
- {
129
- type: 'axfer',
130
- name: 'txn'
131
- },
132
- {
133
- type: 'uint64',
134
- name: 'min_swap_amt'
135
- }
136
- ],
137
- returns: {
138
- type: 'uint64'
139
- }
140
- },
141
- {
142
- name: 'redeem',
143
- args: [
144
- {
145
- type: 'uint64',
146
- name: 'amount'
147
- }
148
- ],
149
- returns: {
150
- type: 'void'
151
- }
152
- }
153
- ],
154
- networks: {}
155
- };
@@ -1,6 +0,0 @@
1
- export declare const ALGO: {
2
- id: number;
3
- name: string;
4
- unitName: string;
5
- decimals: number;
6
- };
package/dist/constants.js DELETED
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ALGO = void 0;
4
- exports.ALGO = {
5
- id: 0,
6
- name: 'ALGO',
7
- unitName: 'ALGO',
8
- decimals: 6
9
- };
package/dist/types.d.ts DELETED
@@ -1,57 +0,0 @@
1
- export type PoolTypes = 'STABLE' | 'CONSTANT_PRODUCT';
2
- export type IAssetAmt = {
3
- assetA: bigint;
4
- assetB: bigint;
5
- };
6
- export interface TokenPair {
7
- aId: number;
8
- aName: string;
9
- aUnitName: string;
10
- aDecimals: number;
11
- bId: number;
12
- bName: string;
13
- bUnitName: string;
14
- bDecimals: number;
15
- poolId: number;
16
- poolToken: number;
17
- poolState: PoolState;
18
- fee: number;
19
- type: PoolTypes;
20
- }
21
- export interface IndexerAssetParams {
22
- creator: string;
23
- decimals: number;
24
- 'default-frozen': boolean;
25
- name: string;
26
- 'name-b64': string;
27
- total: number;
28
- 'unit-name': string;
29
- 'unit-name-b64': string;
30
- }
31
- export interface IndexerAsset {
32
- index: number;
33
- params: IndexerAssetParams;
34
- }
35
- export interface AssetList {
36
- [key: number]: IndexerAsset;
37
- }
38
- export interface PoolList {
39
- [key: string]: TokenPair;
40
- }
41
- export interface PoolState {
42
- a: number;
43
- b: number;
44
- set: number;
45
- ra: number;
46
- rb: number;
47
- ma: number;
48
- f?: number;
49
- p: number;
50
- pt?: PoolTypes;
51
- gov: string;
52
- }
53
- export interface StablePoolState extends PoolState {
54
- ad: number;
55
- bd: number;
56
- amp: number;
57
- }
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/dist/utils.js DELETED
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decodeStateArray = exports.getMethodByName = exports.sqrt = void 0;
4
- const algosdk_1 = require("algosdk");
5
- function sqrt(value) {
6
- if (value < BigInt(0)) {
7
- throw 'square root of negative numbers is not supported';
8
- }
9
- if (value < BigInt(2)) {
10
- return value;
11
- }
12
- function newtonIteration(n, x0) {
13
- const x1 = (BigInt(n / x0) + x0) >> BigInt(1);
14
- if (x0 === x1 || x0 === x1 - BigInt(1)) {
15
- return x0;
16
- }
17
- return newtonIteration(n, x1);
18
- }
19
- return newtonIteration(value, BigInt(1));
20
- }
21
- exports.sqrt = sqrt;
22
- function getMethodByName(contract, name) {
23
- const m = contract.methods.find((mt) => {
24
- return mt.name == name;
25
- });
26
- if (m === undefined)
27
- throw Error('Method undefined: ' + name);
28
- return m;
29
- }
30
- exports.getMethodByName = getMethodByName;
31
- function decodeStateArray(stateArray) {
32
- const state = {};
33
- stateArray.forEach((pair) => {
34
- const key = Buffer.from(pair['key'], 'base64');
35
- let value = pair['value'];
36
- const valueType = value['type'];
37
- if (valueType == 2)
38
- value = value['uint'];
39
- if (valueType == 1)
40
- value = Buffer.from(value['bytes']);
41
- if (key.toString() == 'gov') {
42
- state['gov'] = (0, algosdk_1.encodeAddress)(value);
43
- }
44
- else if (key.toString() == 'pt') {
45
- state['pt'] = atob(value.toString());
46
- }
47
- else {
48
- state[key.toString()] = value;
49
- }
50
- });
51
- return state;
52
- }
53
- exports.decodeStateArray = decodeStateArray;