This contract for Lemonade LEDGIS smart contract It contains normal market releated actions
npm loginon@ibct-devto get@ibct-dev/sclestpackage : Our guidedocker loginonibctto getledgis-nodeosimage
$ git clone https://github.com/ibct-dev/lemonade-contract --recursive
or
$ git clone https://github.com/ibct-dev/lemonade-contract
$ cd contract-boilerplate
$ git submodule update --init --recursive-
init();
컨트랙트 최초 배포 이후 최초 1회만 실행한다. config 테이블에 있는 초기 설정값을 세팅한다.
Example
WIP-
issuelem();
LEM 토큰 신규 발행 액션, config 테이블에 저장된
last_lem_bucket_fill과 현재 시간을 이용하여 신규 발행량을 계산해서 해당 수량만큼만 발행한다.
Example
WIP-
setbtcprice();
config 테이블에 BTC price를 설정한다.
Example
WIP-
setledprice();
config2 테이블에 LED price를 설정한다.
Example
WIP-
addproduct ( const name &product_name, const double &minimum_yield, const double &maximum_yield, const bool &has_lem_rewards,
**const bool &has_prediction, const asset &amount_per_account, const optional<asset> &maximum_amount_limit, const optional<uint32_t> &duration);**product_name이름을 갖는 예치 상품을 생성한다. 해당 상품의 연이율은minimum_yield와maximum_yield사이의 값을 가지며 계정당amount_per_account의 토큰을 예치할 수 있으며 상품 전체의 제한은maximum_amount_limit이다. 또한 의무 예치기간은duration이다
Example
WIP-
rmproduct (const name &product_name);
product_name이름을 갖는 예치 상품을 삭제한다.
Example
WIP-
claimled (const name &owner, const name &product_name);
owner의product_name이름을 갖는 예치 상품에 대해 현재 시간까지 쌓인 LED 보상을 수령한다. 이 액션으로 발생한 보상은 즉시 수령한다.
Example
WIP-
claimlem (const name &owner, const name &product_name);
owner의product_name이름을 갖는 예치 상품에 대해 현재 시간까지 쌓인 LEM 보상을 수령한다. 이 액션으로 발생한 보상은 즉시 수령한다. 또한 LEM이 보상으로 주어지지 않은 상품 가입자는 보상을 받을 수 없다.
Example
WIP-
unstake (const name &owner, const name &product_name);
owner의product_name이름을 갖는 예치 상품에 대해 unstake를 수행한다. 기존에 미리 수령하였던 LED 및 LEM 보상을 제외한 나머지 보상을 한번에 수령하며 원금과 이자를 포함한 금액은 트랜잭션 발생 이 후 일정 시간 이후에 transfer 된다.
Example
WIP-
changeyield (const name &owner, const name &product_name, double &yield, const string &memo);
owner의product_name이름을 갖는 예치 상품에 대해 연 이율을yield를 변경한다.yield는 상품 자체의 최대 및 최소 연이율을 초과할 수 없다.
Example
WIP-
createbet (const uint32_t &started_at, const uint32_t &betting_ended_at, const uint32_t &ended_at);
started_at에 시작하며betting_ended_at에 베팅이 종료되고ended_at에 게임이 종료되는 게임을 생성한다.
Example
WIP-
setbet (const uint64_t bet_id, const uint8_t &status,const optional &base_price, const optional &final_price);
bet_id을 갖는 게임의 상태를 변경한다.
Example
WIP-
rmbet (const uint64_t bet_id);
bet_id을 갖는 게임을 삭제한다. 베팅 인원이 1명이라도 있다면 삭제가 불가능하다.
Example
WIP-
claimbet (const uint64_t bet_id);
bet_id을 갖는 게임에 대해 정산을 수행한다. 승리 포지션은win_position이다.
Example
WIP-
inittoken (const name user, const symbol new_symbol, const extended_asset initial_pool1, const extended_asset initial_pool2);
새로운 Pool을 생성한다. 토큰 쌍 및 유동성은
initial_pool1,initial_pool2으로 설정하며 LP 토큰의 이름은new_symbol이 된다.
Example
WIP-
openext (const name& user, const extended_symbol& ext_symbol);
user의 accounts 테이블에ext_symbol의 심볼명을 갖는 row를 0의 잔액으로 설정한다.
Example
WIP-
closeext (const name& user, const name& to, const extended_symbol& ext_symbol, string memo);
user의 accounts 테이블에ext_symbol의 심볼명을 갖는 row를 삭제한다. 잔액이 존재할 경우 그 토큰은to에게 전송된다.
Example
WIP-
withdraw (name user, name to, extended_asset to_withdraw, string memo);
user의 accounts 테이블에ext_symbol의 심볼명을 갖는 row의 잔액을to에게 전송된다.
Example
WIP-
addliquidity (name user, asset to_buy, asset max_asset1, asset max_asset2);
user가to_buyLP토큰 만큼 유동성을 공급하고자 함, 유저는 최대max_asset1max_asset2만큼 토큰을 공급하고자 함
Example
WIP-
rmliquidity (name user, asset to_sell, asset min_asset1, asset min_asset2);
user가to_sellLP토큰 만큼 유동성을 회수하고자 함, 유저는 최소min_asset1min_asset2만큼 토큰을 회수하고자 함
Example
WIP-
exchange (name user, symbol_code pair_token, extended_asset ext_asset_in, asset min_expected);
user가pair_token의 거래쌍을 이용해 스왑을 시도함,ext_asset_in을 넣고min_expected를 받을 것이라 기대함
Example
WIP-
clmpoolreward (name user, string pair_token_symbol);
user는 본인이 예치한pair_token_symbol거래쌍의 중간 보상을 받음
Example
WIP설정값을 저장하고 있는 table
Example
const result = await rpc.get_table_rows({
json: true, // Get the response as json
code: 'lemonade.c', // Contract that we target
scope: `lemonade.c`, // Account that owns the data
table: 'configs', // Table name
limit: 1, // Maximum number of rows that we want to get
});
console.log(result)설정값을 저장하고 있는 두번째 table
Example
const result = await rpc.get_table_rows({
json: true, // Get the response as json
code: 'lemonade.c', // Contract that we target
scope: `lemonade.c`, // Account that owns the data
table: 'configs2', // Table name
limit: 1, // Maximum number of rows that we want to get
});
console.log(result)예치 상품들을 저장하고 있는 table
Example
const result = await rpc.get_table_rows({
json: true, // Get the response as json
code: 'lemonade.c', // Contract that we target
scope: `lemonade.c`, // Account that owns the data
table: 'products', // Table name
limit: 1000, // Maximum number of rows that we want to get
});
console.log(result)예치한 계좌 목록
Example
const result = await rpc.get_table_rows({
json: true, // Get the response as json
code: 'lemonade.c', // Contract that we target
scope: `${account_name}`, // Account that owns the data
table: 'stakings', // Table name
limit: 1000, // Maximum number of rows that we want to get
});
console.log(result)betting 게임 목록
Example
const result = await rpc.get_table_rows({
json: true, // Get the response as json
code: 'lemonade.c', // Contract that we target
scope: 'lemonade.c', // Account that owns the data
table: 'bettings', // Table name
limit: 1000, // Maximum number of rows that we want to get
});
console.log(result)계정의 토큰 목록, led.token의 accounts와는 별개
Example
const result = await rpc.get_table_rows({
json: true, // Get the response as json
code: 'lemonade.c', // Contract that we target
scope: ${account_name}, // Account that owns the data
table: 'accounts', // Table name
limit: 1000, // Maximum number of rows that we want to get
});
console.log(result)거래쌍 목록
Example
const result = await rpc.get_table_rows({
json: true, // Get the response as json
code: 'lemonade.c', // Contract that we target
scope: 'lemonade.c', // Account that owns the data
table: 'stats', // Table name
limit: 1000, // Maximum number of rows that we want to get
});
console.log(result)레모네이드 계정에 예치된 토큰 테이블
Example
const result = await rpc.get_table_rows({
json: true, // Get the response as json
code: 'lemonade.c', // Contract that we target
scope: ${account_name}, // Account that owns the data
table: 'dexacnts', // Table name
limit: 1000, // Maximum number of rows that we want to get
});
console.log(result)memo schema: stake/<product_name>/<prediction_position>
cleos push action led.token transfer '["myaccount", "lemonade.c", "1.0000 LED", "stake/normal"]' -p myaccount
cleos push action led.token transfer '["myaccount", "lemonade.c", "1.0000 LED", "stake/fixed2/long"]' -p myaccountmemo schema: bet/<bet_id>/<prediction_position>
cleos push action led.token transfer '["myaccount", "lemonade.c", "1.0000 LED", "bet/0/long"]' -p myaccountmemo schema: deposit
cleos push action led.token transfer '["myaccount", "lemonade.c", "1.0000 LED", "deposit"]' -p myaccountmemo schema: exchange/<lp_token_symbol>/<min_expected>
cleos push action led.token transfer '["myaccount", "lemonade.c", "1.0000 LED", "exchange/LEDLEM/1.0000 LEM"]' -p myaccount- exchange has own action too (lemonade::exchange)
cleos push action lemonade.c exchange '["myaccount", "LEDLEM", "1.0000 LED", "1.0000 LEM"]' -p myaccount