Skip to content

Commit

Permalink
Merge pull request #299 from EdgeApp/matthew/fixSpendTargetAmount
Browse files Browse the repository at this point in the history
Fix spend target native amount
  • Loading branch information
peachbits authored Nov 8, 2023
2 parents 626da91 + 92ac078 commit 0ae93d7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
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

0 comments on commit 0ae93d7

Please sign in to comment.