Skip to content

Commit

Permalink
Enable ERC20 tokens (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechilds authored and sindresorhus committed Jul 27, 2018
1 parent e3538f8 commit cbfce65
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 79 deletions.
2 changes: 1 addition & 1 deletion app/marketmaker/supported-currencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -1920,7 +1920,7 @@ const supportedCurrencies = [
etomic: '0xE41d2489571d322189246DaFA5ebDe1F4699F498',
rpcport: 80,
},
].filter(currency => !currency.etomic || currency.coin === 'ETH');
];

const getCurrencySymbols = () => (
_(supportedCurrencies)
Expand Down
79 changes: 1 addition & 78 deletions app/renderer/swap-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,84 +183,7 @@ class SwapDB {
//
// It also allows us to correctly rebuild the tx chain of swaps that
// didn't quite go to plan like claiming bobdeposit or alicepayment.
const amounts = (() => {
const [alicespend, bobspend, bobpayment, alicepayment, bobdeposit, otherfee, myfee, bobrefund, bobreclaim, alicereclaim, aliceclaim] = message.values;
return {alicespend, bobspend, bobpayment, alicepayment, bobdeposit, otherfee, myfee, bobrefund, bobreclaim, alicereclaim, aliceclaim};
})();

const aliceCurrency = message.alicetomic ? 'ETOMIC' : message.alice;
const bobCurrency = message.bobtomic ? 'ETOMIC' : message.bob;

swap.transactions = [];
if (message.sentflags.includes('myfee')) {
swap.transactions.push({
stage: 'myfee',
coin: aliceCurrency,
txid: message.alicedexfee,
amount: amounts.myfee,
});
}
if (message.sentflags.includes('bobdeposit')) {
swap.transactions.push({
stage: 'bobdeposit',
coin: bobCurrency,
txid: message.bobdeposit,
amount: amounts.bobdeposit,
});
}
if (message.sentflags.includes('alicepayment')) {
swap.transactions.push({
stage: 'alicepayment',
coin: aliceCurrency,
txid: message.alicepayment,
amount: amounts.alicepayment,
});
}
if (message.sentflags.includes('bobpayment')) {
swap.transactions.push({
stage: 'bobpayment',
coin: bobCurrency,
txid: message.bobpayment,
amount: amounts.bobpayment,
});
}

// This is the final tx claiming bobpayment for a trade that completed as expected.
if (message.sentflags.includes('alicespend')) {
swap.transactions.push({
stage: 'alicespend',
coin: bobCurrency,
txid: message.paymentspent,
amount: amounts.alicespend,
});
}

// This is the final tx in the case that bob doesn't send bobpayment.
// We can claim bobdeposit which gives us a 12.5% bonus to punish bob.
if (message.sentflags.includes('aliceclaim')) {
// There is a bug in marketmaker where it doesn't always correctly report
// the values. If aliceclaim is 0 we fallback to bobdeposit as it should
// be very close (same amount minus our claim txfee)
// https://github.com/jl777/SuperNET/issues/920
swap.transactions.push({
stage: 'aliceclaim',
coin: bobCurrency,
txid: message.depositspent,
amount: amounts.aliceclaim || amounts.bobdeposit,
});
}

// This is the final tx in the case that bob doesn't send anything after
// we've already sent alicepayment. We don't get any of the currency we
// want, just claim our original payment back.
if (message.sentflags.includes('alicereclaim')) {
swap.transactions.push({
stage: 'alicereclaim',
coin: aliceCurrency,
txid: message.Apaymentspent,
amount: amounts.alicereclaim,
});
}
swap.transactions = message.txChain;

// Overrride status to failed if we don't have a successful completion transaction
if (!(
Expand Down

0 comments on commit cbfce65

Please sign in to comment.