Skip to content
Draft
3 changes: 2 additions & 1 deletion agent_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def __init__(self):
"./injective_functions/exchange/exchange_schema.json",
"./injective_functions/staking/staking_schema.json",
"./injective_functions/token_factory/token_factory_schema.json",
"./injective_functions/utils/utils_schema.json",
"./injective_functions/wasm/wasm_schema.json",
"./injective_functions/utils/mito_get_requests_schema.json"
]
self.function_schemas = FunctionSchemaLoader.load_schemas(schema_paths)

Expand Down
5 changes: 3 additions & 2 deletions injective_functions/exchange/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@

from typing import Dict, List


class InjectiveExchange(InjectiveBase):
def __init__(self, chain_client) -> None:
# Initializes the network and the composer
super().__init__(chain_client)

async def get_subaccount_deposits(
self, subaccount_idx: int, denoms: List[str] = None
) -> Dict:
Expand Down Expand Up @@ -208,7 +209,7 @@ async def trader_derivative_orders_by_hash(
)
return {"success": True, "result": orders}
except Exception as e:
return {"success": False, "result": detailed_exception_info(e)}
return {"success": False, "error": detailed_exception_info(e)}

async def trader_spot_orders_by_hash(
self, market_id: str, subaccount_idx: int, order_hashes: List[str]
Expand Down
6 changes: 5 additions & 1 deletion injective_functions/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
from injective_functions.exchange.trader import InjectiveTrading
from injective_functions.staking import InjectiveStaking
from injective_functions.token_factory import InjectiveTokenFactory
from injective_functions.utils.mito_requests import MitoAPIClient
from injective_functions.wasm.mito_contracts import InjectiveMitoContracts


MITO_BASE_URI = "https://k8s.mainnet.mito.grpc-web.injective.network/api/v1"
class InjectiveClientFactory:
"""Factory for creating Injective client instances."""

Expand Down Expand Up @@ -41,6 +43,8 @@ async def create_all(private_key: str, network_type: str = "mainnet") -> Dict:
"trader": InjectiveTrading(chain_client),
"staking": InjectiveStaking(chain_client),
"token_factory": InjectiveTokenFactory(chain_client),
"mito_fetch_data": MitoAPIClient(MITO_BASE_URI),
"mito_transactions": InjectiveMitoContracts(chain_client)
}
print(clients)
return clients
49 changes: 49 additions & 0 deletions injective_functions/utils/function_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,55 @@ class InjectiveFunctionMapper:
"mint": ("token_factory", "mint"),
"burn": ("token_factory", "burn"),
"set_denom_metadata": ("token_factory", "set_denom_metadata"),
# Mito fetch functions
"get_vaults": ("mito_fetch_data", "get_vaults"),
"get_vault": ("mito_fetch_data", "get_vault"),
"get_lp_token_price_chart": ("mito_fetch_data", "get_lp_token_price_chart"),
"get_tvl_chart": ("mito_fetch_data", "get_tvl_chart"),
"get_vaults_by_holder_address": (
"mito_fetch_data",
"get_vaults_by_holder_address",
),
"get_lp_holders": ("mito_fetch_data", "get_lp_holders"),
"get_portfolio": ("mito_fetch_data", "get_portfolio"),
"get_leaderboard": ("mito_fetch_data", "get_leaderboard"),
"get_leaderboard_epochs": ("mito_fetch_data", "get_leaderboard_epochs"),
"get_transfers_history": ("mito_fetch_data", "get_transfers_history"),
"get_staking_pools": ("mito_fetch_data", "get_staking_pools"),
"get_staking_reward_by_account": (
"mito_fetch_data",
"get_staking_reward_by_account",
),
"get_staking_history": ("mito_fetch_data", "get_staking_history"),
"get_staking_amount_at_height": (
"mito_fetch_data",
"get_staking_amount_at_height",
),
"get_health": ("mito_fetch_data", "get_health"),
"get_execution": ("mito_fetch_data", "get_execution"),
"get_missions": ("mito_fetch_data", "get_missions"),
"get_mission_leaderboard": ("mito,fetch_data", "get_mission_leaderboard"),
"list_idos": ("mito_fetch_data", "list_idos"),
"get_ido": ("mito_fetch_data", "get_ido"),
"get_ido_subscribers": ("mito_fetch_data", "get_ido_subscribers"),
"get_ido_subscription": ("mito_fetch_data", "get_ido_subscription"),
"get_ido_activities": ("mito_fetch_data", "get_ido_activities"),
"get_whitelist": ("mito_fetch_data", "get_whitelist"),
"get_token_metadata": ("mito_fetch_data", "get_token_metadata"),
"get_claim_references": ("mito_fetch_data", "get_claim_references"),
# Mito txs
"subscribe_to_launchpad": ("mito_transactions", "subscribe_to_launchpad"),
"claim_launchpad_subscription": (
"mito_transactions",
"claim_launchpad_subscription",
),
"subscription_mito_spot": ("mito_transactions", "subscription_mito_spot"),
"redeem_mito_vault": ("mito_transactions", "redeem_mito_vault"),
"stake_mito_vault": ("mito_transactions", "stake_mito_vault"),
"unstake_mito": ("mito_transactions", "unstake_mito"),
"claim_stake_mito_vault": ("mito_transactions", "claim_stake_mito_vault"),
"claim_rewards_mito": ("mito_transactions", "claim_rewards_mito"),
"instantiate_cpmm_vault": ("mito_transactions", "instantiate_cpmm_vault"),
}

@classmethod
Expand Down
7 changes: 3 additions & 4 deletions injective_functions/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ async def impute_market_id(market_id):


def detailed_exception_info(e) -> Dict:
return {
"success": False,
"error": {
return (
{
"message": str(e),
"type": type(e).__name__,
"module": e.__class__.__module__,
Expand All @@ -89,4 +88,4 @@ def detailed_exception_info(e) -> Dict:
"context": str(e.__context__) if e.__context__ else None,
},
},
}
)
Loading