addLiq.mjs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. export const addLiquidity = async (position, symbol, maxUsdValue) => {
  2. // https://discord.com/api/webhooks/1457714616636280978/YFMGaZEj2gJwUjINpFfJIkagG1I3SLZRwz9bGpc2OlGFWBVa88r73cMIkBpX3iGpSIjV discord 通知
  3. fetch('http://91.108.80.73/api/lp-copy', {
  4. method: 'POST',
  5. headers: {
  6. 'Content-Type': 'application/json',
  7. 'Authorization': 'Basic YWRtaW46YzU4ODk5Njc='
  8. },
  9. body: JSON.stringify({
  10. positionAddress: position.positionAddress,
  11. maxUsdValue: maxUsdValue || 1,
  12. }),
  13. })
  14. .then((res) => res.json())
  15. .then((data) => {
  16. if (data.success) {
  17. console.log('快速复制成功')
  18. // discord 通知
  19. fetch('https://discord.com/api/webhooks/1457714616636280978/YFMGaZEj2gJwUjINpFfJIkagG1I3SLZRwz9bGpc2OlGFWBVa88r73cMIkBpX3iGpSIjV', {
  20. method: 'POST',
  21. headers: {
  22. 'Content-Type': 'application/json',
  23. },
  24. body: JSON.stringify({
  25. content: `${symbol} 复制流动性成功: https://www.byreal.io/en/portfolio?userAddress=${position.walletAddress}&tab=current&positionAddress=${position.positionAddress}`,
  26. }),
  27. })
  28. } else {
  29. // discord 通知
  30. fetch('https://discord.com/api/webhooks/1457714616636280978/YFMGaZEj2gJwUjINpFfJIkagG1I3SLZRwz9bGpc2OlGFWBVa88r73cMIkBpX3iGpSIjV', {
  31. method: 'POST',
  32. headers: {
  33. 'Content-Type': 'application/json',
  34. },
  35. body: JSON.stringify({
  36. content: `${symbol} 复制流动性失败: https://www.byreal.io/en/portfolio?userAddress=${position.walletAddress}&tab=current&positionAddress=${position.positionAddress}`,
  37. }),
  38. })
  39. }
  40. })
  41. .catch((err) => {
  42. console.error('Error quick copying:', err)
  43. // discord 通知
  44. fetch('https://discord.com/api/webhooks/1457714616636280978/YFMGaZEj2gJwUjINpFfJIkagG1I3SLZRwz9bGpc2OlGFWBVa88r73cMIkBpX3iGpSIjV', {
  45. method: 'POST',
  46. headers: {
  47. 'Content-Type': 'application/json',
  48. },
  49. body: JSON.stringify({
  50. content: `${symbol} 复制流动性失败: https://www.byreal.io/en/portfolio?userAddress=${position.walletAddress}&tab=current&positionAddress=${position.positionAddress}, ${err.message}`,
  51. }),
  52. })
  53. })
  54. }