An example implementation of a contract that is a Union member. Once registered, this contract can borrow DAI and use it to buy OSQTH.
//SPDX-License-Identifier: MITpragmasolidity ^0.8.0;import"@unioncredit/v1-sdk/contracts/UnionBorrower.sol";/** * @notice A UnionMember that borrows DAI to go long on OSQTH */contractSqueethWithFriendsisUnionBorrower {addresspublic dai;constructor(address_dai) { dai = _dai; }functionborrowAndSqueeth(uint256_amountInDai) external {_borrow(_amountInDai);_investInSqueeth(_amountInDai); }functionsellAndRepay(uint_amountInSqueeth) external {_sellSqueeth(_amountInSqueeth);uint balance =IERC20(dai).balanceOf(address(this));_repayBorrow(balance); }function_investInSqueeth(uint256_amountInDai) internal {// buy OSQTH with DAI }function_sellSqueeth(uint256_amountInSqueeth) internal {// sell OSQTH for DAI }}
Example Voucher
An example implementation of a contract that is a Union member. Once registered, this contract can vouch for frankfrank holders.
//SPDX-License-Identifier: MITpragmasolidity ^0.8.0;import"@unioncredit/v1-sdk/contracts/UnionVoucher.sol";/** * @notice A UnionMember that vouches for holders of frankfrank */contractVouchForFrankFrankisUnionVoucher {uint256public vouchAmount; IERC721 public frank;constructor(uint_vouchAmount,IERC721_frank) { vouchAmount = _vouchAmount; frank = _frank; }functionstake() external {uint balance =IERC20(dai).balanceOf(address(this));_stake(balance); }functionvouchForFrankFrank(address holder) external {require(frank.balanceOf(holder) >0,"!holder");_updateTrust(holder, vouchAmount); }functioncancelPaperHands(address holder) external {require(frank.balanceOf(holder) <=0,"!paper hands");_cancelVouch(holder); }}