[Mangata] Replace rpc and types with type definition package (#9657)

This commit is contained in:
Michal Danco 2023-07-03 20:27:55 +02:00 committed by GitHub
parent 7b1b325d4b
commit f16406488e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 95 additions and 223 deletions

View File

@ -31,6 +31,7 @@
"@kiltprotocol/type-definitions": "0.33.1",
"@laminar/type-definitions": "0.3.1",
"@logion/node-api": "0.16.0",
"@mangata-finance/type-definitions": "^1.0.0",
"@metaverse-network-sdk/type-definitions": "0.0.1-16",
"@parallel-finance/type-definitions": "1.7.17",
"@peaqnetwork/type-definitions": "0.0.4",

View File

@ -11,6 +11,7 @@ import type { Balance } from '@polkadot/types/interfaces';
import type { FrameSystemAccountInfo } from '@polkadot/types/lookup';
import type { OverrideBundleDefinition } from '@polkadot/types/types';
import { mangataTypesBundleForPolkadotApps } from '@mangata-finance/type-definitions';
import { combineLatest, map } from 'rxjs';
import { memo } from '@polkadot/api-derive/util';
@ -72,207 +73,7 @@ const definitions: OverrideBundleDefinition = {
all: getBalance
}
},
types: [
{
// on all versions
minmax: [0, undefined],
types: {
ShufflingSeed: {
seed: 'H256',
proof: 'H512'
},
Header: {
parentHash: 'Hash',
number: 'Compact<BlockNumber>',
stateRoot: 'Hash',
extrinsicsRoot: 'Hash',
digest: 'Digest',
seed: 'ShufflingSeed',
count: 'BlockNumber'
},
XYKRpcResult: {
price: 'Balance'
},
RPCAmountsResult: {
firstAssetAmount: 'Balance',
secondAssetAmount: 'Balance'
},
VestingInfo: {
locked: 'Balance',
perBlock: 'Balance',
startingBlock: 'BlockNumber'
},
TokenId: 'u32',
VestingInfosWithLockedAt: {
vestingInfosWithLockedAt: 'Vec<(VestingInfo<Balance, BlockNumber>, Balance)>'
}
}
}
],
rpc: {
xyk: {
calculate_buy_price: {
description: '',
params: [
{
name: 'input_reserve',
type: 'Balance'
},
{
name: 'output_reserve',
type: 'Balance'
},
{
name: 'sell_amount',
type: 'Balance'
}
],
type: 'XYKRpcResult<Balance>'
},
calculate_sell_price: {
description: '',
params: [
{
name: 'input_reserve',
type: 'Balance'
},
{
name: 'output_reserve',
type: 'Balance'
},
{
name: 'sell_amount',
type: 'Balance'
}
],
type: 'XYKRpcResult<Balance>'
},
get_burn_amount: {
description: '',
params: [
{
name: 'first_asset_id',
type: 'TokenId'
},
{
name: 'second_asset_id',
type: 'TokenId'
},
{
name: 'liquidity_asset_amount',
type: 'Balance'
}
],
type: 'RPCAmountsResult<Balance>'
},
calculate_sell_price_id: {
description: '',
params: [
{
name: 'sold_token_id',
type: 'TokenId'
},
{
name: 'bought_token_id',
type: 'TokenId'
},
{
name: 'sell_amount',
type: 'Balance'
}
],
type: 'XYKRpcResult<Balance>'
},
calculate_buy_price_id: {
description: '',
params: [
{
name: 'sold_token_id',
type: 'TokenId'
},
{
name: 'bought_token_id',
type: 'TokenId'
},
{
name: 'buy_amount',
type: 'Balance'
}
],
type: 'XYKRpcResult<Balance>'
},
calculate_rewards_amount: {
description: '',
params: [
{
name: 'user',
type: 'AccountId'
},
{
name: 'liquidity_asset_id',
type: 'TokenId'
}
],
type: 'XYKRpcResult<Balance>'
},
calculate_balanced_sell_amount: {
description: '',
params: [
{
name: 'total_amount',
type: 'Balance'
},
{
name: 'reserve_amount',
type: 'Balance'
}
],
type: 'XYKRpcResult<Balance>'
},
get_max_instant_unreserve_amount: {
description: '',
params: [
{
name: 'user',
type: 'AccountId'
},
{
name: 'liquidity_asset_id',
type: 'TokenId'
}
],
type: 'Balance'
},
get_max_instant_burn_amount: {
description: '',
params: [
{
name: 'user',
type: 'AccountId'
},
{
name: 'liquidity_asset_id',
type: 'TokenId'
}
],
type: 'Balance'
},
get_vesting_locked_at: {
description: '',
params: [
{
name: 'who',
type: 'AccountId'
},
{
name: 'token_id',
type: 'TokenId'
}
],
type: 'VestingInfosWithLockedAt<Balance, BlockNumber>'
}
}
}
...mangataTypesBundleForPolkadotApps
};
export default definitions;

