Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.starkfi.io/llms.txt

Use this file to discover all available pages before exploring further.

After a user performs a deposit operation, they can withdraw their invested funds at any time. Fees are only charged on the earnings generated, based on the time the user remains in the protocol.
POST /yield/withdraw
1

Building a withdraw operation

Request body example

ParameterTypeRequiredDescription
providerstringThe provider is the protocol where the user wants to withdraw their funds. (e.g. jupiter_lend)
assetstringThe asset symbol is chosen by the user.
walletstringUser’s wallet public address
amountstringThe amount the user wants to withdraw (e.g. 100.00)
chain_namestringThe chain is the network where the user wants to withdraw their funds.
2

Request example

curl --request POST \
  --url https://api.starkfi.io/order/create \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api_key>' \
  --data '{
  	"provider": "jupiter_lend",
    "asset": "USDC",
    "wallet": "FmTGYpzX27fDqaiytXUdFVaphC5o68G61Q3uhVM2d8bm",
    "amount": "0.01",
    "chain_name": "solana"
}'
3

Expected response

{
    "statusCode": 200,
    "success": true,
    "status": "withdraw_yield_strategy_ok",
    "message": "Yield strategy withdraw successfully",
    "data": {
      "position_id": "cmonlfpv0000301nmnizxwob4",
	  "fee_policy": {
	    "is_full_withdraw": true,
	    "has_tracked_profit": false,
	    "charged_fixed_no_profit_fee": true,
	    "charged_starkfi_fee_amount": 0.1,
	    "charged_whitelabel_fee_amount": 0.05
	  },
      "transaction": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAgS22bfvVtZOhr1Ao5ejkqU88w9QuW2nkrUyxjbPcRilgwcj71J70/rvu0J/yTO1674UGxqeljWsbxMzyBLGGTIhSHv8RXo/oDIxDUXee+zF0aH8JxoGfVZG/MkrkRIFKnYRAnp8rwC8ekxRjtwZYsqePDt4B29OZXjYjrMeikbGqxl9d/9fISvdail973OoWIuKzq/h/xTqHG5CFYaOosb3gIRE+8/cf8FyV6ejOFzFvFRe8v54cSEIbvrhfgwTQQYeXyzPK1sDIBzsh2kxDdkBYXtOfawRnLIelHWBYy3JvqgC5ZIwUW4+UWatmCd5Vc8UzUhP8EscD1FvC2CJQgA1veA4oganO3BaPj9y3TzLqfiwk9dDCxaIuRcmdJ+MiQSCv4el+RWy7kuZColtQumOW/ySBZLynRpY6hFkqzWzMMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEcn8RD5rZyCj3b2Rq49ZiVsmScRvvn3bU9qhBHACBPVR6mnvvwFsKRZEO8A58f97e1/yRiQ5ahJERwinC6lqslJomRsm5Gr9y9W+wdHAcnDKneVfnQTMTEQq+wdbs8IgIyXJY9OJInxuz0QKRSODYMLWhOZ2v8QhASOe9jb6fhZxvp6877brTo9ZfNqq8l0MbG75MLS9uDkfKYCA0UvXWEK/huRLkhelf0V6yk33/xLN6MW0KY4Ev8Cukm0xsGNHgbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCpgtJyjk/h0MsE3SufVrZlQCwvZ4LziCRh1dcUMqZxVrwBEBEAAgMPCwEGBQgMBwQJDREOChDyI8aJUuHythAnAAAAAAAA"
    }
}
When a user initiates a withdrawal operation, we determine whether they are withdrawing their full position or performing a partial withdrawal. We then calculate the profit generated in order to apply the fee charge. In the fee_policy field, you can view the applied policy and the fee amount charged for the operation.
4

Signing a operation transaction

When performing an operation, it is essential to never send it directly using sendTransaction or any external broadcast method.For the operation to succeed, it must only be signed and submitted through StarkFi’s internal broadcast system via our HTTP API.
import { Wallet } from "ethers";

const privateKey = "SUA_PRIVATE_KEY_AQUI";
const wallet = new Wallet(privateKey);

const tx = {
  from:                 "0x9b57847b69D0354837F7b723133B9dBCbefb4F9F",
  to:                   "0x23183C87c9c6668edf5974893905AF475c3664c9",
  data:                 "0x40180def000000000000000000000000fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb90000000000000000000000009b57847b69d0354837f7b723133b9dbcbefb4f9f000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000009b57847b69d0354837f7b723133b9dbcbefb4f9f0000000000000000000000001e659faad0181ab1a30891d99f69df115db77eef0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000e3220000000000000000000000000000000000000000000000000000000000000706",
  value:                0n,
  chainId:              42161,
  gasLimit:             82499n,
  maxPriorityFeePerGas: 0n,
  maxFeePerGas:         52514800n,
  nonce:                36,
  type:                 2,
};

const signedTx = await wallet.signTransaction(tx);
console.log("Transação assinada:", signedTx);
You can now submit your signed transaction using our broadcast endpoint.