체인의정석

DeFI 코드 참고 소스 본문

블록체인/디파이

DeFI 코드 참고 소스

체인의정석 2021. 2. 3. 09:33
728x90
반응형

money-legos.studydefi.com/#/dydx

 

money-legos docs

 

money-legos.studydefi.com

solo Margin contract를 이용하여 flash loan사용 가능.

1. X 만큼의 토큰을 Withdraw로 빌린다.

2. Call a function (이미 진행됨)

3. X + 2wei 만큼을 Deoposit으로 갚는다

이 3개를 한번에 시킨다. 

 

 

docs.dydx.exchange/#introduction

 

dYdX Documentation

 

docs.dydx.exchange

dydx 공식 문서

 

 

However, if you write smart contracts, then our protocol documentation would be useful to you: https://docs.dydx.exchange/#/protocol. A canonical "Flash Loan" would be achieved by chaining Withdraw, Call, and Deposit actions into a single Operation.

 

flash loan 이라는 것은 Withdraw -> Call -> Deposit 순서대로 한번에 실행시키는 것.

 

solo의 공식 테스트넷  id=42 (Kovan) 배포 컨트렉트

github.com/dydxprotocol/solo/blob/master/migrations/deployed.json

 

dydxprotocol/solo

dYdX V2 Margin Trading Protocol. Contribute to dydxprotocol/solo development by creating an account on GitHub.

github.com

dydx에서 지원중인 토큰은 다음과 같다.

// token address
address public WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address public SAI = 0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359;
address public USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
address public DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F;

이 토큰들을 통하여 플래시론을 실행할 것이므로, 해당 토큰을 잔고로 보유

 

 

kovan에서는 dydx의 solo 계정이 있다.

 

kovan.etherscan.io/address/0x4EC3570cADaAEE08Ae384779B0f3A45EF85289DE#readContract

 

Contract Address 0x4EC3570cADaAEE08Ae384779B0f3A45EF85289DE | Etherscan

The Contract Address 0x4EC3570cADaAEE08Ae384779B0f3A45EF85289DE page allows users to view the source code, transactions, balances, and analytics for the contract address. Users can also interact and make transactions to the contract directly on Etherscan.

kovan.etherscan.io

 

29.의 get market을 사용하면 연결된 토큰을 확인할 수 있다.

 

weth 이더스캔 - kovan

kovan.etherscan.io/address/0xd0A1E359811322d97991E03f863a0C30C2cF029C

 

Contract Address 0xd0A1E359811322d97991E03f863a0C30C2cF029C | Etherscan

The Contract Address 0xd0A1E359811322d97991E03f863a0C30C2cF029C page allows users to view the source code, transactions, balances, and analytics for the contract address. Users can also interact and make transactions to the contract directly on Etherscan.

kovan.etherscan.io

DAI 이더스캔 - kovan

kovan.etherscan.io/address/0xC4375B7De8af5a38a93548eb8453a498222C4fF2

 

Contract Address 0xC4375B7De8af5a38a93548eb8453a498222C4fF2 | Etherscan

The Contract Address 0xC4375B7De8af5a38a93548eb8453a498222C4fF2 page allows users to view the source code, transactions, balances, and analytics for the contract address. Users can also interact and make transactions to the contract directly on Etherscan.

kovan.etherscan.io

TEST USDC -  kovan

kovan.etherscan.io/address/0x03226d9241875DbFBfE0e814ADF54151e4F3fd4B

 

Contract Address 0x03226d9241875DbFBfE0e814ADF54151e4F3fd4B | Etherscan

The Contract Address 0x03226d9241875DbFBfE0e814ADF54151e4F3fd4B page allows users to view the source code, transactions, balances, and analytics for the contract address. Users can also interact and make transactions to the contract directly on Etherscan.

kovan.etherscan.io

깃허브에서 DyDX를 사용한 소스를 찾아와 보았다.

그래도 디파이가 인기를 끈지 조금 되어서 그런지 깃허브에서 소스코드를 어렵지 않게 찾을 수 있었다.

 

github.com/Devilla/eth-arbitrage/blob/master/contracts/Arbitrage.sol

 

Devilla/eth-arbitrage

A DeFi Arbitrage Bot with DyDx Flashloans. Contribute to Devilla/eth-arbitrage development by creating an account on GitHub.

github.com

 

728x90
반응형
Comments