compass_api_sdk 1.1.1__py3-none-any.whl → 2.2.1rc3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. compass_api_sdk/_hooks/sdkhooks.py +4 -4
  2. compass_api_sdk/_hooks/types.py +1 -2
  3. compass_api_sdk/_version.py +3 -3
  4. compass_api_sdk/aave_v3.py +386 -114
  5. compass_api_sdk/aerodrome_slipstream.py +104 -54
  6. compass_api_sdk/basesdk.py +6 -0
  7. compass_api_sdk/bridge.py +536 -0
  8. compass_api_sdk/earn.py +2026 -0
  9. compass_api_sdk/erc_4626_vaults.py +28 -10
  10. compass_api_sdk/errors/__init__.py +8 -0
  11. compass_api_sdk/errors/apierror.py +1 -1
  12. compass_api_sdk/errors/compassapierror.py +1 -1
  13. compass_api_sdk/errors/httpvalidationerror.py +1 -1
  14. compass_api_sdk/errors/mintpreparenotfoundresponse_error.py +49 -0
  15. compass_api_sdk/errors/no_response_error.py +1 -1
  16. compass_api_sdk/errors/responsevalidationerror.py +1 -1
  17. compass_api_sdk/ethena.py +36 -10
  18. compass_api_sdk/gas_sponsorship.py +458 -0
  19. compass_api_sdk/httpclient.py +0 -1
  20. compass_api_sdk/models/__init__.py +820 -392
  21. compass_api_sdk/models/aaveborrowparams.py +4 -13
  22. compass_api_sdk/models/aaveborrowrequest.py +10 -14
  23. compass_api_sdk/models/aavehistoricaltransactionsresponse.py +3 -3
  24. compass_api_sdk/models/aavelooprequest.py +32 -28
  25. compass_api_sdk/models/aaveposition.py +104 -0
  26. compass_api_sdk/models/aaverepayparams.py +4 -13
  27. compass_api_sdk/models/aaverepayrequest.py +10 -14
  28. compass_api_sdk/models/aavesetuseremodeparams.py +28 -0
  29. compass_api_sdk/models/aavesetuseremoderequest.py +48 -0
  30. compass_api_sdk/models/aavesupplyparams.py +4 -13
  31. compass_api_sdk/models/aavesupplyrequest.py +10 -14
  32. compass_api_sdk/models/aavevenue.py +27 -0
  33. compass_api_sdk/models/aavewithdrawparams.py +4 -13
  34. compass_api_sdk/models/aavewithdrawrequest.py +10 -14
  35. compass_api_sdk/models/aerodromeenrichedposition.py +109 -0
  36. compass_api_sdk/models/aerodromelppositionsresponse.py +10 -7
  37. compass_api_sdk/models/aerodromeslipstreambuyexactlyparams.py +8 -25
  38. compass_api_sdk/models/aerodromeslipstreambuyexactlyrequest.py +14 -26
  39. compass_api_sdk/models/aerodromeslipstreamincreaseliquidityprovisionrequest.py +6 -1
  40. compass_api_sdk/models/aerodromeslipstreammintliquidityprovisionparams.py +8 -25
  41. compass_api_sdk/models/aerodromeslipstreammintliquidityprovisionrequest.py +14 -26
  42. compass_api_sdk/models/aerodromeslipstreampoolpriceresponse.py +8 -25
  43. compass_api_sdk/models/aerodromeslipstreamsellexactlyparams.py +8 -25
  44. compass_api_sdk/models/aerodromeslipstreamsellexactlyrequest.py +13 -25
  45. compass_api_sdk/models/aerodromeslipstreamwithdrawliquidityprovisionrequest.py +6 -1
  46. compass_api_sdk/models/approvetransferrequest.py +32 -0
  47. compass_api_sdk/models/approvetransferresponse.py +52 -0
  48. compass_api_sdk/models/batchedsafeoperationsresponse_input.py +52 -0
  49. compass_api_sdk/models/batchedsafeoperationsresponse_output.py +52 -0
  50. compass_api_sdk/models/batcheduseroperationsrequest.py +15 -4
  51. compass_api_sdk/models/chainmarketinfo.py +29 -0
  52. compass_api_sdk/models/{compass_api_backend_models_generic_read_response_portfolio_tokenbalance.py → compass_api_backend_v1_models_generic_read_response_portfolio_tokenbalance.py} +6 -15
  53. compass_api_sdk/models/{compass_api_backend_models_morpho_read_response_check_user_position_apydata.py → compass_api_backend_v1_models_morpho_read_response_check_user_position_apydata.py} +2 -2
  54. compass_api_sdk/models/{compass_api_backend_models_morpho_read_response_check_user_position_asset.py → compass_api_backend_v1_models_morpho_read_response_check_user_position_asset.py} +2 -2
  55. compass_api_sdk/models/{compass_api_backend_models_morpho_read_response_check_user_position_marketstate.py → compass_api_backend_v1_models_morpho_read_response_check_user_position_marketstate.py} +4 -2
  56. compass_api_sdk/models/compass_api_backend_v1_models_morpho_read_response_check_user_position_vaultposition.py +30 -0
  57. compass_api_sdk/models/{compass_api_backend_models_morpho_read_response_check_user_position_vaultstate.py → compass_api_backend_v1_models_morpho_read_response_check_user_position_vaultstate.py} +2 -2
  58. compass_api_sdk/models/{compass_api_backend_models_morpho_read_response_get_market_apydata.py → compass_api_backend_v1_models_morpho_read_response_get_market_apydata.py} +2 -2
  59. compass_api_sdk/models/{compass_api_backend_models_morpho_read_response_get_market_asset.py → compass_api_backend_v1_models_morpho_read_response_get_market_asset.py} +5 -5
  60. compass_api_sdk/models/{compass_api_backend_models_morpho_read_response_get_market_marketstate.py → compass_api_backend_v1_models_morpho_read_response_get_market_marketstate.py} +4 -2
  61. compass_api_sdk/models/{compass_api_backend_models_morpho_read_response_get_markets_asset.py → compass_api_backend_v1_models_morpho_read_response_get_markets_asset.py} +2 -2
  62. compass_api_sdk/models/{compass_api_backend_models_morpho_read_response_get_markets_marketstate.py → compass_api_backend_v1_models_morpho_read_response_get_markets_marketstate.py} +2 -2
  63. compass_api_sdk/models/{compass_api_backend_models_morpho_read_response_get_vaults_asset.py → compass_api_backend_v1_models_morpho_read_response_get_vaults_asset.py} +2 -2
  64. compass_api_sdk/models/{compass_api_backend_models_morpho_read_response_get_vaults_vaultstate.py → compass_api_backend_v1_models_morpho_read_response_get_vaults_vaultstate.py} +4 -2
  65. compass_api_sdk/models/{compass_api_backend_models_pendle_read_response_market_userposition.py → compass_api_backend_v1_models_pendle_read_response_market_userposition.py} +2 -2
  66. compass_api_sdk/models/{compass_api_backend_models_pendle_read_response_positions_tokenbalance.py → compass_api_backend_v1_models_pendle_read_response_positions_tokenbalance.py} +2 -2
  67. compass_api_sdk/models/{compass_api_backend_models_vaults_read_response_vault_userposition.py → compass_api_backend_v1_models_vaults_read_response_vault_userposition.py} +2 -2
  68. compass_api_sdk/models/compass_api_backend_v1_models_wildcat_read_response_market_userposition.py +22 -0
  69. compass_api_sdk/models/compass_api_backend_v2_models_earn_read_response_positions_vaultposition.py +103 -0
  70. compass_api_sdk/models/compass_api_backend_v2_models_gas_sponsorship_permit_2_typed_data_eip712domain.py +36 -0
  71. compass_api_sdk/models/compass_api_backend_v2_models_gas_sponsorship_permit_2_typed_data_eip712types.py +36 -0
  72. compass_api_sdk/models/compass_api_backend_v2_models_gas_sponsorship_permit_typed_data_eip712domain.py +37 -0
  73. compass_api_sdk/models/compass_api_backend_v2_models_gas_sponsorship_permit_typed_data_eip712types.py +32 -0
  74. compass_api_sdk/models/compass_api_backend_v2_models_safe_transact_response_batched_safe_operations_eip712domain.py +29 -0
  75. compass_api_sdk/models/compass_api_backend_v2_models_safe_transact_response_batched_safe_operations_eip712types.py +34 -0
  76. compass_api_sdk/models/createaccountrequest.py +40 -0
  77. compass_api_sdk/models/createaccountresponse.py +56 -0
  78. compass_api_sdk/models/depositevent.py +61 -0
  79. compass_api_sdk/models/depositforburnrequest.py +77 -0
  80. compass_api_sdk/models/depositforburnresponse.py +100 -0
  81. compass_api_sdk/models/earnmanageparams.py +76 -0
  82. compass_api_sdk/models/earnmanagerequest.py +132 -0
  83. compass_api_sdk/models/earnmanageresponse.py +52 -0
  84. compass_api_sdk/models/earnpositionsresponse.py +48 -0
  85. compass_api_sdk/models/earnswapparams.py +74 -0
  86. compass_api_sdk/models/earnswaprequest.py +90 -0
  87. compass_api_sdk/models/earnswapresponse.py +55 -0
  88. compass_api_sdk/models/earntransferrequest.py +104 -0
  89. compass_api_sdk/models/earntransferresponse.py +71 -0
  90. compass_api_sdk/models/eip712domainfield.py +20 -0
  91. compass_api_sdk/models/eip712field.py +20 -0
  92. compass_api_sdk/models/ethenadepositrequest.py +6 -1
  93. compass_api_sdk/models/ethenagetvaultresponse.py +5 -5
  94. compass_api_sdk/models/ethenarequesttowithdrawrequest.py +6 -1
  95. compass_api_sdk/models/ethenaunstakerequest.py +6 -1
  96. compass_api_sdk/models/fee.py +43 -0
  97. compass_api_sdk/models/listaavemarketsresponse.py +21 -0
  98. compass_api_sdk/models/marketposition.py +5 -5
  99. compass_api_sdk/models/maxsupplyapyinfo.py +34 -0
  100. compass_api_sdk/models/mintpreparecompletedresponse.py +46 -0
  101. compass_api_sdk/models/mintpreparependingresponse.py +65 -0
  102. compass_api_sdk/models/mintpreparereadyresponse.py +43 -0
  103. compass_api_sdk/models/mintpreparerequest.py +25 -0
  104. compass_api_sdk/models/morphoborrowrequest.py +6 -1
  105. compass_api_sdk/models/morphocheckuserpositionresponse.py +9 -3
  106. compass_api_sdk/models/morphodepositrequest.py +6 -1
  107. compass_api_sdk/models/morphogetmarketresponse.py +72 -31
  108. compass_api_sdk/models/morphomarket.py +26 -20
  109. compass_api_sdk/models/morphorepayrequest.py +11 -1
  110. compass_api_sdk/models/morphosupplycollateralrequest.py +11 -1
  111. compass_api_sdk/models/morphovault.py +10 -10
  112. compass_api_sdk/models/morphowithdrawcollateralrequest.py +6 -1
  113. compass_api_sdk/models/morphowithdrawrequest.py +6 -1
  114. compass_api_sdk/models/multicallexecuterequest.py +7 -2
  115. compass_api_sdk/models/odosswapparams.py +9 -30
  116. compass_api_sdk/models/odosswaprequest.py +15 -33
  117. compass_api_sdk/models/oneinchswapparams.py +59 -0
  118. compass_api_sdk/models/openposition.py +7 -7
  119. compass_api_sdk/models/operationtype.py +11 -0
  120. compass_api_sdk/models/pendledepositevent.py +49 -0
  121. compass_api_sdk/models/pendlegetmarketresponse.py +5 -5
  122. compass_api_sdk/models/pendlemanageliquidityparams.py +2 -15
  123. compass_api_sdk/models/pendlemanageliquidityrequest.py +8 -16
  124. compass_api_sdk/models/pendlemarketinfo.py +138 -0
  125. compass_api_sdk/models/pendlemarketsresponse.py +30 -0
  126. compass_api_sdk/models/pendleptposition.py +111 -0
  127. compass_api_sdk/models/pendleptvenue.py +78 -0
  128. compass_api_sdk/models/pendleredeemyieldrequest.py +6 -1
  129. compass_api_sdk/models/pendletradeptparams.py +2 -15
  130. compass_api_sdk/models/pendletradeptrequest.py +8 -16
  131. compass_api_sdk/models/pendletradeytparams.py +2 -15
  132. compass_api_sdk/models/pendletradeytrequest.py +8 -16
  133. compass_api_sdk/models/pendlewithdrawalevent.py +54 -0
  134. compass_api_sdk/models/permit2typeddata_input.py +46 -0
  135. compass_api_sdk/models/permit2typeddata_output.py +46 -0
  136. compass_api_sdk/models/permitfield.py +20 -0
  137. compass_api_sdk/models/permitmessage.py +39 -0
  138. compass_api_sdk/models/permittransferfrommessage.py +29 -0
  139. compass_api_sdk/models/permittypeddataresponse_input.py +50 -0
  140. compass_api_sdk/models/permittypeddataresponse_output.py +50 -0
  141. compass_api_sdk/models/portfolio.py +5 -5
  142. compass_api_sdk/models/positionpnl.py +52 -0
  143. compass_api_sdk/models/reserve.py +6 -15
  144. compass_api_sdk/models/safetransactionparams.py +78 -0
  145. compass_api_sdk/models/safetransactionresponse.py +28 -0
  146. compass_api_sdk/models/safetxfield.py +20 -0
  147. compass_api_sdk/models/safetxmessage.py +66 -0
  148. compass_api_sdk/models/setallowanceparams.py +3 -16
  149. compass_api_sdk/models/setallowancerequest.py +9 -17
  150. compass_api_sdk/models/skybuyrequest.py +6 -1
  151. compass_api_sdk/models/skydepositrequest.py +7 -2
  152. compass_api_sdk/models/skysellrequest.py +7 -2
  153. compass_api_sdk/models/skywithdrawrequest.py +7 -2
  154. compass_api_sdk/models/sponsorgasrequest.py +71 -0
  155. compass_api_sdk/models/sponsorgasresponse.py +14 -0
  156. compass_api_sdk/models/tokenbalanceresponse.py +5 -15
  157. compass_api_sdk/models/tokenconfig.py +30 -0
  158. compass_api_sdk/models/tokenlistresponse.py +21 -0
  159. compass_api_sdk/models/tokenmarketdata.py +27 -0
  160. compass_api_sdk/models/tokenpermissions.py +20 -0
  161. compass_api_sdk/models/tokentransferparams.py +2 -15
  162. compass_api_sdk/models/tokentransferrequest.py +8 -16
  163. compass_api_sdk/models/uniswapbuyexactlyparams.py +8 -33
  164. compass_api_sdk/models/uniswapbuyexactlyrequest.py +14 -34
  165. compass_api_sdk/models/uniswapincreaseliquidityprovisionrequest.py +6 -1
  166. compass_api_sdk/models/uniswapmintliquidityprovisionparams.py +8 -25
  167. compass_api_sdk/models/uniswapmintliquidityprovisionrequest.py +14 -26
  168. compass_api_sdk/models/uniswappoolpriceresponse.py +8 -25
  169. compass_api_sdk/models/uniswapsellexactlyparams.py +4 -29
  170. compass_api_sdk/models/uniswapsellexactlyrequest.py +10 -30
  171. compass_api_sdk/models/uniswapwithdrawliquidityprovisionrequest.py +6 -1
  172. compass_api_sdk/models/unsignedmulticalltransaction.py +34 -3
  173. compass_api_sdk/models/unsignedtransaction.py +34 -3
  174. compass_api_sdk/models/unwrapwethrequest.py +6 -1
  175. compass_api_sdk/models/useroperation.py +33 -24
  176. compass_api_sdk/models/v1_aave_aave_supported_tokensop.py +1 -1
  177. compass_api_sdk/models/v1_aave_avg_rateop.py +15 -93
  178. compass_api_sdk/models/v1_aave_historical_transactionsop.py +15 -15
  179. compass_api_sdk/models/v1_aave_liquidity_changeop.py +8 -86
  180. compass_api_sdk/models/v1_aave_rateop.py +8 -86
  181. compass_api_sdk/models/v1_aave_reserve_overviewop.py +8 -86
  182. compass_api_sdk/models/v1_aave_std_rateop.py +15 -93
  183. compass_api_sdk/models/v1_aave_token_priceop.py +8 -86
  184. compass_api_sdk/models/v1_aave_user_position_per_tokenop.py +14 -92
  185. compass_api_sdk/models/v1_aave_user_position_summaryop.py +8 -8
  186. compass_api_sdk/models/v1_aerodrome_slipstream_liquidity_provision_positionsop.py +48 -3
  187. compass_api_sdk/models/v1_aerodrome_slipstream_pool_priceop.py +12 -168
  188. compass_api_sdk/models/v1_ethena_vaultop.py +1 -1
  189. compass_api_sdk/models/v1_generic_allowanceop.py +12 -26
  190. compass_api_sdk/models/v1_generic_ensop.py +2 -2
  191. compass_api_sdk/models/v1_generic_portfolioop.py +2 -2
  192. compass_api_sdk/models/v1_morpho_market_positionop.py +3 -3
  193. compass_api_sdk/models/v1_morpho_marketop.py +2 -2
  194. compass_api_sdk/models/v1_morpho_marketsop.py +10 -30
  195. compass_api_sdk/models/v1_morpho_user_positionop.py +2 -2
  196. compass_api_sdk/models/v1_morpho_vaultop.py +8 -8
  197. compass_api_sdk/models/v1_morpho_vaultsop.py +6 -16
  198. compass_api_sdk/models/v1_pendle_marketop.py +8 -8
  199. compass_api_sdk/models/v1_pendle_marketsop.py +1 -1
  200. compass_api_sdk/models/v1_pendle_positionsop.py +2 -2
  201. compass_api_sdk/models/v1_sky_positionop.py +5 -6
  202. compass_api_sdk/models/v1_token_balanceop.py +12 -25
  203. compass_api_sdk/models/{v1_generic_supported_tokensop.py → v1_token_listop.py} +6 -6
  204. compass_api_sdk/models/v1_token_priceop.py +8 -9
  205. compass_api_sdk/models/v1_transaction_bundler_aave_loopop.py +6 -6
  206. compass_api_sdk/models/v1_uniswap_liquidity_provision_in_rangeop.py +2 -2
  207. compass_api_sdk/models/v1_uniswap_liquidity_provision_positionsop.py +2 -2
  208. compass_api_sdk/models/v1_uniswap_pool_priceop.py +12 -168
  209. compass_api_sdk/models/v1_uniswap_quote_buy_exactlyop.py +20 -176
  210. compass_api_sdk/models/v1_uniswap_quote_sell_exactlyop.py +20 -176
  211. compass_api_sdk/models/v1_vaults_vaultop.py +8 -8
  212. compass_api_sdk/models/v1_wildcat_marketop.py +82 -0
  213. compass_api_sdk/models/v2_cctp_mintop.py +47 -0
  214. compass_api_sdk/models/v2_earn_aave_marketsop.py +57 -0
  215. compass_api_sdk/models/v2_earn_pendle_marketsop.py +105 -0
  216. compass_api_sdk/models/v2_earn_positionsop.py +31 -0
  217. compass_api_sdk/models/v2_earn_vaultsop.py +105 -0
  218. compass_api_sdk/models/v2bundlerequest.py +33 -0
  219. compass_api_sdk/models/v2bundleresponse.py +67 -0
  220. compass_api_sdk/models/v2useroperation.py +37 -0
  221. compass_api_sdk/models/vault.py +14 -14
  222. compass_api_sdk/models/vaultdepositrequest.py +6 -1
  223. compass_api_sdk/models/vaultgetvaultresponse.py +5 -5
  224. compass_api_sdk/models/vaultinfo.py +129 -0
  225. compass_api_sdk/models/vaultsresponse.py +30 -0
  226. compass_api_sdk/models/vaultvenue.py +27 -0
  227. compass_api_sdk/models/vaultwithdrawrequest.py +6 -1
  228. compass_api_sdk/models/wildcatgetmarketresponse.py +151 -0
  229. compass_api_sdk/models/{redeemunderlying.py → withdraw.py} +2 -2
  230. compass_api_sdk/models/withdrawalevent.py +61 -0
  231. compass_api_sdk/models/wrapethrequest.py +6 -1
  232. compass_api_sdk/morpho.py +126 -78
  233. compass_api_sdk/pendle.py +68 -44
  234. compass_api_sdk/sdk.py +18 -11
  235. compass_api_sdk/sky.py +62 -38
  236. compass_api_sdk/smart_account.py +10 -2
  237. compass_api_sdk/swap.py +22 -22
  238. compass_api_sdk/{token_sdk.py → token.py} +511 -103
  239. compass_api_sdk/transaction_bundler.py +46 -16
  240. compass_api_sdk/types/basemodel.py +41 -3
  241. compass_api_sdk/uniswap_v3.py +152 -114
  242. compass_api_sdk/universal.py +44 -606
  243. compass_api_sdk/utils/__init__.py +0 -3
  244. compass_api_sdk/utils/annotations.py +32 -8
  245. compass_api_sdk/utils/enums.py +60 -0
  246. compass_api_sdk/utils/forms.py +21 -10
  247. compass_api_sdk/utils/queryparams.py +14 -2
  248. compass_api_sdk/utils/requestbodies.py +3 -3
  249. compass_api_sdk/utils/retries.py +69 -5
  250. compass_api_sdk/utils/serializers.py +0 -20
  251. compass_api_sdk/utils/unmarshal_json_response.py +15 -1
  252. compass_api_sdk/wildcat.py +208 -0
  253. compass_api_sdk-2.2.1rc3.dist-info/METADATA +624 -0
  254. compass_api_sdk-2.2.1rc3.dist-info/RECORD +356 -0
  255. {compass_api_sdk-1.1.1.dist-info → compass_api_sdk-2.2.1rc3.dist-info}/WHEEL +1 -1
  256. compass_api_sdk/models/aerodromeposition.py +0 -70
  257. compass_api_sdk/models/token_enum.py +0 -81
  258. compass_api_sdk/models/tokenaddressresponse.py +0 -15
  259. compass_api_sdk/models/tokeninfo.py +0 -17
  260. compass_api_sdk/models/v1_token_addressop.py +0 -109
  261. compass_api_sdk/models/vaultposition.py +0 -24
  262. compass_api_sdk-1.1.1.dist-info/METADATA +0 -592
  263. compass_api_sdk-1.1.1.dist-info/RECORD +0 -275
@@ -0,0 +1,2026 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from .basesdk import BaseSDK
4
+ from compass_api_sdk import errors, models, utils
5
+ from compass_api_sdk._hooks import HookContext
6
+ from compass_api_sdk.types import OptionalNullable, UNSET
7
+ from compass_api_sdk.utils.unmarshal_json_response import unmarshal_json_response
8
+ from typing import Any, List, Mapping, Optional, Union
9
+
10
+
11
+ class Earn(BaseSDK):
12
+ def earn_positions(
13
+ self,
14
+ *,
15
+ chain: models.V2EarnPositionsChain,
16
+ owner: str,
17
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
18
+ server_url: Optional[str] = None,
19
+ timeout_ms: Optional[int] = None,
20
+ http_headers: Optional[Mapping[str, str]] = None,
21
+ ) -> models.EarnPositionsResponse:
22
+ r"""List earn positions
23
+
24
+ List all Earn positions for a given owner with PnL tracking.
25
+
26
+ Returns position data including current balance, cost basis, and profit and loss.
27
+ Use this endpoint to display portfolio performance, track yields over time, or build
28
+ position management interfaces.
29
+
30
+ Positions are tracked across all venue types (vaults and Aave markets). Each
31
+ position includes the venue address, deposited amount, and performance metrics.
32
+
33
+ :param chain:
34
+ :param owner: The address of the owner of the earn account to get positions for.
35
+ :param retries: Override the default retry configuration for this method
36
+ :param server_url: Override the default server URL for this method
37
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
38
+ :param http_headers: Additional headers to set or replace on requests.
39
+ """
40
+ base_url = None
41
+ url_variables = None
42
+ if timeout_ms is None:
43
+ timeout_ms = self.sdk_configuration.timeout_ms
44
+
45
+ if server_url is not None:
46
+ base_url = server_url
47
+ else:
48
+ base_url = self._get_url(base_url, url_variables)
49
+
50
+ request = models.V2EarnPositionsRequest(
51
+ chain=chain,
52
+ owner=owner,
53
+ )
54
+
55
+ req = self._build_request(
56
+ method="GET",
57
+ path="/v2/earn/positions",
58
+ base_url=base_url,
59
+ url_variables=url_variables,
60
+ request=request,
61
+ request_body_required=False,
62
+ request_has_path_params=False,
63
+ request_has_query_params=True,
64
+ user_agent_header="user-agent",
65
+ accept_header_value="application/json",
66
+ http_headers=http_headers,
67
+ security=self.sdk_configuration.security,
68
+ allow_empty_value=None,
69
+ timeout_ms=timeout_ms,
70
+ )
71
+
72
+ if retries == UNSET:
73
+ if self.sdk_configuration.retry_config is not UNSET:
74
+ retries = self.sdk_configuration.retry_config
75
+
76
+ retry_config = None
77
+ if isinstance(retries, utils.RetryConfig):
78
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
79
+
80
+ http_res = self.do_request(
81
+ hook_ctx=HookContext(
82
+ config=self.sdk_configuration,
83
+ base_url=base_url or "",
84
+ operation_id="v2_earn_positions",
85
+ oauth2_scopes=None,
86
+ security_source=self.sdk_configuration.security,
87
+ ),
88
+ request=req,
89
+ error_status_codes=["422", "4XX", "5XX"],
90
+ retry_config=retry_config,
91
+ )
92
+
93
+ response_data: Any = None
94
+ if utils.match_response(http_res, "200", "application/json"):
95
+ return unmarshal_json_response(models.EarnPositionsResponse, http_res)
96
+ if utils.match_response(http_res, "422", "application/json"):
97
+ response_data = unmarshal_json_response(
98
+ errors.HTTPValidationErrorData, http_res
99
+ )
100
+ raise errors.HTTPValidationError(response_data, http_res)
101
+ if utils.match_response(http_res, "4XX", "*"):
102
+ http_res_text = utils.stream_to_text(http_res)
103
+ raise errors.APIError("API error occurred", http_res, http_res_text)
104
+ if utils.match_response(http_res, "5XX", "*"):
105
+ http_res_text = utils.stream_to_text(http_res)
106
+ raise errors.APIError("API error occurred", http_res, http_res_text)
107
+
108
+ raise errors.APIError("Unexpected response received", http_res)
109
+
110
+ async def earn_positions_async(
111
+ self,
112
+ *,
113
+ chain: models.V2EarnPositionsChain,
114
+ owner: str,
115
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
116
+ server_url: Optional[str] = None,
117
+ timeout_ms: Optional[int] = None,
118
+ http_headers: Optional[Mapping[str, str]] = None,
119
+ ) -> models.EarnPositionsResponse:
120
+ r"""List earn positions
121
+
122
+ List all Earn positions for a given owner with PnL tracking.
123
+
124
+ Returns position data including current balance, cost basis, and profit and loss.
125
+ Use this endpoint to display portfolio performance, track yields over time, or build
126
+ position management interfaces.
127
+
128
+ Positions are tracked across all venue types (vaults and Aave markets). Each
129
+ position includes the venue address, deposited amount, and performance metrics.
130
+
131
+ :param chain:
132
+ :param owner: The address of the owner of the earn account to get positions for.
133
+ :param retries: Override the default retry configuration for this method
134
+ :param server_url: Override the default server URL for this method
135
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
136
+ :param http_headers: Additional headers to set or replace on requests.
137
+ """
138
+ base_url = None
139
+ url_variables = None
140
+ if timeout_ms is None:
141
+ timeout_ms = self.sdk_configuration.timeout_ms
142
+
143
+ if server_url is not None:
144
+ base_url = server_url
145
+ else:
146
+ base_url = self._get_url(base_url, url_variables)
147
+
148
+ request = models.V2EarnPositionsRequest(
149
+ chain=chain,
150
+ owner=owner,
151
+ )
152
+
153
+ req = self._build_request_async(
154
+ method="GET",
155
+ path="/v2/earn/positions",
156
+ base_url=base_url,
157
+ url_variables=url_variables,
158
+ request=request,
159
+ request_body_required=False,
160
+ request_has_path_params=False,
161
+ request_has_query_params=True,
162
+ user_agent_header="user-agent",
163
+ accept_header_value="application/json",
164
+ http_headers=http_headers,
165
+ security=self.sdk_configuration.security,
166
+ allow_empty_value=None,
167
+ timeout_ms=timeout_ms,
168
+ )
169
+
170
+ if retries == UNSET:
171
+ if self.sdk_configuration.retry_config is not UNSET:
172
+ retries = self.sdk_configuration.retry_config
173
+
174
+ retry_config = None
175
+ if isinstance(retries, utils.RetryConfig):
176
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
177
+
178
+ http_res = await self.do_request_async(
179
+ hook_ctx=HookContext(
180
+ config=self.sdk_configuration,
181
+ base_url=base_url or "",
182
+ operation_id="v2_earn_positions",
183
+ oauth2_scopes=None,
184
+ security_source=self.sdk_configuration.security,
185
+ ),
186
+ request=req,
187
+ error_status_codes=["422", "4XX", "5XX"],
188
+ retry_config=retry_config,
189
+ )
190
+
191
+ response_data: Any = None
192
+ if utils.match_response(http_res, "200", "application/json"):
193
+ return unmarshal_json_response(models.EarnPositionsResponse, http_res)
194
+ if utils.match_response(http_res, "422", "application/json"):
195
+ response_data = unmarshal_json_response(
196
+ errors.HTTPValidationErrorData, http_res
197
+ )
198
+ raise errors.HTTPValidationError(response_data, http_res)
199
+ if utils.match_response(http_res, "4XX", "*"):
200
+ http_res_text = await utils.stream_to_text_async(http_res)
201
+ raise errors.APIError("API error occurred", http_res, http_res_text)
202
+ if utils.match_response(http_res, "5XX", "*"):
203
+ http_res_text = await utils.stream_to_text_async(http_res)
204
+ raise errors.APIError("API error occurred", http_res, http_res_text)
205
+
206
+ raise errors.APIError("Unexpected response received", http_res)
207
+
208
+ def earn_vaults(
209
+ self,
210
+ *,
211
+ order_by: str,
212
+ direction: Optional[models.V2EarnVaultsDirection] = None,
213
+ offset: Optional[int] = None,
214
+ limit: Optional[int] = None,
215
+ chain: OptionalNullable[models.Chain] = UNSET,
216
+ asset_symbol: OptionalNullable[str] = UNSET,
217
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
218
+ server_url: Optional[str] = None,
219
+ timeout_ms: Optional[int] = None,
220
+ http_headers: Optional[Mapping[str, str]] = None,
221
+ ) -> models.VaultsResponse:
222
+ r"""List vaults
223
+
224
+ List ERC-4626 yield vaults across DeFi venues.
225
+
226
+ Returns vault data including APY, TVL, and underlying asset information. Use this endpoint to discover yield opportunities, compare rates across venues, or build vault selection interfaces.
227
+
228
+ Supports dozens of vaults and markets like Morpho and other ERC-4626 compatible yield venues.
229
+
230
+ To deposit into a vault, use the [manage endpoint](https://docs.compasslabs.ai/v2/api-reference/earn/manage-earn-position) with `venue_type=VAULTS`.
231
+
232
+ :param order_by: The field to order the results by.
233
+ :param direction: The direction to order the results by.
234
+ :param offset: The offset of the first item to return.
235
+ :param limit: The number of items to return.
236
+ :param chain: Optional chain filter. If not provided, returns vaults for all chains.
237
+ :param asset_symbol: Filter vaults by underlying asset symbol (e.g., 'USDC', 'WETH').
238
+ :param retries: Override the default retry configuration for this method
239
+ :param server_url: Override the default server URL for this method
240
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
241
+ :param http_headers: Additional headers to set or replace on requests.
242
+ """
243
+ base_url = None
244
+ url_variables = None
245
+ if timeout_ms is None:
246
+ timeout_ms = self.sdk_configuration.timeout_ms
247
+
248
+ if server_url is not None:
249
+ base_url = server_url
250
+ else:
251
+ base_url = self._get_url(base_url, url_variables)
252
+
253
+ request = models.V2EarnVaultsRequest(
254
+ order_by=order_by,
255
+ direction=direction,
256
+ offset=offset,
257
+ limit=limit,
258
+ chain=chain,
259
+ asset_symbol=asset_symbol,
260
+ )
261
+
262
+ req = self._build_request(
263
+ method="GET",
264
+ path="/v2/earn/vaults",
265
+ base_url=base_url,
266
+ url_variables=url_variables,
267
+ request=request,
268
+ request_body_required=False,
269
+ request_has_path_params=False,
270
+ request_has_query_params=True,
271
+ user_agent_header="user-agent",
272
+ accept_header_value="application/json",
273
+ http_headers=http_headers,
274
+ security=self.sdk_configuration.security,
275
+ allow_empty_value=None,
276
+ timeout_ms=timeout_ms,
277
+ )
278
+
279
+ if retries == UNSET:
280
+ if self.sdk_configuration.retry_config is not UNSET:
281
+ retries = self.sdk_configuration.retry_config
282
+
283
+ retry_config = None
284
+ if isinstance(retries, utils.RetryConfig):
285
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
286
+
287
+ http_res = self.do_request(
288
+ hook_ctx=HookContext(
289
+ config=self.sdk_configuration,
290
+ base_url=base_url or "",
291
+ operation_id="v2_earn_vaults",
292
+ oauth2_scopes=None,
293
+ security_source=self.sdk_configuration.security,
294
+ ),
295
+ request=req,
296
+ error_status_codes=["422", "4XX", "5XX"],
297
+ retry_config=retry_config,
298
+ )
299
+
300
+ response_data: Any = None
301
+ if utils.match_response(http_res, "200", "application/json"):
302
+ return unmarshal_json_response(models.VaultsResponse, http_res)
303
+ if utils.match_response(http_res, "422", "application/json"):
304
+ response_data = unmarshal_json_response(
305
+ errors.HTTPValidationErrorData, http_res
306
+ )
307
+ raise errors.HTTPValidationError(response_data, http_res)
308
+ if utils.match_response(http_res, "4XX", "*"):
309
+ http_res_text = utils.stream_to_text(http_res)
310
+ raise errors.APIError("API error occurred", http_res, http_res_text)
311
+ if utils.match_response(http_res, "5XX", "*"):
312
+ http_res_text = utils.stream_to_text(http_res)
313
+ raise errors.APIError("API error occurred", http_res, http_res_text)
314
+
315
+ raise errors.APIError("Unexpected response received", http_res)
316
+
317
+ async def earn_vaults_async(
318
+ self,
319
+ *,
320
+ order_by: str,
321
+ direction: Optional[models.V2EarnVaultsDirection] = None,
322
+ offset: Optional[int] = None,
323
+ limit: Optional[int] = None,
324
+ chain: OptionalNullable[models.Chain] = UNSET,
325
+ asset_symbol: OptionalNullable[str] = UNSET,
326
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
327
+ server_url: Optional[str] = None,
328
+ timeout_ms: Optional[int] = None,
329
+ http_headers: Optional[Mapping[str, str]] = None,
330
+ ) -> models.VaultsResponse:
331
+ r"""List vaults
332
+
333
+ List ERC-4626 yield vaults across DeFi venues.
334
+
335
+ Returns vault data including APY, TVL, and underlying asset information. Use this endpoint to discover yield opportunities, compare rates across venues, or build vault selection interfaces.
336
+
337
+ Supports dozens of vaults and markets like Morpho and other ERC-4626 compatible yield venues.
338
+
339
+ To deposit into a vault, use the [manage endpoint](https://docs.compasslabs.ai/v2/api-reference/earn/manage-earn-position) with `venue_type=VAULTS`.
340
+
341
+ :param order_by: The field to order the results by.
342
+ :param direction: The direction to order the results by.
343
+ :param offset: The offset of the first item to return.
344
+ :param limit: The number of items to return.
345
+ :param chain: Optional chain filter. If not provided, returns vaults for all chains.
346
+ :param asset_symbol: Filter vaults by underlying asset symbol (e.g., 'USDC', 'WETH').
347
+ :param retries: Override the default retry configuration for this method
348
+ :param server_url: Override the default server URL for this method
349
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
350
+ :param http_headers: Additional headers to set or replace on requests.
351
+ """
352
+ base_url = None
353
+ url_variables = None
354
+ if timeout_ms is None:
355
+ timeout_ms = self.sdk_configuration.timeout_ms
356
+
357
+ if server_url is not None:
358
+ base_url = server_url
359
+ else:
360
+ base_url = self._get_url(base_url, url_variables)
361
+
362
+ request = models.V2EarnVaultsRequest(
363
+ order_by=order_by,
364
+ direction=direction,
365
+ offset=offset,
366
+ limit=limit,
367
+ chain=chain,
368
+ asset_symbol=asset_symbol,
369
+ )
370
+
371
+ req = self._build_request_async(
372
+ method="GET",
373
+ path="/v2/earn/vaults",
374
+ base_url=base_url,
375
+ url_variables=url_variables,
376
+ request=request,
377
+ request_body_required=False,
378
+ request_has_path_params=False,
379
+ request_has_query_params=True,
380
+ user_agent_header="user-agent",
381
+ accept_header_value="application/json",
382
+ http_headers=http_headers,
383
+ security=self.sdk_configuration.security,
384
+ allow_empty_value=None,
385
+ timeout_ms=timeout_ms,
386
+ )
387
+
388
+ if retries == UNSET:
389
+ if self.sdk_configuration.retry_config is not UNSET:
390
+ retries = self.sdk_configuration.retry_config
391
+
392
+ retry_config = None
393
+ if isinstance(retries, utils.RetryConfig):
394
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
395
+
396
+ http_res = await self.do_request_async(
397
+ hook_ctx=HookContext(
398
+ config=self.sdk_configuration,
399
+ base_url=base_url or "",
400
+ operation_id="v2_earn_vaults",
401
+ oauth2_scopes=None,
402
+ security_source=self.sdk_configuration.security,
403
+ ),
404
+ request=req,
405
+ error_status_codes=["422", "4XX", "5XX"],
406
+ retry_config=retry_config,
407
+ )
408
+
409
+ response_data: Any = None
410
+ if utils.match_response(http_res, "200", "application/json"):
411
+ return unmarshal_json_response(models.VaultsResponse, http_res)
412
+ if utils.match_response(http_res, "422", "application/json"):
413
+ response_data = unmarshal_json_response(
414
+ errors.HTTPValidationErrorData, http_res
415
+ )
416
+ raise errors.HTTPValidationError(response_data, http_res)
417
+ if utils.match_response(http_res, "4XX", "*"):
418
+ http_res_text = await utils.stream_to_text_async(http_res)
419
+ raise errors.APIError("API error occurred", http_res, http_res_text)
420
+ if utils.match_response(http_res, "5XX", "*"):
421
+ http_res_text = await utils.stream_to_text_async(http_res)
422
+ raise errors.APIError("API error occurred", http_res, http_res_text)
423
+
424
+ raise errors.APIError("Unexpected response received", http_res)
425
+
426
+ def earn_aave_markets(
427
+ self,
428
+ *,
429
+ chain: OptionalNullable[models.Chain] = UNSET,
430
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
431
+ server_url: Optional[str] = None,
432
+ timeout_ms: Optional[int] = None,
433
+ http_headers: Optional[Mapping[str, str]] = None,
434
+ ) -> models.ListAaveMarketsResponse:
435
+ r"""List aave markets
436
+
437
+ List Aave lending markets with supply and borrow rates.
438
+
439
+ Returns rates organized by token symbol, with chain-specific data for each token. Each token includes rates for all chains where it's available, plus information about which chain offers the highest supply APY.
440
+
441
+ APY values are returned in percentage format (e.g., 4.5 means 4.5%). Tokens with zero APY on both supply and borrow are excluded.
442
+
443
+ To deposit into an Aave market, use the [manage endpoint](https://docs.compasslabs.ai/v2/api-reference/earn/manage-earn-position) with `venue_type=AAVE`.
444
+
445
+ :param chain: Optional chain filter. If not provided, returns rates for all chains.
446
+ :param retries: Override the default retry configuration for this method
447
+ :param server_url: Override the default server URL for this method
448
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
449
+ :param http_headers: Additional headers to set or replace on requests.
450
+ """
451
+ base_url = None
452
+ url_variables = None
453
+ if timeout_ms is None:
454
+ timeout_ms = self.sdk_configuration.timeout_ms
455
+
456
+ if server_url is not None:
457
+ base_url = server_url
458
+ else:
459
+ base_url = self._get_url(base_url, url_variables)
460
+
461
+ request = models.V2EarnAaveMarketsRequest(
462
+ chain=chain,
463
+ )
464
+
465
+ req = self._build_request(
466
+ method="GET",
467
+ path="/v2/earn/aave_markets",
468
+ base_url=base_url,
469
+ url_variables=url_variables,
470
+ request=request,
471
+ request_body_required=False,
472
+ request_has_path_params=False,
473
+ request_has_query_params=True,
474
+ user_agent_header="user-agent",
475
+ accept_header_value="application/json",
476
+ http_headers=http_headers,
477
+ security=self.sdk_configuration.security,
478
+ allow_empty_value=None,
479
+ timeout_ms=timeout_ms,
480
+ )
481
+
482
+ if retries == UNSET:
483
+ if self.sdk_configuration.retry_config is not UNSET:
484
+ retries = self.sdk_configuration.retry_config
485
+
486
+ retry_config = None
487
+ if isinstance(retries, utils.RetryConfig):
488
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
489
+
490
+ http_res = self.do_request(
491
+ hook_ctx=HookContext(
492
+ config=self.sdk_configuration,
493
+ base_url=base_url or "",
494
+ operation_id="v2_earn_aave_markets",
495
+ oauth2_scopes=None,
496
+ security_source=self.sdk_configuration.security,
497
+ ),
498
+ request=req,
499
+ error_status_codes=["422", "4XX", "5XX"],
500
+ retry_config=retry_config,
501
+ )
502
+
503
+ response_data: Any = None
504
+ if utils.match_response(http_res, "200", "application/json"):
505
+ return unmarshal_json_response(models.ListAaveMarketsResponse, http_res)
506
+ if utils.match_response(http_res, "422", "application/json"):
507
+ response_data = unmarshal_json_response(
508
+ errors.HTTPValidationErrorData, http_res
509
+ )
510
+ raise errors.HTTPValidationError(response_data, http_res)
511
+ if utils.match_response(http_res, "4XX", "*"):
512
+ http_res_text = utils.stream_to_text(http_res)
513
+ raise errors.APIError("API error occurred", http_res, http_res_text)
514
+ if utils.match_response(http_res, "5XX", "*"):
515
+ http_res_text = utils.stream_to_text(http_res)
516
+ raise errors.APIError("API error occurred", http_res, http_res_text)
517
+
518
+ raise errors.APIError("Unexpected response received", http_res)
519
+
520
+ async def earn_aave_markets_async(
521
+ self,
522
+ *,
523
+ chain: OptionalNullable[models.Chain] = UNSET,
524
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
525
+ server_url: Optional[str] = None,
526
+ timeout_ms: Optional[int] = None,
527
+ http_headers: Optional[Mapping[str, str]] = None,
528
+ ) -> models.ListAaveMarketsResponse:
529
+ r"""List aave markets
530
+
531
+ List Aave lending markets with supply and borrow rates.
532
+
533
+ Returns rates organized by token symbol, with chain-specific data for each token. Each token includes rates for all chains where it's available, plus information about which chain offers the highest supply APY.
534
+
535
+ APY values are returned in percentage format (e.g., 4.5 means 4.5%). Tokens with zero APY on both supply and borrow are excluded.
536
+
537
+ To deposit into an Aave market, use the [manage endpoint](https://docs.compasslabs.ai/v2/api-reference/earn/manage-earn-position) with `venue_type=AAVE`.
538
+
539
+ :param chain: Optional chain filter. If not provided, returns rates for all chains.
540
+ :param retries: Override the default retry configuration for this method
541
+ :param server_url: Override the default server URL for this method
542
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
543
+ :param http_headers: Additional headers to set or replace on requests.
544
+ """
545
+ base_url = None
546
+ url_variables = None
547
+ if timeout_ms is None:
548
+ timeout_ms = self.sdk_configuration.timeout_ms
549
+
550
+ if server_url is not None:
551
+ base_url = server_url
552
+ else:
553
+ base_url = self._get_url(base_url, url_variables)
554
+
555
+ request = models.V2EarnAaveMarketsRequest(
556
+ chain=chain,
557
+ )
558
+
559
+ req = self._build_request_async(
560
+ method="GET",
561
+ path="/v2/earn/aave_markets",
562
+ base_url=base_url,
563
+ url_variables=url_variables,
564
+ request=request,
565
+ request_body_required=False,
566
+ request_has_path_params=False,
567
+ request_has_query_params=True,
568
+ user_agent_header="user-agent",
569
+ accept_header_value="application/json",
570
+ http_headers=http_headers,
571
+ security=self.sdk_configuration.security,
572
+ allow_empty_value=None,
573
+ timeout_ms=timeout_ms,
574
+ )
575
+
576
+ if retries == UNSET:
577
+ if self.sdk_configuration.retry_config is not UNSET:
578
+ retries = self.sdk_configuration.retry_config
579
+
580
+ retry_config = None
581
+ if isinstance(retries, utils.RetryConfig):
582
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
583
+
584
+ http_res = await self.do_request_async(
585
+ hook_ctx=HookContext(
586
+ config=self.sdk_configuration,
587
+ base_url=base_url or "",
588
+ operation_id="v2_earn_aave_markets",
589
+ oauth2_scopes=None,
590
+ security_source=self.sdk_configuration.security,
591
+ ),
592
+ request=req,
593
+ error_status_codes=["422", "4XX", "5XX"],
594
+ retry_config=retry_config,
595
+ )
596
+
597
+ response_data: Any = None
598
+ if utils.match_response(http_res, "200", "application/json"):
599
+ return unmarshal_json_response(models.ListAaveMarketsResponse, http_res)
600
+ if utils.match_response(http_res, "422", "application/json"):
601
+ response_data = unmarshal_json_response(
602
+ errors.HTTPValidationErrorData, http_res
603
+ )
604
+ raise errors.HTTPValidationError(response_data, http_res)
605
+ if utils.match_response(http_res, "4XX", "*"):
606
+ http_res_text = await utils.stream_to_text_async(http_res)
607
+ raise errors.APIError("API error occurred", http_res, http_res_text)
608
+ if utils.match_response(http_res, "5XX", "*"):
609
+ http_res_text = await utils.stream_to_text_async(http_res)
610
+ raise errors.APIError("API error occurred", http_res, http_res_text)
611
+
612
+ raise errors.APIError("Unexpected response received", http_res)
613
+
614
+ def earn_pendle_markets(
615
+ self,
616
+ *,
617
+ order_by: str,
618
+ direction: Optional[models.V2EarnPendleMarketsDirection] = None,
619
+ offset: Optional[int] = None,
620
+ limit: Optional[int] = None,
621
+ chain: OptionalNullable[models.Chain] = UNSET,
622
+ underlying_symbol: OptionalNullable[str] = UNSET,
623
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
624
+ server_url: Optional[str] = None,
625
+ timeout_ms: Optional[int] = None,
626
+ http_headers: Optional[Mapping[str, str]] = None,
627
+ ) -> models.PendleMarketsResponse:
628
+ r"""List pendle markets
629
+
630
+ List Pendle yield trading markets with TVL and implied APY.
631
+
632
+ Returns Pendle market data including Principal Token (PT), Standardized Yield (SY),
633
+ and Yield Token (YT) addresses, along with market expiry, TVL, and implied APY.
634
+
635
+ Use this endpoint to discover yield trading opportunities, compare rates across
636
+ Pendle markets, or build market selection interfaces.
637
+
638
+ APY values are returned in percentage format (e.g., 5.25 means 5.25%). Markets
639
+ without complete metadata or statistics are excluded.
640
+
641
+ :param order_by: The field to order the results by.
642
+ :param direction: The direction to order the results by.
643
+ :param offset: The offset of the first item to return.
644
+ :param limit: The number of items to return.
645
+ :param chain: Optional chain filter. If not provided, returns markets for all chains.
646
+ :param underlying_symbol: Filter markets by underlying asset symbol (e.g., 'USDC', 'WETH').
647
+ :param retries: Override the default retry configuration for this method
648
+ :param server_url: Override the default server URL for this method
649
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
650
+ :param http_headers: Additional headers to set or replace on requests.
651
+ """
652
+ base_url = None
653
+ url_variables = None
654
+ if timeout_ms is None:
655
+ timeout_ms = self.sdk_configuration.timeout_ms
656
+
657
+ if server_url is not None:
658
+ base_url = server_url
659
+ else:
660
+ base_url = self._get_url(base_url, url_variables)
661
+
662
+ request = models.V2EarnPendleMarketsRequest(
663
+ order_by=order_by,
664
+ direction=direction,
665
+ offset=offset,
666
+ limit=limit,
667
+ chain=chain,
668
+ underlying_symbol=underlying_symbol,
669
+ )
670
+
671
+ req = self._build_request(
672
+ method="GET",
673
+ path="/v2/earn/pendle_markets",
674
+ base_url=base_url,
675
+ url_variables=url_variables,
676
+ request=request,
677
+ request_body_required=False,
678
+ request_has_path_params=False,
679
+ request_has_query_params=True,
680
+ user_agent_header="user-agent",
681
+ accept_header_value="application/json",
682
+ http_headers=http_headers,
683
+ security=self.sdk_configuration.security,
684
+ allow_empty_value=None,
685
+ timeout_ms=timeout_ms,
686
+ )
687
+
688
+ if retries == UNSET:
689
+ if self.sdk_configuration.retry_config is not UNSET:
690
+ retries = self.sdk_configuration.retry_config
691
+
692
+ retry_config = None
693
+ if isinstance(retries, utils.RetryConfig):
694
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
695
+
696
+ http_res = self.do_request(
697
+ hook_ctx=HookContext(
698
+ config=self.sdk_configuration,
699
+ base_url=base_url or "",
700
+ operation_id="v2_earn_pendle_markets",
701
+ oauth2_scopes=None,
702
+ security_source=self.sdk_configuration.security,
703
+ ),
704
+ request=req,
705
+ error_status_codes=["422", "4XX", "5XX"],
706
+ retry_config=retry_config,
707
+ )
708
+
709
+ response_data: Any = None
710
+ if utils.match_response(http_res, "200", "application/json"):
711
+ return unmarshal_json_response(models.PendleMarketsResponse, http_res)
712
+ if utils.match_response(http_res, "422", "application/json"):
713
+ response_data = unmarshal_json_response(
714
+ errors.HTTPValidationErrorData, http_res
715
+ )
716
+ raise errors.HTTPValidationError(response_data, http_res)
717
+ if utils.match_response(http_res, "4XX", "*"):
718
+ http_res_text = utils.stream_to_text(http_res)
719
+ raise errors.APIError("API error occurred", http_res, http_res_text)
720
+ if utils.match_response(http_res, "5XX", "*"):
721
+ http_res_text = utils.stream_to_text(http_res)
722
+ raise errors.APIError("API error occurred", http_res, http_res_text)
723
+
724
+ raise errors.APIError("Unexpected response received", http_res)
725
+
726
+ async def earn_pendle_markets_async(
727
+ self,
728
+ *,
729
+ order_by: str,
730
+ direction: Optional[models.V2EarnPendleMarketsDirection] = None,
731
+ offset: Optional[int] = None,
732
+ limit: Optional[int] = None,
733
+ chain: OptionalNullable[models.Chain] = UNSET,
734
+ underlying_symbol: OptionalNullable[str] = UNSET,
735
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
736
+ server_url: Optional[str] = None,
737
+ timeout_ms: Optional[int] = None,
738
+ http_headers: Optional[Mapping[str, str]] = None,
739
+ ) -> models.PendleMarketsResponse:
740
+ r"""List pendle markets
741
+
742
+ List Pendle yield trading markets with TVL and implied APY.
743
+
744
+ Returns Pendle market data including Principal Token (PT), Standardized Yield (SY),
745
+ and Yield Token (YT) addresses, along with market expiry, TVL, and implied APY.
746
+
747
+ Use this endpoint to discover yield trading opportunities, compare rates across
748
+ Pendle markets, or build market selection interfaces.
749
+
750
+ APY values are returned in percentage format (e.g., 5.25 means 5.25%). Markets
751
+ without complete metadata or statistics are excluded.
752
+
753
+ :param order_by: The field to order the results by.
754
+ :param direction: The direction to order the results by.
755
+ :param offset: The offset of the first item to return.
756
+ :param limit: The number of items to return.
757
+ :param chain: Optional chain filter. If not provided, returns markets for all chains.
758
+ :param underlying_symbol: Filter markets by underlying asset symbol (e.g., 'USDC', 'WETH').
759
+ :param retries: Override the default retry configuration for this method
760
+ :param server_url: Override the default server URL for this method
761
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
762
+ :param http_headers: Additional headers to set or replace on requests.
763
+ """
764
+ base_url = None
765
+ url_variables = None
766
+ if timeout_ms is None:
767
+ timeout_ms = self.sdk_configuration.timeout_ms
768
+
769
+ if server_url is not None:
770
+ base_url = server_url
771
+ else:
772
+ base_url = self._get_url(base_url, url_variables)
773
+
774
+ request = models.V2EarnPendleMarketsRequest(
775
+ order_by=order_by,
776
+ direction=direction,
777
+ offset=offset,
778
+ limit=limit,
779
+ chain=chain,
780
+ underlying_symbol=underlying_symbol,
781
+ )
782
+
783
+ req = self._build_request_async(
784
+ method="GET",
785
+ path="/v2/earn/pendle_markets",
786
+ base_url=base_url,
787
+ url_variables=url_variables,
788
+ request=request,
789
+ request_body_required=False,
790
+ request_has_path_params=False,
791
+ request_has_query_params=True,
792
+ user_agent_header="user-agent",
793
+ accept_header_value="application/json",
794
+ http_headers=http_headers,
795
+ security=self.sdk_configuration.security,
796
+ allow_empty_value=None,
797
+ timeout_ms=timeout_ms,
798
+ )
799
+
800
+ if retries == UNSET:
801
+ if self.sdk_configuration.retry_config is not UNSET:
802
+ retries = self.sdk_configuration.retry_config
803
+
804
+ retry_config = None
805
+ if isinstance(retries, utils.RetryConfig):
806
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
807
+
808
+ http_res = await self.do_request_async(
809
+ hook_ctx=HookContext(
810
+ config=self.sdk_configuration,
811
+ base_url=base_url or "",
812
+ operation_id="v2_earn_pendle_markets",
813
+ oauth2_scopes=None,
814
+ security_source=self.sdk_configuration.security,
815
+ ),
816
+ request=req,
817
+ error_status_codes=["422", "4XX", "5XX"],
818
+ retry_config=retry_config,
819
+ )
820
+
821
+ response_data: Any = None
822
+ if utils.match_response(http_res, "200", "application/json"):
823
+ return unmarshal_json_response(models.PendleMarketsResponse, http_res)
824
+ if utils.match_response(http_res, "422", "application/json"):
825
+ response_data = unmarshal_json_response(
826
+ errors.HTTPValidationErrorData, http_res
827
+ )
828
+ raise errors.HTTPValidationError(response_data, http_res)
829
+ if utils.match_response(http_res, "4XX", "*"):
830
+ http_res_text = await utils.stream_to_text_async(http_res)
831
+ raise errors.APIError("API error occurred", http_res, http_res_text)
832
+ if utils.match_response(http_res, "5XX", "*"):
833
+ http_res_text = await utils.stream_to_text_async(http_res)
834
+ raise errors.APIError("API error occurred", http_res, http_res_text)
835
+
836
+ raise errors.APIError("Unexpected response received", http_res)
837
+
838
+ def earn_create_account(
839
+ self,
840
+ *,
841
+ chain: models.CreateAccountRequestChain,
842
+ sender: str,
843
+ owner: str,
844
+ estimate_gas: Optional[bool] = None,
845
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
846
+ server_url: Optional[str] = None,
847
+ timeout_ms: Optional[int] = None,
848
+ http_headers: Optional[Mapping[str, str]] = None,
849
+ ) -> models.CreateAccountResponse:
850
+ r"""Create earn account
851
+
852
+ Create an Earn Account for a wallet address.
853
+
854
+ Before depositing into venues or managing positions, the owner must create an Earn Account. Each wallet address has one Earn Account per chain.
855
+
856
+ Returns an unsigned transaction to create the account. The `sender` signs and broadcasts this transaction.
857
+
858
+ **If owner pays gas:** Set `sender` to the owner's address.
859
+
860
+ **If someone else pays gas:** Set `sender` to the wallet that will sign and broadcast the transaction on behalf of the owner.
861
+
862
+ :param chain:
863
+ :param sender: The address of the transaction sender.
864
+ :param owner: The address that will own and control the compass account
865
+ :param estimate_gas: Determines whether to estimate gas costs for transactions, also verifying that the transaction can be successfully executed.
866
+ :param retries: Override the default retry configuration for this method
867
+ :param server_url: Override the default server URL for this method
868
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
869
+ :param http_headers: Additional headers to set or replace on requests.
870
+ """
871
+ base_url = None
872
+ url_variables = None
873
+ if timeout_ms is None:
874
+ timeout_ms = self.sdk_configuration.timeout_ms
875
+
876
+ if server_url is not None:
877
+ base_url = server_url
878
+ else:
879
+ base_url = self._get_url(base_url, url_variables)
880
+
881
+ request = models.CreateAccountRequest(
882
+ chain=chain,
883
+ sender=sender,
884
+ estimate_gas=estimate_gas,
885
+ owner=owner,
886
+ )
887
+
888
+ req = self._build_request(
889
+ method="POST",
890
+ path="/v2/earn/create_account",
891
+ base_url=base_url,
892
+ url_variables=url_variables,
893
+ request=request,
894
+ request_body_required=True,
895
+ request_has_path_params=False,
896
+ request_has_query_params=True,
897
+ user_agent_header="user-agent",
898
+ accept_header_value="application/json",
899
+ http_headers=http_headers,
900
+ security=self.sdk_configuration.security,
901
+ get_serialized_body=lambda: utils.serialize_request_body(
902
+ request, False, False, "json", models.CreateAccountRequest
903
+ ),
904
+ allow_empty_value=None,
905
+ timeout_ms=timeout_ms,
906
+ )
907
+
908
+ if retries == UNSET:
909
+ if self.sdk_configuration.retry_config is not UNSET:
910
+ retries = self.sdk_configuration.retry_config
911
+
912
+ retry_config = None
913
+ if isinstance(retries, utils.RetryConfig):
914
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
915
+
916
+ http_res = self.do_request(
917
+ hook_ctx=HookContext(
918
+ config=self.sdk_configuration,
919
+ base_url=base_url or "",
920
+ operation_id="v2_earn_create_account",
921
+ oauth2_scopes=None,
922
+ security_source=self.sdk_configuration.security,
923
+ ),
924
+ request=req,
925
+ error_status_codes=["422", "4XX", "5XX"],
926
+ retry_config=retry_config,
927
+ )
928
+
929
+ response_data: Any = None
930
+ if utils.match_response(http_res, "200", "application/json"):
931
+ return unmarshal_json_response(models.CreateAccountResponse, http_res)
932
+ if utils.match_response(http_res, "422", "application/json"):
933
+ response_data = unmarshal_json_response(
934
+ errors.HTTPValidationErrorData, http_res
935
+ )
936
+ raise errors.HTTPValidationError(response_data, http_res)
937
+ if utils.match_response(http_res, "4XX", "*"):
938
+ http_res_text = utils.stream_to_text(http_res)
939
+ raise errors.APIError("API error occurred", http_res, http_res_text)
940
+ if utils.match_response(http_res, "5XX", "*"):
941
+ http_res_text = utils.stream_to_text(http_res)
942
+ raise errors.APIError("API error occurred", http_res, http_res_text)
943
+
944
+ raise errors.APIError("Unexpected response received", http_res)
945
+
946
+ async def earn_create_account_async(
947
+ self,
948
+ *,
949
+ chain: models.CreateAccountRequestChain,
950
+ sender: str,
951
+ owner: str,
952
+ estimate_gas: Optional[bool] = None,
953
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
954
+ server_url: Optional[str] = None,
955
+ timeout_ms: Optional[int] = None,
956
+ http_headers: Optional[Mapping[str, str]] = None,
957
+ ) -> models.CreateAccountResponse:
958
+ r"""Create earn account
959
+
960
+ Create an Earn Account for a wallet address.
961
+
962
+ Before depositing into venues or managing positions, the owner must create an Earn Account. Each wallet address has one Earn Account per chain.
963
+
964
+ Returns an unsigned transaction to create the account. The `sender` signs and broadcasts this transaction.
965
+
966
+ **If owner pays gas:** Set `sender` to the owner's address.
967
+
968
+ **If someone else pays gas:** Set `sender` to the wallet that will sign and broadcast the transaction on behalf of the owner.
969
+
970
+ :param chain:
971
+ :param sender: The address of the transaction sender.
972
+ :param owner: The address that will own and control the compass account
973
+ :param estimate_gas: Determines whether to estimate gas costs for transactions, also verifying that the transaction can be successfully executed.
974
+ :param retries: Override the default retry configuration for this method
975
+ :param server_url: Override the default server URL for this method
976
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
977
+ :param http_headers: Additional headers to set or replace on requests.
978
+ """
979
+ base_url = None
980
+ url_variables = None
981
+ if timeout_ms is None:
982
+ timeout_ms = self.sdk_configuration.timeout_ms
983
+
984
+ if server_url is not None:
985
+ base_url = server_url
986
+ else:
987
+ base_url = self._get_url(base_url, url_variables)
988
+
989
+ request = models.CreateAccountRequest(
990
+ chain=chain,
991
+ sender=sender,
992
+ estimate_gas=estimate_gas,
993
+ owner=owner,
994
+ )
995
+
996
+ req = self._build_request_async(
997
+ method="POST",
998
+ path="/v2/earn/create_account",
999
+ base_url=base_url,
1000
+ url_variables=url_variables,
1001
+ request=request,
1002
+ request_body_required=True,
1003
+ request_has_path_params=False,
1004
+ request_has_query_params=True,
1005
+ user_agent_header="user-agent",
1006
+ accept_header_value="application/json",
1007
+ http_headers=http_headers,
1008
+ security=self.sdk_configuration.security,
1009
+ get_serialized_body=lambda: utils.serialize_request_body(
1010
+ request, False, False, "json", models.CreateAccountRequest
1011
+ ),
1012
+ allow_empty_value=None,
1013
+ timeout_ms=timeout_ms,
1014
+ )
1015
+
1016
+ if retries == UNSET:
1017
+ if self.sdk_configuration.retry_config is not UNSET:
1018
+ retries = self.sdk_configuration.retry_config
1019
+
1020
+ retry_config = None
1021
+ if isinstance(retries, utils.RetryConfig):
1022
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1023
+
1024
+ http_res = await self.do_request_async(
1025
+ hook_ctx=HookContext(
1026
+ config=self.sdk_configuration,
1027
+ base_url=base_url or "",
1028
+ operation_id="v2_earn_create_account",
1029
+ oauth2_scopes=None,
1030
+ security_source=self.sdk_configuration.security,
1031
+ ),
1032
+ request=req,
1033
+ error_status_codes=["422", "4XX", "5XX"],
1034
+ retry_config=retry_config,
1035
+ )
1036
+
1037
+ response_data: Any = None
1038
+ if utils.match_response(http_res, "200", "application/json"):
1039
+ return unmarshal_json_response(models.CreateAccountResponse, http_res)
1040
+ if utils.match_response(http_res, "422", "application/json"):
1041
+ response_data = unmarshal_json_response(
1042
+ errors.HTTPValidationErrorData, http_res
1043
+ )
1044
+ raise errors.HTTPValidationError(response_data, http_res)
1045
+ if utils.match_response(http_res, "4XX", "*"):
1046
+ http_res_text = await utils.stream_to_text_async(http_res)
1047
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1048
+ if utils.match_response(http_res, "5XX", "*"):
1049
+ http_res_text = await utils.stream_to_text_async(http_res)
1050
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1051
+
1052
+ raise errors.APIError("Unexpected response received", http_res)
1053
+
1054
+ def earn_transfer(
1055
+ self,
1056
+ *,
1057
+ owner: str,
1058
+ chain: models.Chain,
1059
+ token: str,
1060
+ amount: Union[
1061
+ models.EarnTransferRequestAmount, models.EarnTransferRequestAmountTypedDict
1062
+ ],
1063
+ action: models.EarnTransferRequestAction,
1064
+ gas_sponsorship: Optional[bool] = None,
1065
+ spender: OptionalNullable[str] = UNSET,
1066
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
1067
+ server_url: Optional[str] = None,
1068
+ timeout_ms: Optional[int] = None,
1069
+ http_headers: Optional[Mapping[str, str]] = None,
1070
+ ) -> models.EarnTransferResponse:
1071
+ r"""Transfer tokens to/from account
1072
+
1073
+ Transfer tokens between an owner's wallet and their Earn Account.
1074
+
1075
+ Use `DEPOSIT` to move tokens from the owner's wallet into their Earn Account. Use `WITHDRAW` to move tokens from the Earn Account back to the owner's wallet.
1076
+
1077
+ **Gas-sponsored deposits** require two steps:
1078
+
1079
+ **Step 1 (once per token):** Set up Permit2 allowance
1080
+ 1. Call [/gas_sponsorship/approve_transfer](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/approve-token-transfer) to get EIP-712 typed data
1081
+ 2. Owner signs the typed data
1082
+ 3. Submit signature + typed data to [/gas_sponsorship/prepare](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/prepare-gas-sponsored-transaction)
1083
+
1084
+ **Step 2 (each transfer):** Execute the gas-sponsored transfer
1085
+ 1. Call this endpoint with `gas_sponsorship=true` to get EIP-712 typed data
1086
+ 2. Owner signs the typed data
1087
+ 3. Submit signature + typed data to [/gas_sponsorship/prepare](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/prepare-gas-sponsored-transaction)
1088
+
1089
+ **Note:** This endpoint moves tokens to/from the Earn Account itself—not into yield venues. To deposit into a vault or Aave market, use the [manage endpoint](https://docs.compasslabs.ai/v2/api-reference/earn/manage-earn-position).
1090
+
1091
+ :param owner: The owner's wallet address.
1092
+ :param chain: The chain to use.
1093
+ :param token: The token you would like to transfer.
1094
+ :param amount: The amount of 'token' to transfer.
1095
+ :param action: Whether you are depositing to or withdrawing from your earn account.
1096
+ :param gas_sponsorship: Optionally request gas sponsorship. If set to `true`, EIP-712 signature data will be returned that must be signed by the `owner` and submitted to the `/gas_sponsorship/prepare` endpoint.
1097
+ :param spender: The address of the wallet which will send the transaction. This only needs to be set when `action` is 'DEPOSIT' and `gas_sponsorship` is `true`.
1098
+ :param retries: Override the default retry configuration for this method
1099
+ :param server_url: Override the default server URL for this method
1100
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1101
+ :param http_headers: Additional headers to set or replace on requests.
1102
+ """
1103
+ base_url = None
1104
+ url_variables = None
1105
+ if timeout_ms is None:
1106
+ timeout_ms = self.sdk_configuration.timeout_ms
1107
+
1108
+ if server_url is not None:
1109
+ base_url = server_url
1110
+ else:
1111
+ base_url = self._get_url(base_url, url_variables)
1112
+
1113
+ request = models.EarnTransferRequest(
1114
+ owner=owner,
1115
+ chain=chain,
1116
+ token=token,
1117
+ amount=amount,
1118
+ action=action,
1119
+ gas_sponsorship=gas_sponsorship,
1120
+ spender=spender,
1121
+ )
1122
+
1123
+ req = self._build_request(
1124
+ method="POST",
1125
+ path="/v2/earn/transfer",
1126
+ base_url=base_url,
1127
+ url_variables=url_variables,
1128
+ request=request,
1129
+ request_body_required=True,
1130
+ request_has_path_params=False,
1131
+ request_has_query_params=True,
1132
+ user_agent_header="user-agent",
1133
+ accept_header_value="application/json",
1134
+ http_headers=http_headers,
1135
+ security=self.sdk_configuration.security,
1136
+ get_serialized_body=lambda: utils.serialize_request_body(
1137
+ request, False, False, "json", models.EarnTransferRequest
1138
+ ),
1139
+ allow_empty_value=None,
1140
+ timeout_ms=timeout_ms,
1141
+ )
1142
+
1143
+ if retries == UNSET:
1144
+ if self.sdk_configuration.retry_config is not UNSET:
1145
+ retries = self.sdk_configuration.retry_config
1146
+
1147
+ retry_config = None
1148
+ if isinstance(retries, utils.RetryConfig):
1149
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1150
+
1151
+ http_res = self.do_request(
1152
+ hook_ctx=HookContext(
1153
+ config=self.sdk_configuration,
1154
+ base_url=base_url or "",
1155
+ operation_id="v2_earn_transfer",
1156
+ oauth2_scopes=None,
1157
+ security_source=self.sdk_configuration.security,
1158
+ ),
1159
+ request=req,
1160
+ error_status_codes=["422", "4XX", "5XX"],
1161
+ retry_config=retry_config,
1162
+ )
1163
+
1164
+ response_data: Any = None
1165
+ if utils.match_response(http_res, "200", "application/json"):
1166
+ return unmarshal_json_response(models.EarnTransferResponse, http_res)
1167
+ if utils.match_response(http_res, "422", "application/json"):
1168
+ response_data = unmarshal_json_response(
1169
+ errors.HTTPValidationErrorData, http_res
1170
+ )
1171
+ raise errors.HTTPValidationError(response_data, http_res)
1172
+ if utils.match_response(http_res, "4XX", "*"):
1173
+ http_res_text = utils.stream_to_text(http_res)
1174
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1175
+ if utils.match_response(http_res, "5XX", "*"):
1176
+ http_res_text = utils.stream_to_text(http_res)
1177
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1178
+
1179
+ raise errors.APIError("Unexpected response received", http_res)
1180
+
1181
+ async def earn_transfer_async(
1182
+ self,
1183
+ *,
1184
+ owner: str,
1185
+ chain: models.Chain,
1186
+ token: str,
1187
+ amount: Union[
1188
+ models.EarnTransferRequestAmount, models.EarnTransferRequestAmountTypedDict
1189
+ ],
1190
+ action: models.EarnTransferRequestAction,
1191
+ gas_sponsorship: Optional[bool] = None,
1192
+ spender: OptionalNullable[str] = UNSET,
1193
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
1194
+ server_url: Optional[str] = None,
1195
+ timeout_ms: Optional[int] = None,
1196
+ http_headers: Optional[Mapping[str, str]] = None,
1197
+ ) -> models.EarnTransferResponse:
1198
+ r"""Transfer tokens to/from account
1199
+
1200
+ Transfer tokens between an owner's wallet and their Earn Account.
1201
+
1202
+ Use `DEPOSIT` to move tokens from the owner's wallet into their Earn Account. Use `WITHDRAW` to move tokens from the Earn Account back to the owner's wallet.
1203
+
1204
+ **Gas-sponsored deposits** require two steps:
1205
+
1206
+ **Step 1 (once per token):** Set up Permit2 allowance
1207
+ 1. Call [/gas_sponsorship/approve_transfer](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/approve-token-transfer) to get EIP-712 typed data
1208
+ 2. Owner signs the typed data
1209
+ 3. Submit signature + typed data to [/gas_sponsorship/prepare](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/prepare-gas-sponsored-transaction)
1210
+
1211
+ **Step 2 (each transfer):** Execute the gas-sponsored transfer
1212
+ 1. Call this endpoint with `gas_sponsorship=true` to get EIP-712 typed data
1213
+ 2. Owner signs the typed data
1214
+ 3. Submit signature + typed data to [/gas_sponsorship/prepare](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/prepare-gas-sponsored-transaction)
1215
+
1216
+ **Note:** This endpoint moves tokens to/from the Earn Account itself—not into yield venues. To deposit into a vault or Aave market, use the [manage endpoint](https://docs.compasslabs.ai/v2/api-reference/earn/manage-earn-position).
1217
+
1218
+ :param owner: The owner's wallet address.
1219
+ :param chain: The chain to use.
1220
+ :param token: The token you would like to transfer.
1221
+ :param amount: The amount of 'token' to transfer.
1222
+ :param action: Whether you are depositing to or withdrawing from your earn account.
1223
+ :param gas_sponsorship: Optionally request gas sponsorship. If set to `true`, EIP-712 signature data will be returned that must be signed by the `owner` and submitted to the `/gas_sponsorship/prepare` endpoint.
1224
+ :param spender: The address of the wallet which will send the transaction. This only needs to be set when `action` is 'DEPOSIT' and `gas_sponsorship` is `true`.
1225
+ :param retries: Override the default retry configuration for this method
1226
+ :param server_url: Override the default server URL for this method
1227
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1228
+ :param http_headers: Additional headers to set or replace on requests.
1229
+ """
1230
+ base_url = None
1231
+ url_variables = None
1232
+ if timeout_ms is None:
1233
+ timeout_ms = self.sdk_configuration.timeout_ms
1234
+
1235
+ if server_url is not None:
1236
+ base_url = server_url
1237
+ else:
1238
+ base_url = self._get_url(base_url, url_variables)
1239
+
1240
+ request = models.EarnTransferRequest(
1241
+ owner=owner,
1242
+ chain=chain,
1243
+ token=token,
1244
+ amount=amount,
1245
+ action=action,
1246
+ gas_sponsorship=gas_sponsorship,
1247
+ spender=spender,
1248
+ )
1249
+
1250
+ req = self._build_request_async(
1251
+ method="POST",
1252
+ path="/v2/earn/transfer",
1253
+ base_url=base_url,
1254
+ url_variables=url_variables,
1255
+ request=request,
1256
+ request_body_required=True,
1257
+ request_has_path_params=False,
1258
+ request_has_query_params=True,
1259
+ user_agent_header="user-agent",
1260
+ accept_header_value="application/json",
1261
+ http_headers=http_headers,
1262
+ security=self.sdk_configuration.security,
1263
+ get_serialized_body=lambda: utils.serialize_request_body(
1264
+ request, False, False, "json", models.EarnTransferRequest
1265
+ ),
1266
+ allow_empty_value=None,
1267
+ timeout_ms=timeout_ms,
1268
+ )
1269
+
1270
+ if retries == UNSET:
1271
+ if self.sdk_configuration.retry_config is not UNSET:
1272
+ retries = self.sdk_configuration.retry_config
1273
+
1274
+ retry_config = None
1275
+ if isinstance(retries, utils.RetryConfig):
1276
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1277
+
1278
+ http_res = await self.do_request_async(
1279
+ hook_ctx=HookContext(
1280
+ config=self.sdk_configuration,
1281
+ base_url=base_url or "",
1282
+ operation_id="v2_earn_transfer",
1283
+ oauth2_scopes=None,
1284
+ security_source=self.sdk_configuration.security,
1285
+ ),
1286
+ request=req,
1287
+ error_status_codes=["422", "4XX", "5XX"],
1288
+ retry_config=retry_config,
1289
+ )
1290
+
1291
+ response_data: Any = None
1292
+ if utils.match_response(http_res, "200", "application/json"):
1293
+ return unmarshal_json_response(models.EarnTransferResponse, http_res)
1294
+ if utils.match_response(http_res, "422", "application/json"):
1295
+ response_data = unmarshal_json_response(
1296
+ errors.HTTPValidationErrorData, http_res
1297
+ )
1298
+ raise errors.HTTPValidationError(response_data, http_res)
1299
+ if utils.match_response(http_res, "4XX", "*"):
1300
+ http_res_text = await utils.stream_to_text_async(http_res)
1301
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1302
+ if utils.match_response(http_res, "5XX", "*"):
1303
+ http_res_text = await utils.stream_to_text_async(http_res)
1304
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1305
+
1306
+ raise errors.APIError("Unexpected response received", http_res)
1307
+
1308
+ def earn_manage(
1309
+ self,
1310
+ *,
1311
+ venue: Union[
1312
+ models.EarnManageRequestVenue, models.EarnManageRequestVenueTypedDict
1313
+ ],
1314
+ action: models.EarnManageRequestAction,
1315
+ amount: Any,
1316
+ owner: str,
1317
+ chain: models.Chain,
1318
+ gas_sponsorship: Optional[bool] = None,
1319
+ fee: OptionalNullable[Union[models.Fee, models.FeeTypedDict]] = UNSET,
1320
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
1321
+ server_url: Optional[str] = None,
1322
+ timeout_ms: Optional[int] = None,
1323
+ http_headers: Optional[Mapping[str, str]] = None,
1324
+ ) -> models.EarnManageResponse:
1325
+ r"""Manage earn position
1326
+
1327
+ Deposit into or withdraw from a yield venue.
1328
+
1329
+ Use `DEPOSIT` to move tokens from the Earn Account into a vault, Aave market, or Pendle PT position. Use `WITHDRAW` to move tokens back from a venue into the Earn Account.
1330
+
1331
+ **Venue types:**
1332
+ - `VAULT`: ERC-4626 vaults (see [/vaults](https://docs.compasslabs.ai/v2/api-reference/earn/list-vaults) for available options)
1333
+ - `AAVE`: Aave lending pools (see [/aave_markets](https://docs.compasslabs.ai/v2/api-reference/earn/list-aave-markets) for available options)
1334
+ - `PENDLE_PT`: Pendle Principal Tokens (see [/pendle_markets](https://docs.compasslabs.ai/v2/api-reference/earn/list-pendle-markets) for available options)
1335
+
1336
+ **Fees:** A fee can be configured and deducted from the transaction amount (not supported for PENDLE_PT):
1337
+ - `FIXED`: A fixed token amount (e.g., 0.1 means 0.1 tokens)
1338
+ - `PERCENTAGE`: A percentage of the amount (e.g., 1.5 means 1.5%)
1339
+ - `PERFORMANCE`: A percentage of realized profit (withdrawals only)
1340
+
1341
+ **Gas sponsorship:** Set `gas_sponsorship=true` to receive EIP-712 typed data. Owner signs the typed data, then submit to [/gas_sponsorship/prepare](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/prepare-gas-sponsored-transaction).
1342
+
1343
+ :param venue: The earn venue.
1344
+ :param action: Whether you are depositing into or withdrawing from the given Earn `venue`.
1345
+ :param amount: Amount of the underlying asset to act on (deposit or withdraw). For VAULT, this is the vault's underlying token; for AAVE, this is the Aave reserve asset; for PENDLE_PT, this is the amount of `token` to spend (DEPOSIT) or PT to sell (WITHDRAW). Provide as a decimal in token units (not wei); must be > 0.
1346
+ :param owner: The primary wallet address that owns and controls the Earn Account.
1347
+ :param chain: The chain to use.
1348
+ :param gas_sponsorship: Optionally request gas sponsorship. If set to `true`, EIP-712 typed data will be returned that must be signed by the `owner` and submitted to the 'Prepare gas-sponsored transaction' endpoint (`/gas_sponsorship/prepare`).
1349
+ :param fee: Optional fee configuration. If provided, a fee will be applied to the transaction amount and sent to the specified recipient address. The fee can be specified as a percentage of the transaction amount or as a fixed token amount.
1350
+ :param retries: Override the default retry configuration for this method
1351
+ :param server_url: Override the default server URL for this method
1352
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1353
+ :param http_headers: Additional headers to set or replace on requests.
1354
+ """
1355
+ base_url = None
1356
+ url_variables = None
1357
+ if timeout_ms is None:
1358
+ timeout_ms = self.sdk_configuration.timeout_ms
1359
+
1360
+ if server_url is not None:
1361
+ base_url = server_url
1362
+ else:
1363
+ base_url = self._get_url(base_url, url_variables)
1364
+
1365
+ request = models.EarnManageRequest(
1366
+ venue=utils.get_pydantic_model(venue, models.EarnManageRequestVenue),
1367
+ action=action,
1368
+ amount=amount,
1369
+ owner=owner,
1370
+ chain=chain,
1371
+ gas_sponsorship=gas_sponsorship,
1372
+ fee=utils.get_pydantic_model(fee, OptionalNullable[models.Fee]),
1373
+ )
1374
+
1375
+ req = self._build_request(
1376
+ method="POST",
1377
+ path="/v2/earn/manage",
1378
+ base_url=base_url,
1379
+ url_variables=url_variables,
1380
+ request=request,
1381
+ request_body_required=True,
1382
+ request_has_path_params=False,
1383
+ request_has_query_params=True,
1384
+ user_agent_header="user-agent",
1385
+ accept_header_value="application/json",
1386
+ http_headers=http_headers,
1387
+ security=self.sdk_configuration.security,
1388
+ get_serialized_body=lambda: utils.serialize_request_body(
1389
+ request, False, False, "json", models.EarnManageRequest
1390
+ ),
1391
+ allow_empty_value=None,
1392
+ timeout_ms=timeout_ms,
1393
+ )
1394
+
1395
+ if retries == UNSET:
1396
+ if self.sdk_configuration.retry_config is not UNSET:
1397
+ retries = self.sdk_configuration.retry_config
1398
+
1399
+ retry_config = None
1400
+ if isinstance(retries, utils.RetryConfig):
1401
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1402
+
1403
+ http_res = self.do_request(
1404
+ hook_ctx=HookContext(
1405
+ config=self.sdk_configuration,
1406
+ base_url=base_url or "",
1407
+ operation_id="v2_earn_manage",
1408
+ oauth2_scopes=None,
1409
+ security_source=self.sdk_configuration.security,
1410
+ ),
1411
+ request=req,
1412
+ error_status_codes=["422", "4XX", "5XX"],
1413
+ retry_config=retry_config,
1414
+ )
1415
+
1416
+ response_data: Any = None
1417
+ if utils.match_response(http_res, "200", "application/json"):
1418
+ return unmarshal_json_response(models.EarnManageResponse, http_res)
1419
+ if utils.match_response(http_res, "422", "application/json"):
1420
+ response_data = unmarshal_json_response(
1421
+ errors.HTTPValidationErrorData, http_res
1422
+ )
1423
+ raise errors.HTTPValidationError(response_data, http_res)
1424
+ if utils.match_response(http_res, "4XX", "*"):
1425
+ http_res_text = utils.stream_to_text(http_res)
1426
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1427
+ if utils.match_response(http_res, "5XX", "*"):
1428
+ http_res_text = utils.stream_to_text(http_res)
1429
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1430
+
1431
+ raise errors.APIError("Unexpected response received", http_res)
1432
+
1433
+ async def earn_manage_async(
1434
+ self,
1435
+ *,
1436
+ venue: Union[
1437
+ models.EarnManageRequestVenue, models.EarnManageRequestVenueTypedDict
1438
+ ],
1439
+ action: models.EarnManageRequestAction,
1440
+ amount: Any,
1441
+ owner: str,
1442
+ chain: models.Chain,
1443
+ gas_sponsorship: Optional[bool] = None,
1444
+ fee: OptionalNullable[Union[models.Fee, models.FeeTypedDict]] = UNSET,
1445
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
1446
+ server_url: Optional[str] = None,
1447
+ timeout_ms: Optional[int] = None,
1448
+ http_headers: Optional[Mapping[str, str]] = None,
1449
+ ) -> models.EarnManageResponse:
1450
+ r"""Manage earn position
1451
+
1452
+ Deposit into or withdraw from a yield venue.
1453
+
1454
+ Use `DEPOSIT` to move tokens from the Earn Account into a vault, Aave market, or Pendle PT position. Use `WITHDRAW` to move tokens back from a venue into the Earn Account.
1455
+
1456
+ **Venue types:**
1457
+ - `VAULT`: ERC-4626 vaults (see [/vaults](https://docs.compasslabs.ai/v2/api-reference/earn/list-vaults) for available options)
1458
+ - `AAVE`: Aave lending pools (see [/aave_markets](https://docs.compasslabs.ai/v2/api-reference/earn/list-aave-markets) for available options)
1459
+ - `PENDLE_PT`: Pendle Principal Tokens (see [/pendle_markets](https://docs.compasslabs.ai/v2/api-reference/earn/list-pendle-markets) for available options)
1460
+
1461
+ **Fees:** A fee can be configured and deducted from the transaction amount (not supported for PENDLE_PT):
1462
+ - `FIXED`: A fixed token amount (e.g., 0.1 means 0.1 tokens)
1463
+ - `PERCENTAGE`: A percentage of the amount (e.g., 1.5 means 1.5%)
1464
+ - `PERFORMANCE`: A percentage of realized profit (withdrawals only)
1465
+
1466
+ **Gas sponsorship:** Set `gas_sponsorship=true` to receive EIP-712 typed data. Owner signs the typed data, then submit to [/gas_sponsorship/prepare](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/prepare-gas-sponsored-transaction).
1467
+
1468
+ :param venue: The earn venue.
1469
+ :param action: Whether you are depositing into or withdrawing from the given Earn `venue`.
1470
+ :param amount: Amount of the underlying asset to act on (deposit or withdraw). For VAULT, this is the vault's underlying token; for AAVE, this is the Aave reserve asset; for PENDLE_PT, this is the amount of `token` to spend (DEPOSIT) or PT to sell (WITHDRAW). Provide as a decimal in token units (not wei); must be > 0.
1471
+ :param owner: The primary wallet address that owns and controls the Earn Account.
1472
+ :param chain: The chain to use.
1473
+ :param gas_sponsorship: Optionally request gas sponsorship. If set to `true`, EIP-712 typed data will be returned that must be signed by the `owner` and submitted to the 'Prepare gas-sponsored transaction' endpoint (`/gas_sponsorship/prepare`).
1474
+ :param fee: Optional fee configuration. If provided, a fee will be applied to the transaction amount and sent to the specified recipient address. The fee can be specified as a percentage of the transaction amount or as a fixed token amount.
1475
+ :param retries: Override the default retry configuration for this method
1476
+ :param server_url: Override the default server URL for this method
1477
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1478
+ :param http_headers: Additional headers to set or replace on requests.
1479
+ """
1480
+ base_url = None
1481
+ url_variables = None
1482
+ if timeout_ms is None:
1483
+ timeout_ms = self.sdk_configuration.timeout_ms
1484
+
1485
+ if server_url is not None:
1486
+ base_url = server_url
1487
+ else:
1488
+ base_url = self._get_url(base_url, url_variables)
1489
+
1490
+ request = models.EarnManageRequest(
1491
+ venue=utils.get_pydantic_model(venue, models.EarnManageRequestVenue),
1492
+ action=action,
1493
+ amount=amount,
1494
+ owner=owner,
1495
+ chain=chain,
1496
+ gas_sponsorship=gas_sponsorship,
1497
+ fee=utils.get_pydantic_model(fee, OptionalNullable[models.Fee]),
1498
+ )
1499
+
1500
+ req = self._build_request_async(
1501
+ method="POST",
1502
+ path="/v2/earn/manage",
1503
+ base_url=base_url,
1504
+ url_variables=url_variables,
1505
+ request=request,
1506
+ request_body_required=True,
1507
+ request_has_path_params=False,
1508
+ request_has_query_params=True,
1509
+ user_agent_header="user-agent",
1510
+ accept_header_value="application/json",
1511
+ http_headers=http_headers,
1512
+ security=self.sdk_configuration.security,
1513
+ get_serialized_body=lambda: utils.serialize_request_body(
1514
+ request, False, False, "json", models.EarnManageRequest
1515
+ ),
1516
+ allow_empty_value=None,
1517
+ timeout_ms=timeout_ms,
1518
+ )
1519
+
1520
+ if retries == UNSET:
1521
+ if self.sdk_configuration.retry_config is not UNSET:
1522
+ retries = self.sdk_configuration.retry_config
1523
+
1524
+ retry_config = None
1525
+ if isinstance(retries, utils.RetryConfig):
1526
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1527
+
1528
+ http_res = await self.do_request_async(
1529
+ hook_ctx=HookContext(
1530
+ config=self.sdk_configuration,
1531
+ base_url=base_url or "",
1532
+ operation_id="v2_earn_manage",
1533
+ oauth2_scopes=None,
1534
+ security_source=self.sdk_configuration.security,
1535
+ ),
1536
+ request=req,
1537
+ error_status_codes=["422", "4XX", "5XX"],
1538
+ retry_config=retry_config,
1539
+ )
1540
+
1541
+ response_data: Any = None
1542
+ if utils.match_response(http_res, "200", "application/json"):
1543
+ return unmarshal_json_response(models.EarnManageResponse, http_res)
1544
+ if utils.match_response(http_res, "422", "application/json"):
1545
+ response_data = unmarshal_json_response(
1546
+ errors.HTTPValidationErrorData, http_res
1547
+ )
1548
+ raise errors.HTTPValidationError(response_data, http_res)
1549
+ if utils.match_response(http_res, "4XX", "*"):
1550
+ http_res_text = await utils.stream_to_text_async(http_res)
1551
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1552
+ if utils.match_response(http_res, "5XX", "*"):
1553
+ http_res_text = await utils.stream_to_text_async(http_res)
1554
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1555
+
1556
+ raise errors.APIError("Unexpected response received", http_res)
1557
+
1558
+ def earn_swap(
1559
+ self,
1560
+ *,
1561
+ token_in: str,
1562
+ token_out: str,
1563
+ amount_in: Union[
1564
+ models.EarnSwapRequestAmountIn, models.EarnSwapRequestAmountInTypedDict
1565
+ ],
1566
+ owner: str,
1567
+ chain: models.Chain,
1568
+ slippage: Optional[
1569
+ Union[
1570
+ models.EarnSwapRequestSlippage, models.EarnSwapRequestSlippageTypedDict
1571
+ ]
1572
+ ] = None,
1573
+ gas_sponsorship: Optional[bool] = None,
1574
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
1575
+ server_url: Optional[str] = None,
1576
+ timeout_ms: Optional[int] = None,
1577
+ http_headers: Optional[Mapping[str, str]] = None,
1578
+ ) -> models.EarnSwapResponse:
1579
+ r"""Swap tokens within Earn Account
1580
+
1581
+ Swap tokens within an Earn Account.
1582
+
1583
+ Use this endpoint to exchange one token for another without transferring funds out of the Earn Account.
1584
+
1585
+ The swap executes atomically within the Earn Account and can be combined with other actions using the [bundle endpoint](https://docs.compasslabs.ai/v2/api-reference/earn/execute-multiple-earn-actions). For example, swap ETH to USDC, then deposit USDC into a vault—all in one transaction.
1586
+
1587
+ Returns either an unsigned transaction (when `gas_sponsorship=false`) or EIP-712 typed data for off-chain signing (when `gas_sponsorship=true`). For gas-sponsored swaps, submit the signed typed data to `/gas_sponsorship/prepare`.
1588
+
1589
+ :param token_in: Token to sell (input). Provide a token symbol from a limited set (e.g., 'USDC') or any token address.
1590
+ :param token_out: Token to buy (output). Provide a token symbol from a limited set (e.g., 'USDT') or any token address.
1591
+ :param amount_in: Human-readable amount of `token_in` to swap (token units, not wei).
1592
+ :param owner: The owner's wallet address.
1593
+ :param chain: The chain to use.
1594
+ :param slippage: Maximum slippage tolerance as a percentage (e.g., 0.5 = 0.5%).
1595
+ :param gas_sponsorship: Optionally request gas sponsorship. If `true`, EIP-712 typed data will be returned that must be signed by the `owner` and submitted to the 'Prepare gas-sponsored transaction' endpoint (`/gas_sponsorship/prepare`).
1596
+ :param retries: Override the default retry configuration for this method
1597
+ :param server_url: Override the default server URL for this method
1598
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1599
+ :param http_headers: Additional headers to set or replace on requests.
1600
+ """
1601
+ base_url = None
1602
+ url_variables = None
1603
+ if timeout_ms is None:
1604
+ timeout_ms = self.sdk_configuration.timeout_ms
1605
+
1606
+ if server_url is not None:
1607
+ base_url = server_url
1608
+ else:
1609
+ base_url = self._get_url(base_url, url_variables)
1610
+
1611
+ request = models.EarnSwapRequest(
1612
+ token_in=token_in,
1613
+ token_out=token_out,
1614
+ amount_in=amount_in,
1615
+ slippage=slippage,
1616
+ owner=owner,
1617
+ chain=chain,
1618
+ gas_sponsorship=gas_sponsorship,
1619
+ )
1620
+
1621
+ req = self._build_request(
1622
+ method="POST",
1623
+ path="/v2/earn/swap",
1624
+ base_url=base_url,
1625
+ url_variables=url_variables,
1626
+ request=request,
1627
+ request_body_required=True,
1628
+ request_has_path_params=False,
1629
+ request_has_query_params=True,
1630
+ user_agent_header="user-agent",
1631
+ accept_header_value="application/json",
1632
+ http_headers=http_headers,
1633
+ security=self.sdk_configuration.security,
1634
+ get_serialized_body=lambda: utils.serialize_request_body(
1635
+ request, False, False, "json", models.EarnSwapRequest
1636
+ ),
1637
+ allow_empty_value=None,
1638
+ timeout_ms=timeout_ms,
1639
+ )
1640
+
1641
+ if retries == UNSET:
1642
+ if self.sdk_configuration.retry_config is not UNSET:
1643
+ retries = self.sdk_configuration.retry_config
1644
+
1645
+ retry_config = None
1646
+ if isinstance(retries, utils.RetryConfig):
1647
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1648
+
1649
+ http_res = self.do_request(
1650
+ hook_ctx=HookContext(
1651
+ config=self.sdk_configuration,
1652
+ base_url=base_url or "",
1653
+ operation_id="v2_earn_swap",
1654
+ oauth2_scopes=None,
1655
+ security_source=self.sdk_configuration.security,
1656
+ ),
1657
+ request=req,
1658
+ error_status_codes=["422", "4XX", "5XX"],
1659
+ retry_config=retry_config,
1660
+ )
1661
+
1662
+ response_data: Any = None
1663
+ if utils.match_response(http_res, "200", "application/json"):
1664
+ return unmarshal_json_response(models.EarnSwapResponse, http_res)
1665
+ if utils.match_response(http_res, "422", "application/json"):
1666
+ response_data = unmarshal_json_response(
1667
+ errors.HTTPValidationErrorData, http_res
1668
+ )
1669
+ raise errors.HTTPValidationError(response_data, http_res)
1670
+ if utils.match_response(http_res, "4XX", "*"):
1671
+ http_res_text = utils.stream_to_text(http_res)
1672
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1673
+ if utils.match_response(http_res, "5XX", "*"):
1674
+ http_res_text = utils.stream_to_text(http_res)
1675
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1676
+
1677
+ raise errors.APIError("Unexpected response received", http_res)
1678
+
1679
+ async def earn_swap_async(
1680
+ self,
1681
+ *,
1682
+ token_in: str,
1683
+ token_out: str,
1684
+ amount_in: Union[
1685
+ models.EarnSwapRequestAmountIn, models.EarnSwapRequestAmountInTypedDict
1686
+ ],
1687
+ owner: str,
1688
+ chain: models.Chain,
1689
+ slippage: Optional[
1690
+ Union[
1691
+ models.EarnSwapRequestSlippage, models.EarnSwapRequestSlippageTypedDict
1692
+ ]
1693
+ ] = None,
1694
+ gas_sponsorship: Optional[bool] = None,
1695
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
1696
+ server_url: Optional[str] = None,
1697
+ timeout_ms: Optional[int] = None,
1698
+ http_headers: Optional[Mapping[str, str]] = None,
1699
+ ) -> models.EarnSwapResponse:
1700
+ r"""Swap tokens within Earn Account
1701
+
1702
+ Swap tokens within an Earn Account.
1703
+
1704
+ Use this endpoint to exchange one token for another without transferring funds out of the Earn Account.
1705
+
1706
+ The swap executes atomically within the Earn Account and can be combined with other actions using the [bundle endpoint](https://docs.compasslabs.ai/v2/api-reference/earn/execute-multiple-earn-actions). For example, swap ETH to USDC, then deposit USDC into a vault—all in one transaction.
1707
+
1708
+ Returns either an unsigned transaction (when `gas_sponsorship=false`) or EIP-712 typed data for off-chain signing (when `gas_sponsorship=true`). For gas-sponsored swaps, submit the signed typed data to `/gas_sponsorship/prepare`.
1709
+
1710
+ :param token_in: Token to sell (input). Provide a token symbol from a limited set (e.g., 'USDC') or any token address.
1711
+ :param token_out: Token to buy (output). Provide a token symbol from a limited set (e.g., 'USDT') or any token address.
1712
+ :param amount_in: Human-readable amount of `token_in` to swap (token units, not wei).
1713
+ :param owner: The owner's wallet address.
1714
+ :param chain: The chain to use.
1715
+ :param slippage: Maximum slippage tolerance as a percentage (e.g., 0.5 = 0.5%).
1716
+ :param gas_sponsorship: Optionally request gas sponsorship. If `true`, EIP-712 typed data will be returned that must be signed by the `owner` and submitted to the 'Prepare gas-sponsored transaction' endpoint (`/gas_sponsorship/prepare`).
1717
+ :param retries: Override the default retry configuration for this method
1718
+ :param server_url: Override the default server URL for this method
1719
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1720
+ :param http_headers: Additional headers to set or replace on requests.
1721
+ """
1722
+ base_url = None
1723
+ url_variables = None
1724
+ if timeout_ms is None:
1725
+ timeout_ms = self.sdk_configuration.timeout_ms
1726
+
1727
+ if server_url is not None:
1728
+ base_url = server_url
1729
+ else:
1730
+ base_url = self._get_url(base_url, url_variables)
1731
+
1732
+ request = models.EarnSwapRequest(
1733
+ token_in=token_in,
1734
+ token_out=token_out,
1735
+ amount_in=amount_in,
1736
+ slippage=slippage,
1737
+ owner=owner,
1738
+ chain=chain,
1739
+ gas_sponsorship=gas_sponsorship,
1740
+ )
1741
+
1742
+ req = self._build_request_async(
1743
+ method="POST",
1744
+ path="/v2/earn/swap",
1745
+ base_url=base_url,
1746
+ url_variables=url_variables,
1747
+ request=request,
1748
+ request_body_required=True,
1749
+ request_has_path_params=False,
1750
+ request_has_query_params=True,
1751
+ user_agent_header="user-agent",
1752
+ accept_header_value="application/json",
1753
+ http_headers=http_headers,
1754
+ security=self.sdk_configuration.security,
1755
+ get_serialized_body=lambda: utils.serialize_request_body(
1756
+ request, False, False, "json", models.EarnSwapRequest
1757
+ ),
1758
+ allow_empty_value=None,
1759
+ timeout_ms=timeout_ms,
1760
+ )
1761
+
1762
+ if retries == UNSET:
1763
+ if self.sdk_configuration.retry_config is not UNSET:
1764
+ retries = self.sdk_configuration.retry_config
1765
+
1766
+ retry_config = None
1767
+ if isinstance(retries, utils.RetryConfig):
1768
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1769
+
1770
+ http_res = await self.do_request_async(
1771
+ hook_ctx=HookContext(
1772
+ config=self.sdk_configuration,
1773
+ base_url=base_url or "",
1774
+ operation_id="v2_earn_swap",
1775
+ oauth2_scopes=None,
1776
+ security_source=self.sdk_configuration.security,
1777
+ ),
1778
+ request=req,
1779
+ error_status_codes=["422", "4XX", "5XX"],
1780
+ retry_config=retry_config,
1781
+ )
1782
+
1783
+ response_data: Any = None
1784
+ if utils.match_response(http_res, "200", "application/json"):
1785
+ return unmarshal_json_response(models.EarnSwapResponse, http_res)
1786
+ if utils.match_response(http_res, "422", "application/json"):
1787
+ response_data = unmarshal_json_response(
1788
+ errors.HTTPValidationErrorData, http_res
1789
+ )
1790
+ raise errors.HTTPValidationError(response_data, http_res)
1791
+ if utils.match_response(http_res, "4XX", "*"):
1792
+ http_res_text = await utils.stream_to_text_async(http_res)
1793
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1794
+ if utils.match_response(http_res, "5XX", "*"):
1795
+ http_res_text = await utils.stream_to_text_async(http_res)
1796
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1797
+
1798
+ raise errors.APIError("Unexpected response received", http_res)
1799
+
1800
+ def earn_bundle(
1801
+ self,
1802
+ *,
1803
+ owner: str,
1804
+ chain: models.Chain,
1805
+ actions: Union[
1806
+ List[models.V2UserOperation], List[models.V2UserOperationTypedDict]
1807
+ ],
1808
+ gas_sponsorship: Optional[bool] = None,
1809
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
1810
+ server_url: Optional[str] = None,
1811
+ timeout_ms: Optional[int] = None,
1812
+ http_headers: Optional[Mapping[str, str]] = None,
1813
+ ) -> models.V2BundleResponse:
1814
+ r"""Execute multiple earn actions
1815
+
1816
+ Combine multiple actions into a single atomic transaction.
1817
+
1818
+ Bundle swaps and venue deposits/withdrawals into one transaction executed through the Earn Account. This saves gas compared to executing actions separately and ensures all actions succeed or fail together.
1819
+
1820
+ **Example:** Swap AUSD to USDC, then deposit USDC into a vault - all in one transaction.
1821
+
1822
+ **Action types:**
1823
+ - `V2_SWAP`: Swap tokens within the Earn Account
1824
+ - `V2_MANAGE`: Deposit/withdraw to ERC-4626 vaults or Aave markets
1825
+
1826
+ Actions execute in the order provided.
1827
+
1828
+ **Gas sponsorship:** Set `gas_sponsorship=true` to receive EIP-712 typed data. Owner signs the typed data, then submit to [/gas_sponsorship/prepare](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/prepare-gas-sponsored-transaction).
1829
+
1830
+ :param owner: The owner's wallet address that controls the Earn Account.
1831
+ :param chain: The chain to use.
1832
+ :param actions: List of actions to bundle. Actions are executed in order.
1833
+ :param gas_sponsorship: If true, returns EIP-712 typed data for gas sponsorship. The owner must sign this data and submit to /gas_sponsorship/prepare.
1834
+ :param retries: Override the default retry configuration for this method
1835
+ :param server_url: Override the default server URL for this method
1836
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1837
+ :param http_headers: Additional headers to set or replace on requests.
1838
+ """
1839
+ base_url = None
1840
+ url_variables = None
1841
+ if timeout_ms is None:
1842
+ timeout_ms = self.sdk_configuration.timeout_ms
1843
+
1844
+ if server_url is not None:
1845
+ base_url = server_url
1846
+ else:
1847
+ base_url = self._get_url(base_url, url_variables)
1848
+
1849
+ request = models.V2BundleRequest(
1850
+ owner=owner,
1851
+ chain=chain,
1852
+ actions=utils.get_pydantic_model(actions, List[models.V2UserOperation]),
1853
+ gas_sponsorship=gas_sponsorship,
1854
+ )
1855
+
1856
+ req = self._build_request(
1857
+ method="POST",
1858
+ path="/v2/earn/bundle",
1859
+ base_url=base_url,
1860
+ url_variables=url_variables,
1861
+ request=request,
1862
+ request_body_required=True,
1863
+ request_has_path_params=False,
1864
+ request_has_query_params=True,
1865
+ user_agent_header="user-agent",
1866
+ accept_header_value="application/json",
1867
+ http_headers=http_headers,
1868
+ security=self.sdk_configuration.security,
1869
+ get_serialized_body=lambda: utils.serialize_request_body(
1870
+ request, False, False, "json", models.V2BundleRequest
1871
+ ),
1872
+ allow_empty_value=None,
1873
+ timeout_ms=timeout_ms,
1874
+ )
1875
+
1876
+ if retries == UNSET:
1877
+ if self.sdk_configuration.retry_config is not UNSET:
1878
+ retries = self.sdk_configuration.retry_config
1879
+
1880
+ retry_config = None
1881
+ if isinstance(retries, utils.RetryConfig):
1882
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1883
+
1884
+ http_res = self.do_request(
1885
+ hook_ctx=HookContext(
1886
+ config=self.sdk_configuration,
1887
+ base_url=base_url or "",
1888
+ operation_id="v2_earn_bundle",
1889
+ oauth2_scopes=None,
1890
+ security_source=self.sdk_configuration.security,
1891
+ ),
1892
+ request=req,
1893
+ error_status_codes=["422", "4XX", "5XX"],
1894
+ retry_config=retry_config,
1895
+ )
1896
+
1897
+ response_data: Any = None
1898
+ if utils.match_response(http_res, "200", "application/json"):
1899
+ return unmarshal_json_response(models.V2BundleResponse, http_res)
1900
+ if utils.match_response(http_res, "422", "application/json"):
1901
+ response_data = unmarshal_json_response(
1902
+ errors.HTTPValidationErrorData, http_res
1903
+ )
1904
+ raise errors.HTTPValidationError(response_data, http_res)
1905
+ if utils.match_response(http_res, "4XX", "*"):
1906
+ http_res_text = utils.stream_to_text(http_res)
1907
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1908
+ if utils.match_response(http_res, "5XX", "*"):
1909
+ http_res_text = utils.stream_to_text(http_res)
1910
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1911
+
1912
+ raise errors.APIError("Unexpected response received", http_res)
1913
+
1914
+ async def earn_bundle_async(
1915
+ self,
1916
+ *,
1917
+ owner: str,
1918
+ chain: models.Chain,
1919
+ actions: Union[
1920
+ List[models.V2UserOperation], List[models.V2UserOperationTypedDict]
1921
+ ],
1922
+ gas_sponsorship: Optional[bool] = None,
1923
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
1924
+ server_url: Optional[str] = None,
1925
+ timeout_ms: Optional[int] = None,
1926
+ http_headers: Optional[Mapping[str, str]] = None,
1927
+ ) -> models.V2BundleResponse:
1928
+ r"""Execute multiple earn actions
1929
+
1930
+ Combine multiple actions into a single atomic transaction.
1931
+
1932
+ Bundle swaps and venue deposits/withdrawals into one transaction executed through the Earn Account. This saves gas compared to executing actions separately and ensures all actions succeed or fail together.
1933
+
1934
+ **Example:** Swap AUSD to USDC, then deposit USDC into a vault - all in one transaction.
1935
+
1936
+ **Action types:**
1937
+ - `V2_SWAP`: Swap tokens within the Earn Account
1938
+ - `V2_MANAGE`: Deposit/withdraw to ERC-4626 vaults or Aave markets
1939
+
1940
+ Actions execute in the order provided.
1941
+
1942
+ **Gas sponsorship:** Set `gas_sponsorship=true` to receive EIP-712 typed data. Owner signs the typed data, then submit to [/gas_sponsorship/prepare](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/prepare-gas-sponsored-transaction).
1943
+
1944
+ :param owner: The owner's wallet address that controls the Earn Account.
1945
+ :param chain: The chain to use.
1946
+ :param actions: List of actions to bundle. Actions are executed in order.
1947
+ :param gas_sponsorship: If true, returns EIP-712 typed data for gas sponsorship. The owner must sign this data and submit to /gas_sponsorship/prepare.
1948
+ :param retries: Override the default retry configuration for this method
1949
+ :param server_url: Override the default server URL for this method
1950
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1951
+ :param http_headers: Additional headers to set or replace on requests.
1952
+ """
1953
+ base_url = None
1954
+ url_variables = None
1955
+ if timeout_ms is None:
1956
+ timeout_ms = self.sdk_configuration.timeout_ms
1957
+
1958
+ if server_url is not None:
1959
+ base_url = server_url
1960
+ else:
1961
+ base_url = self._get_url(base_url, url_variables)
1962
+
1963
+ request = models.V2BundleRequest(
1964
+ owner=owner,
1965
+ chain=chain,
1966
+ actions=utils.get_pydantic_model(actions, List[models.V2UserOperation]),
1967
+ gas_sponsorship=gas_sponsorship,
1968
+ )
1969
+
1970
+ req = self._build_request_async(
1971
+ method="POST",
1972
+ path="/v2/earn/bundle",
1973
+ base_url=base_url,
1974
+ url_variables=url_variables,
1975
+ request=request,
1976
+ request_body_required=True,
1977
+ request_has_path_params=False,
1978
+ request_has_query_params=True,
1979
+ user_agent_header="user-agent",
1980
+ accept_header_value="application/json",
1981
+ http_headers=http_headers,
1982
+ security=self.sdk_configuration.security,
1983
+ get_serialized_body=lambda: utils.serialize_request_body(
1984
+ request, False, False, "json", models.V2BundleRequest
1985
+ ),
1986
+ allow_empty_value=None,
1987
+ timeout_ms=timeout_ms,
1988
+ )
1989
+
1990
+ if retries == UNSET:
1991
+ if self.sdk_configuration.retry_config is not UNSET:
1992
+ retries = self.sdk_configuration.retry_config
1993
+
1994
+ retry_config = None
1995
+ if isinstance(retries, utils.RetryConfig):
1996
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1997
+
1998
+ http_res = await self.do_request_async(
1999
+ hook_ctx=HookContext(
2000
+ config=self.sdk_configuration,
2001
+ base_url=base_url or "",
2002
+ operation_id="v2_earn_bundle",
2003
+ oauth2_scopes=None,
2004
+ security_source=self.sdk_configuration.security,
2005
+ ),
2006
+ request=req,
2007
+ error_status_codes=["422", "4XX", "5XX"],
2008
+ retry_config=retry_config,
2009
+ )
2010
+
2011
+ response_data: Any = None
2012
+ if utils.match_response(http_res, "200", "application/json"):
2013
+ return unmarshal_json_response(models.V2BundleResponse, http_res)
2014
+ if utils.match_response(http_res, "422", "application/json"):
2015
+ response_data = unmarshal_json_response(
2016
+ errors.HTTPValidationErrorData, http_res
2017
+ )
2018
+ raise errors.HTTPValidationError(response_data, http_res)
2019
+ if utils.match_response(http_res, "4XX", "*"):
2020
+ http_res_text = await utils.stream_to_text_async(http_res)
2021
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2022
+ if utils.match_response(http_res, "5XX", "*"):
2023
+ http_res_text = await utils.stream_to_text_async(http_res)
2024
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2025
+
2026
+ raise errors.APIError("Unexpected response received", http_res)