# pDAI/pUSDC to MATH 1.1

The cost of 1 [MATH](https://affection.gitbook.io/docs/token-contracts/libatropamath-v1.1-math) is 1 [pDAI](https://affection.gitbook.io/docs/token-contracts/pdai-dai) or 1 [pUSDC](https://affection.gitbook.io/docs/token-contracts/pusdc-usdc), to get this price you have to call a function on the [MATH](https://affection.gitbook.io/docs/token-contracts/libatropamath-v1.1-math) contract.

We can look at the verified contract code to see the prices: [View the contract code](https://scan.mypinata.cloud/ipfs/bafybeidn64pd2u525lmoipjl4nh3ooa2imd7huionjsdepdsphl5slfowy/#/token/0xB680F0cc810317933F234f67EB6A9E923407f05D?tab=contract).

This guide assumes you’ve read and understand [how to interact with contracts](https://affection.gitbook.io/docs/contract-gui).

{% hint style="danger" %}
Buying only works with [pDAI](https://affection.gitbook.io/docs/token-contracts/pdai-dai) and [pUSDC](https://affection.gitbook.io/docs/token-contracts/pusdc-usdc) because [pUSDT](https://affection.gitbook.io/docs/token-contracts/pusdt-usdt) is bugged!
{% endhint %}

{% hint style="info" %}
Check the current [exchange rates](https://affection.gitbook.io/docs/faq#what-are-the-current-prices) to know which route is profitable!
{% endhint %}

## Step-by-step Guide

1. Add [pDAI](https://affection.gitbook.io/docs/token-contracts/pdai-dai) or [pUSDC](https://affection.gitbook.io/docs/token-contracts/pusdc-usdc) to [scgui.aff.icu](https://scgui.aff.icu). For this example we will use [pDAI](https://affection.gitbook.io/docs/token-contracts/pdai-dai).\\

   <figure><img src="https://724266576-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvpQTLAHrVaPSs8HZzOYQ%2Fuploads%2FBBdw41Km328bbphUERyY%2Fimage.png?alt=media&#x26;token=670a8e9b-73c9-43de-a297-a10e4f4dbe6a" alt=""><figcaption></figcaption></figure>

2. Add [MATH 1.1](https://affection.gitbook.io/docs/token-contracts/libatropamath-v1.1-math) to [scgui.aff.icu](https://scgui.aff.icu)\\

   <figure><img src="https://724266576-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvpQTLAHrVaPSs8HZzOYQ%2Fuploads%2FDK1THGVlwGUBRNpwaa5A%2Fimage.png?alt=media&#x26;token=cbe997ea-f74a-4efd-b841-42c7d5b957dd" alt=""><figcaption></figcaption></figure>

3. Open the [pDAI](https://affection.gitbook.io/docs/token-contracts/pdai-dai) contract and call approve() with spender [MATH 1.1](https://affection.gitbook.io/docs/token-contracts/libatropamath-v1.1-math) and amount 1000000000000000000 for 1 token\\

   <figure><img src="https://724266576-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvpQTLAHrVaPSs8HZzOYQ%2Fuploads%2F5zVJga4wMPPUyVtcA5yE%2Fimage.png?alt=media&#x26;token=1debf135-d82f-4453-b700-bf71247080bc" alt=""><figcaption></figcaption></figure>

4. Open the [MATH 1.1](https://affection.gitbook.io/docs/token-contracts/libatropamath-v1.1-math) contract and call Random() to mint 1 token, this is sent to the contract\\

   <figure><img src="https://724266576-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvpQTLAHrVaPSs8HZzOYQ%2Fuploads%2F9zrQ3z3S78UnpArUtF82%2Fimage.png?alt=media&#x26;token=9be9aae3-178e-4ab2-933b-f7e213a27fa8" alt=""><figcaption></figcaption></figure>

5. With the [MATH 1.1](https://affection.gitbook.io/docs/token-contracts/libatropamath-v1.1-math) contract open, call BuyWithDAI() with amount 1000000000000000000 to buy 1 token, this is sent straight to your wallet\\

   <figure><img src="https://724266576-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvpQTLAHrVaPSs8HZzOYQ%2Fuploads%2FmZdhMCo9AlZMLkXNEdMN%2Fimage.png?alt=media&#x26;token=30e7c5f7-3b0c-4471-a35d-16bf14b93bc8" alt=""><figcaption></figcaption></figure>

6. Swap the [MATH 1.1](https://affection.gitbook.io/docs/multi-mint-contracts/multi-math-1.1) on PulseX for PLS or [pDAI](https://affection.gitbook.io/docs/token-contracts/pdai-dai)

Repeat steps 3-6 as long as there is a decent profit margin. Once you are comfortable you can approve a higher amount of tokens to skip step 3 and speed up your arbs!

## Optimizations

Use my [multi mint contracts](https://affection.gitbook.io/docs/multi-mint-contracts) to do this even faster! Instead of calling BuyWithDAI() once per transaction you can now loop it up to 1000-2000 times in a single transaction!

6. Open the [pDAI](https://affection.gitbook.io/docs/token-contracts/pdai-dai) contract on [scgui.aff.icu](https://scgui.aff.icu) and call approve() with spender [0x1322Dab9eE385Bb3D81f75EBb8356015B0872e53](https://affection.gitbook.io/docs/multi-mint-contracts/multi-math-1.1) and any amount followed by 18 zeros, example: 100000000000000000000 for 100 tokens

   <figure><img src="https://724266576-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvpQTLAHrVaPSs8HZzOYQ%2Fuploads%2Fuiy6ml4PdpoFvY9ssf6n%2Fimage.png?alt=media&#x26;token=28c78f13-a040-4bc8-904e-cac401c6012e" alt=""><figcaption></figcaption></figure>

7. Add the [Multi MATH 1.1](https://affection.gitbook.io/docs/multi-mint-contracts/multi-math-1.1) contract to scgui.aff.icu\\

   <figure><img src="https://724266576-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvpQTLAHrVaPSs8HZzOYQ%2Fuploads%2F1645PbNmLGQoc1evdpq7%2Fimage.png?alt=media&#x26;token=0073ec91-ba56-4ff0-aa8c-b01983b19758" alt=""><figcaption></figcaption></figure>

8. Open it and call the function multiBuyWithDAI() with iterations 100, this will purchase 100 [MATH 1.1](https://affection.gitbook.io/docs/token-contracts/libatropamath-v1.1-math) from the contract in one transaction\\

   <figure><img src="https://724266576-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvpQTLAHrVaPSs8HZzOYQ%2Fuploads%2FgLOFo2dJNlYB0ups75Mq%2Fimage.png?alt=media&#x26;token=8c8bfebd-a418-4e1a-b11e-dae80022caa1" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
This should help reduce the gas costs to mint each token down to 5-10 PLS
{% endhint %}
