addLiq.mjs 2.1 KB

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