Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add dex-general and dex-stable rpc defs #103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
283 changes: 282 additions & 1 deletion definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
null
],
"types": {
"AssetBalance": "Balance",
"AssetId": "CurrencyId",
"Balance": "u128",
"BalanceWrapper": {
"amount": "String"
},
Expand Down Expand Up @@ -47,6 +50,7 @@
"InterbtcStablePoolId": "u32",
"LendTokenId": "u32",
"StablePoolId": "u32",
"PoolId": "StablePoolId",
"Rate": "FixedU128",
"Ratio": "Permill",
"Liquidity": "FixedU128",
Expand Down Expand Up @@ -102,6 +106,283 @@
"type": "void"
}
},
"dexGeneral": {
"getPairByAssetId": {
"params": [
{
"name": "asset_0",
"type": "AssetId"
},
{
"name": "asset_1",
"type": "AssetId"
}
],
"type": "Option<PairInfo<AccountId, NumberOrHex, AssetId>>"
},
"getAmountInPrice": {
"params": [
{
"name": "supply",
"type": "AssetBalance"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't this crash serde?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested and I think not, although I'm not sure if I'm missing something or if this was indeed fixed in serde

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw many of the rpcs using FixedU128 would have the same issue

Copy link
Member

@sander2 sander2 Feb 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw many of the rpcs using FixedU128 would have the same issue

That's not true, FixedU128 has a customSerialize implementation that serializes as string (similarly to our balance wrapper)

Copy link
Member

@sander2 sander2 Feb 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if you tested then I guess they must have fixed it upstream. Edit: it seems you just need the arbitrary_precision feature. We don't explicitly enable it but maybe one of our dependencies does serde-rs/json#548 . Edit 2: cargo tree -e features does not show the arbitrary_precision feature being enabled..

},
{
"name": "path",
"type": "Vec<AssetId>"
}
],
"type": "NumberOrHex"
},
"getAmountOutPrice": {
"params": [
{
"name": "supply",
"type": "AssetBalance"
},
{
"name": "path",
"type": "Vec<AssetId>"
}
],
"type": "NumberOrHex"
},
"getEstimateLptoken": {
"params": [
{
"name": "asset_0",
"type": "AssetId"
},
{
"name": "asset_1",
"type": "AssetId"
},
{
"name": "amount_0_desired",
"type": "AssetBalance"
},
{
"name": "amount_1_desired",
"type": "AssetBalance"
},
{
"name": "amount_0_min",
"type": "AssetBalance"
},
{
"name": "amount_1_min",
"type": "AssetBalance"
}
],
"type": "NumberOrHex"
},
"calculateRemoveLiquidity": {
"params": [
{
"name": "asset_0",
"type": "AssetId"
},
{
"name": "asset_1",
"type": "AssetId"
},
{
"name": "amount",
"type": "AssetBalance"
}
],
"type": "Option<(AssetBalance, AssetBalance)>"
}
},
"dexStable": {
"getVirtualPrice": {
"params": [
{
"name": "pool_id",
"type": "PoolId"
}
],
"type": "NumberOrHex"
},
"getA": {
"params": [
{
"name": "pool_id",
"type": "PoolId"
}
],
"type": "NumberOrHex"
},
"getAPrecise": {
"params": [
{
"name": "pool_id",
"type": "PoolId"
}
],
"type": "NumberOrHex"
},
"getCurrencies": {
"params": [
{
"name": "pool_id",
"type": "PoolId"
}
],
"type": "Vec<CurrencyId>"
},
"getCurrency": {
"params": [
{
"name": "pool_id",
"type": "PoolId"
},
{
"name": "index",
"type": "u32"
}
],
"type": "CurrencyId"
},
"getLpCurrency": {
"params": [
{
"name": "pool_id",
"type": "PoolId"
}
],
"type": "CurrencyId"
},
"getCurrencyIndex": {
"params": [
{
"name": "pool_id",
"type": "PoolId"
},
{
"name": "currency",
"type": "CurrencyId"
}
],
"type": "u32"
},
"getCurrencyPrecisionMultipliers": {
"params": [
{
"name": "pool_id",
"type": "PoolId"
}
],
"type": "Vec<NumberOrHex>"
},
"getCurrencyBalances": {
"params": [
{
"name": "pool_id",
"type": "PoolId"
}
],
"type": "Vec<NumberOrHex>"
},
"getNumberOfCurrencies": {
"params": [
{
"name": "pool_id",
"type": "PoolId"
}
],
"type": "u32"
},
"getAdminBalances": {
"params": [
{
"name": "pool_id",
"type": "PoolId"
}
],
"type": "Vec<NumberOrHex>"
},
"getAdminBalance": {
"params": [
{
"name": "pool_id",
"type": "PoolId"
},
{
"name": "index",
"type": "u32"
}
],
"type": "NumberOrHex"
},
"calculateCurrencyAmount": {
"params": [
{
"name": "pool_id",
"type": "PoolId"
},
{
"name": "amounts",
"type": "Vec<Balance>"
},
{
"name": "deposit",
"type": "bool"
}
],
"type": "NumberOrHex"
},
"calculateSwap": {
"params": [
{
"name": "pool_id",
"type": "PoolId"
},
{
"name": "in_index",
"type": "u32"
},
{
"name": "out_index",
"type": "u32"
},
{
"name": "in_amount",
"type": "Balance"
}
],
"type": "NumberOrHex"
},
"calculateRemoveLiquidity": {
"params": [
{
"name": "pool_id",
"type": "PoolId"
},
{
"name": "amount",
"type": "Balance"
}
],
"type": "Vec<NumberOrHex>"
},
"calculateRemoveLiquidityOneCurrency": {
"params": [
{
"name": "pool_id",
"type": "PoolId"
},
{
"name": "amount",
"type": "Balance"
},
{
"name": "index",
"type": "u32"
}
],
"type": "NumberOrHex"
}
},
"escrow": {
"balanceAt": {
"description": "Get a given user's escrowed balance",
Expand Down Expand Up @@ -506,4 +787,4 @@
"intr"
]
}
}
}