Update app.py
Browse files
app.py
CHANGED
|
@@ -25,8 +25,6 @@ import httpx
|
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
-
from fastapi_mcp import FastApiMCP
|
| 29 |
-
|
| 30 |
|
| 31 |
|
| 32 |
|
|
@@ -39,8 +37,7 @@ from fastapi_mcp import FastApiMCP
|
|
| 39 |
|
| 40 |
|
| 41 |
app=FastAPI()
|
| 42 |
-
|
| 43 |
-
mcp.mount()
|
| 44 |
|
| 45 |
|
| 46 |
|
|
@@ -137,22 +134,21 @@ class UpdatePrice(BaseModel):
|
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
-
LAMPORTS_PER_SOL = 1_000_000_000
|
| 141 |
|
| 142 |
-
|
|
|
|
|
|
|
| 143 |
"""
|
| 144 |
-
Convert a human-readable
|
| 145 |
-
Example: "2.5" ->
|
| 146 |
"""
|
| 147 |
try:
|
| 148 |
-
|
| 149 |
-
if
|
| 150 |
raise ValueError("Amount cannot be negative")
|
| 151 |
-
return int(
|
| 152 |
except (ValueError, TypeError):
|
| 153 |
-
raise ValueError(f"Invalid
|
| 154 |
-
|
| 155 |
-
|
| 156 |
|
| 157 |
|
| 158 |
|
|
@@ -605,7 +601,7 @@ async def FetchVelocityGET(x402id:str,request:Request):
|
|
| 605 |
|
| 606 |
payAI_feepayer="2wKupLR9q6wXYppw8Gr2NvWxKBUqm4PPJKkQfoxHDBg4"
|
| 607 |
|
| 608 |
-
maxAmountRequired=str(
|
| 609 |
#maxAmountRequired="1000000"
|
| 610 |
|
| 611 |
resource=f"https://itsvelocity-velocity.hf.space/api/{x402id}"
|
|
@@ -868,7 +864,8 @@ async def FetchVelocityPost(request:Request):
|
|
| 868 |
|
| 869 |
payAI_feepayer="2wKupLR9q6wXYppw8Gr2NvWxKBUqm4PPJKkQfoxHDBg4"
|
| 870 |
#maxAmountRequired="1000000"
|
| 871 |
-
maxAmountRequired=str(to_lamports(found_price))
|
|
|
|
| 872 |
|
| 873 |
resource="https://itsvelocity-velocity.hf.space/api"
|
| 874 |
|
|
|
|
| 25 |
|
| 26 |
|
| 27 |
|
|
|
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
|
|
|
|
| 37 |
|
| 38 |
|
| 39 |
app=FastAPI()
|
| 40 |
+
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
|
|
|
|
| 134 |
|
| 135 |
|
| 136 |
|
|
|
|
| 137 |
|
| 138 |
+
USDC_DECIMALS = 1_000_000 # 10**6
|
| 139 |
+
|
| 140 |
+
def to_usdc_units(usdc_amount: str | float | int) -> int:
|
| 141 |
"""
|
| 142 |
+
Convert a human-readable USDC amount to its smallest integer units.
|
| 143 |
+
Example: "2.5" -> 2500000
|
| 144 |
"""
|
| 145 |
try:
|
| 146 |
+
usdc_value = float(usdc_amount)
|
| 147 |
+
if usdc_value < 0:
|
| 148 |
raise ValueError("Amount cannot be negative")
|
| 149 |
+
return int(usdc_value * USDC_DECIMALS)
|
| 150 |
except (ValueError, TypeError):
|
| 151 |
+
raise ValueError(f"Invalid USDC amount: {usdc_amount}")
|
|
|
|
|
|
|
| 152 |
|
| 153 |
|
| 154 |
|
|
|
|
| 601 |
|
| 602 |
payAI_feepayer="2wKupLR9q6wXYppw8Gr2NvWxKBUqm4PPJKkQfoxHDBg4"
|
| 603 |
|
| 604 |
+
maxAmountRequired=str(to_usdc_units(found_price))
|
| 605 |
#maxAmountRequired="1000000"
|
| 606 |
|
| 607 |
resource=f"https://itsvelocity-velocity.hf.space/api/{x402id}"
|
|
|
|
| 864 |
|
| 865 |
payAI_feepayer="2wKupLR9q6wXYppw8Gr2NvWxKBUqm4PPJKkQfoxHDBg4"
|
| 866 |
#maxAmountRequired="1000000"
|
| 867 |
+
#maxAmountRequired=str(to_lamports(found_price))
|
| 868 |
+
maxAmountRequired=str(to_usdc_units(found_price))
|
| 869 |
|
| 870 |
resource="https://itsvelocity-velocity.hf.space/api"
|
| 871 |
|