Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix spend target native amount #299

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# edge-exchange-plugins

## Unreleased

- fixed: Use appropriate send amount in spend targets for Uniswap-based providers

## 1.0.2 (2023-11-06)

- fixed: Check max spendable amount of source wallet in xrpdex quote
Expand Down
11 changes: 7 additions & 4 deletions src/swap/defi/uni-v2-based/plugins/spookySwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export function makeSpookySwapPlugin(

// Sanity check: Both wallets should be of the same chain.
if (
fromWallet.currencyInfo.currencyCode !== 'fantom' ||
toWallet.currencyInfo.currencyCode !== 'fantom'
fromWallet.currencyInfo.pluginId !== 'fantom' ||
toWallet.currencyInfo.pluginId !== 'fantom'
)
throw new SwapCurrencyError(swapInfo, request)

Expand Down Expand Up @@ -104,14 +104,17 @@ export function makeSpookySwapPlugin(

const fromAddress = (await fromWallet.getReceiveAddress()).publicAddress
// toEdgeUnsignedTxs
const edgeSpendInfos = swapTxs.map(swapTx => {
const edgeSpendInfos = swapTxs.map((swapTx, i) => {
// Convert to our spendInfo
const edgeSpendInfo: EdgeSpendInfo = {
currencyCode: request.fromCurrencyCode, // what is being sent out, only if token. Blank if not token
spendTargets: [
{
memo: swapTx.data,
nativeAmount: swapTx.value != null ? swapTx.value.toString() : '0', // biggy/number string integer
nativeAmount:
swapTxs.length === 2 && i === 0
? '0' // approval transactions don't have a value
: amountToSwap,
publicAddress: swapTx.to
}
],
Expand Down
11 changes: 7 additions & 4 deletions src/swap/defi/uni-v2-based/plugins/tombSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export function makeTombSwapPlugin(

// Sanity check: Both wallets should be of the same chain.
if (
fromWallet.currencyInfo.currencyCode !== 'fantom' ||
toWallet.currencyInfo.currencyCode !== 'fantom'
fromWallet.currencyInfo.pluginId !== 'fantom' ||
toWallet.currencyInfo.pluginId !== 'fantom'
)
throw new SwapCurrencyError(swapInfo, request)

Expand Down Expand Up @@ -104,14 +104,17 @@ export function makeTombSwapPlugin(

const fromAddress = (await fromWallet.getReceiveAddress()).publicAddress
// toEdgeUnsignedTxs
const edgeSpendInfos = swapTxs.map(swapTx => {
const edgeSpendInfos = swapTxs.map((swapTx, i) => {
// Convert to our spendInfo
const edgeSpendInfo: EdgeSpendInfo = {
currencyCode: request.fromCurrencyCode, // what is being sent out, only if token. Blank if not token
spendTargets: [
{
memo: swapTx.data,
nativeAmount: swapTx.value != null ? swapTx.value.toString() : '0', // biggy/number string integer
nativeAmount:
swapTxs.length === 2 && i === 0
? '0' // approval transactions don't have a value
: amountToSwap,
publicAddress: swapTx.to
}
],
Expand Down
7 changes: 5 additions & 2 deletions src/swap/defi/uni-v2-based/plugins/velodrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,17 @@ export function makeVelodromePlugin(
)
const fromAddress = (await fromWallet.getReceiveAddress()).publicAddress
// toEdgeUnsignedTxs
const edgeSpendInfos = swapTxs.map(swapTx => {
const edgeSpendInfos = swapTxs.map((swapTx, i) => {
// Convert to our spendInfo
const edgeSpendInfo: EdgeSpendInfo = {
currencyCode: request.fromCurrencyCode, // what is being sent out, only if token. Blank if not token
spendTargets: [
{
memo: swapTx.data,
nativeAmount: swapTx.value != null ? swapTx.value.toString() : '0', // biggy/number string integer
nativeAmount:
swapTxs.length === 2 && i === 0
? '0' // approval transactions don't have a value
: amountToSwap,
publicAddress: swapTx.to
}
],
Expand Down
Loading