To interact with the PSM, first identify which coin you want to use, either USDC, USDP (Paxos) or GUSD (Gemini). The contracts you’ll need to interact with are coin-specific.
- USDC
- PSM 0x89B78CfA322F6C5dE0aBcEecab66Aee45393cC5A
- GemJoin 0x0A59649758aa4d66E25f08Dd01271e891fe52199
- USDP
- PSM 0x961Ae24a1Ceba861D1FDf723794f6024Dc5485Cf
- GemJoin 0x7bbd8cA5e413bCa521C2c80D8d1908616894Cf21
- GUSD
- PSM 0x204659B2Fd2aD5723975c362Ce2230Fba11d3900
- GemJoin 0x79A0FA989fb7ADf1F8e80C93ee605Ebb94F7c6A5
Handling decimal places
In cases where the decimals in your token and Dai (18 decimal places) are different, i.e. GUSD (2 decimal places)
- When swapping your token for Dai, for both contract calls you should input the amount of your token that you will be swapping, using that token’s precision. The contract checks the decimal difference and mints the appropriate amount of Dai.
- When swapping Dai for another token, the calls should indicate the amount of Dai that you want to exchange, and likewise, the contract will do the math and return the appropriate amount of tokens to your address.
Legend
Using the coin of your choosing, the steps for interacting with the PSM are explained below.
- <PSM ADDRESS> refers to your coin’s PSM contract’s address
- <GEMJOIN ADDRESS> refers to they GemJoin contract for your coin.
- <YOUR ADDRESS> refers to the address that holds either Dai or the token you want to swap and is executing these transactions
- <TOKEN ADDRESS> refers to the address of the token contract you are using (either GUSD, USDP, or USDC)
- <DAI ADDRESS> refers to the Dai token contract on the Ethereum Main Network
- <TOKEN AMOUNT> refers to the amount of external tokens you want to exchange. Keep in mind that decimal places in these tokens might be different than 18, i.e. GUSD where
decimals = 2
. In this case, to refer to 1 GUSD, this amount should be 1 * 10^decimals = 100
- <DAI AMOUNT> refers to the amount of Dai you want to exchange. Keep in mind that Dai is a standard ERC20 token with 18 decimal places of precision, so 1 DAI =
1 * 10^18
Swapping coins for Dai
- Approve the GemJoin contract to spend the amount of tokens you want to exchange for Dai.
- Call
<TOKEN ADDRESS>.approve(<GEMJOIN ADDRESS>, <TOKEN AMOUNT>)
- Example: https://etherscan.io/tx/0xd3da1dff5e449550311f1058afd82325a7a39802b326f8c96d2619da408f8f23