I'm trying to benefit from the liquidity made available by liquidity pool when I trade, I'm not trying to participate in liquidity pools (I'm not trying to put my money in the pool).
On the xlm/USDC market, I see quite the spread before there is decent liquidity, so I assume the liquidity pool is not making orders as a maker, given it has $4.5M in its pool (am I correct to assume that?).
The doc is a bit unclear regarding how to take advantage of that liquidity. It mentions path payments, without much explanation about how they relate to liquidity pools. So I implemented path payment in my wallet anyway to see if that would do the trick, but it didn't : making a strict send path payment gives me the exact same average price than if I was filling the orderbook. Is there anything special I need to do to buy from liquidity pools?
For reference, here is the code I use:
package horizon
import (
"fmt"
"github.com/stellar/go/clients/horizonclient"
"github.com/stellar/go/keypair"
"github.com/stellar/go/network"
"github.com/stellar/go/txnbuild"
)
func PathPaymentStrictSend(sendAsset, destAsset txnbuild.Asset, sendAmount, minAmount, to, secretKey string, path []txnbuild.Asset) (err error) {
kp, err := keypair.Parse(secretKey)
if err != nil {
return
}
ar := horizonclient.AccountRequest{AccountID: kp.Address()}
sourceAccount, err := client().AccountDetail(ar)
if err != nil {
return
}
op := txnbuild.PathPaymentStrictSend{
SendAsset: sendAsset,
SendAmount: sendAmount,
Destination: to,
DestAsset: destAsset,
DestMin: minAmount,
Path: path,
}
params := txnbuild.TransactionParams{
SourceAccount: &sourceAccount,
Operations: []txnbuild.Operation{&op},
Timebounds: txnbuild.NewTimeout(30),
IncrementSequenceNum: true,
BaseFee: myBaseFee,
}
tx, err := txnbuild.NewTransaction(params)
if err != nil {
return
}
tx, err = tx.Sign(network.PublicNetworkPassphrase, kp.(*keypair.Full))
if err != nil {
return
}
if PROD {
_, err = client().SubmitTransaction(tx)
if err != nil {
printError(err)
return
}
} else {
fmt.Printf("Pretending to transfer %s %#v to %s as %#v\n", sendAmount, sendAsset, to, destAsset)
}
return
}