3
3
WalletWrapper ,
4
4
CosmosWrapper ,
5
5
NEUTRON_DENOM ,
6
- ADMIN_MODULE_ADDRESS ,
7
6
} from '@neutron-org/neutronjsplus/dist/cosmos' ;
8
7
import { TestStateLocalCosmosTestNet } from '@neutron-org/neutronjsplus' ;
9
8
import { getWithAttempts } from '@neutron-org/neutronjsplus/dist/wait' ;
@@ -12,7 +11,6 @@ import {
12
11
DaoMember ,
13
12
getDaoContracts ,
14
13
} from '@neutron-org/neutronjsplus/dist/dao' ;
15
- import axios from 'axios' ;
16
14
17
15
const config = require ( '../../config.json' ) ;
18
16
@@ -58,10 +56,47 @@ describe('Neutron / Slinky', () => {
58
56
59
57
describe ( 'submit proposal' , ( ) => {
60
58
test ( 'create proposal' , async ( ) => {
61
- proposalId = await daoMember1 . submitSingleChoiceProposal (
59
+ proposalId = await daoMember1 . submitUpdateMarketMap (
62
60
'Proposal for update marketmap' ,
63
61
'Add new marketmap with currency pair' ,
64
- [ updateMarketMapProposal ( ) ] ,
62
+ [
63
+ {
64
+ ticker : {
65
+ currency_pair : {
66
+ Base : 'ETH' ,
67
+ Quote : 'USDT' ,
68
+ } ,
69
+ decimals : 8 ,
70
+ min_provider_count : 1 ,
71
+ enabled : true ,
72
+ metadata_JSON : '{}' ,
73
+ } ,
74
+ providers : {
75
+ providers : [
76
+ {
77
+ name : 'kucoin_ws' ,
78
+ off_chain_ticker : 'eth-usdt' ,
79
+ } ,
80
+ ] ,
81
+ } ,
82
+ paths : {
83
+ paths : [
84
+ {
85
+ operations : [
86
+ {
87
+ provider : 'kucoin_ws' ,
88
+ currency_pair : {
89
+ Base : 'ETH' ,
90
+ Quote : 'USDT' ,
91
+ } ,
92
+ invert : false ,
93
+ } ,
94
+ ] ,
95
+ } ,
96
+ ] ,
97
+ } ,
98
+ } ,
99
+ ] ,
65
100
'1000' ,
66
101
) ;
67
102
} ) ;
@@ -88,129 +123,19 @@ describe('Neutron / Slinky', () => {
88
123
// wait to make sure we updated the price in oracle module
89
124
await neutronChain . blockWaiter . waitBlocks ( 5 ) ;
90
125
// check
91
- const res = await queryAllCurrencyPairs ( neutronChain . sdk ) ;
126
+ const res = await neutronChain . queryOracleAllCurrencyPairs ( ) ;
92
127
expect ( res . currency_pairs [ 0 ] . Base ) . toBe ( 'ETH' ) ;
93
128
expect ( res . currency_pairs [ 0 ] . Quote ) . toBe ( 'USDT' ) ;
94
129
} ) ;
95
130
96
131
test ( 'prices not empty' , async ( ) => {
97
- const res = await queryPrices ( neutronChain . sdk , [ 'ETH/USDT' ] ) ;
132
+ const res = await neutronChain . queryOraclePrices ( [ 'ETH/USDT' ] ) ;
98
133
expect ( + res . prices [ 0 ] . price . price ) . toBeGreaterThan ( 0 ) ;
99
134
} ) ;
100
135
101
136
test ( 'eth price present' , async ( ) => {
102
- const res = await queryPrice ( neutronChain . sdk , 'ETH' , 'USDT' ) ;
137
+ const res = await neutronChain . queryOraclePrice ( 'ETH' , 'USDT' ) ;
103
138
expect ( + res . price . price ) . toBeGreaterThan ( 0 ) ;
104
139
} ) ;
105
140
} ) ;
106
141
} ) ;
107
-
108
- const updateMarketMapMessage = JSON . stringify ( {
109
- '@type' : '/slinky.marketmap.v1.MsgUpdateMarketMap' ,
110
- signer : ADMIN_MODULE_ADDRESS ,
111
- create_markets : [
112
- {
113
- ticker : {
114
- currency_pair : {
115
- Base : 'ETH' ,
116
- Quote : 'USDT' ,
117
- } ,
118
- decimals : 8 ,
119
- min_provider_count : 1 ,
120
- enabled : true ,
121
- metadata_JSON : '{}' ,
122
- } ,
123
- providers : {
124
- providers : [
125
- {
126
- name : 'kucoin_ws' ,
127
- off_chain_ticker : 'eth-usdt' ,
128
- } ,
129
- ] ,
130
- } ,
131
- paths : {
132
- paths : [
133
- {
134
- operations : [
135
- {
136
- provider : 'kucoin_ws' ,
137
- currency_pair : {
138
- Base : 'ETH' ,
139
- Quote : 'USDT' ,
140
- } ,
141
- invert : false ,
142
- } ,
143
- ] ,
144
- } ,
145
- ] ,
146
- } ,
147
- } ,
148
- ] ,
149
- } ) ;
150
-
151
- const updateMarketMapProposal = ( ) : any => ( {
152
- custom : {
153
- submit_admin_proposal : {
154
- admin_proposal : {
155
- proposal_execute_message : {
156
- message : updateMarketMapMessage ,
157
- } ,
158
- } ,
159
- } ,
160
- } ,
161
- } ) ;
162
-
163
- type GetPriceResponse = {
164
- price : {
165
- price : string ;
166
- block_timestamp : string ;
167
- block_height : string ;
168
- } ;
169
- nonce : string ;
170
- decimals : string ;
171
- id : string ;
172
- } ;
173
-
174
- type GetPricesResponse = {
175
- prices : GetPriceResponse [ ] ;
176
- } ;
177
-
178
- type CurrencyPair = {
179
- Quote : string ;
180
- Base : string ;
181
- } ;
182
-
183
- type GetAllCurrencyPairsResponse = {
184
- currency_pairs : CurrencyPair [ ] ;
185
- } ;
186
-
187
- const queryPrice = async ( sdk : any , base : string , quote : string ) : Promise < GetPriceResponse > => {
188
- try {
189
- const req = await axios . get < any > ( `${ sdk . url } /slinky/oracle/v1/get_price` , {
190
- params : {
191
- 'currency_pair.Base' : base ,
192
- 'currency_pair.Quote' : quote ,
193
- } ,
194
- } ) ;
195
- return req . data ;
196
- } catch ( e ) {
197
- if ( e . response ?. data ?. message !== undefined ) {
198
- throw new Error ( e . response ?. data ?. message ) ;
199
- }
200
- throw e ;
201
- }
202
- } ;
203
-
204
- const queryPrices = async ( sdk : any , currencyPairIds : string [ ] ) : Promise < GetPricesResponse > => {
205
- const req = await axios . get ( `${ sdk . url } /slinky/oracle/v1/get_prices` , {
206
- params : { currency_pair_ids : currencyPairIds . join ( ',' ) } ,
207
- } ) ;
208
-
209
- return req . data ;
210
- } ;
211
-
212
- const queryAllCurrencyPairs = async ( sdk : any ) : Promise < GetAllCurrencyPairsResponse > => {
213
- const req = await axios . get ( `${ sdk . url } /slinky/oracle/v1/get_all_tickers` ) ;
214
-
215
- return req . data ;
216
- } ;
0 commit comments