Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
lightning-bits
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bitsoko services
lightning-bits
Commits
aaf246e1
Commit
aaf246e1
authored
Mar 15, 2022
by
Allan Juma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
33f5c0c5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
32 deletions
+34
-32
index.js
src/action/index.js
+3
-0
pool-add-liquid.js
src/action/pool-add-liquid.js
+3
-2
algo.js
src/chains/algo/algo.js
+6
-6
pools.py
src/chains/algo/pools.py
+21
-23
pay-pool-confirm.js
src/view/pay-pool-confirm.js
+1
-1
No files found.
src/action/index.js
View file @
aaf246e1
...
...
@@ -173,7 +173,10 @@ when(
}
var
accountInfo
=
await
Algorand
.
getAccount
(
store
.
settings
.
chains
.
algo
.
chain
,
store
.
settings
.
chains
.
algo
.
account
.
address
);
console
.
log
(
'algo account! '
+
accountInfo
);
//var poolStats = await grpc.initPyface(['/data/lightning-bits/src/chains/algo/pools.py', 'bootstrap', 70232824, 0, '289:BITS', 'ALGO', 'TTNTINGI6AKN6JBHCAOXVFZN72BAMDNBTHZ3ZRQC3ILAMWONKN7XRRQ6GM' ]);
...
...
src/action/pool-add-liquid.js
View file @
aaf246e1
...
...
@@ -143,8 +143,8 @@ class PoolAddAction {
//check if contract has enough balance first
console
.
log
(
parseFloat
(
this
.
_store
.
settings
.
chains
.
algo
.
account
.
balance
)
*
100
,
(
amount
*
1.01
));
if
(
parseFloat
(
this
.
_store
.
settings
.
chains
.
algo
.
account
.
balance
)
*
100
>
(
amount
*
1.01
)){
console
.
log
(
parseFloat
(
this
.
_store
.
settings
.
chains
.
algo
.
account
.
balance
)
*
100
0000
,
(
amount
*
1.01
));
if
(
parseFloat
(
this
.
_store
.
settings
.
chains
.
algo
.
account
.
balance
)
*
100
0000
>
(
amount
*
1.01
)){
console
.
log
(
'INFO! contract has sufficient balance'
);
}
else
{
...
...
@@ -190,6 +190,7 @@ class PoolAddAction {
var
amount
=
toSatoshis
(
this
.
_store
.
payment
.
amount
,
settings
);
if
(
parseFloat
(
this
.
_store
.
settings
.
chains
.
algo
.
account
.
balance
)
*
1000000
>
(
amount
*
1.01
)){
console
.
log
(
'INFO! sufficient BTC in contract. skipping lightning swap...'
);
this
.
_store
.
payment
.
address
=
''
;
}
else
if
(
!
this
.
_store
.
payment
.
address
)
{
return
this
.
_notification
.
display
({
msg
:
'Enter an invoice or address'
});
}
...
...
src/chains/algo/algo.js
View file @
aaf246e1
...
...
@@ -18,25 +18,25 @@ const Algorand = {
getClient
:
network
=>
{
let
token
=
{
"X-Algo-API-Token"
:
store
.
chains
.
algo
.
rpc
[
network
].
key
"X-Algo-API-Token"
:
store
.
settings
.
chains
.
algo
.
rpc
[
store
.
settings
.
chains
.
algo
.
chain
].
key
};
if
(
store
.
chains
.
algo
.
rpc
[
network
].
server
.
search
(
"purestake"
)
>=
0
)
{
if
(
store
.
settings
.
chains
.
algo
.
rpc
[
store
.
settings
.
chains
.
algo
.
chain
].
server
.
search
(
"purestake"
)
>=
0
)
{
token
=
{
"X-API-Key"
:
store
.
chains
.
algo
.
rpc
[
network
].
key
"X-API-Key"
:
store
.
settings
.
chains
.
algo
.
rpc
[
store
.
settings
.
chains
.
algo
.
chain
].
key
};
}
return
new
algosdk
.
Algod
(
token
,
store
.
chains
.
algo
.
rpc
[
network
].
server
,
store
.
chains
.
algo
.
rpc
[
network
].
port
store
.
settings
.
chains
.
algo
.
rpc
[
store
.
settings
.
chains
.
algo
.
chain
].
server
,
store
.
settings
.
chains
.
algo
.
rpc
[
store
.
settings
.
chains
.
algo
.
chain
].
port
);
},
getClientForTx
:
network
=>
{
let
token
=
{
"X-API-Key"
:
store
.
chains
.
algo
.
rpc
[
network
].
key
,
"X-API-Key"
:
store
.
settings
.
chains
.
algo
.
rpc
[
network
].
key
,
"Content-Type"
:
"application/x-binary"
};
...
...
src/chains/algo/pools.py
View file @
aaf246e1
...
...
@@ -67,12 +67,29 @@ def swap(client,action,aID1,aID2,account,mne,amount):
txid
=
client
.
algod
.
send_transactions
(
transaction_group
.
signed_transactions
)
wait_for_confirmation
(
txid
)
# Fetch our two assets of interest
ASA
=
Asset
(
id
=
aID1
,
name
=
'ASA'
,
unit_name
=
'ASA'
,
decimals
=
0
)
BTC
=
Asset
(
id
=
aID2
,
name
=
'BTC satoshis'
,
unit_name
=
'BTC'
,
decimals
=
6
)
ASA
=
client
.
fetch_asset
(
aID1
)
BTC
=
client
.
fetch_asset
(
aID2
)
# Create the pool we will work with and fetch its on-chain state
pool
=
Pool
(
client
,
asset_a
=
ASA
,
asset_b
=
BTC
,
fetch
=
True
)
#pool = Pool(client, asset_a=ASA, asset_b=BTC, fetch=True)
pool
=
client
.
fetch_pool
(
ASA
,
BTC
)
r
=
pool
.
info
()
if
(
not
client
.
asset_is_opted_in
(
aID1
)):
print
(
'Account not opted into asset {aID1}, opting in now..'
)
transaction_group
=
client
.
prepare_asset_optin_transactions
(
aID1
,
account
[
'address'
])
for
i
,
txn
in
enumerate
(
transaction_group
.
transactions
):
if
txn
.
sender
==
account
[
'address'
]:
transaction_group
.
signed_transactions
[
i
]
=
txn
.
sign
(
account
[
'private_key'
])
txid
=
client
.
algod
.
send_transactions
(
transaction_group
.
signed_transactions
)
#wait_for_confirmation(txid)
if
(
not
client
.
asset_is_opted_in
(
aID2
)
and
aID2
>
0
):
print
(
'Account not opted into asset {aID2}, opting in now..'
)
transaction_group
=
client
.
prepare_asset_optin_transactions
(
aID2
,
account
[
'address'
])
for
i
,
txn
in
enumerate
(
transaction_group
.
transactions
):
if
txn
.
sender
==
account
[
'address'
]:
transaction_group
.
signed_transactions
[
i
]
=
txn
.
sign
(
account
[
'private_key'
])
txid
=
client
.
algod
.
send_transactions
(
transaction_group
.
signed_transactions
)
#wait_for_confirmation(txid)
#amount = 10_000_000
# Get a quote for a swap of 1 ALGO to TINYUSDC with 1% slippage tolerance
...
...
@@ -231,25 +248,6 @@ if action == "pooling":
txid
=
client
.
algod
.
send_transactions
(
transaction_group
.
signed_transactions
)
wait_for_confirmation
(
txid
)
if
(
not
client
.
asset_is_opted_in
(
aID1
,
account
[
'address'
])):
print
(
'Account not opted into asset {aID1}, opting in now..'
)
transaction_group
=
client
.
prepare_asset_optin_transactions
(
aID1
,
account
[
'address'
])
for
i
,
txn
in
enumerate
(
transaction_group
.
transactions
):
if
txn
.
sender
==
account
[
'address'
]:
transaction_group
.
signed_transactions
[
i
]
=
txn
.
sign
(
account
[
'private_key'
])
txid
=
client
.
algod
.
send_transactions
(
transaction_group
.
signed_transactions
)
#wait_for_confirmation(txid)
if
(
not
client
.
asset_is_opted_in
(
aID2
)):
print
(
'Account not opted into asset {aID2}, opting in now..'
)
transaction_group
=
client
.
prepare_asset_optin_transactions
(
aID1
,
account
[
'address'
])
for
i
,
txn
in
enumerate
(
transaction_group
.
transactions
):
if
txn
.
sender
==
account
[
'address'
]:
transaction_group
.
signed_transactions
[
i
]
=
txn
.
sign
(
account
[
'private_key'
])
txid
=
client
.
algod
.
send_transactions
(
transaction_group
.
signed_transactions
)
#wait_for_confirmation(txid)
# Fetch our two assets of interest
ASA
=
client
.
fetch_asset
(
aID1
)
BTC
=
client
.
fetch_asset
(
aID2
)
...
...
src/view/pay-pool-confirm.js
View file @
aaf246e1
...
...
@@ -36,7 +36,7 @@ ChartJS.register(ArcElement, Tooltip, Legend);
const
{
settings
}
=
store
;
var
amount
=
toSatoshis
(
store
.
payment
.
amount
,
settings
);
if
(
parseFloat
(
store
.
settings
.
chains
.
algo
.
account
.
balance
)
*
100
>
(
amount
*
1.01
)){
if
(
parseFloat
(
store
.
settings
.
chains
.
algo
.
account
.
balance
)
*
100
0000
>
(
amount
*
1.01
)){
console
.
log
(
'INFO! sufficient BTC in contract. skipping lightning swap...'
);
var
poolStats
=
await
grpc
.
initPyface
([
'/data/lightning-bits/src/chains/algo/pools.py'
,
'swap'
,
store
.
selectedPool
.
assetID
,
0
,
amount
,
store
.
settings
.
chains
.
algo
.
account
.
address
,
store
.
settings
.
chains
.
algo
.
account
.
mnemonic
,
'add'
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment