-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: feemarket models to decimal and api extensions
- Loading branch information
Showing
17 changed files
with
644 additions
and
364 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import Decimal from 'decimal.js'; | ||
import { | ||
BaseFee, | ||
FeemarketDenomParams, | ||
FeemarketParams, | ||
FeemarketState, | ||
} from '../../../core/feemarket'; | ||
import { LCDClient } from '../LCDClient'; | ||
import { FeemarketAPI } from './FeemarketAPI'; | ||
import { Coin } from '../../../core'; | ||
|
||
const lcd = new LCDClient({ | ||
'pisco-1': { | ||
chainID: 'pisco-1', | ||
gasAdjustment: 1.5, | ||
gasPrices: { | ||
uluna: 0.02, | ||
}, | ||
lcd: 'http://localhost:1317/', | ||
prefix: 'terra', | ||
}, | ||
}); | ||
const feemarket = new FeemarketAPI(lcd); | ||
|
||
describe('FeemarketAPI', () => { | ||
it('asset the module params', async () => { | ||
const res = await feemarket.params('pisco-1'); | ||
|
||
expect(res).toStrictEqual( | ||
new FeemarketParams( | ||
new Decimal(0), | ||
new Decimal(1), | ||
new Decimal(0), | ||
new Decimal(0.125), | ||
new Decimal(0.125), | ||
new Decimal(15000000), | ||
new Decimal(30000000), | ||
new Decimal(1), | ||
true, | ||
'uluna' | ||
) | ||
); | ||
|
||
expect(res.toData()).toEqual({ | ||
alpha: '0', | ||
beta: '1', | ||
theta: '0', | ||
min_learning_rate: '0.125', | ||
max_learning_rate: '0.125', | ||
target_block_utilization: '15000000', | ||
max_block_utilization: '30000000', | ||
window: '1', | ||
enabled: true, | ||
default_fee_denom: 'uluna', | ||
}); | ||
}); | ||
|
||
it('asset the module state', async () => { | ||
const res = await feemarket.state('pisco-1'); | ||
expect(res).toStrictEqual( | ||
new FeemarketState(new Decimal(0.125), [new Decimal(0)], new Decimal(0)) | ||
); | ||
expect(res.toData()).toEqual({ | ||
learning_rate: '0.125', | ||
window: ['0'], | ||
index: '0', | ||
}); | ||
}); | ||
|
||
it('get base fee', async () => { | ||
const res = await feemarket.baseFee('pisco-1', 'uluna'); | ||
expect(res).toStrictEqual(new BaseFee(new Coin('uluna', '0.0015'))); | ||
expect(res.toData()).toEqual({ | ||
fee: { | ||
amount: '0.001500000000000000', | ||
denom: 'uluna', | ||
}, | ||
}); | ||
}); | ||
|
||
it('get fee denom params', async () => { | ||
const res = await feemarket.feeDenomParam('pisco-1', 'uluna'); | ||
expect(res).toStrictEqual([ | ||
new FeemarketDenomParams( | ||
'uluna', | ||
new Decimal('0.0015'), | ||
new Decimal('0.0015') | ||
), | ||
]); | ||
expect(res[0].toData()).toEqual({ | ||
fee_denom: 'uluna', | ||
min_base_fee: '0.0015', | ||
base_fee: '0.0015', | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export * from './v1/models/FeemarketParams'; | ||
export * from './v1/proposals/MsgFeeDenomParam'; | ||
export * from './v1/proposals/MsgParams'; | ||
export * from './v1/models/FeemarketState'; | ||
export * from './v1/models/FeemarketBaseFee'; | ||
export * from './v1/models/FeemarketDenomParams'; |
Oops, something went wrong.