Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
ab217ba8
Commit
ab217ba8
authored
1 year ago
by
Branislav Kontur
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
[asset-conversion] nits: removed unnecessary clone (#14726)
parent
b24b66c9
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
substrate/frame/asset-conversion/src/lib.rs
+11
-12
11 additions, 12 deletions
substrate/frame/asset-conversion/src/lib.rs
with
11 additions
and
12 deletions
substrate/frame/asset-conversion/src/lib.rs
+
11
−
12
View file @
ab217ba8
...
...
@@ -481,22 +481,21 @@ pub mod pallet {
}
else
{
(
amount2_desired
,
amount1_desired
,
amount2_min
,
amount1_min
)
};
let
(
asset1
,
asset2
)
=
pool_id
.clone
();
ensure!
(
amount1_desired
>
Zero
::
zero
()
&&
amount2_desired
>
Zero
::
zero
(),
Error
::
<
T
>
::
WrongDesiredAmount
);
let
maybe_pool
=
Pools
::
<
T
>
::
get
(
pool_id
.clone
()
);
let
maybe_pool
=
Pools
::
<
T
>
::
get
(
&
pool_id
);
let
pool
=
maybe_pool
.as_ref
()
.ok_or
(
Error
::
<
T
>
::
PoolNotFound
)
?
;
let
pool_account
=
Self
::
get_pool_account
(
&
pool_id
);
let
(
asset1
,
asset2
)
=
&
pool_id
;
let
reserve1
=
Self
::
get_balance
(
&
pool_account
,
asset1
)
?
;
let
reserve2
=
Self
::
get_balance
(
&
pool_account
,
asset2
)
?
;
let
amount1
:
T
::
AssetBalance
;
let
amount2
:
T
::
AssetBalance
;
let
pool_account
=
Self
::
get_pool_account
(
&
pool_id
);
let
reserve1
=
Self
::
get_balance
(
&
pool_account
,
&
asset1
)
?
;
let
reserve2
=
Self
::
get_balance
(
&
pool_account
,
&
asset2
)
?
;
if
reserve1
.is_zero
()
||
reserve2
.is_zero
()
{
amount1
=
amount1_desired
;
amount2
=
amount2_desired
;
...
...
@@ -525,13 +524,13 @@ pub mod pallet {
}
}
Self
::
validate_minimal_amount
(
amount1
.saturating_add
(
reserve1
),
&
asset1
)
Self
::
validate_minimal_amount
(
amount1
.saturating_add
(
reserve1
),
asset1
)
.map_err
(|
_
|
Error
::
<
T
>
::
AmountOneLessThanMinimal
)
?
;
Self
::
validate_minimal_amount
(
amount2
.saturating_add
(
reserve2
),
&
asset2
)
Self
::
validate_minimal_amount
(
amount2
.saturating_add
(
reserve2
),
asset2
)
.map_err
(|
_
|
Error
::
<
T
>
::
AmountTwoLessThanMinimal
)
?
;
Self
::
transfer
(
&
asset1
,
&
sender
,
&
pool_account
,
amount1
,
true
)
?
;
Self
::
transfer
(
&
asset2
,
&
sender
,
&
pool_account
,
amount2
,
true
)
?
;
Self
::
transfer
(
asset1
,
&
sender
,
&
pool_account
,
amount1
,
true
)
?
;
Self
::
transfer
(
asset2
,
&
sender
,
&
pool_account
,
amount2
,
true
)
?
;
let
total_supply
=
T
::
PoolAssets
::
total_issuance
(
pool
.lp_token
.clone
());
...
...
@@ -596,7 +595,7 @@ pub mod pallet {
ensure!
(
lp_token_burn
>
Zero
::
zero
(),
Error
::
<
T
>
::
ZeroLiquidity
);
let
maybe_pool
=
Pools
::
<
T
>
::
get
(
pool_id
.clone
()
);
let
maybe_pool
=
Pools
::
<
T
>
::
get
(
&
pool_id
);
let
pool
=
maybe_pool
.as_ref
()
.ok_or
(
Error
::
<
T
>
::
PoolNotFound
)
?
;
let
pool_account
=
Self
::
get_pool_account
(
&
pool_id
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment