# Exchange Issuance Bounty \[December 2020\] - IN PROGRESS

**URL:** https://gov.indexcoop.com/t/exchange-issuance-bounty-december-2020-in-progress/631
**Category:** Engineering
**Created:** [29 December 2020 23:15 UTC](https://gov.indexcoop.com/t/exchange-issuance-bounty-december-2020-in-progress/631 "2020-12-29T23:15:45Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![setoshi](https://yyz1.discourse-cdn.com/flex027/user_avatar/gov.indexcoop.com/setoshi/32/54_2.png) [@setoshi](https://gov.indexcoop.com/u/setoshi)
#### Post date: [29 December 2020 23:15 UTC](https://gov.indexcoop.com/t/exchange-issuance-bounty-december-2020-in-progress/631/1 "2020-12-29T23:15:45Z")

</div>

The Index Coop wishes to deploy a smart contract that enables a user to purchase or sell an index product in a single transaction using decentralized exchange liquidity (e.g. Uniswap/Sushiswap). It is advised that you take inspiration from [DeFi Pulse’s arb bot](https://github.com/ConcourseOpen/DPI_Arb_Bot_Example/blob/master/DPI_Arb_Bot-master/smart-contract/contracts/DefiPulseIndexTrade.sol), which has much of the logic for issuance and on-chain DEX trades.

Specification:

- Should allow using the best price via sushiswap or uniswap for each purchase
- Should allow payment or receiving using an erc20 or Ether
- Should allow issuance or redemption using the BasicIssuanceModule of any Index or Set token

Successfully completing this bounty requires:

- Writing smart contract code in solidity, writing unit tests, and writing deployment scripts
- Code to be reviewed and audited by the Set engineering team
- Code is ultimately deployed into production

Bounty: 400 INDEX

Implementor: Currently being implemented by @ncitron and @alphaguy

---

<div class="post-metadata">

### Author: ![Kiba](https://yyz1.discourse-cdn.com/flex027/user_avatar/gov.indexcoop.com/kiba/32/1436_2.png) [@Kiba](https://gov.indexcoop.com/u/Kiba)
#### Post date: [30 December 2020 11:27 UTC](https://gov.indexcoop.com/t/exchange-issuance-bounty-december-2020-in-progress/631/2 "2020-12-30T11:27:08Z")

</div>

Must all computation be done on-chain (e.g. picking uni vs sushi)?

Should they optimize the tx for lowest gas or best price?

---

<div class="post-metadata">

### Author: ![setoshi](https://yyz1.discourse-cdn.com/flex027/user_avatar/gov.indexcoop.com/setoshi/32/54_2.png) [@setoshi](https://gov.indexcoop.com/u/setoshi)
#### Post date: [31 December 2020 18:53 UTC](https://gov.indexcoop.com/t/exchange-issuance-bounty-december-2020-in-progress/631/3 "2020-12-31T18:53:21Z")

</div>

1 - Yep - on chain

2 - Best Price

---

<div class="post-metadata">

### Author: ![ncitron](https://yyz1.discourse-cdn.com/flex027/user_avatar/gov.indexcoop.com/ncitron/32/151_2.png) [@ncitron](https://gov.indexcoop.com/u/ncitron)
#### Post date: [12 January 2021 19:42 UTC](https://gov.indexcoop.com/t/exchange-issuance-bounty-december-2020-in-progress/631/4 "2021-01-12T19:42:43Z")

</div>

I might give this bounty a try. Any tips on how I should deal with the leftover dust due to the uni/sushi trades? Maybe there could be a boolean argument for it to either be swapped back to ETH and sent back to the user, or to be donated to the coop (which I imagine many people will opt to do since the additional gas cost may not be worth it).

---

<div class="post-metadata">

### Author: ![setoshi](https://yyz1.discourse-cdn.com/flex027/user_avatar/gov.indexcoop.com/setoshi/32/54_2.png) [@setoshi](https://gov.indexcoop.com/u/setoshi)
#### Post date: [12 January 2021 19:45 UTC](https://gov.indexcoop.com/t/exchange-issuance-bounty-december-2020-in-progress/631/5 "2021-01-12T19:45:45Z")

</div>

I believe it is possible to get exact amounts out of a uniswap/sushi trade, so there will not be dust. That said, you may need to send more of the payment token than expected.

Ping me on discord and we discuss more!

---

<div class="post-metadata">

### Author: ![ncitron](https://yyz1.discourse-cdn.com/flex027/user_avatar/gov.indexcoop.com/ncitron/32/151_2.png) [@ncitron](https://gov.indexcoop.com/u/ncitron)
#### Post date: [12 January 2021 20:00 UTC](https://gov.indexcoop.com/t/exchange-issuance-bounty-december-2020-in-progress/631/6 "2021-01-12T20:00:28Z")

</div>

Your right. Looks like `swapETHForExactTokens` is what I am looking for. I’ll ping you on Discord if I have any other questions.
