Replies: 3 comments 10 replies
-
윤수님이 진행하시는거랑 결정적으로 다른건 User 구조체가 없다는 점입니다. 일단 체인링크의 기본적인 업데이트 인터벌인 한시간 간격으로 정하고 진행하면 되지 않을까 해서요 |
Beta Was this translation helpful? Give feedback.
6 replies
-
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "../Price/PriceConsumer.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract Swaps is PriceConsumer {
using Counters for Counters.Counter;
Counters.Counter private _swapId;
enum Status {pending, active, claimable, expired, liquidated}
mapping(uint256 => Swap) private _swaps;
struct User {
address addr;
uint256 priceOfAsset;
uint256 deposit;
}
struct Swap {
User buyer;
User seller;
uint8 claimPrice;
uint8 liquidationPrice;
uint8 premium;
Status status;
}
event MakeSwap(address indexed buyer, uint8 premium, uint8 claimPrice, uint8 liquidationPrice);
function _makeSwap(address _addr, uint8 _claimPrice, uint8 _liquidationPrice, uint8 _premium) public returns (uint256) {
_swapId.increment();
uint256 newSwapId = _swapId.current();
_swaps[newSwapId].buyer.addr = _addr;
_swaps[newSwapId].buyer.priceOfAsset = getPriceFromOracle();
_swaps[newSwapId].claimPrice = _claimPrice;
_swaps[newSwapId].liquidationPrice = _liquidationPrice;
_swaps[newSwapId].premium = _premium;
emit MakeSwap(_addr, _premium, _claimPrice, _liquidationPrice);
return newSwapId;
}
function swap(uint256 swapId) public view returns (Swap memory) {
return _swaps[swapId];
}
function _acceptSwap(address _addr) public returns (uint256) {
}
}
|
Beta Was this translation helpful? Give feedback.
3 replies
-
그러면 일단 윤수님께서 스마트 컨트랙트 구조도 잘 잡아주시고 코드도 멋지게 작성해주셔서 제가 백엔드 서버쪽 기본 골격을 잡는 작업을 진행해볼까 합니다. 시퀄라이즈, mysql, express.js 활용해서 기본적인 api 골격과, db에 들어갈 목킹데이터작업까지 준비해보겠습니다. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Beta Was this translation helpful? Give feedback.
All reactions