View File

@ -59884,7 +59884,7 @@ export const typesBundle = {
"rpc": {
"xyk": {
"calculate_buy_price": {
"description": "",
"description": "Calculates and returns sold_token_amount while providing bought_token_amount and respective reserves",
"params": [
{
"name": "input_reserve",
@ -59902,7 +59902,7 @@ export const typesBundle = {
"type": "XYKRpcResult<Balance>"
},
"calculate_sell_price": {
"description": "",
"description": "Calculates and returns bought_token_amount while providing sold_token_amount and respective reserves",
"params": [
{
"name": "input_reserve",
@ -59920,7 +59920,7 @@ export const typesBundle = {
"type": "XYKRpcResult<Balance>"
},
"get_burn_amount": {
"description": "",
"description": "Returns amounts of tokens received by burning provided liquidity_token_amount in pool of provided token ids",
"params": [
{
"name": "first_asset_id",
@ -59938,7 +59938,7 @@ export const typesBundle = {
"type": "RPCAmountsResult<Balance>"
},
"calculate_sell_price_id": {
"description": "",
"description": "Same as calculate_sell_price, but providing token_id instead of reserves. Reserves are fetched by function.",
"params": [
{
"name": "sold_token_id",
@ -59956,7 +59956,7 @@ export const typesBundle = {
"type": "XYKRpcResult<Balance>"
},
"calculate_buy_price_id": {
"description": "",
"description": "Same as calculate_buy_price, but providing token_id instead of reserves. Reserves are fetched by function.",
"params": [
{
"name": "sold_token_id",
@ -59974,7 +59974,7 @@ export const typesBundle = {
"type": "XYKRpcResult<Balance>"
},
"calculate_rewards_amount": {
"description": "",
"description": "Calculate rewards amount of liquidity token id for the user",
"params": [
{
"name": "user",
@ -59988,7 +59988,7 @@ export const typesBundle = {
"type": "XYKRpcResult<Balance>"
},
"calculate_balanced_sell_amount": {
"description": "",
"description": "Calculates how much amount x we need to swap from total_amount, so that after y = swap(x), the resulting balance equals (total_amount - x) / y = pool_x / pool_y - the resulting amounts can then be used to `mint_liquidity` with minimal leftover after operation",
"params": [
{
"name": "total_amount",
@ -60002,7 +60002,7 @@ export const typesBundle = {
"type": "XYKRpcResult<Balance>"
},
"get_max_instant_unreserve_amount": {
"description": "",
"description": "Instant unreserve amount",
"params": [
{
"name": "user",
@ -60013,7 +60013,7 @@ export const typesBundle = {
"type": "TokenId"
}
],
"type": "Balance"
"type": "XYKRpcResult<Balance>"
},
"get_max_instant_burn_amount": {
"description": "",
@ -60027,9 +60027,39 @@ export const typesBundle = {
"type": "TokenId"
}
],
"type": "Balance"
"type": "XYKRpcResult<Balance>"
},
"get_vesting_locked_at": {
"is_sell_asset_lock_free": {
"description": "",
"params": [
{
"name": "path",
"type": "Vec<TokenId>"
},
{
"name": "input_amount",
"type": "Balance"
}
],
"type": "Option<bool>"
},
"is_buy_asset_lock_free": {
"description": "",
"params": [
{
"name": "path",
"type": "Vec<TokenId>"
},
{
"name": "input_amount",
"type": "Balance"
}
],
"type": "Option<bool>"
}
},
"vesting": {
"getVestingLockedAt": {
"description": "",
"params": [
{
@ -60089,7 +60119,7 @@ export const typesBundle = {
"rpc": {
"xyk": {
"calculate_buy_price": {
"description": "",
"description": "Calculates and returns sold_token_amount while providing bought_token_amount and respective reserves",
"params": [
{
"name": "input_reserve",
@ -60107,7 +60137,7 @@ export const typesBundle = {
"type": "XYKRpcResult<Balance>"
},
"calculate_sell_price": {
"description": "",
"description": "Calculates and returns bought_token_amount while providing sold_token_amount and respective reserves",
"params": [
{
"name": "input_reserve",
@ -60125,7 +60155,7 @@ export const typesBundle = {
"type": "XYKRpcResult<Balance>"
},
"get_burn_amount": {
"description": "",
"description": "Returns amounts of tokens received by burning provided liquidity_token_amount in pool of provided token ids",
"params": [
{
"name": "first_asset_id",
@ -60143,7 +60173,7 @@ export const typesBundle = {
"type": "RPCAmountsResult<Balance>"
},
"calculate_sell_price_id": {
"description": "",
"description": "Same as calculate_sell_price, but providing token_id instead of reserves. Reserves are fetched by function.",
"params": [
{
"name": "sold_token_id",
@ -60161,7 +60191,7 @@ export const typesBundle = {
"type": "XYKRpcResult<Balance>"
},
"calculate_buy_price_id": {
"description": "",
"description": "Same as calculate_buy_price, but providing token_id instead of reserves. Reserves are fetched by function.",
"params": [
{
"name": "sold_token_id",
@ -60179,7 +60209,7 @@ export const typesBundle = {
"type": "XYKRpcResult<Balance>"
},
"calculate_rewards_amount": {
"description": "",
"description": "Calculate rewards amount of liquidity token id for the user",
"params": [
{
"name": "user",
@ -60193,7 +60223,7 @@ export const typesBundle = {
"type": "XYKRpcResult<Balance>"
},
"calculate_balanced_sell_amount": {
"description": "",
"description": "Calculates how much amount x we need to swap from total_amount, so that after y = swap(x), the resulting balance equals (total_amount - x) / y = pool_x / pool_y - the resulting amounts can then be used to `mint_liquidity` with minimal leftover after operation",
"params": [
{
"name": "total_amount",
@ -60207,7 +60237,7 @@ export const typesBundle = {
"type": "XYKRpcResult<Balance>"
},
"get_max_instant_unreserve_amount": {
"description": "",
"description": "Instant unreserve amount",
"params": [
{
"name": "user",
@ -60218,7 +60248,7 @@ export const typesBundle = {
"type": "TokenId"
}
],
"type": "Balance"
"type": "XYKRpcResult<Balance>"
},
"get_max_instant_burn_amount": {
"description": "",
@ -60232,9 +60262,39 @@ export const typesBundle = {
"type": "TokenId"
}
],
"type": "Balance"
"type": "XYKRpcResult<Balance>"
},
"get_vesting_locked_at": {
"is_sell_asset_lock_free": {
"description": "",
"params": [
{
"name": "path",
"type": "Vec<TokenId>"
},
{
"name": "input_amount",
"type": "Balance"
}
],
"type": "Option<bool>"
},
"is_buy_asset_lock_free": {
"description": "",
"params": [
{
"name": "path",
"type": "Vec<TokenId>"
},
{
"name": "input_amount",
"type": "Balance"
}
],
"type": "Option<bool>"
}
},
"vesting": {
"getVestingLockedAt": {
"description": "",
"params": [
{

View File

@ -967,6 +967,15 @@ __metadata:
languageName: node
linkType: hard
"@mangata-finance/type-definitions@npm:^1.0.0":
version: 1.0.0
resolution: "@mangata-finance/type-definitions@npm:1.0.0"
peerDependencies:
"@polkadot/types": ^10.7.3
checksum: 6b93fd4c4e53b7fa0b1c145929ecd170fcbd7921a49ec18b128b32dafab2a4e06d678cc8058ffc7b95f921481387062b3b32bf31c9929005827d87599392e389
languageName: node
linkType: hard
"@metamask/detect-provider@npm:^2.0.0":
version: 2.0.0
resolution: "@metamask/detect-provider@npm:2.0.0"
@ -1854,6 +1863,7 @@ __metadata:
"@kiltprotocol/type-definitions": 0.33.1
"@laminar/type-definitions": 0.3.1
"@logion/node-api": 0.16.0
"@mangata-finance/type-definitions": ^1.0.0
"@metaverse-network-sdk/type-definitions": 0.0.1-16
"@parallel-finance/type-definitions": 1.7.17
"@peaqnetwork/type-definitions": 0.0.4